From: Itagaki Takahiro Date: Tue, 11 May 2010 04:56:37 +0000 (+0000) Subject: Set per-function GUC settings during validating the function. X-Git-Tag: REL8_4_4~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=871a6086b1919512824f96c2278ed70de546dfc3;p=postgresql 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. --- diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 18e8b28627..fc0fc3c54a 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.164.2.3 2010/03/19 22:54:49 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.164.2.4 2010/05/11 04:56:37 itagaki Exp $ * *------------------------------------------------------------------------- */ @@ -556,9 +556,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;