mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Revise the API for GUC variable assign hooks.
The previous functions of assign hooks are now split between check hooks and assign hooks, where the former can fail but the latter shouldn't. Aside from being conceptually clearer, this approach exposes the "canonicalized" form of the variable value to guc.c without having to do an actual assignment. And that lets us fix the problem recently noted by Bernd Helmle that the auto-tune patch for wal_buffers resulted in bogus log messages about "parameter "wal_buffers" cannot be changed without restarting the server". There may be some speed advantage too, because this design lets hook functions avoid re-parsing variable values when restoring a previous state after a rollback (they can store a pre-parsed representation of the value instead). This patch also resolves a longstanding annoyance about custom error messages from variable assign hooks: they should modify, not appear separately from, guc.c's own message about "invalid parameter value".
This commit is contained in:
@ -1444,27 +1444,39 @@ pg_timezone_initialize(void)
|
||||
{
|
||||
pg_tz *def_tz = NULL;
|
||||
|
||||
/* Do we need to try to figure the session timezone? */
|
||||
if (pg_strcasecmp(GetConfigOption("timezone", false), "UNKNOWN") == 0)
|
||||
/*
|
||||
* Make sure that session_timezone and log_timezone are set.
|
||||
* (session_timezone could still be NULL even if a timezone value was set
|
||||
* in postgresql.conf, if that setting was interval-based rather than
|
||||
* timezone-based.)
|
||||
*/
|
||||
if (!session_timezone)
|
||||
{
|
||||
/* Select setting */
|
||||
def_tz = select_default_timezone();
|
||||
session_timezone = def_tz;
|
||||
/* Tell GUC about the value. Will redundantly call pg_tzset() */
|
||||
SetConfigOption("timezone", pg_get_timezone_name(def_tz),
|
||||
PGC_POSTMASTER, PGC_S_ARGV);
|
||||
}
|
||||
|
||||
/* What about the log timezone? */
|
||||
if (pg_strcasecmp(GetConfigOption("log_timezone", false), "UNKNOWN") == 0)
|
||||
if (!log_timezone)
|
||||
{
|
||||
/* Select setting, but don't duplicate work */
|
||||
/* Don't duplicate work */
|
||||
if (!def_tz)
|
||||
def_tz = select_default_timezone();
|
||||
log_timezone = def_tz;
|
||||
}
|
||||
|
||||
/* Now, set the timezone GUC if it's not already set */
|
||||
if (GetConfigOption("timezone", false) == NULL)
|
||||
{
|
||||
/* Tell GUC about the value. Will redundantly call pg_tzset() */
|
||||
SetConfigOption("log_timezone", pg_get_timezone_name(def_tz),
|
||||
PGC_POSTMASTER, PGC_S_ARGV);
|
||||
SetConfigOption("timezone", pg_get_timezone_name(session_timezone),
|
||||
PGC_POSTMASTER, PGC_S_ENV_VAR);
|
||||
}
|
||||
|
||||
/* Likewise for log timezone */
|
||||
if (GetConfigOption("log_timezone", false) == NULL)
|
||||
{
|
||||
/* Tell GUC about the value. Will redundantly call pg_tzset() */
|
||||
SetConfigOption("log_timezone", pg_get_timezone_name(log_timezone),
|
||||
PGC_POSTMASTER, PGC_S_ENV_VAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user