Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88016a5

Browse files
Jan WieckJan Wieck
authored andcommitted
Fixed bug in targetlist expression replacement of
SET DEFAULT referential action triggers. Jan
1 parent d1e6368 commit 88016a5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/backend/utils/adt/ri_triggers.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* 1999 Jan Wieck
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.10 1999/12/10 12:34:13 wieck Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.11 2000/01/06 16:30:43 wieck Exp $
1010
*
1111
* ----------
1212
*/
@@ -1903,7 +1903,12 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
19031903
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
19041904

19051905
/* ----------
1906-
* Now replace the CONST NULL targetlist expressions
1906+
* Here now follows very ugly code depending on internals
1907+
* of the SPI manager.
1908+
*
1909+
* EVIL EVIL EVIL (but must be - Jan)
1910+
*
1911+
* We replace the CONST NULL targetlist expressions
19071912
* in the generated plan by (any) default values found
19081913
* in the tuple constructor.
19091914
* ----------
@@ -1931,7 +1936,8 @@ RI_FKey_setdefault_del (FmgrInfo *proinfo)
19311936
* ----------
19321937
*/
19331938
spi_qptle = (TargetEntry *)
1934-
nth(i, spi_plan->targetlist);
1939+
nth(defval[j].adnum - 1,
1940+
spi_plan->targetlist);
19351941
spi_qptle->expr = stringToNode(defval[j].adbin);
19361942

19371943
break;
@@ -2188,7 +2194,8 @@ RI_FKey_setdefault_upd (FmgrInfo *proinfo)
21882194
* ----------
21892195
*/
21902196
spi_qptle = (TargetEntry *)
2191-
nth(i, spi_plan->targetlist);
2197+
nth(defval[j].adnum - 1,
2198+
spi_plan->targetlist);
21922199
spi_qptle->expr = stringToNode(defval[j].adbin);
21932200

21942201
break;

0 commit comments

Comments
 (0)