]> granicus.if.org Git - postgresql/commitdiff
Accept multiple -I, -P, -T and -n options in pg_restore.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 28 Aug 2013 06:43:34 +0000 (09:43 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 28 Aug 2013 06:43:34 +0000 (09:43 +0300)
We already did this for -t (--table) in 9.3, but missed the other similar
options. For consistency, allow all of them to be specified multiple times.

Unfortunately it's too late to sneak this into 9.3, so commit to master
only.

doc/src/sgml/ref/pg_restore.sgml
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_restore.c

index 7c48fcd288f303b6e6024138722315e66eaf0b4e..717da4272dd422035060f09c82f48dfa105c6a37 100644 (file)
       <term><option>--index=<replaceable class="parameter">index</replaceable></option></term>
       <listitem>
        <para>
-        Restore definition of named index only.
+        Restore definition of named index only.  Multiple indexes
+        may be specified with multiple <option>-I</> switches.
        </para>
       </listitem>
      </varlistentry>
       <term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term>
       <listitem>
        <para>
-        Restore only objects that are in the named schema.  This can be
+        Restore only objects that are in the named schema.  Multiple schemas
+        may be specified with multiple <option>-n</> switches.  This can be
         combined with the <option>-t</option> option to restore just a
         specific table.
        </para>
        <para>
         Restore the named function only.  Be careful to spell the function
         name and arguments exactly as they appear in the dump file's table
-        of contents.
+        of contents.  Multiple functions may be specified with multiple
+        <option>-P</> switches.
        </para>
       </listitem>
      </varlistentry>
       <term><option>--trigger=<replaceable class="parameter">trigger</replaceable></option></term>
       <listitem>
        <para>
-        Restore named trigger only.
+        Restore named trigger only.  Multiple triggers may be specified with
+        multiple <option>-T</> switches.
        </para>
       </listitem>
      </varlistentry>
index b456f959692ba07c15302f183cc04849f18d1098..6927968de0a0d7e087d14f05089111c90403f341 100644 (file)
@@ -129,10 +129,10 @@ typedef struct _restoreOptions
        int                     selFunction;
        int                     selTrigger;
        int                     selTable;
-       char       *indexNames;
-       char       *functionNames;
-       char       *schemaNames;
-       char       *triggerNames;
+       SimpleStringList indexNames;
+       SimpleStringList functionNames;
+       SimpleStringList schemaNames;
+       SimpleStringList triggerNames;
        SimpleStringList tableNames;
 
        int                     useDB;
index 5204ceb96430d7f635eab4b2dc4fb876e9791a76..50619a2815782bd6be9e3f17a7337bb4389bc227 100644 (file)
@@ -2456,12 +2456,12 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
        }
 
        /* Check options for selective dump/restore */
-       if (ropt->schemaNames)
+       if (ropt->schemaNames.head != NULL)
        {
                /* If no namespace is specified, it means all. */
                if (!te->namespace)
                        return 0;
-               if (strcmp(ropt->schemaNames, te->namespace) != 0)
+               if (!(simple_string_list_member(&ropt->schemaNames, te->namespace)))
                        return 0;
        }
 
@@ -2479,21 +2479,21 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
                {
                        if (!ropt->selIndex)
                                return 0;
-                       if (ropt->indexNames && strcmp(ropt->indexNames, te->tag) != 0)
+                       if (ropt->indexNames.head != NULL && (!(simple_string_list_member(&ropt->indexNames, te->tag))))
                                return 0;
                }
                else if (strcmp(te->desc, "FUNCTION") == 0)
                {
                        if (!ropt->selFunction)
                                return 0;
-                       if (ropt->functionNames && strcmp(ropt->functionNames, te->tag) != 0)
+                       if (ropt->functionNames.head != NULL && (!(simple_string_list_member(&ropt->functionNames, te->tag))))
                                return 0;
                }
                else if (strcmp(te->desc, "TRIGGER") == 0)
                {
                        if (!ropt->selTrigger)
                                return 0;
-                       if (ropt->triggerNames && strcmp(ropt->triggerNames, te->tag) != 0)
+                       if (ropt->triggerNames.head != NULL && (!(simple_string_list_member(&ropt->triggerNames, te->tag))))
                                return 0;
                }
                else
index 985c82621ba5a66cc0bdc936af927e044d6e66fc..26480033a2dbda5b8af02aedd90646ba7958edce 100644 (file)
@@ -196,7 +196,7 @@ main(int argc, char **argv)
                                break;
 
                        case 'n':                       /* Dump data for this schema only */
-                               opts->schemaNames = pg_strdup(optarg);
+                               simple_string_list_append(&opts->schemaNames, optarg);
                                break;
 
                        case 'O':
@@ -213,17 +213,17 @@ main(int argc, char **argv)
                        case 'P':                       /* Function */
                                opts->selTypes = 1;
                                opts->selFunction = 1;
-                               opts->functionNames = pg_strdup(optarg);
+                               simple_string_list_append(&opts->functionNames, optarg);
                                break;
                        case 'I':                       /* Index */
                                opts->selTypes = 1;
                                opts->selIndex = 1;
-                               opts->indexNames = pg_strdup(optarg);
+                               simple_string_list_append(&opts->indexNames, optarg);
                                break;
                        case 'T':                       /* Trigger */
                                opts->selTypes = 1;
                                opts->selTrigger = 1;
-                               opts->triggerNames = pg_strdup(optarg);
+                               simple_string_list_append(&opts->triggerNames, optarg);
                                break;
                        case 's':                       /* dump schema only */
                                opts->schemaOnly = 1;