mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 09:41:17 +02:00
Add some additional tests for row filters in logical replication.
Commit 52e4f0cd47
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/6bdbd7fc-e81a-9a77-d963-24adeb95f29e@enterprisedb.com
This commit is contained in:
parent
f7ea240aa7
commit
ceb57afd3c
@ -2382,6 +2382,15 @@ my %tests = (
|
|||||||
like => { %full_runs, section_post_data => 1, },
|
like => { %full_runs, section_post_data => 1, },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'CREATE PUBLICATION pub4' => {
|
||||||
|
create_order => 50,
|
||||||
|
create_sql => 'CREATE PUBLICATION pub4;',
|
||||||
|
regexp => qr/^
|
||||||
|
\QCREATE PUBLICATION pub4 WITH (publish = 'insert, update, delete, truncate');\E
|
||||||
|
/xm,
|
||||||
|
like => { %full_runs, section_post_data => 1, },
|
||||||
|
},
|
||||||
|
|
||||||
'CREATE SUBSCRIPTION sub1' => {
|
'CREATE SUBSCRIPTION sub1' => {
|
||||||
create_order => 50,
|
create_order => 50,
|
||||||
create_sql => 'CREATE SUBSCRIPTION sub1
|
create_sql => 'CREATE SUBSCRIPTION sub1
|
||||||
@ -2439,6 +2448,31 @@ my %tests = (
|
|||||||
like => { %full_runs, section_post_data => 1, },
|
like => { %full_runs, section_post_data => 1, },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'ALTER PUBLICATION pub4 ADD TABLE test_table WHERE (col1 > 0);' => {
|
||||||
|
create_order => 51,
|
||||||
|
create_sql =>
|
||||||
|
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_table WHERE (col1 > 0);',
|
||||||
|
regexp => qr/^
|
||||||
|
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_table WHERE ((col1 > 0));\E
|
||||||
|
/xm,
|
||||||
|
like => { %full_runs, section_post_data => 1, },
|
||||||
|
unlike => {
|
||||||
|
exclude_dump_test_schema => 1,
|
||||||
|
exclude_test_table => 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
'ALTER PUBLICATION pub4 ADD TABLE test_second_table WHERE (col2 = \'test\');' => {
|
||||||
|
create_order => 52,
|
||||||
|
create_sql =>
|
||||||
|
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_second_table WHERE (col2 = \'test\');',
|
||||||
|
regexp => qr/^
|
||||||
|
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_second_table WHERE ((col2 = 'test'::text));\E
|
||||||
|
/xm,
|
||||||
|
like => { %full_runs, section_post_data => 1, },
|
||||||
|
unlike => { exclude_dump_test_schema => 1, },
|
||||||
|
},
|
||||||
|
|
||||||
'CREATE SCHEMA public' => {
|
'CREATE SCHEMA public' => {
|
||||||
regexp => qr/^CREATE SCHEMA public;/m,
|
regexp => qr/^CREATE SCHEMA public;/m,
|
||||||
|
|
||||||
|
@ -263,6 +263,12 @@ Tables:
|
|||||||
"public.testpub_rf_tbl1"
|
"public.testpub_rf_tbl1"
|
||||||
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
||||||
|
|
||||||
|
\d testpub_rf_tbl3
|
||||||
|
Table "public.testpub_rf_tbl3"
|
||||||
|
Column | Type | Collation | Nullable | Default
|
||||||
|
--------+---------+-----------+----------+---------
|
||||||
|
e | integer | | |
|
||||||
|
|
||||||
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
@ -274,6 +280,14 @@ Tables:
|
|||||||
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
"public.testpub_rf_tbl2" WHERE ((c <> 'test'::text) AND (d < 5))
|
||||||
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
|
"public.testpub_rf_tbl3" WHERE ((e > 1000) AND (e < 2000))
|
||||||
|
|
||||||
|
\d testpub_rf_tbl3
|
||||||
|
Table "public.testpub_rf_tbl3"
|
||||||
|
Column | Type | Collation | Nullable | Default
|
||||||
|
--------+---------+-----------+----------+---------
|
||||||
|
e | integer | | |
|
||||||
|
Publications:
|
||||||
|
"testpub5" WHERE ((e > 1000) AND (e < 2000))
|
||||||
|
|
||||||
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
Publication testpub5
|
Publication testpub5
|
||||||
@ -294,6 +308,14 @@ ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500)
|
|||||||
Tables:
|
Tables:
|
||||||
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
|
"public.testpub_rf_tbl3" WHERE ((e > 300) AND (e < 500))
|
||||||
|
|
||||||
|
\d testpub_rf_tbl3
|
||||||
|
Table "public.testpub_rf_tbl3"
|
||||||
|
Column | Type | Collation | Nullable | Default
|
||||||
|
--------+---------+-----------+----------+---------
|
||||||
|
e | integer | | |
|
||||||
|
Publications:
|
||||||
|
"testpub5" WHERE ((e > 300) AND (e < 500))
|
||||||
|
|
||||||
-- test \d <tablename> (now it displays filter information)
|
-- test \d <tablename> (now it displays filter information)
|
||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');
|
||||||
|
@ -150,13 +150,16 @@ SET client_min_messages = 'ERROR';
|
|||||||
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub5 FOR TABLE testpub_rf_tbl1, testpub_rf_tbl2 WHERE (c <> 'test' AND d < 5) WITH (publish = 'insert');
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
|
\d testpub_rf_tbl3
|
||||||
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
ALTER PUBLICATION testpub5 ADD TABLE testpub_rf_tbl3 WHERE (e > 1000 AND e < 2000);
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
|
\d testpub_rf_tbl3
|
||||||
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
ALTER PUBLICATION testpub5 DROP TABLE testpub_rf_tbl2;
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
|
-- remove testpub_rf_tbl1 and add testpub_rf_tbl3 again (another WHERE expression)
|
||||||
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
|
ALTER PUBLICATION testpub5 SET TABLE testpub_rf_tbl3 WHERE (e > 300 AND e < 500);
|
||||||
\dRp+ testpub5
|
\dRp+ testpub5
|
||||||
|
\d testpub_rf_tbl3
|
||||||
-- test \d <tablename> (now it displays filter information)
|
-- test \d <tablename> (now it displays filter information)
|
||||||
SET client_min_messages = 'ERROR';
|
SET client_min_messages = 'ERROR';
|
||||||
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');
|
CREATE PUBLICATION testpub_rf_yes FOR TABLE testpub_rf_tbl1 WHERE (a > 1) WITH (publish = 'insert');
|
||||||
|
Loading…
Reference in New Issue
Block a user