diff --git a/contrib/test_decoding/expected/replorigin.out b/contrib/test_decoding/expected/replorigin.out index 8ea4ddda977..3b249f4856f 100644 --- a/contrib/test_decoding/expected/replorigin.out +++ b/contrib/test_decoding/expected/replorigin.out @@ -2,38 +2,38 @@ SET synchronous_commit = on; CREATE TABLE origin_tbl(id serial primary key, data text); CREATE TABLE target_tbl(id serial primary key, data text); -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_slot'); pg_replication_origin_create ------------------------------ 1 (1 row) -- ensure duplicate creations fail -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_slot'); ERROR: duplicate key value violates unique constraint "pg_replication_origin_roname_index" -DETAIL: Key (roname)=(test_decoding: regression_slot) already exists. +DETAIL: Key (roname)=(regress_test_decoding: regression_slot) already exists. --ensure deletions work (once) -SELECT pg_replication_origin_create('test_decoding: temp'); +SELECT pg_replication_origin_create('regress_test_decoding: temp'); pg_replication_origin_create ------------------------------ 2 (1 row) -SELECT pg_replication_origin_drop('test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); pg_replication_origin_drop ---------------------------- (1 row) -SELECT pg_replication_origin_drop('test_decoding: temp'); -ERROR: replication origin "test_decoding: temp" does not exist +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); +ERROR: replication origin "regress_test_decoding: temp" does not exist -- various failure checks for undefined slots -select pg_replication_origin_advance('test_decoding: temp', '0/1'); -ERROR: replication origin "test_decoding: temp" does not exist -select pg_replication_origin_session_setup('test_decoding: temp'); -ERROR: replication origin "test_decoding: temp" does not exist -select pg_replication_origin_progress('test_decoding: temp', true); -ERROR: replication origin "test_decoding: temp" does not exist +select pg_replication_origin_advance('regress_test_decoding: temp', '0/1'); +ERROR: replication origin "regress_test_decoding: temp" does not exist +select pg_replication_origin_session_setup('regress_test_decoding: temp'); +ERROR: replication origin "regress_test_decoding: temp" does not exist +select pg_replication_origin_progress('regress_test_decoding: temp', true); +ERROR: replication origin "regress_test_decoding: temp" does not exist SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); ?column? ---------- @@ -57,14 +57,14 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded again'); -- mark session as replaying -SELECT pg_replication_origin_session_setup('test_decoding: regression_slot'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot'); pg_replication_origin_session_setup ------------------------------------- (1 row) -- ensure we prevent duplicate setup -SELECT pg_replication_origin_session_setup('test_decoding: regression_slot'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot'); ERROR: cannot setup replication origin when one is already setup SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will not be decoded'); ?column? @@ -103,19 +103,19 @@ SELECT pg_replication_origin_session_reset(); (1 row) SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origin_status; - local_id | external_id | remote_lsn | ?column? -----------+--------------------------------+------------+---------- - 1 | test_decoding: regression_slot | 0/AABBCCDD | t + local_id | external_id | remote_lsn | ?column? +----------+----------------------------------------+------------+---------- + 1 | regress_test_decoding: regression_slot | 0/AABBCCDD | t (1 row) -- check replication progress identified by name is correct -SELECT pg_replication_origin_progress('test_decoding: regression_slot', false); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', false); pg_replication_origin_progress -------------------------------- 0/AABBCCDD (1 row) -SELECT pg_replication_origin_progress('test_decoding: regression_slot', true); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', true); pg_replication_origin_progress -------------------------------- 0/AABBCCDD @@ -146,7 +146,7 @@ SELECT pg_drop_replication_slot('regression_slot'); (1 row) -SELECT pg_replication_origin_drop('test_decoding: regression_slot'); +SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot'); pg_replication_origin_drop ---------------------------- diff --git a/contrib/test_decoding/expected/rewrite.out b/contrib/test_decoding/expected/rewrite.out index 28998b86f9e..b30999c436b 100644 --- a/contrib/test_decoding/expected/rewrite.out +++ b/contrib/test_decoding/expected/rewrite.out @@ -11,7 +11,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile EXECUTE $1; END; $f$; -CREATE ROLE justforcomments NOLOGIN; +CREATE ROLE regress_justforcomments NOLOGIN; SELECT exec( format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTABLE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$, (SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i)))); @@ -29,7 +29,7 @@ SELECT exec( (1 row) SELECT exec( - format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$, + format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$, iamalongfunction())); exec ------ @@ -161,4 +161,4 @@ SELECT pg_drop_replication_slot('regression_slot'); DROP TABLE IF EXISTS replication_example; DROP FUNCTION iamalongfunction(); DROP FUNCTION exec(text); -DROP ROLE justforcomments; +DROP ROLE regress_justforcomments; diff --git a/contrib/test_decoding/sql/replorigin.sql b/contrib/test_decoding/sql/replorigin.sql index 451cd4bc3b2..8979b306160 100644 --- a/contrib/test_decoding/sql/replorigin.sql +++ b/contrib/test_decoding/sql/replorigin.sql @@ -4,19 +4,19 @@ SET synchronous_commit = on; CREATE TABLE origin_tbl(id serial primary key, data text); CREATE TABLE target_tbl(id serial primary key, data text); -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_slot'); -- ensure duplicate creations fail -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_slot'); --ensure deletions work (once) -SELECT pg_replication_origin_create('test_decoding: temp'); -SELECT pg_replication_origin_drop('test_decoding: temp'); -SELECT pg_replication_origin_drop('test_decoding: temp'); +SELECT pg_replication_origin_create('regress_test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); -- various failure checks for undefined slots -select pg_replication_origin_advance('test_decoding: temp', '0/1'); -select pg_replication_origin_session_setup('test_decoding: temp'); -select pg_replication_origin_progress('test_decoding: temp', true); +select pg_replication_origin_advance('regress_test_decoding: temp', '0/1'); +select pg_replication_origin_session_setup('regress_test_decoding: temp'); +select pg_replication_origin_progress('regress_test_decoding: temp', true); SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding'); @@ -31,10 +31,10 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded again'); -- mark session as replaying -SELECT pg_replication_origin_session_setup('test_decoding: regression_slot'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot'); -- ensure we prevent duplicate setup -SELECT pg_replication_origin_session_setup('test_decoding: regression_slot'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot'); SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will not be decoded'); @@ -54,8 +54,8 @@ SELECT pg_replication_origin_session_reset(); SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origin_status; -- check replication progress identified by name is correct -SELECT pg_replication_origin_progress('test_decoding: regression_slot', false); -SELECT pg_replication_origin_progress('test_decoding: regression_slot', true); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', false); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', true); -- ensure reset requires previously setup state SELECT pg_replication_origin_session_reset(); @@ -68,4 +68,4 @@ INSERT INTO origin_tbl(data) VALUES ('will be replicated'); SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1'); SELECT pg_drop_replication_slot('regression_slot'); -SELECT pg_replication_origin_drop('test_decoding: regression_slot'); +SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot'); diff --git a/contrib/test_decoding/sql/rewrite.sql b/contrib/test_decoding/sql/rewrite.sql index c9503a0da59..62dead3a9b1 100644 --- a/contrib/test_decoding/sql/rewrite.sql +++ b/contrib/test_decoding/sql/rewrite.sql @@ -13,7 +13,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile EXECUTE $1; END; $f$; -CREATE ROLE justforcomments NOLOGIN; +CREATE ROLE regress_justforcomments NOLOGIN; SELECT exec( format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTABLE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$, @@ -22,7 +22,7 @@ SELECT exec( format($outer$COMMENT ON FUNCTION iamalongfunction() IS %L$outer$, iamalongfunction())); SELECT exec( - format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$, + format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$, iamalongfunction())); CREATE TABLE iamalargetable AS SELECT iamalongfunction() longfunctionoutput; @@ -104,4 +104,4 @@ SELECT pg_drop_replication_slot('regression_slot'); DROP TABLE IF EXISTS replication_example; DROP FUNCTION iamalongfunction(); DROP FUNCTION exec(text); -DROP ROLE justforcomments; +DROP ROLE regress_justforcomments; diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010_dump_connstr.pl index 28a9eb7dc75..d221682790e 100644 --- a/src/bin/pg_dump/t/010_dump_connstr.pl +++ b/src/bin/pg_dump/t/010_dump_connstr.pl @@ -22,29 +22,42 @@ $ENV{PGCLIENTENCODING} = 'LATIN1'; # Create database and user names covering the range of LATIN1 # characters, for use in a connection string by pg_dumpall. Skip ',' # because of pg_regress --create-role, skip [\n\r] because pg_dumpall -# does not allow them. +# does not allow them. We also skip many ASCII letters, to keep the +# total number of tested characters to what will fit in four names. +# The odds of finding something interesting by testing all ASCII letters +# seem too small to justify the cycles of testing a fifth name. my $dbname1 = - generate_ascii_string(1, 9) + 'regression' + . generate_ascii_string(1, 9) . generate_ascii_string(11, 12) . generate_ascii_string(14, 33) - . ($TestLib::windows_os ? '' : '"x"') - . # IPC::Run mishandles '"' on Windows - generate_ascii_string(35, 43) - . generate_ascii_string(45, 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); + . ($TestLib::windows_os ? '' : '"x"') # IPC::Run mishandles '"' on Windows + . generate_ascii_string(35, 43) # skip ',' + . generate_ascii_string(45, 54); +my $dbname2 = 'regression' . generate_ascii_string(55, 65) # skip 'B'-'W' + . generate_ascii_string(88, 99) # skip 'd'-'w' + . generate_ascii_string(120, 149); +my $dbname3 = 'regression' . generate_ascii_string(150, 202); +my $dbname4 = 'regression' . generate_ascii_string(203, 255); + +(my $username1 = $dbname1) =~ s/^regression/regress_/; +(my $username2 = $dbname2) =~ s/^regression/regress_/; +(my $username3 = $dbname3) =~ s/^regression/regress_/; +(my $username4 = $dbname4) =~ s/^regression/regress_/; + +my $src_bootstrap_super = 'regress_postgres'; +my $dst_bootstrap_super = 'boot'; my $node = get_new_node('main'); -$node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]); +$node->init(extra => + [ '-U', $src_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); # prep pg_hba.conf and pg_ident.conf $node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $node->data_dir, '--create-role', - "$dbname1,$dbname2,$dbname3,$dbname4" + "$username1,$username2,$username3,$username4" ]); $node->start; @@ -53,11 +66,18 @@ my $discard = "$backupdir/discard.sql"; my $plain = "$backupdir/plain.sql"; my $dirfmt = "$backupdir/dirfmt"; -foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase') -{ - $node->run_log([ 'createdb', $dbname ]); - $node->run_log([ 'createuser', '-s', $dbname ]); -} +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname1 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username1 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname2 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username2 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname3 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username3 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname4 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username4 ]); # For these tests, pg_dumpall -r is used because it produces a short @@ -66,98 +86,109 @@ $node->command_ok( [ 'pg_dumpall', '-r', '-f', $discard, '--dbname', $node->connstr($dbname1), - '-U', $dbname4 + '-U', $username4 ], 'pg_dumpall with long ASCII name 1'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname2), - '-U', $dbname3 + '-U', $username3 ], 'pg_dumpall with long ASCII name 2'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname3), - '-U', $dbname2 + '-U', $username2 ], 'pg_dumpall with long ASCII name 3'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname4), - '-U', $dbname1 + '-U', $username1 ], 'pg_dumpall with long ASCII name 4'); $node->command_ok( - [ 'pg_dumpall', '--no-sync', '-r', '-l', 'dbname=template1' ], + [ + 'pg_dumpall', '-U', + $src_bootstrap_super, '--no-sync', + '-r', '-l', + 'dbname=template1' + ], 'pg_dumpall -l accepts connection string'); -$node->run_log([ 'createdb', "foo\n\rbar" ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, "foo\n\rbar" ]); # not sufficient to use -r here $node->command_fails( - [ 'pg_dumpall', '--no-sync', '-f', $discard ], + [ 'pg_dumpall', '-U', $src_bootstrap_super, '--no-sync', '-f', $discard ], 'pg_dumpall with \n\r in database name'); -$node->run_log([ 'dropdb', "foo\n\rbar" ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, "foo\n\rbar" ]); # make a table, so the parallel worker has something to dump -$node->safe_psql($dbname1, 'CREATE TABLE t0()'); +$node->safe_psql( + $dbname1, + 'CREATE TABLE t0()', + extra_params => [ '-U', $src_bootstrap_super ]); # XXX no printed message when this fails, just SIGPIPE termination $node->command_ok( [ - 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $dbname1, + 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $username1, $node->connstr($dbname1) ], 'parallel dump'); # recreate $dbname1 for restore test -$node->run_log([ 'dropdb', $dbname1 ]); -$node->run_log([ 'createdb', $dbname1 ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, $dbname1 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname1 ]); $node->command_ok( - [ 'pg_restore', '-v', '-d', 'template1', '-j2', '-U', $dbname1, $dirfmt ], + [ + 'pg_restore', '-v', '-d', 'template1', + '-j2', '-U', $username1, $dirfmt + ], 'parallel restore'); -$node->run_log([ 'dropdb', $dbname1 ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, $dbname1 ]); $node->command_ok( [ 'pg_restore', '-C', '-v', '-d', - 'template1', '-j2', '-U', $dbname1, + 'template1', '-j2', '-U', $username1, $dirfmt ], 'parallel restore with create'); -$node->command_ok([ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $dbname1 ], +$node->command_ok( + [ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $username1 ], 'take full dump'); system_log('cat', $plain); my ($stderr, $result); -my $bootstrap_super = 'boot'; -my $restore_super = qq{a'b\\c=d\\ne"f}; +my $restore_super = qq{regress_a'b\\c=d\\ne"f}; # Restore full dump through psql using environment variables for # dbname/user connection parameters my $envar_node = get_new_node('destination_envar'); -$envar_node->init( - extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); +$envar_node->init(extra => + [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); $envar_node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $envar_node->data_dir, '--create-role', - "$bootstrap_super,$restore_super" + "$dst_bootstrap_super,$restore_super" ]); $envar_node->start; # make superuser for restore $envar_node->run_log( - [ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]); + [ 'createuser', '-U', $dst_bootstrap_super, '-s', $restore_super ]); { local $ENV{PGPORT} = $envar_node->port; @@ -177,17 +208,17 @@ is($stderr, '', 'no dump errors'); $restore_super =~ s/"//g if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows my $cmdline_node = get_new_node('destination_cmdline'); -$cmdline_node->init( - extra => [ '-U', $bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); +$cmdline_node->init(extra => + [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); $cmdline_node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $cmdline_node->data_dir, '--create-role', - "$bootstrap_super,$restore_super" + "$dst_bootstrap_super,$restore_super" ]); $cmdline_node->start; $cmdline_node->run_log( - [ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]); + [ 'createuser', '-U', $dst_bootstrap_super, '-s', $restore_super ]); { $result = run_log( [ diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh index d6d196ac27c..78820247b35 100644 --- a/src/bin/pg_upgrade/test.sh +++ b/src/bin/pg_upgrade/test.sh @@ -159,9 +159,9 @@ dbname1=`awk 'BEGIN { for (i= 1; i < 46; i++) dbname1='\"\'$dbname1'\\"\\\' dbname2=`awk 'BEGIN { for (i = 46; i < 91; i++) printf "%c", i }'