diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index ee54a17..844b285 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -499,14 +499,6 @@ pgoutput_truncate(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, continue; /* - * Don't send partitioned tables unless publication wants to send - * only the root tables, because partitions will be sent instead. - */ - if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE && - relentry->publish_as_relid != relid) - continue; - - /* * Don't send partitions if the publication wants to send only the * root tables through it. */ @@ -644,6 +636,7 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) { RelationSyncEntry *entry; bool am_partition = get_rel_relispartition(relid); + char relkind = get_rel_relkind(relid); bool found; MemoryContext oldctx; @@ -692,10 +685,8 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) if (pub->alltables) { publish = true; - if (pub->pubviaroot) - publish_as_relid = am_partition ? - llast_oid(get_partition_ancestors(relid)) : - relid; + if (pub->pubviaroot && am_partition) + publish_as_relid = llast_oid(get_partition_ancestors(relid)); } if (!publish) @@ -732,7 +723,13 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) publish = true; } - if (publish) + /* + * Don't publish changes for partitioned tables, because + * publishing those of its partitions suffices, unless partition + * changes won't be published due to pubviaroot being set. + */ + if (publish && + (relkind != RELKIND_PARTITIONED_TABLE || pub->pubviaroot)) { entry->pubactions.pubinsert |= pub->pubactions.pubinsert; entry->pubactions.pubupdate |= pub->pubactions.pubupdate;