From 08c3f7979011fae982c3c32691c56ab3d4886c08 Mon Sep 17 00:00:00 2001 From: amitlan Date: Thu, 20 May 2021 21:35:09 +0900 Subject: [PATCH v5 2/2] pgoutput: don't send leaf partition schema when publishing via ancestor --- src/backend/replication/pgoutput/pgoutput.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index de89b14308..0b1ec102cb 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -74,7 +74,8 @@ static void send_relation_and_attrs(Relation relation, TransactionId xid, /* * Entry in the map used to remember which relation schemas we sent. * - * The schema_sent flag determines if the current schema record was already + * The schema_sent flag determines if the current schema record for the + * relation (or for its ancestor if publish_as_relid is set) was already * sent to the subscriber (in which case we don't need to send it again). * * The schema cache on downstream is however updated only at commit time, @@ -440,9 +441,8 @@ maybe_send_schema(LogicalDecodingContext *ctx, /* * Nope, so send the schema. If the changes will be published using an * ancestor's schema, not the relation's own, send that ancestor's schema - * before sending relation's own (XXX - maybe sending only the former - * suffices?). This is also a good place to set the map that will be used - * to convert the relation's tuples into the ancestor's format, if needed. + * instead. This is also a good place to set the map that will be used to + * convert the relation's tuples into the ancestor's format, if needed. */ if (relentry->publish_as_relid != RelationGetRelid(relation)) { @@ -473,8 +473,8 @@ maybe_send_schema(LogicalDecodingContext *ctx, MemoryContextSwitchTo(oldctx); RelationClose(ancestor); } - - send_relation_and_attrs(relation, xid, ctx); + else + send_relation_and_attrs(relation, xid, ctx); if (in_streaming) set_schema_sent_in_streamed_txn(relentry, topxid); -- 2.24.1