diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index e4c73cc8686..4be6c5dab08 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -271,6 +271,9 @@ deleteObjectsInList(ObjectAddresses *targetObjects, Relation *depRel, * PERFORM_DELETION_CONCURRENT_LOCK: perform the drop normally but with a lock * as if it were concurrent. This is used by REINDEX CONCURRENTLY. * + * PERFORM_DELETION_SKIP_CASCADE_HINT: omit the DROP ... CASCADE hint when + * RESTRICT fails, for callers that cannot offer cascading deletion. + * */ void performDeletion(const ObjectAddress *object, @@ -1169,6 +1172,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects, getObjectDescription(origObject, false)), errdetail_internal("%s", clientdetail.data), errdetail_log("%s", logdetail.data), + (flags & PERFORM_DELETION_SKIP_CASCADE_HINT) ? 0 : errhint("Use DROP ... CASCADE to drop the dependent objects too."))); else ereport(ERROR, @@ -1176,6 +1180,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects, errmsg("cannot drop desired object(s) because other objects depend on them"), errdetail_internal("%s", clientdetail.data), errdetail_log("%s", logdetail.data), + (flags & PERFORM_DELETION_SKIP_CASCADE_HINT) ? 0 : errhint("Use DROP ... CASCADE to drop the dependent objects too."))); } else if (numReportedClient > 1) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index cb06018b0d8..65b034ed6fa 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -2689,7 +2689,9 @@ drop_sub_conflict_log_table(Oid subid, char *subname, Oid subconflictlogrelid, CommandCounterIncrement(); ObjectAddressSet(object, RelationRelationId, subconflictlogrelid); - performDeletion(&object, behavior, PERFORM_DELETION_INTERNAL); + performDeletion(&object, behavior, + PERFORM_DELETION_INTERNAL | + PERFORM_DELETION_SKIP_CASCADE_HINT); } ereport(NOTICE, diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h index 9782d0df2a7..9ff6e3c5ed3 100644 --- a/src/include/catalog/dependency.h +++ b/src/include/catalog/dependency.h @@ -96,6 +96,7 @@ typedef struct ObjectAddresses ObjectAddresses; #define PERFORM_DELETION_SKIP_EXTENSIONS 0x0010 /* keep extensions */ #define PERFORM_DELETION_CONCURRENT_LOCK 0x0020 /* normal drop with * concurrent lock mode */ +#define PERFORM_DELETION_SKIP_CASCADE_HINT 0x0040 /* omit CASCADE hint */ /* in dependency.c */