Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0894c6b

Browse files
committed
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.
1 parent 8539a0e commit 0894c6b

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/backend/utils/misc/guc-file.l

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.62 2009/10/03 18:04:57 tgl Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.63 2009/11/12 18:20:23 tgl Exp $
88
*/
99

1010
%{
@@ -316,18 +316,33 @@ ProcessConfigFile(GucContext context)
316316

317317
/* In SIGHUP cases in the postmaster, report changes */
318318
if (context == PGC_SIGHUP && !IsUnderPostmaster)
319-
pre_value = pstrdup(GetConfigOption(item->name, false));
319+
{
320+
const char *preval = GetConfigOption(item->name, false);
321+
322+
/* string variables could be NULL; treat that as empty */
323+
if (!preval)
324+
preval = "";
325+
/* must dup, else might have dangling pointer below */
326+
pre_value = pstrdup(preval);
327+
}
320328

321329
if (set_config_option(item->name, item->value, context,
322330
PGC_S_FILE, GUC_ACTION_SET, true))
323331
{
324332
set_config_sourcefile(item->name, item->filename,
325333
item->sourceline);
326-
if (pre_value &&
327-
strcmp(pre_value, GetConfigOption(item->name, false)) != 0)
328-
ereport(elevel,
329-
(errmsg("parameter \"%s\" changed to \"%s\"",
330-
item->name, item->value)));
334+
335+
if (pre_value)
336+
{
337+
const char *post_value = GetConfigOption(item->name, false);
338+
339+
if (!post_value)
340+
post_value = "";
341+
if (strcmp(pre_value, post_value) != 0)
342+
ereport(elevel,
343+
(errmsg("parameter \"%s\" changed to \"%s\"",
344+
item->name, item->value)));
345+
}
331346
}
332347

333348
if (pre_value)

0 commit comments

Comments
 (0)