aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-11-12 18:20:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-11-12 18:20:23 +0000
commit0894c6b83862f1d091e3c37713e6e5db355248ef (patch)
tree060d583c830a489dc246762b2ae4276755c0c3b8 /src/backend
parent8539a0e00a39872a58dc004e3c131bfb7be23609 (diff)
downloadpostgresql-0894c6b83862f1d091e3c37713e6e5db355248ef.tar.gz
postgresql-0894c6b83862f1d091e3c37713e6e5db355248ef.zip
The recent patch to log changes in postgresql.conf settings dumped core
if the initial value of a string variable was NULL, which is entirely possible. Noted while experimenting with custom_variable_classes.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/misc/guc-file.l29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index 424caea13f5..208e54f10c1 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -4,7 +4,7 @@
*
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.62 2009/10/03 18:04:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.63 2009/11/12 18:20:23 tgl Exp $
*/
%{
@@ -316,18 +316,33 @@ ProcessConfigFile(GucContext context)
/* In SIGHUP cases in the postmaster, report changes */
if (context == PGC_SIGHUP && !IsUnderPostmaster)
- pre_value = pstrdup(GetConfigOption(item->name, false));
+ {
+ const char *preval = GetConfigOption(item->name, false);
+
+ /* string variables could be NULL; treat that as empty */
+ if (!preval)
+ preval = "";
+ /* must dup, else might have dangling pointer below */
+ pre_value = pstrdup(preval);
+ }
if (set_config_option(item->name, item->value, context,
PGC_S_FILE, GUC_ACTION_SET, true))
{
set_config_sourcefile(item->name, item->filename,
item->sourceline);
- if (pre_value &&
- strcmp(pre_value, GetConfigOption(item->name, false)) != 0)
- ereport(elevel,
- (errmsg("parameter \"%s\" changed to \"%s\"",
- item->name, item->value)));
+
+ if (pre_value)
+ {
+ const char *post_value = GetConfigOption(item->name, false);
+
+ if (!post_value)
+ post_value = "";
+ if (strcmp(pre_value, post_value) != 0)
+ ereport(elevel,
+ (errmsg("parameter \"%s\" changed to \"%s\"",
+ item->name, item->value)));
+ }
}
if (pre_value)