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

Commita4b0d95

Browse files
committed
Fix ALTER SYSTEM to cope with duplicate entries in postgresql.auto.conf.
ALTER SYSTEM itself normally won't make duplicate entries (althoughup till this patch, it was possible to confuse it by writing casevariants of a GUC's name). However, if some external tool has appendedentries to the file, that could result in duplicate entries for a singleGUC name. In such a situation, ALTER SYSTEM did exactly the wrong thing,because it replaced or removed only the first matching entry, leavingthe later one(s) still there and hence still determining the active value.This patch fixes that by making ALTER SYSTEM sweep through the file andremove all matching entries, then (if not ALTER SYSTEM RESET) append thenew setting to the end. This means entries will be in order of lastsetting rather than first setting, but that shouldn't hurt anything.Also, make the comparisons case-insensitive so that the right thingshappen if you do, say, ALTER SYSTEM SET "TimeZone" = 'whatever'.This has been broken since ALTER SYSTEM was invented, so back-patchto all supported branches.Ian Barwick, with minor mods by meDiscussion:https://postgr.es/m/aed6cc9f-98f3-2693-ac81-52bb0052307e@2ndquadrant.com
1 parent63ae888 commita4b0d95

File tree

1 file changed

+22
-25
lines changed
  • src/backend/utils/misc

1 file changed

+22
-25
lines changed

‎src/backend/utils/misc/guc.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6614,40 +6614,37 @@ replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
66146614
constchar*name,constchar*value)
66156615
{
66166616
ConfigVariable*item,
6617+
*next,
66176618
*prev=NULL;
66186619

6619-
/* Search the list for an existing match (we assume there's only one) */
6620-
for (item=*head_p;item!=NULL;item=item->next)
6620+
/*
6621+
* Remove any existing match(es) for "name". Normally there'd be at most
6622+
* one, but if external tools have modified the config file, there could
6623+
* be more.
6624+
*/
6625+
for (item=*head_p;item!=NULL;item=next)
66216626
{
6622-
if (strcmp(item->name,name)==0)
6627+
next=item->next;
6628+
if (guc_name_compare(item->name,name)==0)
66236629
{
6624-
/* found a match, replace it */
6625-
pfree(item->value);
6626-
if (value!=NULL)
6627-
{
6628-
/* update the parameter value */
6629-
item->value=pstrdup(value);
6630-
}
6630+
/* found a match, delete it */
6631+
if (prev)
6632+
prev->next=next;
66316633
else
6632-
{
6633-
/* delete the configuration parameter from list */
6634-
if (*head_p==item)
6635-
*head_p=item->next;
6636-
else
6637-
prev->next=item->next;
6638-
if (*tail_p==item)
6639-
*tail_p=prev;
6634+
*head_p=next;
6635+
if (next==NULL)
6636+
*tail_p=prev;
66406637

6641-
pfree(item->name);
6642-
pfree(item->filename);
6643-
pfree(item);
6644-
}
6645-
return;
6638+
pfree(item->name);
6639+
pfree(item->value);
6640+
pfree(item->filename);
6641+
pfree(item);
66466642
}
6647-
prev=item;
6643+
else
6644+
prev=item;
66486645
}
66496646

6650-
/*Not there; no work if we're trying to delete it */
6647+
/*Done if we're trying to delete it */
66516648
if (value==NULL)
66526649
return;
66536650

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp