Skip to content

Commit 5d6d037

Browse files
committed
Set per-function GUC settings during validating the function.
Now validators work properly even when the settings contain parameters that affect behavior of the function, like search_path. Reported by Erwin Brandstetter.
1 parent ed83f6e commit 5d6d037

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/backend/catalog/pg_proc.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.174 2010/04/05 01:09:52 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.175 2010/05/11 04:52:28 itagaki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -621,9 +621,29 @@ ProcedureCreate(const char *procedureName,
621621
/* Verify function body */
622622
if (OidIsValid(languageValidator))
623623
{
624+
ArrayType *set_items;
625+
int save_nestlevel;
626+
624627
/* Advance command counter so new tuple can be seen by validator */
625628
CommandCounterIncrement();
629+
630+
/* Set per-function configuration parameters */
631+
set_items = (ArrayType *) DatumGetPointer(proconfig);
632+
if (set_items) /* Need a new GUC nesting level */
633+
{
634+
save_nestlevel = NewGUCNestLevel();
635+
ProcessGUCArray(set_items,
636+
(superuser() ? PGC_SUSET : PGC_USERSET),
637+
PGC_S_SESSION,
638+
GUC_ACTION_SAVE);
639+
}
640+
else
641+
save_nestlevel = 0; /* keep compiler quiet */
642+
626643
OidFunctionCall1(languageValidator, ObjectIdGetDatum(retval));
644+
645+
if (set_items)
646+
AtEOXact_GUC(true, save_nestlevel);
627647
}
628648

629649
return retval;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy