diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index cb06018b0d8..a73d4ee555a 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -2658,7 +2658,7 @@ drop_sub_conflict_log_table(Oid subid, char *subname, Oid subconflictlogrelid, elog(ERROR, "cache lookup failed for relation %u", subconflictlogrelid); - if (is_drop_sub) + if (is_drop_sub && behavior == DROP_RESTRICT) { /* * The subscription is being dropped, so drop the table through it @@ -2679,7 +2679,12 @@ drop_sub_conflict_log_table(Oid subid, char *subname, Oid subconflictlogrelid, * The subscription stays, so drop only the table, and a RESTRICT * failure names the table rather than the subscription. Remove * the internal dependency first, or the table can't be dropped - * without the subscription. + * + * With DROP SUBSCRIPTION ... CASCADE, do not pass + * PERFORM_DELETION_INTERNAL, so that event triggers see the + * objects that depend on the table, which are dropped as well. + * The subscription itself is not part of this deletion, so it is + * not reported twice. */ deleteDependencyRecordsForSpecific(RelationRelationId, subconflictlogrelid, @@ -2689,7 +2694,8 @@ 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, + is_drop_sub ? 0 : PERFORM_DELETION_INTERNAL); } ereport(NOTICE,