mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
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.
This commit is contained in:
parent
db01ccc052
commit
ba7b77133e
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.148.2.1 2009/10/02 18:13:19 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.148.2.2 2010/05/11 04:57:51 itagaki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -412,9 +412,29 @@ ProcedureCreate(const char *procedureName,
|
||||
/* Verify function body */
|
||||
if (OidIsValid(languageValidator))
|
||||
{
|
||||
ArrayType *set_items;
|
||||
int save_nestlevel;
|
||||
|
||||
/* Advance command counter so new tuple can be seen by validator */
|
||||
CommandCounterIncrement();
|
||||
|
||||
/* Set per-function configuration parameters */
|
||||
set_items = (ArrayType *) DatumGetPointer(proconfig);
|
||||
if (set_items) /* Need a new GUC nesting level */
|
||||
{
|
||||
save_nestlevel = NewGUCNestLevel();
|
||||
ProcessGUCArray(set_items,
|
||||
(superuser() ? PGC_SUSET : PGC_USERSET),
|
||||
PGC_S_SESSION,
|
||||
GUC_ACTION_SAVE);
|
||||
}
|
||||
else
|
||||
save_nestlevel = 0; /* keep compiler quiet */
|
||||
|
||||
OidFunctionCall1(languageValidator, ObjectIdGetDatum(retval));
|
||||
|
||||
if (set_items)
|
||||
AtEOXact_GUC(true, save_nestlevel);
|
||||
}
|
||||
|
||||
return retval;
|
||||
|
Loading…
Reference in New Issue
Block a user