summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas2013-08-28 06:43:34 +0000
committerHeikki Linnakangas2013-08-28 06:43:34 +0000
commitda85fb4747ac0b7f787ef7a402adea2747e32d8e (patch)
treef09c62c5b60f2b003795bd4f15b7b3a3d296db29 /src
parente246cfc95f020b5fcb20a1fb946efe77113edf00 (diff)
Accept multiple -I, -P, -T and -n options in pg_restore.
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.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup.h8
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c10
-rw-r--r--src/bin/pg_dump/pg_restore.c8
3 files changed, 13 insertions, 13 deletions
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index b456f959692..6927968de0a 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -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;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 5204ceb9643..50619a28157 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -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
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 985c82621ba..26480033a2d 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -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;