<cmdsynopsis>
<command>clusterdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
- <group choice="opt"><arg choice="plain"><option>--verbose</option></arg><arg choice="plain"><option>-v</option></arg></group>
+ <arg rep="repeat"><replaceable>option</replaceable></arg>
<arg choice="plain" rep="repeat">
<arg choice="opt">
</arg>
</arg>
- <arg choice="opt"><replaceable>dbname</replaceable></arg>
- </cmdsynopsis>
-
- <cmdsynopsis>
- <command>clusterdb</command>
- <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
- <group choice="opt"><arg choice="plain"><option>--verbose</option></arg><arg choice="plain"><option>-v</option></arg></group>
- <group choice="plain"><arg choice="plain"><option>--all</option></arg><arg choice="plain"><option>-a</option></arg></group>
+ <arg choice="opt">
+ <group choice="plain">
+ <arg choice="plain"><replaceable>dbname</replaceable></arg>
+ <arg choice="plain"><option>-a</option></arg>
+ <arg choice="plain"><option>--all</option></arg>
+ </group>
+ </arg>
</cmdsynopsis>
</refsynopsisdiv>
static void cluster_one_database(const ConnParams *cparams, const char *table,
const char *progname, bool verbose, bool echo);
-static void cluster_all_databases(ConnParams *cparams, const char *progname,
- bool verbose, bool echo, bool quiet);
+static void cluster_all_databases(ConnParams *cparams, SimpleStringList *tables,
+ const char *progname, bool verbose, bool echo,
+ bool quiet);
static void help(const char *progname);
if (dbname)
pg_fatal("cannot cluster all databases and a specific one at the same time");
- if (tables.head != NULL)
- pg_fatal("cannot cluster specific table(s) in all databases");
-
cparams.dbname = maintenance_db;
- cluster_all_databases(&cparams, progname, verbose, echo, quiet);
+ cluster_all_databases(&cparams, &tables,
+ progname, verbose, echo, quiet);
}
else
{
static void
-cluster_all_databases(ConnParams *cparams, const char *progname,
- bool verbose, bool echo, bool quiet)
+cluster_all_databases(ConnParams *cparams, SimpleStringList *tables,
+ const char *progname, bool verbose, bool echo,
+ bool quiet)
{
PGconn *conn;
PGresult *result;
cparams->override_dbname = dbname;
- cluster_one_database(cparams, NULL, progname, verbose, echo);
+ if (tables->head != NULL)
+ {
+ SimpleStringListCell *cell;
+
+ for (cell = tables->head; cell; cell = cell->next)
+ cluster_one_database(cparams, cell->val,
+ progname, verbose, echo);
+ }
+ else
+ cluster_one_database(cparams, NULL,
+ progname, verbose, echo);
}
PQclear(result);
qr/FATAL: cannot connect to invalid database "regression_invalid"/,
'clusterdb cannot target invalid database');
+$node->safe_psql('postgres',
+ 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x'
+);
+$node->safe_psql('template1',
+ 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x'
+);
+$node->issues_sql_like(
+ [ 'clusterdb', '-a', '-t', 'test1' ],
+ qr/statement: CLUSTER public\.test1/s,
+ 'cluster specific table in all databases');
+
done_testing();