From bec60feed2fd4a9bef2cbdbc934f52b73e9f9aa1 Mon Sep 17 00:00:00 2001 From: amitlan Date: Thu, 20 May 2021 21:42:27 +0900 Subject: [PATCH v6 2/2] pgoutput: don't send leaf partition schema when publishing via ancestor --- src/backend/replication/pgoutput/pgoutput.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index c691c063cd..4a5eb9ccd1 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -57,6 +57,10 @@ static void send_relation_and_attrs(Relation relation, LogicalDecodingContext *c /* * Entry in the map used to remember which relation schemas we sent. * + * 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). + * * For partitions, 'pubactions' considers not only the table's own * publications, but also those of all of its ancestors. */ @@ -295,9 +299,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)) { @@ -328,8 +331,8 @@ maybe_send_schema(LogicalDecodingContext *ctx, MemoryContextSwitchTo(oldctx); RelationClose(ancestor); } - - send_relation_and_attrs(relation, ctx); + else + send_relation_and_attrs(relation, ctx); relentry->schema_sent = true; } -- 2.24.1