diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index 8e268295f9..ca33432528 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -865,18 +865,28 @@ pg_get_publication_tables(PG_FUNCTION_ARGS) PUBLICATION_PART_ROOT : PUBLICATION_PART_LEAF); - tables = list_concat_unique_oid(relids, schemarelids); - - /* - * If the publication publishes partition changes via their - * respective root partitioned tables, we must exclude partitions - * in favor of including the root partitioned tables. Otherwise, - * the function could return both the child and parent tables which - * could cause data of the child table to be double-published on the - * subscriber side. - */ - if (publication->pubviaroot) - tables = filter_partitions(tables); + if (schemarelids) + { + /* + * If the publication publishes partition changes via their + * respective root partitioned tables, we must exclude + * partitions in favor of including the root partitioned + * tables. Otherwise, the function could return both the child + * and parent tables which could cause data of the child table + * to be double-published on the subscriber side. + * + * XXX As of now, we do this when a publication has associated + * schema or for all tables publication. See + * GetAllTablesPublicationRelations(). + */ + tables = list_concat_unique_oid(relids, schemarelids); + if (publication->pubviaroot) + tables = filter_partitions(tables); + } + else + { + tables = relids; + } } funcctx->user_fctx = (void *) tables;