Skip to content

Commit a61bff2

Browse files
author
Amit Kapila
committed
De-duplicate the result of pg_publication_tables view.
We show duplicate values for child tables in publications that have both child and parent tables and are published with publish_via_partition_root as false which is not what the user would expect. We decided not to backpatch this as there is no user complaint about this and it doesn't seem to be a critical issue. Author: Hou Zhijie Reviewed-by: Bharath Rupireddy, Amit Langote, Amit Kapila Discussion: https://postgr.es/m/OS0PR01MB5716E97F00732B52DC2BBC2594989@OS0PR01MB5716.jpnprd01.prod.outlook.com
1 parent 814e1d9 commit a61bff2

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/backend/catalog/pg_publication.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,10 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
487487
systable_endscan(scan);
488488
table_close(pubrelsrel, AccessShareLock);
489489

490+
/* Now sort and de-duplicate the result list */
491+
list_sort(result, list_oid_cmp);
492+
list_deduplicate_oid(result);
493+
490494
return result;
491495
}
492496

src/test/regress/expected/publication.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,14 @@ SELECT * FROM pg_publication_tables;
832832
pub | sch2 | tbl1_part1
833833
(1 row)
834834

835+
-- Table publication that includes both the parent table and the child table
836+
ALTER PUBLICATION pub ADD TABLE sch1.tbl1;
837+
SELECT * FROM pg_publication_tables;
838+
pubname | schemaname | tablename
839+
---------+------------+------------
840+
pub | sch2 | tbl1_part1
841+
(1 row)
842+
835843
DROP PUBLICATION pub;
836844
DROP TABLE sch2.tbl1_part1;
837845
DROP TABLE sch1.tbl1;

src/test/regress/sql/publication.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@ DROP PUBLICATION pub;
469469
CREATE PUBLICATION pub FOR TABLE sch2.tbl1_part1 WITH (PUBLISH_VIA_PARTITION_ROOT=0);
470470
SELECT * FROM pg_publication_tables;
471471

472+
-- Table publication that includes both the parent table and the child table
473+
ALTER PUBLICATION pub ADD TABLE sch1.tbl1;
474+
SELECT * FROM pg_publication_tables;
475+
472476
DROP PUBLICATION pub;
473477
DROP TABLE sch2.tbl1_part1;
474478
DROP TABLE sch1.tbl1;

0 commit comments

Comments
 (0)