Commit f1fa94a4 authored by Bruce Momjian's avatar Bruce Momjian

Fix logic to prevent pg_dump from dumping system schemas; bug introduced

in recent -t/-n/-T/-N patch.

Small style cleanups.
parent 959aee5b
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* by PostgreSQL * by PostgreSQL
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.444 2006/08/01 21:05:00 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.445 2006/08/02 21:43:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -625,6 +625,7 @@ main(int argc, char **argv) ...@@ -625,6 +625,7 @@ main(int argc, char **argv)
/* Check schema selection flags */ /* Check schema selection flags */
resetPQExpBuffer(query); resetPQExpBuffer(query);
switch_include_exclude = true; switch_include_exclude = true;
for (this_obj_name = schemaList; this_obj_name; this_obj_name = this_obj_name->next) for (this_obj_name = schemaList; this_obj_name; this_obj_name = this_obj_name->next)
{ {
if (switch_include_exclude) if (switch_include_exclude)
...@@ -686,6 +687,7 @@ main(int argc, char **argv) ...@@ -686,6 +687,7 @@ main(int argc, char **argv)
/* Check table selection flags */ /* Check table selection flags */
resetPQExpBuffer(query); resetPQExpBuffer(query);
switch_include_exclude = true; switch_include_exclude = true;
for (this_obj_name = tableList; this_obj_name; this_obj_name = this_obj_name->next) for (this_obj_name = tableList; this_obj_name; this_obj_name = this_obj_name->next)
{ {
if (switch_include_exclude) if (switch_include_exclude)
...@@ -937,21 +939,23 @@ selectDumpableNamespace(NamespaceInfo *nsinfo) ...@@ -937,21 +939,23 @@ selectDumpableNamespace(NamespaceInfo *nsinfo)
* namespaces. If specific namespaces are being dumped, dump just * namespaces. If specific namespaces are being dumped, dump just
* those namespaces. Otherwise, dump all non-system namespaces. * those namespaces. Otherwise, dump all non-system namespaces.
*/ */
if (matchingTables != NULL)
nsinfo->dobj.dump = false; nsinfo->dobj.dump = false;
if (matchingTables != NULL)
/* false */;
else if (matchingSchemas != NULL) else if (matchingSchemas != NULL)
{ {
char *searchname = NULL; char *search_oid = malloc(20);
searchname = malloc(20);
sprintf(searchname, " %d ", nsinfo->dobj.catId.oid); sprintf(search_oid, " %d ", nsinfo->dobj.catId.oid);
if (strstr(matchingSchemas, searchname) != NULL) if (strstr(matchingSchemas, search_oid) != NULL)
nsinfo->dobj.dump = true; nsinfo->dobj.dump = true;
free(searchname);
free(search_oid);
} }
else if (strncmp(nsinfo->dobj.name, "pg_", 3) == 0 || /* The server prevents users from creating pg_ schemas */
strcmp(nsinfo->dobj.name, "information_schema") == 0) else if (strncmp(nsinfo->dobj.name, "pg_", 3) != 0 &&
nsinfo->dobj.dump = false; strcmp(nsinfo->dobj.name, "information_schema") != 0)
else
nsinfo->dobj.dump = true; nsinfo->dobj.dump = true;
} }
...@@ -968,16 +972,21 @@ selectDumpableTable(TableInfo *tbinfo) ...@@ -968,16 +972,21 @@ selectDumpableTable(TableInfo *tbinfo)
* dump. * dump.
*/ */
tbinfo->dobj.dump = false; tbinfo->dobj.dump = false;
if (tbinfo->dobj.namespace->dobj.dump || matchingTables == NULL)
if (matchingTables == NULL)
{
if (tbinfo->dobj.namespace->dobj.dump)
tbinfo->dobj.dump = true; tbinfo->dobj.dump = true;
}
else else
{ {
char *searchname = NULL; char *search_oid = malloc(20);
searchname = malloc(20);
sprintf(searchname, " %d ", tbinfo->dobj.catId.oid); sprintf(search_oid, " %d ", tbinfo->dobj.catId.oid);
if (strstr(matchingTables, searchname) != NULL) if (strstr(matchingTables, search_oid) != NULL)
tbinfo->dobj.dump = true; tbinfo->dobj.dump = true;
free(searchname);
free(search_oid);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment