Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb155310

Browse files
committed
Fix overly tense optimization of PLpgSQL_func_hashkey: we must represent
the isTrigger state explicitly, not rely on nonzero-ness of trigrelOidto indicate trigger-hood, because trigrelOid will be left zero when compilingfor validation. The (useless) function hash entry built by the validatorwas able to match an ordinary non-trigger call later in the same session,thereby bypassing the check that is supposed to prevent such a call.Per report from Alvaro.It might be worth suppressing the useless hash entry altogether, butthat's a bigger change than I want to consider back-patching.Back-patch to 8.0. 7.4 doesn't have the problem because it doesn'thave validation mode.
1 parent1b0f58a commitb155310

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

‎src/pl/plpgsql/src/pl_comp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.130 2008/09/01 20:42:46 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.131 2008/10/09 16:35:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1941,12 +1941,15 @@ compute_function_hashkey(FunctionCallInfo fcinfo,
19411941
/* get function OID */
19421942
hashkey->funcOid=fcinfo->flinfo->fn_oid;
19431943

1944+
/* get call context */
1945+
hashkey->isTrigger=CALLED_AS_TRIGGER(fcinfo);
1946+
19441947
/*
19451948
* if trigger, get relation OID. In validation mode we do not know what
19461949
* relation is intended to be used, so we leave trigrelOid zero; the hash
19471950
* entry built in this case will never really be used.
19481951
*/
1949-
if (CALLED_AS_TRIGGER(fcinfo)&& !forValidator)
1952+
if (hashkey->isTrigger&& !forValidator)
19501953
{
19511954
TriggerData*trigdata= (TriggerData*)fcinfo->context;
19521955

‎src/pl/plpgsql/src/plpgsql.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.100 2008/05/15 22:39:49 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.101 2008/10/09 16:35:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -616,6 +616,10 @@ typedef struct PLpgSQL_func_hashkey
616616
{/* Hash lookup key for functions */
617617
OidfuncOid;
618618

619+
boolisTrigger;/* true if called as a trigger */
620+
621+
/* be careful that pad bytes in this struct get zeroed! */
622+
619623
/*
620624
* For a trigger function, the OID of the relation triggered on is part of
621625
* the hashkey --- we want to compile the trigger separately for each

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp