Check for pending trigger events on far end when dropping an FK constraint.
authorTom Lane
Fri, 25 Nov 2016 18:44:48 +0000 (13:44 -0500)
committerTom Lane
Fri, 25 Nov 2016 18:44:48 +0000 (13:44 -0500)
commitf7166ce243aec3f5df454377d81b67032d85f35c
treea51c6f53e94cbe14170c3505fde05e3046ef6834
parent15f3e0cb13e7711195915996664e0b035c0498f9
Check for pending trigger events on far end when dropping an FK constraint.

When dropping a foreign key constraint with ALTER TABLE DROP CONSTRAINT,
we refuse the drop if there are any pending trigger events on the named
table; this ensures that we won't remove the pg_trigger row that will be
consulted by those events.  But we should make the same check for the
referenced relation, else we might remove a due-to-be-referenced pg_trigger
row for that relation too, resulting in "could not find trigger NNN" or
"relation NNN has no triggers" errors at commit.  Per bug #14431 from
Benjie Gillam.  Back-patch to all supported branches.

Report: <20161124114911[email protected]>
src/backend/commands/tablecmds.c
src/test/regress/expected/foreign_key.out
src/test/regress/sql/foreign_key.sql