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

Commit32d38f5

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 parent4dea8ad commit32d38f5

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
@@ -7281,40 +7281,37 @@ replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p,
72817281
constchar*name,constchar*value)
72827282
{
72837283
ConfigVariable*item,
7284+
*next,
72847285
*prev=NULL;
72857286

7286-
/* Search the list for an existing match (we assume there's only one) */
7287-
for (item=*head_p;item!=NULL;item=item->next)
7287+
/*
7288+
* Remove any existing match(es) for "name". Normally there'd be at most
7289+
* one, but if external tools have modified the config file, there could
7290+
* be more.
7291+
*/
7292+
for (item=*head_p;item!=NULL;item=next)
72887293
{
7289-
if (strcmp(item->name,name)==0)
7294+
next=item->next;
7295+
if (guc_name_compare(item->name,name)==0)
72907296
{
7291-
/* found a match, replace it */
7292-
pfree(item->value);
7293-
if (value!=NULL)
7294-
{
7295-
/* update the parameter value */
7296-
item->value=pstrdup(value);
7297-
}
7297+
/* found a match, delete it */
7298+
if (prev)
7299+
prev->next=next;
72987300
else
7299-
{
7300-
/* delete the configuration parameter from list */
7301-
if (*head_p==item)
7302-
*head_p=item->next;
7303-
else
7304-
prev->next=item->next;
7305-
if (*tail_p==item)
7306-
*tail_p=prev;
7301+
*head_p=next;
7302+
if (next==NULL)
7303+
*tail_p=prev;
73077304

7308-
pfree(item->name);
7309-
pfree(item->filename);
7310-
pfree(item);
7311-
}
7312-
return;
7305+
pfree(item->name);
7306+
pfree(item->value);
7307+
pfree(item->filename);
7308+
pfree(item);
73137309
}
7314-
prev=item;
7310+
else
7311+
prev=item;
73157312
}
73167313

7317-
/*Not there; no work if we're trying to delete it */
7314+
/*Done if we're trying to delete it */
73187315
if (value==NULL)
73197316
return;
73207317

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp