Skip to content

Commit 3abf496

Browse files
committed
> > There is a bug in check_foreign_key of refint.c which is bundled with
> > the standard distribution. It occurs when a trigger calling this > > function recursively fires another trigger which calls the same > > function. The calling check_foreign_key loses its plan informantion and > > when it tries to use it the backend closes its channel. You can check it > > with the sql script I am attaching below. > > The solution to this is to do a find_plan again before executing it at > > line 483 of refint.c. > > Therefore two more lines should be added before line 483: Anand Surelia
1 parent b7ed6f8 commit 3abf496

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

contrib/spi/refint.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ check_foreign_key()
480480

481481
relname = args[0];
482482

483+
sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
484+
plan = find_plan(ident, &FPlans, &nFPlans);
483485
ret = SPI_execp(plan->splan[r], kvals, NULL, tcount);
484486
/* we have no NULLs - so we pass ^^^^ here */
485487

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,13 @@ catalogs.
281281
<variablelist>
282282
<varlistentry>
283283
<term>
284-
rules and views
284+
rules
285285
<listitem>
286286
<para>
287287
<application>pg_dump</application>
288-
does not understand user-defined rules and views and
288+
does not understand user-defined rules and
289289
will fail to dump them properly. (This is due to the fact that
290-
rules are stored as plans in the catalogs and not textually).
290+
rules are stored as plans in the catalogs and not textually.)
291291

292292
<varlistentry>
293293
<term>

0 commit comments

Comments
 (0)