From 2586750a7af742d3aee5316671e31e13fc5285af Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Wed, 13 Jan 2021 16:35:00 +0530 Subject: [PATCH v2 1/2] Fix ALTER PUBLICATION...DROP TABLE behaviour Currently, in logical replication, publisher/walsender publishes the tables even though they aren't part of the publication i.e they are dropped from the publication. Because of this ALTER PUBLICATION...DROP TABLE doesn't work as expected. --- src/backend/replication/pgoutput/pgoutput.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 2f01137b42..7a4a376e29 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1055,6 +1055,18 @@ get_rel_sync_entry(PGOutputData *data, Oid relid) entry->pubactions.pubdelete |= pub->pubactions.pubdelete; entry->pubactions.pubtruncate |= pub->pubactions.pubtruncate; } + else + { + /* + * Relation is not associated with the publication anymore i.e + * it would have been dropped from the publication. So no need + * to publish the changes for it. + */ + entry->pubactions.pubinsert = false; + entry->pubactions.pubupdate = false; + entry->pubactions.pubdelete = false; + entry->pubactions.pubtruncate = false; + } if (entry->pubactions.pubinsert && entry->pubactions.pubupdate && entry->pubactions.pubdelete && entry->pubactions.pubtruncate) -- 2.30.0