Hi, When a table is listed explicitly and also reached through its inheritance parent, CREATE PUBLICATION reports an error for the wrong table. For example: CREATE TABLE par (a int); CREATE TABLE c1 () INHERITS (par); CREATE TABLE c2 () INHERITS (par);
--- The table listed is c2, but the error reports c1. CREATE PUBLICATION pub FOR TABLE c2, par WHERE (a > 0); ERROR: conflicting or redundant WHERE clauses for table "c1" The same problem occurs with column lists: CREATE PUBLICATION pub FOR TABLE c2, par (a); ERROR: conflicting or redundant column lists for table "c1" While looping over a table's children, OpenTableList() uses rel = table_open(childrelid, NoLock), overwriting rel, which holds the explicitly named table. Both error messages use RelationGetRelationName(rel), so they report the last child opened rather than the conflicting table. In this example, c1 is not yet in the list, so it is opened into rel. When c2 is found to be a duplicate, rel still points to c1. The attached patch opens each child into a separate local variable, childrel, leaving rel unchanged. It also uses get_rel_name(childrelid) to report the conflicting child in both error messages. The child is already locked by find_all_inheritors(), so its name is available. Regards, Vignesh
v1-0001-Report-the-correct-table-in-publication-duplicate.patch
Description: Binary data
