Fix pg_restore -n option to do what the man page says it does. The
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Apr 2006 22:18:48 +0000 (22:18 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 12 Apr 2006 22:18:48 +0000 (22:18 +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 7b883967a330312061c2fcac5bcbd5ed48c97717..e9fea7e3a70732fdb557b04210298ca160bd9bf6 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.125 2006/02/14 23:30:43 tgl Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.126 2006/04/12 22:18:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1908,17 +1908,18 @@ _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)
        {
index dc233c9b0ee8db518ea6d5e48cdddd0ae917b9ac..f9799be68b3209643a7254fd542b8bc9943faf84 100644 (file)
@@ -34,7 +34,7 @@
  *
  *
  * IDENTIFICATION
- *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.76 2006/02/12 06:11:51 momjian Exp $
+ *     $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.77 2006/04/12 22:18:48 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -188,7 +188,6 @@ main(int argc, char **argv)
                break;
 
            case 'n':           /* Dump data for this schema only */
-               opts->selTypes = 1;
                opts->schemaNames = strdup(optarg);
                break;