diff options
| author | Amit Kapila <akapila@postgresql.org> | 2025-10-23 08:30:27 +0000 |
|---|---|---|
| committer | Amit Kapila <akapila@postgresql.org> | 2025-10-23 08:30:27 +0000 |
| commit | f0b3573c3aac6c0ea4cbc278f98178516579d370 (patch) | |
| tree | af2caa24d8562050b79ccb302d97437596b4cc55 /src/backend/replication/logical/relation.c | |
| parent | 6ae08d9583e9a5e951286948bdd9fcd58e67718a (diff) | |
Introduce "REFRESH SEQUENCES" for subscriptions.
This patch adds support for a new SQL command:
ALTER SUBSCRIPTION ... REFRESH SEQUENCES
This command updates the sequence entries present in the
pg_subscription_rel catalog table with the INIT state to trigger
resynchronization.
In addition to the new command, the following subscription commands have
been enhanced to automatically refresh sequence mappings:
ALTER SUBSCRIPTION ... REFRESH PUBLICATION
ALTER SUBSCRIPTION ... ADD PUBLICATION
ALTER SUBSCRIPTION ... DROP PUBLICATION
ALTER SUBSCRIPTION ... SET PUBLICATION
These commands will perform the following actions:
Add newly published sequences that are not yet part of the subscription.
Remove sequences that are no longer included in the publication.
This ensures that sequence replication remains aligned with the current
state of the publication on the publisher side.
Note that the actual synchronization of sequence data/values will be
handled in a subsequent patch that introduces a dedicated sequence sync
worker.
Author: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Nisha Moond <nisha.moond412@gmail.com>
Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>
Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
Diffstat (limited to 'src/backend/replication/logical/relation.c')
| -rw-r--r-- | src/backend/replication/logical/relation.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c index f59046ad620..745fd3bab64 100644 --- a/src/backend/replication/logical/relation.c +++ b/src/backend/replication/logical/relation.c @@ -196,6 +196,17 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel) entry->remoterel.atttyps[i] = remoterel->atttyps[i]; } entry->remoterel.replident = remoterel->replident; + + /* + * XXX The walsender currently does not transmit the relkind of the remote + * relation when replicating changes. Since we support replicating only + * table changes at present, we default to initializing relkind as + * RELKIND_RELATION. This is needed in CheckSubscriptionRelkind() to check + * if the publisher and subscriber relation kinds are compatible. + */ + entry->remoterel.relkind = + (remoterel->relkind == 0) ? RELKIND_RELATION : remoterel->relkind; + entry->remoterel.attkeys = bms_copy(remoterel->attkeys); MemoryContextSwitchTo(oldctx); } @@ -425,6 +436,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode) /* Check for supported relkind. */ CheckSubscriptionRelkind(entry->localrel->rd_rel->relkind, + remoterel->relkind, remoterel->nspname, remoterel->relname); /* |
