aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/error/elog.c29
-rw-r--r--src/backend/utils/misc/guc-file.l1
-rw-r--r--src/backend/utils/misc/guc.c21
-rw-r--r--src/backend/utils/misc/postgresql.conf.sample4
4 files changed, 28 insertions, 27 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 6e8e5aef4e0..f0b3b1feb06 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1805,24 +1805,20 @@ setup_formatted_log_time(void)
{
struct timeval tv;
pg_time_t stamp_time;
- pg_tz *tz;
char msbuf[8];
gettimeofday(&tv, NULL);
stamp_time = (pg_time_t) tv.tv_sec;
/*
- * Normally we print log timestamps in log_timezone, but during startup we
- * could get here before that's set. If so, fall back to gmt_timezone
- * (which guc.c ensures is set up before Log_line_prefix can become
- * nonempty).
+ * Note: we expect that guc.c will ensure that log_timezone is set up
+ * (at least with a minimal GMT value) before Log_line_prefix can become
+ * nonempty or CSV mode can be selected.
*/
- tz = log_timezone ? log_timezone : gmt_timezone;
-
pg_strftime(formatted_log_time, FORMATTED_TS_LEN,
/* leave room for milliseconds... */
"%Y-%m-%d %H:%M:%S %Z",
- pg_localtime(&stamp_time, tz));
+ pg_localtime(&stamp_time, log_timezone));
/* 'paste' milliseconds into place... */
sprintf(msbuf, ".%03d", (int) (tv.tv_usec / 1000));
@@ -1836,19 +1832,15 @@ static void
setup_formatted_start_time(void)
{
pg_time_t stamp_time = (pg_time_t) MyStartTime;
- pg_tz *tz;
/*
- * Normally we print log timestamps in log_timezone, but during startup we
- * could get here before that's set. If so, fall back to gmt_timezone
- * (which guc.c ensures is set up before Log_line_prefix can become
- * nonempty).
+ * Note: we expect that guc.c will ensure that log_timezone is set up
+ * (at least with a minimal GMT value) before Log_line_prefix can become
+ * nonempty or CSV mode can be selected.
*/
- tz = log_timezone ? log_timezone : gmt_timezone;
-
pg_strftime(formatted_start_time, FORMATTED_TS_LEN,
"%Y-%m-%d %H:%M:%S %Z",
- pg_localtime(&stamp_time, tz));
+ pg_localtime(&stamp_time, log_timezone));
}
/*
@@ -1947,14 +1939,11 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
case 't':
{
pg_time_t stamp_time = (pg_time_t) time(NULL);
- pg_tz *tz;
char strfbuf[128];
- tz = log_timezone ? log_timezone : gmt_timezone;
-
pg_strftime(strfbuf, sizeof(strfbuf),
"%Y-%m-%d %H:%M:%S %Z",
- pg_localtime(&stamp_time, tz));
+ pg_localtime(&stamp_time, log_timezone));
appendStringInfoString(buf, strfbuf);
}
break;
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index 70abf40a28e..809307da8d3 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -292,7 +292,6 @@ ProcessConfigFile(GucContext context)
if (context == PGC_SIGHUP)
{
InitializeGUCOptionsFromEnvironment();
- pg_timezone_initialize();
pg_timezone_abbrev_initialize();
/* this selects SQL_ASCII in processes not connected to a database */
SetConfigOption("client_encoding", GetDatabaseEncodingName(),
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 6670997acde..a71729c2e70 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -187,6 +187,7 @@ static bool check_log_stats(bool *newval, void **extra, GucSource source);
static bool check_canonical_path(char **newval, void **extra, GucSource source);
static bool check_timezone_abbreviations(char **newval, void **extra, GucSource source);
static void assign_timezone_abbreviations(const char *newval, void *extra);
+static void pg_timezone_abbrev_initialize(void);
static const char *show_archive_command(void);
static void assign_tcp_keepalives_idle(int newval, void *extra);
static void assign_tcp_keepalives_interval(int newval, void *extra);
@@ -2547,7 +2548,7 @@ static struct config_string ConfigureNamesString[] =
NULL
},
&log_timezone_string,
- NULL,
+ "GMT",
check_log_timezone, assign_log_timezone, show_log_timezone
},
@@ -2827,7 +2828,7 @@ static struct config_string ConfigureNamesString[] =
GUC_REPORT
},
&timezone_string,
- NULL,
+ "GMT",
check_timezone, assign_timezone, show_timezone
},
{
@@ -3817,7 +3818,7 @@ InitializeGUCOptions(void)
* Before log_line_prefix could possibly receive a nonempty setting, make
* sure that timezone processing is minimally alive (see elog.c).
*/
- pg_timezone_pre_initialize();
+ pg_timezone_initialize();
/*
* Build sorted array of all GUC variables.
@@ -4115,6 +4116,15 @@ SelectConfigFiles(const char *userDoption, const char *progname)
SetConfigOption("data_directory", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);
/*
+ * If timezone_abbreviations wasn't set in the configuration file, install
+ * the default value. We do it this way because we can't safely install
+ * a "real" value until my_exec_path is set, which may not have happened
+ * when InitializeGUCOptions runs, so the bootstrap default value cannot
+ * be the real desired default.
+ */
+ pg_timezone_abbrev_initialize();
+
+ /*
* Figure out where pg_hba.conf is, and make sure the path is absolute.
*/
if (HbaFileName)
@@ -8444,8 +8454,11 @@ assign_timezone_abbreviations(const char *newval, void *extra)
* This is called after initial loading of postgresql.conf. If no
* timezone_abbreviations setting was found therein, select default.
* If a non-default value is already installed, nothing will happen.
+ *
+ * This can also be called from ProcessConfigFile to establish the default
+ * value after a postgresql.conf entry for it is removed.
*/
-void
+static void
pg_timezone_abbrev_initialize(void)
{
SetConfigOption("timezone_abbreviations", "Default",
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e713defea2c..a18f14ae253 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -406,7 +406,7 @@
#log_temp_files = -1 # log temporary files equal or larger
# than the specified size in kilobytes;
# -1 disables, 0 logs all temp files
-#log_timezone = '(defaults to server environment setting)'
+#log_timezone = 'GMT'
#------------------------------------------------------------------------------
@@ -486,7 +486,7 @@
#datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
-#timezone = '(defaults to server environment setting)'
+#timezone = 'GMT'
#timezone_abbreviations = 'Default' # Select the set of available time zone
# abbreviations. Currently, there are
# Default