Re: BUG #18517: Dropping a table referenced by an initially deferred foreign key fails with an error
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2024-06-20T16:43:36Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes: > The following script: > CREATE TABLE pkt (id int PRIMARY KEY); > CREATE TABLE fkt (id int PRIMARY KEY, fk int REFERENCES pkt INITIALLY > DEFERRED); > INSERT INTO pkt VALUES (1); > BEGIN; > INSERT INTO fkt VALUES (101, 1); > DROP TABLE pkt CASCADE; > COMMIT; > fails on commit with a weird error: > ERROR: relation 16390 has no triggers Oh, interesting. Furthermore, if I add an unrelated trigger to fkt so that there's still a trigdesc, then I reach ERROR: XX000: could not find trigger 42452 LOCATION: AfterTriggerExecute, trigger.c:4303 So what this demonstrates is that we should not consider it an error if afterTriggerInvokeEvents finds an event for a trigger that no longer exists. Perhaps an alternative could be to run through the pending events at DROP time and throw an error if there's an unfired event for the trigger. That doesn't sound better to me though. I see no very good reason why we shouldn't allow the above sequence of commands and treat the constraint as no longer to be enforced. regards, tom lane
Commits
-
Don't throw an error if a queued AFTER trigger no longer exists.
- e6d0d16adf7f 17.0 landed
- b0037bbefda3 12.20 landed
- 9ce8ee9d3e75 13.16 landed
- 88f3baa06afd 14.13 landed
- 4f1966676270 16.4 landed
- 1424c7abc44f 15.8 landed