1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Remember the source GucContext for each GUC parameter.

We used to just remember the GucSource, but saving GucContext too provides
a little more information --- notably, whether a SET was done by a
superuser or regular user.  This allows us to rip out the fairly dodgy code
that define_custom_variable used to use to try to infer the context to
re-install a pre-existing setting with.  In particular, it now works for
a superuser to SET a extension's SUSET custom variable before loading the
associated extension, because GUC can remember whether the SET was done as
a superuser or not.  The plperl regression tests contain an example where
this is useful.
This commit is contained in:
Tom Lane
2011-10-04 16:13:16 -04:00
parent 09e196e453
commit 9f5836d224
9 changed files with 73 additions and 81 deletions

View File

@@ -296,11 +296,7 @@ ProcessConfigFile(GucContext context)
GUC_ACTION_SET, true);
if (scres > 0)
{
/* variable was updated, so remember the source location */
set_config_sourcefile(item->name, item->filename,
item->sourceline);
/* and log the change if appropriate */
/* variable was updated, so log the change if appropriate */
if (pre_value)
{
const char *post_value = GetConfigOption(item->name, true, false);
@@ -315,7 +311,17 @@ ProcessConfigFile(GucContext context)
}
else if (scres == 0)
error = true;
/* else no error but variable was not changed, do nothing */
/* else no error but variable's active value was not changed */
/*
* We should update source location unless there was an error, since
* even if the active value didn't change, the reset value might have.
* (In the postmaster, there won't be a difference, but it does matter
* in backends.)
*/
if (scres != 0)
set_config_sourcefile(item->name, item->filename,
item->sourceline);
if (pre_value)
pfree(pre_value);