From 26ae4b8fb3637c8281aecc2b696f02bd1f935b7c Mon Sep 17 00:00:00 2001 From: Hanefi Onaldi Date: Wed, 12 Oct 2022 13:24:04 +0300 Subject: [PATCH] Rename a function that collides with PG15 (#6422) PG15 introduced a function called ReplicationSlotName that causes conflicts with our function with the same name. I solved this issue by renaming our function to ReplicationSlotNameForNodeAndOwner Relevant PG commit: https://github.com/postgres/postgres/commit/c3b5992b91c4b0d2c4f4eab0fb856f34854c129d (cherry picked from commit ec3eebbaf66012cdc5c002c6e8e45dc05028a8d6) --- .../worker_split_shard_replication_setup_udf.c | 8 +++++--- .../replication/multi_logical_replication.c | 15 +++++++++------ .../distributed/multi_logical_replication.h | 3 ++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/backend/distributed/operations/worker_split_shard_replication_setup_udf.c b/src/backend/distributed/operations/worker_split_shard_replication_setup_udf.c index f4ffc6184..cd8c58426 100644 --- a/src/backend/distributed/operations/worker_split_shard_replication_setup_udf.c +++ b/src/backend/distributed/operations/worker_split_shard_replication_setup_udf.c @@ -281,7 +281,8 @@ PopulateShardSplitInfoInSM(ShardSplitInfoSMHeader *shardSplitInfoSMHeader) { uint32_t nodeId = entry->key.nodeId; uint32_t tableOwnerId = entry->key.tableOwnerId; - char *derivedSlotName = ReplicationSlotName(SHARD_SPLIT, nodeId, tableOwnerId); + char *derivedSlotName = ReplicationSlotNameForNodeAndOwner(SHARD_SPLIT, nodeId, + tableOwnerId); List *shardSplitInfoList = entry->shardSplitInfoList; ShardSplitInfo *splitShardInfo = NULL; @@ -389,8 +390,9 @@ ReturnReplicationSlotInfo(Tuplestorestate *tupleStore, TupleDesc char *tableOwnerName = GetUserNameFromId(entry->key.tableOwnerId, false); values[1] = CStringGetTextDatum(tableOwnerName); - char *slotName = ReplicationSlotName(SHARD_SPLIT, entry->key.nodeId, - entry->key.tableOwnerId); + char *slotName = ReplicationSlotNameForNodeAndOwner(SHARD_SPLIT, + entry->key.nodeId, + entry->key.tableOwnerId); values[2] = CStringGetTextDatum(slotName); tuplestore_putvalues(tupleStore, tupleDescriptor, values, nulls); diff --git a/src/backend/distributed/replication/multi_logical_replication.c b/src/backend/distributed/replication/multi_logical_replication.c index c8b1dae6e..850daca24 100644 --- a/src/backend/distributed/replication/multi_logical_replication.c +++ b/src/backend/distributed/replication/multi_logical_replication.c @@ -501,9 +501,9 @@ CreateShardMoveLogicalRepTargetList(HTAB *publicationInfoHash, List *shardList) target->newShards = NIL; target->subscriptionOwnerName = SubscriptionRoleName(SHARD_MOVE, ownerId); target->replicationSlot = palloc0(sizeof(ReplicationSlotInfo)); - target->replicationSlot->name = ReplicationSlotName(SHARD_MOVE, - nodeId, - ownerId); + target->replicationSlot->name = ReplicationSlotNameForNodeAndOwner(SHARD_MOVE, + nodeId, + ownerId); target->replicationSlot->targetNodeId = nodeId; target->replicationSlot->tableOwnerId = ownerId; logicalRepTargetList = lappend(logicalRepTargetList, target); @@ -1381,11 +1381,14 @@ PublicationName(LogicalRepType type, uint32_t nodeId, Oid ownerId) /* - * ReplicationSlotName returns the name of the replication slot for the given - * node and table owner. + * ReplicationSlotNameForNodeAndOwner returns the name of the replication slot for the + * given node and table owner. + * + * Note that PG15 introduced a new ReplicationSlotName function that caused name conflicts + * and we renamed this function. */ char * -ReplicationSlotName(LogicalRepType type, uint32_t nodeId, Oid ownerId) +ReplicationSlotNameForNodeAndOwner(LogicalRepType type, uint32_t nodeId, Oid ownerId) { StringInfo slotName = makeStringInfo(); appendStringInfo(slotName, "%s%u_%u", replicationSlotPrefix[type], nodeId, diff --git a/src/include/distributed/multi_logical_replication.h b/src/include/distributed/multi_logical_replication.h index a40aebff9..f042b4326 100644 --- a/src/include/distributed/multi_logical_replication.h +++ b/src/include/distributed/multi_logical_replication.h @@ -157,7 +157,8 @@ extern void DropPublications(MultiConnection *sourceConnection, extern void DropAllLogicalReplicationLeftovers(LogicalRepType type); extern char * PublicationName(LogicalRepType type, uint32_t nodeId, Oid ownerId); -extern char * ReplicationSlotName(LogicalRepType type, uint32_t nodeId, Oid ownerId); +extern char * ReplicationSlotNameForNodeAndOwner(LogicalRepType type, uint32_t nodeId, Oid + ownerId); extern char * SubscriptionName(LogicalRepType type, Oid ownerId); extern char * SubscriptionRoleName(LogicalRepType type, Oid ownerId);