From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Subject: BUG #18517: Dropping a table referenced by an initially deferred foreign key fails with an error
Date: Thu, 20 Jun 2024 11:00:01 +0000
Message-ID: <18517-af2d19882240902c@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18517
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 17beta1
Operating system: Ubuntu 22.04
Description:
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
BACKTRACE:
afterTriggerInvokeEvents at trigger.c:4700:7
AfterTriggerFireDeferred at trigger.c:5224:6
CommitTransaction at xact.c:2219:8
CommitTransactionCommandInternal at xact.c:3169:18
CommitTransactionCommand at xact.c:3099:9
finish_xact_command at postgres.c:2783:3
exec_simple_query at postgres.c:1299:4
PostgresMain at postgres.c:4684:27
BackendInitialize at backend_startup.c:123:1
postmaster_child_launch at launch_backend.c:269:9
BackendStartup at postmaster.c:3593:8
ServerLoop at postmaster.c:1677:10
PostmasterMain at postmaster.c:1372:11
startup_hacks at main.c:217:1
afterTriggerInvokeEvents() coding is:
/*
* So let's fire it... but first, find the correct relation
if
* this is not the same relation as before.
*/
if (rel == NULL || RelationGetRelid(rel) !=
evtshared->ats_relid)
{
...
if (trigdesc == NULL) /* should not happen */
elog(ERROR, "relation %u has no triggers",
evtshared->ats_relid);
Reproduced on REL_12_STABLE .. master.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, exclusion@gmail.com
Subject: Re: BUG #18517: Dropping a table referenced by an initially deferred foreign key fails with an error
In-Reply-To: <18517-af2d19882240902c@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox