@@ -677,21 +677,45 @@ ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (d > 99);
677677UPDATE rf_tbl_abcd_pk SET a = 1;
678678ERROR: cannot update table "rf_tbl_abcd_pk"
679679DETAIL: Column used in the publication WHERE expression is not part of the replica identity.
680+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
681+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
682+ ----------+------------+----------------+-----------+-----------+------------------
683+ testpub6 | public | rf_tbl_abcd_pk | {a,b,c,d} | (d > 99) | default
684+ (1 row)
685+
680686-- 1b. REPLICA IDENTITY is DEFAULT and table has no PK
681687ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99);
682688-- fail - "a" is not part of REPLICA IDENTITY
683689UPDATE rf_tbl_abcd_nopk SET a = 1;
684690ERROR: cannot update table "rf_tbl_abcd_nopk"
685691DETAIL: Column used in the publication WHERE expression is not part of the replica identity.
692+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
693+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
694+ ----------+------------+------------------+-----------+-----------+------------------
695+ testpub6 | public | rf_tbl_abcd_nopk | {a,b,c,d} | (a > 99) | default
696+ (1 row)
697+
686698-- Case 2. REPLICA IDENTITY FULL
687699ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL;
688700ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL;
689701ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99);
690702-- ok - "c" is in REPLICA IDENTITY now even though not in PK
691703UPDATE rf_tbl_abcd_pk SET a = 1;
704+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
705+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
706+ ----------+------------+----------------+-----------+-----------+------------------
707+ testpub6 | public | rf_tbl_abcd_pk | {a,b,c,d} | (c > 99) | full
708+ (1 row)
709+
692710ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99);
693711-- ok - "a" is in REPLICA IDENTITY now
694712UPDATE rf_tbl_abcd_nopk SET a = 1;
713+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
714+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
715+ ----------+------------+------------------+-----------+-----------+------------------
716+ testpub6 | public | rf_tbl_abcd_nopk | {a,b,c,d} | (a > 99) | full
717+ (1 row)
718+
695719-- Case 3. REPLICA IDENTITY NOTHING
696720ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING;
697721ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING;
@@ -705,11 +729,23 @@ ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99);
705729UPDATE rf_tbl_abcd_pk SET a = 1;
706730ERROR: cannot update table "rf_tbl_abcd_pk"
707731DETAIL: Column used in the publication WHERE expression is not part of the replica identity.
732+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
733+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
734+ ----------+------------+----------------+-----------+-----------+------------------
735+ testpub6 | public | rf_tbl_abcd_pk | {a,b,c,d} | (c > 99) | nothing
736+ (1 row)
737+
708738ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99);
709739-- fail - "a" is not in REPLICA IDENTITY NOTHING
710740UPDATE rf_tbl_abcd_nopk SET a = 1;
711741ERROR: cannot update table "rf_tbl_abcd_nopk"
712742DETAIL: Column used in the publication WHERE expression is not part of the replica identity.
743+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
744+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
745+ ----------+------------+------------------+-----------+-----------+------------------
746+ testpub6 | public | rf_tbl_abcd_nopk | {a,b,c,d} | (a > 99) | nothing
747+ (1 row)
748+
713749-- Case 4. REPLICA IDENTITY INDEX
714750ALTER TABLE rf_tbl_abcd_pk ALTER COLUMN c SET NOT NULL;
715751CREATE UNIQUE INDEX idx_abcd_pk_c ON rf_tbl_abcd_pk(c);
@@ -725,6 +761,12 @@ DETAIL: Column used in the publication WHERE expression is not part of the repl
725761ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_pk WHERE (c > 99);
726762-- ok - "c" is not in PK but it is part of REPLICA IDENTITY INDEX
727763UPDATE rf_tbl_abcd_pk SET a = 1;
764+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
765+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
766+ ----------+------------+----------------+-----------+-----------+------------------
767+ testpub6 | public | rf_tbl_abcd_pk | {a,b,c,d} | (c > 99) | index
768+ (1 row)
769+
728770ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (a > 99);
729771-- fail - "a" is not in REPLICA IDENTITY INDEX
730772UPDATE rf_tbl_abcd_nopk SET a = 1;
@@ -733,6 +775,12 @@ DETAIL: Column used in the publication WHERE expression is not part of the repl
733775ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_nopk WHERE (c > 99);
734776-- ok - "c" is part of REPLICA IDENTITY INDEX
735777UPDATE rf_tbl_abcd_nopk SET a = 1;
778+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
779+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
780+ ----------+------------+------------------+-----------+-----------+------------------
781+ testpub6 | public | rf_tbl_abcd_nopk | {a,b,c,d} | (c > 99) | index
782+ (1 row)
783+
736784-- Tests for partitioned table
737785-- set PUBLISH_VIA_PARTITION_ROOT to false and test row filter for partitioned
738786-- table
@@ -779,6 +827,12 @@ ALTER PUBLICATION testpub6 SET TABLE rf_tbl_abcd_part_pk WHERE (b > 99);
779827UPDATE rf_tbl_abcd_part_pk SET a = 1;
780828ERROR: cannot update table "rf_tbl_abcd_part_pk_1"
781829DETAIL: Column used in the publication WHERE expression is not part of the replica identity.
830+ SELECT * FROM pg_publication_tables WHERE pubname = 'testpub6';
831+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
832+ ----------+------------+---------------------+----------+-----------+------------------
833+ testpub6 | public | rf_tbl_abcd_part_pk | {a,b} | (b > 99) | default
834+ (1 row)
835+
782836DROP PUBLICATION testpub6;
783837DROP TABLE rf_tbl_abcd_pk;
784838DROP TABLE rf_tbl_abcd_nopk;
@@ -1863,52 +1917,52 @@ CREATE TABLE sch2.tbl1_part1 PARTITION OF sch1.tbl1 FOR VALUES FROM (1) to (10);
18631917-- Schema publication that does not include the schema that has the parent table
18641918CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=1);
18651919SELECT * FROM pg_publication_tables;
1866- pubname | schemaname | tablename | attnames | rowfilter
1867- ---------+------------+------------+----------+-----------
1868- pub | sch2 | tbl1_part1 | {a} |
1920+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1921+ ---------+------------+------------+----------+-----------+------------------
1922+ pub | sch2 | tbl1_part1 | {a} | | default
18691923(1 row)
18701924
18711925DROP PUBLICATION pub;
18721926-- Table publication that does not include the parent table
18731927CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=1);
18741928SELECT * FROM pg_publication_tables;
1875- pubname | schemaname | tablename | attnames | rowfilter
1876- ---------+------------+------------+----------+-----------
1877- pub | sch2 | tbl1_part1 | {a} |
1929+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1930+ ---------+------------+------------+----------+-----------+------------------
1931+ pub | sch2 | tbl1_part1 | {a} | | default
18781932(1 row)
18791933
18801934-- Table publication that includes both the parent table and the child table
18811935ALTER PUBLICATION pub ADD TABLE sch1.tbl1;
18821936SELECT * FROM pg_publication_tables;
1883- pubname | schemaname | tablename | attnames | rowfilter
1884- ---------+------------+-----------+----------+-----------
1885- pub | sch1 | tbl1 | {a} |
1937+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1938+ ---------+------------+-----------+----------+-----------+------------------
1939+ pub | sch1 | tbl1 | {a} | | default
18861940(1 row)
18871941
18881942DROP PUBLICATION pub;
18891943-- Schema publication that does not include the schema that has the parent table
18901944CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch2 WITH (PUBLISH_VIA_PARTITION_ROOT=0);
18911945SELECT * FROM pg_publication_tables;
1892- pubname | schemaname | tablename | attnames | rowfilter
1893- ---------+------------+------------+----------+-----------
1894- pub | sch2 | tbl1_part1 | {a} |
1946+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1947+ ---------+------------+------------+----------+-----------+------------------
1948+ pub | sch2 | tbl1_part1 | {a} | | default
18951949(1 row)
18961950
18971951DROP PUBLICATION pub;
18981952-- Table publication that does not include the parent table
18991953CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=0);
19001954SELECT * FROM pg_publication_tables;
1901- pubname | schemaname | tablename | attnames | rowfilter
1902- ---------+------------+------------+----------+-----------
1903- pub | sch2 | tbl1_part1 | {a} |
1955+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1956+ ---------+------------+------------+----------+-----------+------------------
1957+ pub | sch2 | tbl1_part1 | {a} | | default
19041958(1 row)
19051959
19061960-- Table publication that includes both the parent table and the child table
19071961ALTER PUBLICATION pub ADD TABLE sch1.tbl1;
19081962SELECT * FROM pg_publication_tables;
1909- pubname | schemaname | tablename | attnames | rowfilter
1910- ---------+------------+------------+----------+-----------
1911- pub | sch2 | tbl1_part1 | {a} |
1963+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1964+ ---------+------------+------------+----------+-----------+------------------
1965+ pub | sch2 | tbl1_part1 | {a} | | default
19121966(1 row)
19131967
19141968DROP PUBLICATION pub;
@@ -1921,9 +1975,9 @@ CREATE TABLE sch1.tbl1_part3 (a int) PARTITION BY RANGE(a);
19211975ALTER TABLE sch1.tbl1 ATTACH PARTITION sch1.tbl1_part3 FOR VALUES FROM (20) to (30);
19221976CREATE PUBLICATION pub FOR TABLES IN SCHEMA sch1 WITH (PUBLISH_VIA_PARTITION_ROOT=1);
19231977SELECT * FROM pg_publication_tables;
1924- pubname | schemaname | tablename | attnames | rowfilter
1925- ---------+------------+-----------+----------+-----------
1926- pub | sch1 | tbl1 | {a} |
1978+ pubname | schemaname | tablename | attnames | rowfilter | replica_identity
1979+ ---------+------------+-----------+----------+-----------+------------------
1980+ pub | sch1 | tbl1 | {a} | | default
19271981(1 row)
19281982
19291983RESET client_min_messages;
0 commit comments