diff options
Diffstat (limited to 'src/bin/scripts/t')
-rw-r--r-- | src/bin/scripts/t/010_clusterdb.pl | 33 | ||||
-rw-r--r-- | src/bin/scripts/t/011_clusterdb_all.pl | 19 | ||||
-rw-r--r-- | src/bin/scripts/t/020_createdb.pl | 50 | ||||
-rw-r--r-- | src/bin/scripts/t/040_createuser.pl | 34 | ||||
-rw-r--r-- | src/bin/scripts/t/050_dropdb.pl | 29 | ||||
-rw-r--r-- | src/bin/scripts/t/070_dropuser.pl | 23 | ||||
-rw-r--r-- | src/bin/scripts/t/080_pg_isready.pl | 20 | ||||
-rw-r--r-- | src/bin/scripts/t/090_reindexdb.pl | 121 | ||||
-rw-r--r-- | src/bin/scripts/t/091_reindexdb_all.pl | 16 | ||||
-rw-r--r-- | src/bin/scripts/t/100_vacuumdb.pl | 124 | ||||
-rw-r--r-- | src/bin/scripts/t/101_vacuumdb_all.pl | 14 | ||||
-rw-r--r-- | src/bin/scripts/t/102_vacuumdb_stages.pl | 35 | ||||
-rw-r--r-- | src/bin/scripts/t/200_connstr.pl | 39 |
13 files changed, 557 insertions, 0 deletions
diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl new file mode 100644 index 0000000..ba093fa --- /dev/null +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -0,0 +1,33 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 14; + +program_help_ok('clusterdb'); +program_version_ok('clusterdb'); +program_options_handling_ok('clusterdb'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + ['clusterdb'], + qr/statement: CLUSTER;/, + 'SQL CLUSTER run'); + +$node->command_fails([ 'clusterdb', '-t', 'nonexistent' ], + 'fails with nonexistent table'); + +$node->safe_psql('postgres', + 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x' +); +$node->issues_sql_like( + [ 'clusterdb', '-t', 'test1' ], + qr/statement: CLUSTER public\.test1;/, + 'cluster specific table'); + +$node->command_ok([qw(clusterdb --echo --verbose dbname=template1)], + 'clusterdb with connection string'); diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl new file mode 100644 index 0000000..efd541b --- /dev/null +++ b/src/bin/scripts/t/011_clusterdb_all.pl @@ -0,0 +1,19 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 2; + +my $node = get_new_node('main'); +$node->init; +$node->start; + +# clusterdb -a is not compatible with -d, hence enforce environment variable +# correctly. +$ENV{PGDATABASE} = 'postgres'; + +$node->issues_sql_like( + [ 'clusterdb', '-a' ], + qr/statement: CLUSTER.*statement: CLUSTER/s, + 'cluster all databases'); diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl new file mode 100644 index 0000000..983dbb1 --- /dev/null +++ b/src/bin/scripts/t/020_createdb.pl @@ -0,0 +1,50 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 22; + +program_help_ok('createdb'); +program_version_ok('createdb'); +program_options_handling_ok('createdb'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + [ 'createdb', 'foobar1' ], + qr/statement: CREATE DATABASE foobar1/, + 'SQL CREATE DATABASE run'); +$node->issues_sql_like( + [ 'createdb', '-l', 'C', '-E', 'LATIN1', '-T', 'template0', 'foobar2' ], + qr/statement: CREATE DATABASE foobar2 ENCODING 'LATIN1'/, + 'create database with encoding'); + +$node->command_fails([ 'createdb', 'foobar1' ], + 'fails if database already exists'); + +# Check quote handling with incorrect option values. +$node->command_checks_all( + [ 'createdb', '--encoding', "foo'; SELECT '1", 'foobar2' ], + 1, + [qr/^$/], + [qr/^createdb: error: "foo'; SELECT '1" is not a valid encoding name/s], + 'createdb with incorrect --encoding'); +$node->command_checks_all( + [ 'createdb', '--lc-collate', "foo'; SELECT '1", 'foobar2' ], + 1, + [qr/^$/], + [ + qr/^createdb: error: database creation failed: ERROR: invalid locale name|^createdb: error: database creation failed: ERROR: new collation \(foo'; SELECT '1\) is incompatible with the collation of the template database/s + ], + 'createdb with incorrect --lc-collate'); +$node->command_checks_all( + [ 'createdb', '--lc-ctype', "foo'; SELECT '1", 'foobar2' ], + 1, + [qr/^$/], + [ + qr/^createdb: error: database creation failed: ERROR: invalid locale name|^createdb: error: database creation failed: ERROR: new LC_CTYPE \(foo'; SELECT '1\) is incompatible with the LC_CTYPE of the template database/s + ], + 'createdb with incorrect --lc-ctype'); diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl new file mode 100644 index 0000000..916d925 --- /dev/null +++ b/src/bin/scripts/t/040_createuser.pl @@ -0,0 +1,34 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 17; + +program_help_ok('createuser'); +program_version_ok('createuser'); +program_options_handling_ok('createuser'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + [ 'createuser', 'regress_user1' ], + qr/statement: CREATE ROLE regress_user1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;/, + 'SQL CREATE USER run'); +$node->issues_sql_like( + [ 'createuser', '-L', 'regress_role1' ], + qr/statement: CREATE ROLE regress_role1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOLOGIN;/, + 'create a non-login role'); +$node->issues_sql_like( + [ 'createuser', '-r', 'regress_user2' ], + qr/statement: CREATE ROLE regress_user2 NOSUPERUSER NOCREATEDB CREATEROLE INHERIT LOGIN;/, + 'create a CREATEROLE user'); +$node->issues_sql_like( + [ 'createuser', '-s', 'regress_user3' ], + qr/statement: CREATE ROLE regress_user3 SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;/, + 'create a superuser'); + +$node->command_fails([ 'createuser', 'regress_user1' ], + 'fails if role already exists'); diff --git a/src/bin/scripts/t/050_dropdb.pl b/src/bin/scripts/t/050_dropdb.pl new file mode 100644 index 0000000..c51babe --- /dev/null +++ b/src/bin/scripts/t/050_dropdb.pl @@ -0,0 +1,29 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 13; + +program_help_ok('dropdb'); +program_version_ok('dropdb'); +program_options_handling_ok('dropdb'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->safe_psql('postgres', 'CREATE DATABASE foobar1'); +$node->issues_sql_like( + [ 'dropdb', 'foobar1' ], + qr/statement: DROP DATABASE foobar1/, + 'SQL DROP DATABASE run'); + +$node->safe_psql('postgres', 'CREATE DATABASE foobar2'); +$node->issues_sql_like( + [ 'dropdb', '--force', 'foobar2' ], + qr/statement: DROP DATABASE foobar2 WITH \(FORCE\);/, + 'SQL DROP DATABASE (FORCE) run'); + +$node->command_fails([ 'dropdb', 'nonexistent' ], + 'fails with nonexistent database'); diff --git a/src/bin/scripts/t/070_dropuser.pl b/src/bin/scripts/t/070_dropuser.pl new file mode 100644 index 0000000..2e858c5 --- /dev/null +++ b/src/bin/scripts/t/070_dropuser.pl @@ -0,0 +1,23 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 11; + +program_help_ok('dropuser'); +program_version_ok('dropuser'); +program_options_handling_ok('dropuser'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->safe_psql('postgres', 'CREATE ROLE regress_foobar1'); +$node->issues_sql_like( + [ 'dropuser', 'regress_foobar1' ], + qr/statement: DROP ROLE regress_foobar1/, + 'SQL DROP ROLE run'); + +$node->command_fails([ 'dropuser', 'regress_nonexistent' ], + 'fails with nonexistent user'); diff --git a/src/bin/scripts/t/080_pg_isready.pl b/src/bin/scripts/t/080_pg_isready.pl new file mode 100644 index 0000000..6da89e1 --- /dev/null +++ b/src/bin/scripts/t/080_pg_isready.pl @@ -0,0 +1,20 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 10; + +program_help_ok('pg_isready'); +program_version_ok('pg_isready'); +program_options_handling_ok('pg_isready'); + +command_fails(['pg_isready'], 'fails with no server running'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +# use a long timeout for the benefit of very slow buildfarm machines +$node->command_ok([qw(pg_isready --timeout=60)], + 'succeeds with server running'); diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl new file mode 100644 index 0000000..d02cca7 --- /dev/null +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -0,0 +1,121 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 44; + +program_help_ok('reindexdb'); +program_version_ok('reindexdb'); +program_options_handling_ok('reindexdb'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$ENV{PGOPTIONS} = '--client-min-messages=WARNING'; + +$node->issues_sql_like( + [ 'reindexdb', 'postgres' ], + qr/statement: REINDEX DATABASE postgres;/, + 'SQL REINDEX run'); + +$node->safe_psql('postgres', + 'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a);'); +$node->issues_sql_like( + [ 'reindexdb', '-t', 'test1', 'postgres' ], + qr/statement: REINDEX TABLE public\.test1;/, + 'reindex specific table'); +$node->issues_sql_like( + [ 'reindexdb', '-i', 'test1x', 'postgres' ], + qr/statement: REINDEX INDEX public\.test1x;/, + 'reindex specific index'); +$node->issues_sql_like( + [ 'reindexdb', '-S', 'pg_catalog', 'postgres' ], + qr/statement: REINDEX SCHEMA pg_catalog;/, + 'reindex specific schema'); +$node->issues_sql_like( + [ 'reindexdb', '-s', 'postgres' ], + qr/statement: REINDEX SYSTEM postgres;/, + 'reindex system tables'); +$node->issues_sql_like( + [ 'reindexdb', '-v', '-t', 'test1', 'postgres' ], + qr/statement: REINDEX \(VERBOSE\) TABLE public\.test1;/, + 'reindex with verbose output'); + +# the same with --concurrently +$node->issues_sql_like( + [ 'reindexdb', '--concurrently', 'postgres' ], + qr/statement: REINDEX DATABASE CONCURRENTLY postgres;/, + 'SQL REINDEX CONCURRENTLY run'); + +$node->issues_sql_like( + [ 'reindexdb', '--concurrently', '-t', 'test1', 'postgres' ], + qr/statement: REINDEX TABLE CONCURRENTLY public\.test1;/, + 'reindex specific table concurrently'); +$node->issues_sql_like( + [ 'reindexdb', '--concurrently', '-i', 'test1x', 'postgres' ], + qr/statement: REINDEX INDEX CONCURRENTLY public\.test1x;/, + 'reindex specific index concurrently'); +$node->issues_sql_like( + [ 'reindexdb', '--concurrently', '-S', 'public', 'postgres' ], + qr/statement: REINDEX SCHEMA CONCURRENTLY public;/, + 'reindex specific schema concurrently'); +$node->command_fails([ 'reindexdb', '--concurrently', '-s', 'postgres' ], + 'reindex system tables concurrently'); +$node->issues_sql_like( + [ 'reindexdb', '--concurrently', '-v', '-t', 'test1', 'postgres' ], + qr/statement: REINDEX \(VERBOSE\) TABLE CONCURRENTLY public\.test1;/, + 'reindex with verbose output concurrently'); + +# connection strings +$node->command_ok([qw(reindexdb --echo --table=pg_am dbname=template1)], + 'reindexdb table with connection string'); +$node->command_ok( + [qw(reindexdb --echo dbname=template1)], + 'reindexdb database with connection string'); +$node->command_ok( + [qw(reindexdb --echo --system dbname=template1)], + 'reindexdb system with connection string'); + +# parallel processing +$node->safe_psql( + 'postgres', q| + CREATE SCHEMA s1; + CREATE TABLE s1.t1(id integer); + CREATE INDEX ON s1.t1(id); + CREATE SCHEMA s2; + CREATE TABLE s2.t2(id integer); + CREATE INDEX ON s2.t2(id); + -- empty schema + CREATE SCHEMA s3; +|); + +$node->command_fails( + [ 'reindexdb', '-j', '2', '-s', 'postgres' ], + 'parallel reindexdb cannot process system catalogs'); +$node->command_fails( + [ 'reindexdb', '-j', '2', '-i', 'i1', 'postgres' ], + 'parallel reindexdb cannot process indexes'); +$node->issues_sql_like( + [ 'reindexdb', '-j', '2', 'postgres' ], + qr/statement:\ REINDEX SYSTEM postgres; +.*statement:\ REINDEX TABLE public\.test1/s, + 'parallel reindexdb for database issues REINDEX SYSTEM first'); +# Note that the ordering of the commands is not stable, so the second +# command for s2.t2 is not checked after. +$node->issues_sql_like( + [ 'reindexdb', '-j', '2', '-S', 's1', '-S', 's2', 'postgres' ], + qr/statement:\ REINDEX TABLE s1.t1;/, + 'parallel reindexdb for schemas does a per-table REINDEX'); +$node->command_ok( + [ 'reindexdb', '-j', '2', '-S', 's3' ], + 'parallel reindexdb with empty schema'); +$node->command_checks_all( + [ 'reindexdb', '-j', '2', '--concurrently', '-d', 'postgres' ], + 0, + [qr/^$/], + [ + qr/^reindexdb: warning: cannot reindex system catalogs concurrently, skipping all/s + ], + 'parallel reindexdb for system with --concurrently skips catalogs'); diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl new file mode 100644 index 0000000..8e60414 --- /dev/null +++ b/src/bin/scripts/t/091_reindexdb_all.pl @@ -0,0 +1,16 @@ +use strict; +use warnings; + +use PostgresNode; +use Test::More tests => 2; + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$ENV{PGOPTIONS} = '--client-min-messages=WARNING'; + +$node->issues_sql_like( + [ 'reindexdb', '-a' ], + qr/statement: REINDEX.*statement: REINDEX/s, + 'reindex all databases'); diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl new file mode 100644 index 0000000..b136bd4 --- /dev/null +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -0,0 +1,124 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 49; + +program_help_ok('vacuumdb'); +program_version_ok('vacuumdb'); +program_options_handling_ok('vacuumdb'); + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + [ 'vacuumdb', 'postgres' ], + qr/statement: VACUUM.*;/, + 'SQL VACUUM run'); +$node->issues_sql_like( + [ 'vacuumdb', '-f', 'postgres' ], + qr/statement: VACUUM \(FULL\).*;/, + 'vacuumdb -f'); +$node->issues_sql_like( + [ 'vacuumdb', '-F', 'postgres' ], + qr/statement: VACUUM \(FREEZE\).*;/, + 'vacuumdb -F'); +$node->issues_sql_like( + [ 'vacuumdb', '-zj2', 'postgres' ], + qr/statement: VACUUM \(ANALYZE\).*;/, + 'vacuumdb -zj2'); +$node->issues_sql_like( + [ 'vacuumdb', '-Z', 'postgres' ], + qr/statement: ANALYZE.*;/, + 'vacuumdb -Z'); +$node->issues_sql_like( + [ 'vacuumdb', '--disable-page-skipping', 'postgres' ], + qr/statement: VACUUM \(DISABLE_PAGE_SKIPPING\).*;/, + 'vacuumdb --disable-page-skipping'); +$node->issues_sql_like( + [ 'vacuumdb', '--skip-locked', 'postgres' ], + qr/statement: VACUUM \(SKIP_LOCKED\).*;/, + 'vacuumdb --skip-locked'); +$node->issues_sql_like( + [ 'vacuumdb', '--skip-locked', '--analyze-only', 'postgres' ], + qr/statement: ANALYZE \(SKIP_LOCKED\).*;/, + 'vacuumdb --skip-locked --analyze-only'); +$node->command_fails( + [ 'vacuumdb', '--analyze-only', '--disable-page-skipping', 'postgres' ], + '--analyze-only and --disable-page-skipping specified together'); +$node->issues_sql_like( + [ 'vacuumdb', '-P', 2, 'postgres' ], + qr/statement: VACUUM \(PARALLEL 2\).*;/, + 'vacuumdb -P 2'); +$node->issues_sql_like( + [ 'vacuumdb', '-P', 0, 'postgres' ], + qr/statement: VACUUM \(PARALLEL 0\).*;/, + 'vacuumdb -P 0'); +$node->command_ok([qw(vacuumdb -Z --table=pg_am dbname=template1)], + 'vacuumdb with connection string'); + +$node->command_fails( + [qw(vacuumdb -Zt pg_am;ABORT postgres)], + 'trailing command in "-t", without COLUMNS'); + +# Unwanted; better if it failed. +$node->command_ok( + [qw(vacuumdb -Zt pg_am(amname);ABORT postgres)], + 'trailing command in "-t", with COLUMNS'); + +$node->safe_psql( + 'postgres', q| + CREATE TABLE "need""q(uot" (")x" text); + CREATE TABLE vactable (a int, b int); + CREATE VIEW vacview AS SELECT 1 as a; + + CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1'; + CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)'; + CREATE TABLE funcidx (x int); + INSERT INTO funcidx VALUES (0),(1),(2),(3); + CREATE INDEX i0 ON funcidx ((f1(x))); +|); +$node->command_ok([qw|vacuumdb -Z --table="need""q(uot"(")x") postgres|], + 'column list'); +$node->command_fails( + [qw|vacuumdb -Zt funcidx postgres|], + 'unqualifed name via functional index'); + +$node->command_fails( + [ 'vacuumdb', '--analyze', '--table', 'vactable(c)', 'postgres' ], + 'incorrect column name with ANALYZE'); +$node->command_fails([ 'vacuumdb', '-P', -1, 'postgres' ], + 'negative parallel degree'); +$node->issues_sql_like( + [ 'vacuumdb', '--analyze', '--table', 'vactable(a, b)', 'postgres' ], + qr/statement: VACUUM \(ANALYZE\) public.vactable\(a, b\);/, + 'vacuumdb --analyze with complete column list'); +$node->issues_sql_like( + [ 'vacuumdb', '--analyze-only', '--table', 'vactable(b)', 'postgres' ], + qr/statement: ANALYZE public.vactable\(b\);/, + 'vacuumdb --analyze-only with partial column list'); +$node->command_checks_all( + [ 'vacuumdb', '--analyze', '--table', 'vacview', 'postgres' ], + 0, + [qr/^.*vacuuming database "postgres"/], + [qr/^WARNING.*cannot vacuum non-tables or special system tables/s], + 'vacuumdb with view'); +$node->command_fails( + [ 'vacuumdb', '--table', 'vactable', '--min-mxid-age', '0', 'postgres' ], + 'vacuumdb --min-mxid-age with incorrect value'); +$node->command_fails( + [ 'vacuumdb', '--table', 'vactable', '--min-xid-age', '0', 'postgres' ], + 'vacuumdb --min-xid-age with incorrect value'); +$node->issues_sql_like( + [ + 'vacuumdb', '--table', 'vactable', '--min-mxid-age', + '2147483000', 'postgres' + ], + qr/GREATEST.*relminmxid.*2147483000/, + 'vacuumdb --table --min-mxid-age'); +$node->issues_sql_like( + [ 'vacuumdb', '--min-xid-age', '2147483001', 'postgres' ], + qr/GREATEST.*relfrozenxid.*2147483001/, + 'vacuumdb --table --min-xid-age'); diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl new file mode 100644 index 0000000..4321258 --- /dev/null +++ b/src/bin/scripts/t/101_vacuumdb_all.pl @@ -0,0 +1,14 @@ +use strict; +use warnings; + +use PostgresNode; +use Test::More tests => 2; + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + [ 'vacuumdb', '-a' ], + qr/statement: VACUUM.*statement: VACUUM/s, + 'vacuum all databases'); diff --git a/src/bin/scripts/t/102_vacuumdb_stages.pl b/src/bin/scripts/t/102_vacuumdb_stages.pl new file mode 100644 index 0000000..17a7fc7 --- /dev/null +++ b/src/bin/scripts/t/102_vacuumdb_stages.pl @@ -0,0 +1,35 @@ +use strict; +use warnings; + +use PostgresNode; +use Test::More tests => 4; + +my $node = get_new_node('main'); +$node->init; +$node->start; + +$node->issues_sql_like( + [ 'vacuumdb', '--analyze-in-stages', 'postgres' ], + qr/statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0; + .*statement:\ ANALYZE + .*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay; + .*statement:\ ANALYZE + .*statement:\ RESET\ default_statistics_target; + .*statement:\ ANALYZE/sx, + 'analyze three times'); + +$node->issues_sql_like( + [ 'vacuumdb', '--analyze-in-stages', '--all' ], + qr/statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0; + .*statement:\ ANALYZE + .*statement:\ SET\ default_statistics_target=1;\ SET\ vacuum_cost_delay=0; + .*statement:\ ANALYZE + .*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay; + .*statement:\ ANALYZE + .*statement:\ SET\ default_statistics_target=10;\ RESET\ vacuum_cost_delay; + .*statement:\ ANALYZE + .*statement:\ RESET\ default_statistics_target; + .*statement:\ ANALYZE + .*statement:\ RESET\ default_statistics_target; + .*statement:\ ANALYZE/sx, + 'analyze more than one database in stages'); diff --git a/src/bin/scripts/t/200_connstr.pl b/src/bin/scripts/t/200_connstr.pl new file mode 100644 index 0000000..ee2523d --- /dev/null +++ b/src/bin/scripts/t/200_connstr.pl @@ -0,0 +1,39 @@ +use strict; +use warnings; + +use PostgresNode; +use TestLib; +use Test::More tests => 3; + +# Tests to check connection string handling in utilities + +# We're going to use byte sequences that aren't valid UTF-8 strings. Use +# LATIN1, which accepts any byte and has a conversion from each byte to UTF-8. +$ENV{LC_ALL} = 'C'; +$ENV{PGCLIENTENCODING} = 'LATIN1'; + +# Create database names covering the range of LATIN1 characters and +# run the utilities' --all options over them. +my $dbname1 = generate_ascii_string(1, 63); # contains '=' +my $dbname2 = + generate_ascii_string(67, 129); # skip 64-66 to keep length to 62 +my $dbname3 = generate_ascii_string(130, 192); +my $dbname4 = generate_ascii_string(193, 255); + +my $node = get_new_node('main'); +$node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]); +$node->start; + +foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase') +{ + $node->run_log([ 'createdb', $dbname ]); +} + +$node->command_ok( + [qw(vacuumdb --all --echo --analyze-only)], + 'vacuumdb --all with unusual database names'); +$node->command_ok([qw(reindexdb --all --echo)], + 'reindexdb --all with unusual database names'); +$node->command_ok( + [qw(clusterdb --all --echo --verbose)], + 'clusterdb --all with unusual database names'); |