Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca129e5

Browse files
committed
Fix regression tests to use only global names beginning with "regress_".
In commit18555b1 we tentatively established a rule that regressiontests should use names containing "regression" for databases, and namesstarting with "regress_" for all other globally-visible object names, soas to circumscribe the side-effects that "make installcheck" could have onan 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 nowalso have globally-visible subscription and replication origin names, and"make installcheck" could very easily clobber user-created objects ofthose types. So it's past time to do something about this.This commit sanitizes the tests enough that they will pass (i.e. notgenerate any visible warnings) with the enforcement mechanism I'll addin the next commit. There are some TAP tests that still trigger thewarnings, but the warnings do not cause test failure. Since these testsdo not actually run against a pre-existing installation, there's no needto 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 isto take that test script out of "make installcheck" altogether, but thatseems like material for a separate patch.Discussion:https://postgr.es/m/16638.1468620817@sss.pgh.pa.us
1 parenta1e61ba commitca129e5

File tree

12 files changed

+254
-205
lines changed

12 files changed

+254
-205
lines changed

‎contrib/test_decoding/expected/replorigin.out

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
SET synchronous_commit = on;
33
CREATE TABLE origin_tbl(id serial primary key, data text);
44
CREATE TABLE target_tbl(id serial primary key, data text);
5-
SELECT pg_replication_origin_create('test_decoding: regression_slot');
5+
SELECT pg_replication_origin_create('regress_test_decoding: regression_slot');
66
pg_replication_origin_create
77
------------------------------
88
1
99
(1 row)
1010

1111
-- ensure duplicate creations fail
12-
SELECT pg_replication_origin_create('test_decoding: regression_slot');
12+
SELECT pg_replication_origin_create('regress_test_decoding: regression_slot');
1313
ERROR: duplicate key value violates unique constraint "pg_replication_origin_roname_index"
14-
DETAIL: Key (roname)=(test_decoding: regression_slot) already exists.
14+
DETAIL: Key (roname)=(regress_test_decoding: regression_slot) already exists.
1515
--ensure deletions work (once)
16-
SELECT pg_replication_origin_create('test_decoding: temp');
16+
SELECT pg_replication_origin_create('regress_test_decoding: temp');
1717
pg_replication_origin_create
1818
------------------------------
1919
2
2020
(1 row)
2121

22-
SELECT pg_replication_origin_drop('test_decoding: temp');
22+
SELECT pg_replication_origin_drop('regress_test_decoding: temp');
2323
pg_replication_origin_drop
2424
----------------------------
2525

2626
(1 row)
2727

28-
SELECT pg_replication_origin_drop('test_decoding: temp');
29-
ERROR: replication origin "test_decoding: temp" does not exist
28+
SELECT pg_replication_origin_drop('regress_test_decoding: temp');
29+
ERROR: replication origin "regress_test_decoding: temp" does not exist
3030
-- various failure checks for undefined slots
31-
select pg_replication_origin_advance('test_decoding: temp', '0/1');
32-
ERROR: replication origin "test_decoding: temp" does not exist
33-
select pg_replication_origin_session_setup('test_decoding: temp');
34-
ERROR: replication origin "test_decoding: temp" does not exist
35-
select pg_replication_origin_progress('test_decoding: temp', true);
36-
ERROR: replication origin "test_decoding: temp" does not exist
31+
select pg_replication_origin_advance('regress_test_decoding: temp', '0/1');
32+
ERROR: replication origin "regress_test_decoding: temp" does not exist
33+
select pg_replication_origin_session_setup('regress_test_decoding: temp');
34+
ERROR: replication origin "regress_test_decoding: temp" does not exist
35+
select pg_replication_origin_progress('regress_test_decoding: temp', true);
36+
ERROR: replication origin "regress_test_decoding: temp" does not exist
3737
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
3838
?column?
3939
----------
@@ -57,14 +57,14 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
5757

5858
INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded again');
5959
-- mark session as replaying
60-
SELECT pg_replication_origin_session_setup('test_decoding: regression_slot');
60+
SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot');
6161
pg_replication_origin_session_setup
6262
-------------------------------------
6363

6464
(1 row)
6565

6666
-- ensure we prevent duplicate setup
67-
SELECT pg_replication_origin_session_setup('test_decoding: regression_slot');
67+
SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot');
6868
ERROR: cannot setup replication origin when one is already setup
6969
SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will not be decoded');
7070
?column?
@@ -103,19 +103,19 @@ SELECT pg_replication_origin_session_reset();
103103
(1 row)
104104

105105
SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_replication_origin_status;
106-
local_id | external_id | remote_lsn | ?column?
107-
----------+--------------------------------+------------+----------
108-
1 |test_decoding: regression_slot | 0/AABBCCDD | t
106+
local_id |external_id | remote_lsn | ?column?
107+
----------+----------------------------------------+------------+----------
108+
1 |regress_test_decoding: regression_slot | 0/AABBCCDD | t
109109
(1 row)
110110

111111
-- check replication progress identified by name is correct
112-
SELECT pg_replication_origin_progress('test_decoding: regression_slot', false);
112+
SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', false);
113113
pg_replication_origin_progress
114114
--------------------------------
115115
0/AABBCCDD
116116
(1 row)
117117

118-
SELECT pg_replication_origin_progress('test_decoding: regression_slot', true);
118+
SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', true);
119119
pg_replication_origin_progress
120120
--------------------------------
121121
0/AABBCCDD
@@ -146,7 +146,7 @@ SELECT pg_drop_replication_slot('regression_slot');
146146

147147
(1 row)
148148

149-
SELECT pg_replication_origin_drop('test_decoding: regression_slot');
149+
SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot');
150150
pg_replication_origin_drop
151151
----------------------------
152152

‎contrib/test_decoding/expected/rewrite.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile
1111
EXECUTE $1;
1212
END;
1313
$f$;
14-
CREATE ROLEjustforcomments NOLOGIN;
14+
CREATE ROLEregress_justforcomments NOLOGIN;
1515
SELECT exec(
1616
format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTABLE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$,
1717
(SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FROM generate_series(1, 500) g(i))));
@@ -29,7 +29,7 @@ SELECT exec(
2929
(1 row)
3030

3131
SELECT exec(
32-
format($outer$COMMENT ON ROLEJUSTFORCOMMENTS IS %L$outer$,
32+
format($outer$COMMENT ON ROLEREGRESS_JUSTFORCOMMENTS IS %L$outer$,
3333
iamalongfunction()));
3434
exec
3535
------
@@ -161,4 +161,4 @@ SELECT pg_drop_replication_slot('regression_slot');
161161
DROP TABLE IF EXISTS replication_example;
162162
DROP FUNCTION iamalongfunction();
163163
DROP FUNCTION exec(text);
164-
DROP ROLEjustforcomments;
164+
DROP ROLEregress_justforcomments;

‎contrib/test_decoding/sql/replorigin.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ SET synchronous_commit = on;
44
CREATETABLEorigin_tbl(idserialprimary key, datatext);
55
CREATETABLEtarget_tbl(idserialprimary key, datatext);
66

7-
SELECT pg_replication_origin_create('test_decoding: regression_slot');
7+
SELECT pg_replication_origin_create('regress_test_decoding: regression_slot');
88
-- ensure duplicate creations fail
9-
SELECT pg_replication_origin_create('test_decoding: regression_slot');
9+
SELECT pg_replication_origin_create('regress_test_decoding: regression_slot');
1010

1111
--ensure deletions work (once)
12-
SELECT pg_replication_origin_create('test_decoding: temp');
13-
SELECT pg_replication_origin_drop('test_decoding: temp');
14-
SELECT pg_replication_origin_drop('test_decoding: temp');
12+
SELECT pg_replication_origin_create('regress_test_decoding: temp');
13+
SELECT pg_replication_origin_drop('regress_test_decoding: temp');
14+
SELECT pg_replication_origin_drop('regress_test_decoding: temp');
1515

1616
-- various failure checks for undefined slots
17-
select pg_replication_origin_advance('test_decoding: temp','0/1');
18-
select pg_replication_origin_session_setup('test_decoding: temp');
19-
select pg_replication_origin_progress('test_decoding: temp', true);
17+
select pg_replication_origin_advance('regress_test_decoding: temp','0/1');
18+
select pg_replication_origin_session_setup('regress_test_decoding: temp');
19+
select pg_replication_origin_progress('regress_test_decoding: temp', true);
2020

2121
SELECT'init'FROM pg_create_logical_replication_slot('regression_slot','test_decoding');
2222

@@ -31,10 +31,10 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
3131
INSERT INTO origin_tbl(data)VALUES ('will be replicated, but not decoded again');
3232

3333
-- mark session as replaying
34-
SELECT pg_replication_origin_session_setup('test_decoding: regression_slot');
34+
SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot');
3535

3636
-- ensure we prevent duplicate setup
37-
SELECT pg_replication_origin_session_setup('test_decoding: regression_slot');
37+
SELECT pg_replication_origin_session_setup('regress_test_decoding: regression_slot');
3838

3939
SELECT''FROM pg_logical_emit_message(false,'test','this message will not be decoded');
4040

@@ -54,8 +54,8 @@ SELECT pg_replication_origin_session_reset();
5454
SELECT local_id, external_id, remote_lsn, local_lsn<>'0/0'FROM pg_replication_origin_status;
5555

5656
-- check replication progress identified by name is correct
57-
SELECT pg_replication_origin_progress('test_decoding: regression_slot', false);
58-
SELECT pg_replication_origin_progress('test_decoding: regression_slot', true);
57+
SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', false);
58+
SELECT pg_replication_origin_progress('regress_test_decoding: regression_slot', true);
5959

6060
-- ensure reset requires previously setup state
6161
SELECT pg_replication_origin_session_reset();
@@ -68,4 +68,4 @@ INSERT INTO origin_tbl(data) VALUES ('will be replicated');
6868
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'include-xids','0','skip-empty-xacts','1','only-local','1');
6969

7070
SELECT pg_drop_replication_slot('regression_slot');
71-
SELECT pg_replication_origin_drop('test_decoding: regression_slot');
71+
SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot');

‎contrib/test_decoding/sql/rewrite.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql volatile
1313
EXECUTE $1;
1414
END;
1515
$f$;
16-
CREATE ROLEjustforcomments NOLOGIN;
16+
CREATE ROLEregress_justforcomments NOLOGIN;
1717

1818
SELECT exec(
1919
format($outer$CREATE FUNCTION iamalongfunction() RETURNSTEXT IMMUTABLE LANGUAGE SQLAS $f$SELECTtext %L$f$$outer$,
@@ -22,7 +22,7 @@ SELECT exec(
2222
format($outer$COMMENTON FUNCTION iamalongfunction() IS %L$outer$,
2323
iamalongfunction()));
2424
SELECT exec(
25-
format($outer$COMMENTON ROLEJUSTFORCOMMENTS IS %L$outer$,
25+
format($outer$COMMENTON ROLEREGRESS_JUSTFORCOMMENTS IS %L$outer$,
2626
iamalongfunction()));
2727
CREATETABLEiamalargetableASSELECT iamalongfunction() longfunctionoutput;
2828

@@ -104,4 +104,4 @@ SELECT pg_drop_replication_slot('regression_slot');
104104
DROPTABLE IF EXISTS replication_example;
105105
DROPFUNCTION iamalongfunction();
106106
DROPFUNCTION exec(text);
107-
DROP ROLEjustforcomments;
107+
DROP ROLEregress_justforcomments;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp