diff options
author | Tom Lane | 2019-06-29 15:09:03 +0000 |
---|---|---|
committer | Tom Lane | 2019-06-29 15:09:03 +0000 |
commit | ca129e58c01f29ef24a734313ff315933b3d5b67 (patch) | |
tree | f681588f868f7004d8b702981431a85b8cdd384a /contrib/test_decoding | |
parent | a1e61badf97bc446053145ba40de6db835678ce3 (diff) |
Fix regression tests to use only global names beginning with "regress_".
In commit 18555b132 we tentatively established a rule that regression
tests should use names containing "regression" for databases, and names
starting with "regress_" for all other globally-visible object names, so
as to circumscribe the side-effects that "make installcheck" could have on
an existing installation. However, no enforcement mechanism was created,
so it's unsurprising that some new violations have crept in since then.
In fact, a whole new *category* of violations has crept in, to wit we now
also have globally-visible subscription and replication origin names, and
"make installcheck" could very easily clobber user-created objects of
those types. So it's past time to do something about this.
This commit sanitizes the tests enough that they will pass (i.e. not
generate any visible warnings) with the enforcement mechanism I'll add
in the next commit. There are some TAP tests that still trigger the
warnings, but the warnings do not cause test failure. Since these tests
do not actually run against a pre-existing installation, there's no need
to worry whether they could conflict with user-created objects.
The problem with rolenames.sql testing special role names like "user"
is still there, and is dealt with only very cosmetically in this patch
(by hiding the warnings :-(). What we actually need to do to be safe is
to take that test script out of "make installcheck" altogether, but that
seems like material for a separate patch.
Discussion: https://postgr.es/m/16638.1468620817@sss.pgh.pa.us
Diffstat (limited to 'contrib/test_decoding')
-rw-r--r-- | contrib/test_decoding/expected/replorigin.out | 42 | ||||
-rw-r--r-- | contrib/test_decoding/expected/rewrite.out | 6 | ||||
-rw-r--r-- | contrib/test_decoding/sql/replorigin.sql | 26 | ||||
-rw-r--r-- | contrib/test_decoding/sql/rewrite.sql | 6 |
4 files changed, 40 insertions, 40 deletions
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; |