Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit648928c

Browse files
vacuumdb: Allow specifying objects to process in all databases.
Presently, vacuumdb's --table, --schema, and --exclude-schemaoptions cannot be used together with --all, i.e., you cannotspecify tables or schemas to process in all databases. This commitremoves this unnecessary restriction, thus enabling potentiallyuseful commands like "vacuumdb --all --schema pg_catalog".Reviewed-by: Kyotaro Horiguchi, Dean RasheedDiscussion:https://postgr.es/m/20230628232402.GA1954626%40nathanxps13
1 parent674e49c commit648928c

File tree

3 files changed

+52
-51
lines changed

3 files changed

+52
-51
lines changed

‎doc/src/sgml/ref/vacuumdb.sgml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ PostgreSQL documentation
3636
</arg>
3737
</arg>
3838

39-
<arg choice="opt"><replaceable>dbname</replaceable></arg>
39+
<arg choice="opt">
40+
<group choice="plain">
41+
<arg choice="plain"><replaceable>dbname</replaceable></arg>
42+
<arg choice="plain"><option>-a</option></arg>
43+
<arg choice="plain"><option>--all</option></arg>
44+
</group>
45+
</arg>
4046
</cmdsynopsis>
4147

4248
<cmdsynopsis>
@@ -47,40 +53,44 @@ PostgreSQL documentation
4753
<arg choice="plain" rep="repeat">
4854
<arg choice="opt">
4955
<group choice="plain">
50-
<arg choice="plain">
51-
<arg choice="opt">
52-
<group choice="plain">
53-
<arg choice="plain"><option>-n</option></arg>
54-
<arg choice="plain"><option>--schema</option></arg>
55-
</group>
56-
<replaceable>schema</replaceable>
57-
</arg>
58-
</arg>
59-
60-
<arg choice="plain">
61-
<arg choice="opt">
62-
<group choice="plain">
63-
<arg choice="plain"><option>-N</option></arg>
64-
<arg choice="plain"><option>--exclude-schema</option></arg>
65-
</group>
66-
<replaceable>schema</replaceable>
67-
</arg>
68-
</arg>
56+
<arg choice="plain"><option>-n</option></arg>
57+
<arg choice="plain"><option>--schema</option></arg>
6958
</group>
59+
<replaceable>schema</replaceable>
7060
</arg>
7161
</arg>
7262

73-
<arg choice="opt"><replaceable>dbname</replaceable></arg>
63+
<arg choice="opt">
64+
<group choice="plain">
65+
<arg choice="plain"><replaceable>dbname</replaceable></arg>
66+
<arg choice="plain"><option>-a</option></arg>
67+
<arg choice="plain"><option>--all</option></arg>
68+
</group>
69+
</arg>
7470
</cmdsynopsis>
7571

7672
<cmdsynopsis>
7773
<command>vacuumdb</command>
7874
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
7975
<arg rep="repeat"><replaceable>option</replaceable></arg>
80-
<group choice="plain">
81-
<arg choice="plain"><option>-a</option></arg>
82-
<arg choice="plain"><option>--all</option></arg>
83-
</group>
76+
77+
<arg choice="plain" rep="repeat">
78+
<arg choice="opt">
79+
<group choice="plain">
80+
<arg choice="plain"><option>-N</option></arg>
81+
<arg choice="plain"><option>--exclude-schema</option></arg>
82+
</group>
83+
<replaceable>schema</replaceable>
84+
</arg>
85+
</arg>
86+
87+
<arg choice="opt">
88+
<group choice="plain">
89+
<arg choice="plain"><replaceable>dbname</replaceable></arg>
90+
<arg choice="plain"><option>-a</option></arg>
91+
<arg choice="plain"><option>--all</option></arg>
92+
</group>
93+
</arg>
8494
</cmdsynopsis>
8595
</refsynopsisdiv>
8696

‎src/bin/scripts/t/100_vacuumdb.pl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@
184184
['vacuumdb','-n','pg_catalog','-N','"Foo"','postgres' ],
185185
qr/cannot vacuum all tables in schema\(s\) and exclude schema\(s\) at the same time/,
186186
'cannot use options -n and -N at the same time');
187-
$node->command_fails_like(
188-
['vacuumdb','-a','-N','"Foo"' ],
189-
qr/cannot exclude specific schema\(s\)in all databases/,
190-
'cannot use options-aand -N at the same time');
191-
$node->command_fails_like(
192-
['vacuumdb','-a','-n','"Foo"' ],
193-
qr/cannot vacuum specific schema\(s\)in all databases/,
194-
'cannot use options-aand -n at the same time');
195-
$node->command_fails_like(
196-
['vacuumdb','-a','-t','"Foo".bar' ],
197-
qr/cannot vacuum specific table\(s\)in all databases/,
198-
'cannot use options-aand -t at the same time');
187+
$node->issues_sql_like(
188+
['vacuumdb','-a','-N','pg_catalog' ],
189+
qr/(?:(?!VACUUM\(SKIP_DATABASE_STATS\)pg_catalog.pg_class).)*/,
190+
'vacuumdb-a-N');
191+
$node->issues_sql_like(
192+
['vacuumdb','-a','-n','pg_catalog' ],
193+
qr/VACUUM\(SKIP_DATABASE_STATS\)pg_catalog.pg_class/,
194+
'vacuumdb-a-n');
195+
$node->issues_sql_like(
196+
['vacuumdb','-a','-t','pg_class' ],
197+
qr/VACUUM\(SKIP_DATABASE_STATS\)pg_catalog.pg_class/,
198+
'vacuumdb-a-t');
199199
$node->command_fails_like(
200200
['vacuumdb','-a','-d','postgres' ],
201201
qr/cannot vacuum all databases and a specific one at the same time/,

‎src/bin/scripts/vacuumdb.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static void vacuum_one_database(ConnParams *cparams,
7272
staticvoidvacuum_all_databases(ConnParams*cparams,
7373
vacuumingOptions*vacopts,
7474
boolanalyze_in_stages,
75+
SimpleStringList*objects,
7576
intconcurrentCons,
7677
constchar*progname,boolecho,boolquiet);
7778

@@ -378,6 +379,7 @@ main(int argc, char *argv[])
378379

379380
vacuum_all_databases(&cparams,&vacopts,
380381
analyze_in_stages,
382+
&objects,
381383
concurrentCons,
382384
progname,echo,quiet);
383385
}
@@ -429,18 +431,6 @@ check_objfilter(void)
429431
(objfilter&OBJFILTER_DATABASE))
430432
pg_fatal("cannot vacuum all databases and a specific one at the same time");
431433

432-
if ((objfilter&OBJFILTER_ALL_DBS)&&
433-
(objfilter&OBJFILTER_TABLE))
434-
pg_fatal("cannot vacuum specific table(s) in all databases");
435-
436-
if ((objfilter&OBJFILTER_ALL_DBS)&&
437-
(objfilter&OBJFILTER_SCHEMA))
438-
pg_fatal("cannot vacuum specific schema(s) in all databases");
439-
440-
if ((objfilter&OBJFILTER_ALL_DBS)&&
441-
(objfilter&OBJFILTER_SCHEMA_EXCLUDE))
442-
pg_fatal("cannot exclude specific schema(s) in all databases");
443-
444434
if ((objfilter&OBJFILTER_TABLE)&&
445435
(objfilter&OBJFILTER_SCHEMA))
446436
pg_fatal("cannot vacuum all tables in schema(s) and specific table(s) at the same time");
@@ -895,6 +885,7 @@ static void
895885
vacuum_all_databases(ConnParams*cparams,
896886
vacuumingOptions*vacopts,
897887
boolanalyze_in_stages,
888+
SimpleStringList*objects,
898889
intconcurrentCons,
899890
constchar*progname,boolecho,boolquiet)
900891
{
@@ -927,7 +918,7 @@ vacuum_all_databases(ConnParams *cparams,
927918

928919
vacuum_one_database(cparams,vacopts,
929920
stage,
930-
NULL,
921+
objects,
931922
concurrentCons,
932923
progname,echo,quiet);
933924
}
@@ -941,7 +932,7 @@ vacuum_all_databases(ConnParams *cparams,
941932

942933
vacuum_one_database(cparams,vacopts,
943934
ANALYZE_NO_STAGE,
944-
NULL,
935+
objects,
945936
concurrentCons,
946937
progname,echo,quiet);
947938
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp