From e8534c1dd518a926c98026e344c0ba247a7107b2 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 2 Dec 2021 00:09:19 +0300 Subject: [PATCH] Drop sequence metadata from workers explicitly --- .../distributed/worker/worker_drop_protocol.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/distributed/worker/worker_drop_protocol.c b/src/backend/distributed/worker/worker_drop_protocol.c index 35b59c374..a78e2d7a7 100644 --- a/src/backend/distributed/worker/worker_drop_protocol.c +++ b/src/backend/distributed/worker/worker_drop_protocol.c @@ -81,6 +81,21 @@ worker_drop_distributed_table(PG_FUNCTION_ARGS) distributedTableObject.objectId = relationId; distributedTableObject.objectSubId = 0; + /* Drop dependent sequences from pg_dist_object */ + #if PG_VERSION_NUM >= PG_VERSION_13 + List *ownedSequences = getOwnedSequences(relationId); + #else + List *ownedSequences = getOwnedSequences(relationId, InvalidAttrNumber); + #endif + + Oid ownedSequenceOid = InvalidOid; + foreach_oid(ownedSequenceOid, ownedSequences) + { + ObjectAddress ownedSequenceAddress = { 0 }; + ObjectAddressSet(ownedSequenceAddress, RelationRelationId, ownedSequenceOid); + UnmarkObjectDistributed(&ownedSequenceAddress); + } + /* drop the server for the foreign relations */ if (relationKind == RELKIND_FOREIGN_TABLE) {