]> granicus.if.org Git - postgresql/blob - src/bin/scripts/t/100_vacuumdb.pl
Empty search_path in Autovacuum and non-psql/pgbench clients.
[postgresql] / src / bin / scripts / t / 100_vacuumdb.pl
1 use strict;
2 use warnings;
3
4 use PostgresNode;
5 use TestLib;
6 use Test::More tests => 23;
7
8 program_help_ok('vacuumdb');
9 program_version_ok('vacuumdb');
10 program_options_handling_ok('vacuumdb');
11
12 my $node = get_new_node('main');
13 $node->init;
14 $node->start;
15
16 $node->issues_sql_like(
17         [ 'vacuumdb', 'postgres' ],
18         qr/statement: VACUUM;/,
19         'SQL VACUUM run');
20 $node->issues_sql_like(
21         [ 'vacuumdb', '-f', 'postgres' ],
22         qr/statement: VACUUM \(FULL\);/,
23         'vacuumdb -f');
24 $node->issues_sql_like(
25         [ 'vacuumdb', '-F', 'postgres' ],
26         qr/statement: VACUUM \(FREEZE\);/,
27         'vacuumdb -F');
28 $node->issues_sql_like(
29         [ 'vacuumdb', '-zj2', 'postgres' ],
30         qr/statement: VACUUM \(ANALYZE\) pg_catalog\./,
31         'vacuumdb -zj2');
32 $node->issues_sql_like(
33         [ 'vacuumdb', '-Z', 'postgres' ],
34         qr/statement: ANALYZE;/,
35         'vacuumdb -Z');
36 $node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)],
37         'vacuumdb with connection string');
38
39 $node->command_fails([qw(vacuumdb -Zt pg_am;ABORT postgres)],
40         'trailing command in "-t", without COLUMNS');
41 # Unwanted; better if it failed.
42 $node->command_ok([qw(vacuumdb -Zt pg_am(amname);ABORT postgres)],
43         'trailing command in "-t", with COLUMNS');
44
45 $node->safe_psql('postgres', q|
46   CREATE TABLE "need""q(uot" (")x" text);
47
48   CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
49   CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)';
50   CREATE TABLE funcidx (x int);
51   INSERT INTO funcidx VALUES (0),(1),(2),(3);
52   CREATE INDEX i0 ON funcidx ((f1(x)));
53 |);
54 $node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|],
55         'column list');
56 $node->command_fails([qw|vacuumdb -Zt funcidx postgres|],
57         'unqualifed name via functional index');