Presently, vacuumdb's --table, --schema, and --exclude-schema
options cannot be used together with --all, i.e., you cannot
specify tables or schemas to process in all databases. This commit
removes this unnecessary restriction, thus enabling potentially
useful commands like "vacuumdb --all --schema pg_catalog".
Reviewed-by: Kyotaro Horiguchi, Dean Rasheed
Discussion: https://postgr.es/m/
20230628232402.GA1954626%40nathanxps13
</arg>
</arg>
- <arg choice="opt"><replaceable>dbname</replaceable></arg>
+ <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>
<cmdsynopsis>
<arg choice="plain" rep="repeat">
<arg choice="opt">
<group choice="plain">
- <arg choice="plain">
- <arg choice="opt">
- <group choice="plain">
- <arg choice="plain"><option>-n</option></arg>
- <arg choice="plain"><option>--schema</option></arg>
- </group>
- <replaceable>schema</replaceable>
- </arg>
- </arg>
-
- <arg choice="plain">
- <arg choice="opt">
- <group choice="plain">
- <arg choice="plain"><option>-N</option></arg>
- <arg choice="plain"><option>--exclude-schema</option></arg>
- </group>
- <replaceable>schema</replaceable>
- </arg>
- </arg>
+ <arg choice="plain"><option>-n</option></arg>
+ <arg choice="plain"><option>--schema</option></arg>
</group>
+ <replaceable>schema</replaceable>
</arg>
</arg>
- <arg choice="opt"><replaceable>dbname</replaceable></arg>
+ <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>
<cmdsynopsis>
<command>vacuumdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>
- <group choice="plain">
- <arg choice="plain"><option>-a</option></arg>
- <arg choice="plain"><option>--all</option></arg>
- </group>
+
+ <arg choice="plain" rep="repeat">
+ <arg choice="opt">
+ <group choice="plain">
+ <arg choice="plain"><option>-N</option></arg>
+ <arg choice="plain"><option>--exclude-schema</option></arg>
+ </group>
+ <replaceable>schema</replaceable>
+ </arg>
+ </arg>
+
+ <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>
[ 'vacuumdb', '-n', 'pg_catalog', '-N', '"Foo"', 'postgres' ],
qr/cannot vacuum all tables in schema\(s\) and exclude schema\(s\) at the same time/,
'cannot use options -n and -N at the same time');
-$node->command_fails_like(
- [ 'vacuumdb', '-a', '-N', '"Foo"' ],
- qr/cannot exclude specific schema\(s\) in all databases/,
- 'cannot use options -a and -N at the same time');
-$node->command_fails_like(
- [ 'vacuumdb', '-a', '-n', '"Foo"' ],
- qr/cannot vacuum specific schema\(s\) in all databases/,
- 'cannot use options -a and -n at the same time');
-$node->command_fails_like(
- [ 'vacuumdb', '-a', '-t', '"Foo".bar' ],
- qr/cannot vacuum specific table\(s\) in all databases/,
- 'cannot use options -a and -t at the same time');
+$node->issues_sql_like(
+ [ 'vacuumdb', '-a', '-N', 'pg_catalog' ],
+ qr/(?:(?!VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class).)*/,
+ 'vacuumdb -a -N');
+$node->issues_sql_like(
+ [ 'vacuumdb', '-a', '-n', 'pg_catalog' ],
+ qr/VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class/,
+ 'vacuumdb -a -n');
+$node->issues_sql_like(
+ [ 'vacuumdb', '-a', '-t', 'pg_class' ],
+ qr/VACUUM \(SKIP_DATABASE_STATS\) pg_catalog.pg_class/,
+ 'vacuumdb -a -t');
$node->command_fails_like(
[ 'vacuumdb', '-a', '-d', 'postgres' ],
qr/cannot vacuum all databases and a specific one at the same time/,
static void vacuum_all_databases(ConnParams *cparams,
vacuumingOptions *vacopts,
bool analyze_in_stages,
+ SimpleStringList *objects,
int concurrentCons,
const char *progname, bool echo, bool quiet);
vacuum_all_databases(&cparams, &vacopts,
analyze_in_stages,
+ &objects,
concurrentCons,
progname, echo, quiet);
}
(objfilter & OBJFILTER_DATABASE))
pg_fatal("cannot vacuum all databases and a specific one at the same time");
- if ((objfilter & OBJFILTER_ALL_DBS) &&
- (objfilter & OBJFILTER_TABLE))
- pg_fatal("cannot vacuum specific table(s) in all databases");
-
- if ((objfilter & OBJFILTER_ALL_DBS) &&
- (objfilter & OBJFILTER_SCHEMA))
- pg_fatal("cannot vacuum specific schema(s) in all databases");
-
- if ((objfilter & OBJFILTER_ALL_DBS) &&
- (objfilter & OBJFILTER_SCHEMA_EXCLUDE))
- pg_fatal("cannot exclude specific schema(s) in all databases");
-
if ((objfilter & OBJFILTER_TABLE) &&
(objfilter & OBJFILTER_SCHEMA))
pg_fatal("cannot vacuum all tables in schema(s) and specific table(s) at the same time");
vacuum_all_databases(ConnParams *cparams,
vacuumingOptions *vacopts,
bool analyze_in_stages,
+ SimpleStringList *objects,
int concurrentCons,
const char *progname, bool echo, bool quiet)
{
vacuum_one_database(cparams, vacopts,
stage,
- NULL,
+ objects,
concurrentCons,
progname, echo, quiet);
}
vacuum_one_database(cparams, vacopts,
ANALYZE_NO_STAGE,
- NULL,
+ objects,
concurrentCons,
progname, echo, quiet);
}