Skip to content

These two new options can be used to either process all tables in #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions doc/src/sgml/ref/vacuumdb.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,40 @@ PostgreSQL documentation
<arg choice="opt"><replaceable>dbname</replaceable></arg>
</cmdsynopsis>

<cmdsynopsis>
<command>vacuumdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
<arg rep="repeat"><replaceable>option</replaceable></arg>

<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>
</group>
</arg>
</arg>

<arg choice="opt"><replaceable>dbname</replaceable></arg>
</cmdsynopsis>

<cmdsynopsis>
<command>vacuumdb</command>
<arg rep="repeat"><replaceable>connection-option</replaceable></arg>
Expand Down Expand Up @@ -244,6 +278,30 @@ PostgreSQL documentation
</listitem>
</varlistentry>

<varlistentry>
<term><option>-n <replaceable class="parameter">schema</replaceable></option></term>
<term><option>--schema=<replaceable class="parameter">schema</replaceable></option></term>
<listitem>
<para>
Clean or analyze all tables in
<replaceable class="parameter">schema</replaceable> only. Multiple
schemas can be vacuumed by writing multiple <option>-n</option> switches.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>-N <replaceable class="parameter">schema</replaceable></option></term>
<term><option>--exclude-schema=<replaceable class="parameter">schema</replaceable></option></term>
<listitem>
<para>
Do not clean or analyze any tables in
<replaceable class="parameter">schema</replaceable>. Multiple schemas
can be excluded by writing multiple <option>-N</option> switches.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><option>--no-index-cleanup</option></term>
<listitem>
Expand Down Expand Up @@ -619,6 +677,14 @@ PostgreSQL documentation
<prompt>$ </prompt><userinput>vacuumdb --analyze --verbose --table='foo(bar)' xyzzy</userinput>
</screen></para>

<para>
To clean all tables in the <literal>foo</literal> and <literal>bar</literal> schemas
in a database named <literal>xyzzy</literal>:
<screen>
<prompt>$ </prompt><userinput>vacuumdb --schema='foo' --schema='bar' xyzzy</userinput>
</screen></para>


</refsect1>

<refsect1>
Expand Down
35 changes: 35 additions & 0 deletions src/bin/scripts/t/100_vacuumdb.pl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
CREATE TABLE funcidx (x int);
INSERT INTO funcidx VALUES (0),(1),(2),(3);
CREATE INDEX i0 ON funcidx ((f1(x)));
CREATE SCHEMA "Foo";
CREATE TABLE "Foo".bar(id int);
|);
$node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|],
'column list');
Expand Down Expand Up @@ -146,5 +148,38 @@
[ 'vacuumdb', '--min-xid-age', '2147483001', 'postgres' ],
qr/GREATEST.*relfrozenxid.*2147483001/,
'vacuumdb --table --min-xid-age');
$node->issues_sql_like(
[ 'vacuumdb', '--schema', '"Foo"', 'postgres' ],
qr/VACUUM "Foo".bar/,
'vacuumdb --schema schema only');
$node->issues_sql_like(
[ 'vacuumdb', '--exclude-schema', '"Foo"', 'postgres' ],
qr/(?:(?!VACUUM "Foo".bar).)*/,
'vacuumdb --exclude-schema schema');
$node->command_fails(
[ 'vacuumdb', '-n', 'pg_catalog', '-t', 'pg_class', 'postgres' ],
'cannot use options -n and -t at the same time');
$node->command_fails(
[ 'vacuumdb', '-n', 'pg_catalog', '-N', '"Foo"', 'postgres' ],
'cannot use options -n and -N at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', '-N', '"Foo"' ],
'cannot use options -a and -N at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', '-n', '"Foo"' ],
'cannot use options -a and -n at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', '-t', '"Foo".bar' ],
'cannot use options -a and -t at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', '-n', '"Foo"', 'postgres' ],
'cannot use options -a and -n at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', '-d', 'postgres' ],
'cannot use options -a and -d at the same time');
$node->command_fails(
[ 'vacuumdb', '-a', 'postgres' ],
'cannot use option -a and a dbname as argument at the same time');


done_testing();
3 changes: 3 additions & 0 deletions src/bin/scripts/t/101_vacuumdb_all.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
[ 'vacuumdb', '-a' ],
qr/statement: VACUUM.*statement: VACUUM/s,
'vacuum all databases');
$node->command_fails(
[ 'vacuumdb', '-a', '-n', 'pg_catalog' ],
'cannot vacuum specific schema(s) in all databases');

done_testing();
Loading