diff options
author | Magnus Hagander <magnus@hagander.net> | 2013-01-17 11:24:47 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2013-01-17 11:24:47 +0100 |
commit | f3af53441ed0b306692a1cc31003a84d1b5b3cf7 (patch) | |
tree | d21b2e0fd1885497eabb8fd294e652cf856b4ad0 /src/bin/scripts/clusterdb.c | |
parent | 36bdfa52a0780d2fcbb48665ab7ca98a13593fdf (diff) | |
download | postgresql-f3af53441ed0b306692a1cc31003a84d1b5b3cf7.tar.gz postgresql-f3af53441ed0b306692a1cc31003a84d1b5b3cf7.zip |
Support multiple -t/--table arguments for more commands
On top of the previous support in pg_dump, add support to specify
multiple tables (by using the -t option multiple times) to
pg_restore, clsuterdb, reindexdb and vacuumdb.
Josh Kupershmidt, reviewed by Karl O. Pinc
Diffstat (limited to 'src/bin/scripts/clusterdb.c')
-rw-r--r-- | src/bin/scripts/clusterdb.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/bin/scripts/clusterdb.c b/src/bin/scripts/clusterdb.c index 414c8c974d0..0ac213d3c31 100644 --- a/src/bin/scripts/clusterdb.c +++ b/src/bin/scripts/clusterdb.c @@ -58,8 +58,8 @@ main(int argc, char *argv[]) bool echo = false; bool quiet = false; bool alldb = false; - char *table = NULL; bool verbose = false; + SimpleStringList tables = {NULL, NULL}; progname = get_progname(argv[0]); set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pgscripts")); @@ -98,7 +98,7 @@ main(int argc, char *argv[]) alldb = true; break; case 't': - table = pg_strdup(optarg); + simple_string_list_append(&tables, optarg); break; case 'v': verbose = true; @@ -140,9 +140,10 @@ main(int argc, char *argv[]) progname); exit(1); } - if (table) + + if (tables.head != NULL) { - fprintf(stderr, _("%s: cannot cluster a specific table in all databases\n"), + fprintf(stderr, _("%s: cannot cluster specific table(s) in all databases\n"), progname); exit(1); } @@ -162,9 +163,21 @@ main(int argc, char *argv[]) dbname = get_user_name(progname); } - cluster_one_database(dbname, verbose, table, - host, port, username, prompt_password, - progname, echo); + if (tables.head != NULL) + { + SimpleStringListCell *cell; + + for (cell = tables.head; cell; cell = cell->next) + { + cluster_one_database(dbname, verbose, cell->val, + host, port, username, prompt_password, + progname, echo); + } + } + else + cluster_one_database(dbname, verbose, NULL, + host, port, username, prompt_password, + progname, echo); } exit(0); @@ -253,7 +266,7 @@ help(const char *progname) printf(_(" -d, --dbname=DBNAME database to cluster\n")); printf(_(" -e, --echo show the commands being sent to the server\n")); printf(_(" -q, --quiet don't write any messages\n")); - printf(_(" -t, --table=TABLE cluster specific table only\n")); + printf(_(" -t, --table=TABLE cluster specific table(s) only\n")); printf(_(" -v, --verbose write a lot of output\n")); printf(_(" -V, --version output version information, then exit\n")); printf(_(" -?, --help show this help, then exit\n")); |