Skip to content

Commit

Permalink
Fix pg_dump for non-babelfish databases (babelfish-for-postgresql#237)
Browse files Browse the repository at this point in the history
Recently, we introduced a change where we mistakenly disallowed pg_dump
for a non-Babelfish databases. This commit fixes this issue.

Task: MANFRED-19333

Signed-off-by: Rishabh Tanwar [email protected]
  • Loading branch information
rishabhtanwar29 authored and priyansx committed Nov 22, 2023
1 parent f4acfe0 commit f1cc78b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/bin/pg_dump/dump_babel_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,15 +878,9 @@ prepareForBabelfishDatabaseDump(Archive *fout, SimpleStringList *schema_include_
int ntups;
int i;

if (fout->dopt->binary_upgrade)
if (!isBabelfishDatabase(fout) || fout->dopt->binary_upgrade)
return;

if (!isBabelfishDatabase(fout))
{
pg_log_error("\"%s\" is not a Babelfish Database.", fout->dopt->cparams.dbname);
exit_nicely(1);
}

query = createPQExpBuffer();
/*
* Get oids of all the Babelfish catalog configuration tables.
Expand Down Expand Up @@ -921,6 +915,7 @@ prepareForBabelfishDatabaseDump(Archive *fout, SimpleStringList *schema_include_
PQclear(res);
destroyPQExpBuffer(query);

/* Return if not logical database dump, continue otherwise. */
if (bbf_db_name == NULL)
return;
/*
Expand Down Expand Up @@ -1153,7 +1148,7 @@ fixCursorForBbfCatalogTableData(Archive *fout, TableInfo *tbinfo, PQExpBuffer bu
*/

if (!isBabelfishDatabase(fout) || !isBabelfishConfigTable(tbinfo))
return;
return;

if (bbf_db_name != NULL)
is_builtin_db = (pg_strcasecmp(bbf_db_name, "master") == 0 ||
Expand Down Expand Up @@ -1370,6 +1365,9 @@ getMbstrlen(const char *mbstr, Archive *fout)
* fixCursorForBbfSqlvariantTableData:
* Prepare custom cursor for all Babelfish tables with atleast one sql_variant
* datatype column to correctly dump sql_variant data.
*
* Returns total number of fields in the cursor which is the sum of existing
* nfields and the extra fields added for each sql_variant column.
*/
int
fixCursorForBbfSqlvariantTableData( Archive *fout,
Expand Down

0 comments on commit f1cc78b

Please sign in to comment.