I have reviewed a portion of v21-001 yet. The comments so far: 1) check_publication_add_relation:
+ Oid relid = RelationGetRelid(targetrel); Please move this inside : + if (targetrel->rd_rel->relispartition) 2) Please shorten this comment: + /* + * If the partition root (the last element of ancestors) is excluded from + * this publication via its EXCEPT clause, the partition is not published + * through this publication at all, so we short-circuit and return + * InvalidOid without walking the ancestor list. Only the root of a + * partition hierarchy can ever appear in a publication's EXCEPT clause (a + * partition itself is rejected from EXCEPT elsewhere), so it's the only + * one worth a catalog lookup. + */ Suggestion: /* * If the partition root is excluded from this publication via its EXCEPT * clause, the partition is not published through this publication, so return * InvalidOid. Since only partition roots can appear in an EXCEPT clause, the * root is the only ancestor worth a catalog lookup. */ 3) postgres=# ALTER TABLE s2.tab_root_new ATTACH PARTITION s2.tab_root FOR VALUES FROM (1) TO (2000); ERROR: cannot attach table "tab_root" as partition because it is referenced in publication "pub1" EXCEPT clause DETAIL: The publication EXCEPT clause cannot contain tables that are partitions. HINT: Change the publication's EXCEPT clause using ALTER PUBLICATION ... SET TABLES IN SCHEMA ... EXCEPT. postgres=# ALTER publication pub1 add TABLE s2.tab_part_1_p2; ERROR: cannot add partition "s2.tab_part_1_p2" to publication "pub1" DETAIL: Ancestor "s2.tab_root" of partition "s2.tab_part_1_p2" is currently listed in the EXCEPT clause of the publication. HINT: Change EXCEPT list using ALTER PUBLICATION ... SET TABLES IN SCHEMA ... EXCEPT. Can we make HINT same? We can retain the wording of HINT given in ATTACH PARTITION case as that is existing one. 4) postgres=# create publication pub1 for tables in schema s2 except (table s2.tab_root), table s2.tab_part_2, table s2.tab_part_1_p2; ERROR: partition "s2.tab_part_2" cannot be both published and excluded DETAIL: Ancestor "s2.tab_root" of partition "s2.tab_part_2" is currently listed in the EXCEPT clause of this command. postgres=# ALTER publication pub1 add TABLE s2.tab_part_1_p2; ERROR: cannot add partition "s2.tab_part_1_p2" to publication "pub1" DETAIL: Ancestor "s2.tab_root" of partition "s2.tab_part_1_p2" is currently listed in the EXCEPT clause of the publication. HINT: Change EXCEPT list using ALTER PUBLICATION ... SET TABLES IN SCHEMA ... EXCEPT. Should the DETAIL be just: DETAIL: Partition root "s2.tab_root" is listed in the publication's EXCEPT clause. Thoughts? thanks Shveta
