Skip to content

Commit ceb57af

Browse files
author
Amit Kapila
committed
Add some additional tests for row filters in logical replication.
Commit 52e4f0c didn't add tests for pg_dump support, so add a few tests for it. Additionally, verify that catalogs are updated after few ALTER PUBLICATION commands that modify row filters by using \d. Reported-by: Tomas Vondra Author: Shi yu, based on initial by Tomas Vondra Reviewed-by: Euler Taveira and Amit Kapila Discussion: https://postgr.es/m/[email protected]
1 parent f7ea240 commit ceb57af

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

src/bin/pg_dump/t/002_pg_dump.pl

+34
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,15 @@
23822382
like => { %full_runs, section_post_data => 1, },
23832383
},
23842384
2385+
'CREATE PUBLICATION pub4' => {
2386+
create_order => 50,
2387+
create_sql => 'CREATE PUBLICATION pub4;',
2388+
regexp => qr/^
2389+
\QCREATE PUBLICATION pub4 WITH (publish = 'insert, update, delete, truncate');\E
2390+
/xm,
2391+
like => { %full_runs, section_post_data => 1, },
2392+
},
2393+
23852394
'CREATE SUBSCRIPTION sub1' => {
23862395
create_order => 50,
23872396
create_sql => 'CREATE SUBSCRIPTION sub1
@@ -2439,6 +2448,31 @@
24392448
like => { %full_runs, section_post_data => 1, },
24402449
},
24412450
2451+
'ALTER PUBLICATION pub4 ADD TABLE test_table WHERE (col1 > 0);' => {
2452+
create_order => 51,
2453+
create_sql =>
2454+
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_table WHERE (col1 > 0);',
2455+
regexp => qr/^
2456+
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_table WHERE ((col1 > 0));\E
2457+
/xm,
2458+
like => { %full_runs, section_post_data => 1, },
2459+
unlike => {
2460+
exclude_dump_test_schema => 1,
2461+
exclude_test_table => 1,
2462+
},
2463+
},
2464+
2465+
'ALTER PUBLICATION pub4 ADD TABLE test_second_table WHERE (col2 = \'test\');' => {
2466+
create_order => 52,
2467+
create_sql =>
2468+
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_second_table WHERE (col2 = \'test\');',
2469+
regexp => qr/^
2470+
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_second_table WHERE ((col2 = 'test'::text));\E
2471+
/xm,
2472+
like => { %full_runs, section_post_data => 1, },
2473+
unlike => { exclude_dump_test_schema => 1, },
2474+
},
2475+
24422476
'CREATE SCHEMA public' => {
24432477
regexp => qr/^CREATE SCHEMA public;/m,
24442478

src/test/regress/expected/publication.out

+22
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ Tables:
263263
"public.testpub_rf_tbl1"
264264
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
265265

266+
\d testpub_rf_tbl3
267+
Table "public.testpub_rf_tbl3"
268+
Column | Type | Collation | Nullable | Default
269+
--------+---------+-----------+----------+---------
270+
e | integer | | |
271+
266272
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
267273
\dRp+ testpub5
268274
Publication testpub5
@@ -274,6 +280,14 @@ Tables:
274280
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
275281
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
276282

283+
\d testpub_rf_tbl3
284+
Table "public.testpub_rf_tbl3"
285+
Column | Type | Collation | Nullable | Default
286+
--------+---------+-----------+----------+---------
287+
e | integer | | |
288+
Publications:
289+
"testpub5" WHERE ((e > 1000) AND (e < 2000))
290+
277291
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
278292
\dRp+ testpub5
279293
Publication testpub5
@@ -294,6 +308,14 @@ ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500)
294308
Tables:
295309
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
296310

311+
\d testpub_rf_tbl3
312+
Table "public.testpub_rf_tbl3"
313+
Column | Type | Collation | Nullable | Default
314+
--------+---------+-----------+----------+---------
315+
e | integer | | |
316+
Publications:
317+
"testpub5" WHERE ((e > 300) AND (e < 500))
318+
297319
-- test \d <tablename> (now it displays filter information)
298320
SET client_min_messages = 'ERROR';
299321
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');

src/test/regress/sql/publication.sql

+3
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ SET client_min_messages = 'ERROR';
150150
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
151151
RESET client_min_messages;
152152
\dRp+ testpub5
153+
\d testpub_rf_tbl3
153154
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
154155
\dRp+ testpub5
156+
\d testpub_rf_tbl3
155157
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
156158
\dRp+ testpub5
157159
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
158160
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
159161
\dRp+ testpub5
162+
\d testpub_rf_tbl3
160163
-- test \d <tablename> (now it displays filter information)
161164
SET client_min_messages = 'ERROR';
162165
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');

0 commit comments

Comments
 (0)