diff options
author | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2010-05-11 04:52:28 +0000 |
---|---|---|
committer | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2010-05-11 04:52:28 +0000 |
commit | 5d6d037822ccfae697f0a530e37a70ae1cd7e420 (patch) | |
tree | 30e7e61e7faa379eaa2133bc866e9a8a0b265f30 | |
parent | ed83f6e38209016ae75832ae8997f190ea4a0c8e (diff) | |
download | postgresql-5d6d037822ccfae697f0a530e37a70ae1cd7e420.tar.gz postgresql-5d6d037822ccfae697f0a530e37a70ae1cd7e420.zip |
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.
-rw-r--r-- | src/backend/catalog/pg_proc.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 64b88727063..05eb868aba1 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.174 2010/04/05 01:09:52 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.175 2010/05/11 04:52:28 itagaki Exp $ * *------------------------------------------------------------------------- */ @@ -621,9 +621,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; |