diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/misc/guc-file.l | 6 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 16 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index 78907b939de..3e9b10328d4 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -306,9 +306,9 @@ ProcessConfigFile(GucContext context) /* In SIGHUP cases in the postmaster, report changes */ if (context == PGC_SIGHUP && !IsUnderPostmaster) { - const char *preval = GetConfigOption(item->name, false); + const char *preval = GetConfigOption(item->name, true, false); - /* string variables could be NULL; treat that as empty */ + /* If option doesn't exist yet or is NULL, treat as empty string */ if (!preval) preval = ""; /* must dup, else might have dangling pointer below */ @@ -323,7 +323,7 @@ ProcessConfigFile(GucContext context) if (pre_value) { - const char *post_value = GetConfigOption(item->name, false); + const char *post_value = GetConfigOption(item->name, true, false); if (!post_value) post_value = ""; 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()) |