Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite3da0d4

Browse files
committed
Change ParseConfigFp() so that it doesn't process unused entry of each parameter.
When more than one setting entries of same parameter exist in theconfiguration file, PostgreSQL uses only entry appearing last inconfiguration file scan. Since the other entries are not used,ParseConfigFp() doesn't need to process them, but previously it didthat. This problematic behavior caused the configuration file scanto detect invalid settings of unused entries (e.g., existence ofmultiple entries of PGC_POSTMASTER parameter) and log the messagescomplaining about them.This commit changes the configuration file scan so that it processesonly last entry of each parameter.Note that when multiple entries of same parameter exist both inpostgresql.conf and postgresql.auto.conf, unused entries inpostgresql.conf are still processed only at postmaster startup.The problem has existed since old version, but a user is more likelyto encounter it since 9.4 where ALTER SYSTEM command was introduced.So back-patch to 9.4.Amit Kapila, slightly modified by me. Per report from Christoph Berg.
1 parent49d1e03 commite3da0d4

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
562562
{
563563
char *opt_name =NULL;
564564
char *opt_value =NULL;
565-
ConfigVariable *item;
565+
ConfigVariable *item,
566+
*cur_item =NULL,
567+
*prev_item =NULL;
566568

567569
if (token == GUC_EOL)/* empty or comment line */
568570
continue;
@@ -645,13 +647,41 @@ ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel,
645647
}
646648
else
647649
{
648-
/* ordinary variable, append to list */
650+
/*
651+
* ordinary variable, append to list. For multiple items of
652+
* same parameter, retain only which comes later.
653+
*/
649654
item =palloc(sizeof *item);
650655
item->name = opt_name;
651656
item->value = opt_value;
652657
item->filename =pstrdup(config_file);
653658
item->sourceline = ConfigFileLineno-1;
654659
item->next =NULL;
660+
661+
/* Remove the existing item of same parameter from the list */
662+
for (cur_item = *head_p; cur_item; prev_item = cur_item,
663+
cur_item = cur_item->next)
664+
{
665+
if (strcmp(item->name, cur_item->name) ==0)
666+
{
667+
if (prev_item ==NULL)
668+
*head_p = cur_item->next;
669+
else
670+
{
671+
prev_item->next = cur_item->next;
672+
/*
673+
* On removing last item in list, we need to update tail
674+
* to ensure that list will be maintianed.
675+
*/
676+
if (prev_item->next ==NULL)
677+
*tail_p = prev_item;
678+
}
679+
680+
pfree(cur_item);
681+
break;
682+
}
683+
}
684+
655685
if (*head_p ==NULL)
656686
*head_p = item;
657687
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp