On Wed, 25 Nov 2026 at 17:23, Nisha Moond <[email protected]> wrote: > > Attached v2 patch fixing above as well as other comments from Hou-san at [2].
DROP SUBSCRIPTION ... CASCADE drops the objects that depend on the
subscription's conflict log table (CLT), such as views but sql_drop
event triggers don't see those objects.
CREATE TABLE dropped_log (object_type text, object_identity text);
CREATE FUNCTION log_drops() RETURNS event_trigger LANGUAGE plpgsql AS $$
BEGIN
INSERT INTO dropped_log
SELECT object_type, object_identity FROM pg_event_trigger_dropped_objects();
END $$;
CREATE EVENT TRIGGER log_drops ON sql_drop EXECUTE FUNCTION log_drops();
CREATE SUBSCRIPTION sub1 CONNECTION 'dbname=postgres' PUBLICATION pub1
WITH (connect = false, slot_name = NONE, conflict_log_destination = 'table');
-- <oid> is the subscription's OID
CREATE VIEW v AS SELECT relid FROM pg_conflict.pg_conflict_log_<oid>;
DROP SUBSCRIPTION sub1 CASCADE;
SELECT * FROM dropped_log;
--------------+-----------------
subscription | sub1
(1 row)
The view v was dropped, but it is not in the list.
drop_sub_conflict_log_table() drops the table with
PERFORM_DELETION_INTERNAL. deleteObjectsInList() skips event-trigger
tracking for every object of a deletion when that flag is set
(dependency.c:196, and the comment at line 255). Only the subscription
is reported, because DropSubscription() adds it by itself.
I felt for CASCADE, drop the conflict table without
PERFORM_DELETION_INTERNAL flag like the changes in the attached patch.
Thoughts?
Regards,
Vignesh
drop_subscription_cascade_event_trigger_fix.patch
Description: Binary data
