Fix pg_restore -n option to do what the man page says it does. The
authorTom Lane <[email protected]>
Wed, 12 Apr 2006 22:19:01 +0000 (22:19 +0000)
committerTom Lane <[email protected]>
Wed, 12 Apr 2006 22:19:01 +0000 (22:19 +0000)
original coding only worked if one of the selTypes restriction options
was also given.  Per report from Nick Johnson.

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_restore.c

index 11c1ce8271f1d99ad4984da4641b14ff81026308..ea85a92495a4e2cba1c24a34611ad8f0f0c22ee2 100644 (file)
@@ -1883,18 +1883,20 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
        if (!ropt->create && strcmp(te->desc, "DATABASE") == 0)
                return 0;
 
-       /* Check if tablename only is wanted */
+       /* Check options for selective dump/restore */
+       if (ropt->schemaNames)
+       {
+               /* If no namespace is specified, it means all. */
+               if (!te->namespace)
+                       return 0;
+               if (strcmp(ropt->schemaNames, te->namespace) != 0)
+                       return 0;
+       }
+
        if (ropt->selTypes)
        {
-               if (ropt->schemaNames)
-               {
-                       /* If no namespace is specified, it means all. */
-                       if (!te->namespace)
-                               return 0;
-                       if (strcmp(ropt->schemaNames, te->namespace) != 0)
-                               return 0;
-               }
-               if ((strcmp(te->desc, "TABLE") == 0) || (strcmp(te->desc, "TABLE DATA") == 0))
+               if (strcmp(te->desc, "TABLE") == 0 ||
+                       strcmp(te->desc, "TABLE DATA") == 0)
                {
                        if (!ropt->selTable)
                                return 0;
index 050518fb01dbc73e214eb476ba718c8c4e2da1c0..7c8ade7ab572fe0495ce80b1cd302d0d81844e5c 100644 (file)
@@ -224,7 +224,6 @@ main(int argc, char **argv)
                                break;
 
                        case 'n':                       /* Dump data for this schema only */
-                               opts->selTypes = 1;
                                opts->schemaNames = strdup(optarg);
                                break;