diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-08 17:02:58 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-07-08 17:02:58 -0400 |
commit | 9d522cb35d8b4f266abadd0d019f68eb8802ae05 (patch) | |
tree | 684addb86e6997476745eaf00738875f6ac94a59 /src/backend/utils/misc/guc.c | |
parent | 89fd72cbf26f5d2e3d86ab19c1ead73ab8fac0fe (diff) | |
download | postgresql-9d522cb35d8b4f266abadd0d019f68eb8802ae05.tar.gz postgresql-9d522cb35d8b4f266abadd0d019f68eb8802ae05.zip |
Fix another oversight in logging of changes in postgresql.conf settings.
We were using GetConfigOption to collect the old value of each setting,
overlooking the possibility that it didn't exist yet. This does happen
in the case of adding a new entry within a custom variable class, as
exhibited in bug #6097 from Maxim Boguk.
To fix, add a missing_ok parameter to GetConfigOption, but only in 9.1
and HEAD --- it seems possible that some third-party code is using that
function, so changing its API in a minor release would cause problems.
In 9.0, create a near-duplicate function instead.
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r-- | src/backend/utils/misc/guc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 5a0e94f8014..5841631e8c3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5828,8 +5828,11 @@ SetConfigOption(const char *name, const char *value, /* - * Fetch the current value of the option `name'. If the option doesn't exist, - * throw an ereport and don't return. + * Fetch the current value of the option `name', as a string. + * + * If the option doesn't exist, return NULL if missing_ok is true (NOTE that + * this cannot be distinguished from a string variable with a NULL value!), + * otherwise throw an ereport and don't return. * * If restrict_superuser is true, we also enforce that only superusers can * see GUC_SUPERUSER_ONLY variables. This should only be passed as true @@ -5839,16 +5842,21 @@ SetConfigOption(const char *name, const char *value, * valid until the next call to configuration related functions. */ const char * -GetConfigOption(const char *name, bool restrict_superuser) +GetConfigOption(const char *name, bool missing_ok, bool restrict_superuser) { struct config_generic *record; static char buffer[256]; record = find_option(name, false, ERROR); if (record == NULL) + { + if (missing_ok) + return NULL; ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("unrecognized configuration parameter \"%s\"", name))); + errmsg("unrecognized configuration parameter \"%s\"", + name))); + } if (restrict_superuser && (record->flags & GUC_SUPERUSER_ONLY) && !superuser()) |