diff --git a/src/backend/distributed/commands/utility_hook.c b/src/backend/distributed/commands/utility_hook.c index 04ba4d209..dfb655fed 100644 --- a/src/backend/distributed/commands/utility_hook.c +++ b/src/backend/distributed/commands/utility_hook.c @@ -669,7 +669,22 @@ ProcessUtilityInternal(PlannedStmt *pstmt, if (ops && ops->address) { ObjectAddress targetObject = GetObjectAddressFromParseTree(parsetree, true); - ErrorIfCircularDependencyExists(&targetObject); + char *objectDescription = NULL; + + #if PG_VERSION_NUM >= PG_VERSION_14 + objectDescription = getObjectDescription(&targetObject, true); + #else + objectDescription = getObjectDescription(&targetObject); + #endif + + /* + * Having object description as NULL means the target object is either dropped + * or it's name has been changed + */ + if (objectDescription != NULL) + { + ErrorIfCircularDependencyExists(&targetObject); + } } if (ops && ops->postprocess) diff --git a/src/backend/distributed/metadata/dependency.c b/src/backend/distributed/metadata/dependency.c index d257cc545..0c3fc85c7 100644 --- a/src/backend/distributed/metadata/dependency.c +++ b/src/backend/distributed/metadata/dependency.c @@ -385,6 +385,12 @@ RecurseObjectDependencies(ObjectAddress target, expandFn expand, followFn follow void ErrorIfCircularDependencyExists(const ObjectAddress *objectAddress) { + + /* + * We need to get the see dependencies created in this command. + */ + CommandCounterIncrement(); + List *dependencies = GetAllSupportedDependenciesForObject(objectAddress); ObjectAddress *dependency = NULL;