mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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.
This commit is contained in:
@ -5391,6 +5391,46 @@ GetConfigOption(const char *name, bool restrict_superuser)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* As above, but return NULL if no such option.
|
||||
* (This is a stopgap to avoid changing GetConfigOption's API within the
|
||||
* 9.0.x release series.)
|
||||
*/
|
||||
const char *
|
||||
GetConfigOptionNoError(const char *name)
|
||||
{
|
||||
struct config_generic *record;
|
||||
static char buffer[256];
|
||||
|
||||
record = find_option(name, false, ERROR);
|
||||
if (record == NULL)
|
||||
return NULL;
|
||||
|
||||
switch (record->vartype)
|
||||
{
|
||||
case PGC_BOOL:
|
||||
return *((struct config_bool *) record)->variable ? "on" : "off";
|
||||
|
||||
case PGC_INT:
|
||||
snprintf(buffer, sizeof(buffer), "%d",
|
||||
*((struct config_int *) record)->variable);
|
||||
return buffer;
|
||||
|
||||
case PGC_REAL:
|
||||
snprintf(buffer, sizeof(buffer), "%g",
|
||||
*((struct config_real *) record)->variable);
|
||||
return buffer;
|
||||
|
||||
case PGC_STRING:
|
||||
return *((struct config_string *) record)->variable;
|
||||
|
||||
case PGC_ENUM:
|
||||
return config_enum_lookup_by_value((struct config_enum *) record,
|
||||
*((struct config_enum *) record)->variable);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the RESET value associated with the given option.
|
||||
*
|
||||
|
Reference in New Issue
Block a user