pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bharath Rupireddy <bharath.rupireddy@enterprisedb.com>
Subject: [PATCH v3 1/2] Fix ALTER PUBLICATION...DROP TABLE behaviour
Date: Wed, 13 Jan 2021 16:35:00 +0530

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 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

inline patch 1: src/backend/replication/pgoutput/pgoutput.c (+13/-0 lines) download inline-1.patchdiff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 2f01137b42..118faf6ce3 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1179,5 +1179,18 @@ rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue) */ hash_seq_init(&status, RelationSyncCache); while ((entry = (RelationSyncEntry *) hash_seq_search(&status)) != NULL) + { entry->replicate_valid = false; + + /* + * There might some relations dropped from the publication, we do + * not need to publish the changes for them. However, we cannot get + * the dropped relations (see above), so we reset pubactions for all + * entries. + */ + entry->pubactions.pubinsert = false; + entry->pubactions.pubupdate = false; + entry->pubactions.pubdelete = false; + entry->pubactions.pubtruncate = false; + } } -- 2.30.0
--=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v3-0002-Invalidate-relation-map-cache-in-subscriber-sysca.patch

Message-ID: <no-message-id-166481@localhost>
Permalink:  ../no-message-id-166481@localhost/
Also on:    postgresql.org/message-id/no-message-id-166481@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bharath.rupireddy@enterprisedb.com
  Subject: Re: [PATCH v3 1/2] Fix ALTER PUBLICATION...DROP TABLE behaviour
  In-Reply-To: <no-message-id-166481@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox