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

Commit5f21560

Browse files
committed
Dept. of second thoughts: interaction between DoIt and makeDepend
in set_config_option wasn't quite right. Also clean up a couple otherthings that could have been done better.
1 parent94bdc48 commit5f21560

File tree

1 file changed

+42
-48
lines changed
  • src/backend/utils/misc

1 file changed

+42
-48
lines changed

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

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.68 2002/05/1701:19:18 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.69 2002/05/1720:32:29 tgl Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -936,43 +936,33 @@ guc_var_compare(const void *a, const void *b)
936936
{
937937
structconfig_generic*confa=*(structconfig_generic**)a;
938938
structconfig_generic*confb=*(structconfig_generic**)b;
939-
charnamea[NAMEDATALEN];
940-
charnameb[NAMEDATALEN];
941-
intlen,
942-
i;
939+
constchar*namea;
940+
constchar*nameb;
943941

944942
/*
945943
* The temptation to use strcasecmp() here must be resisted, because
946944
* the array ordering has to remain stable across setlocale() calls.
947-
* So,apply an ASCII-only downcasing to both names and use strcmp().
945+
* So,build our own with a simple ASCII-only downcasing.
948946
*/
949-
len=strlen(confa->name);
950-
if (len >=NAMEDATALEN)
951-
len=NAMEDATALEN-1;
952-
for (i=0;i<len;i++)
953-
{
954-
charch=confa->name[i];
955-
956-
if (ch >='A'&&ch <='Z')
957-
ch+='a'-'A';
958-
namea[i]=ch;
959-
}
960-
namea[len]='\0';
961-
962-
len=strlen(confb->name);
963-
if (len >=NAMEDATALEN)
964-
len=NAMEDATALEN-1;
965-
for (i=0;i<len;i++)
966-
{
967-
charch=confb->name[i];
968-
969-
if (ch >='A'&&ch <='Z')
970-
ch+='a'-'A';
971-
nameb[i]=ch;
947+
namea=confa->name;
948+
nameb=confb->name;
949+
while (*namea&&*nameb)
950+
{
951+
charcha=*namea++;
952+
charchb=*nameb++;
953+
954+
if (cha >='A'&&cha <='Z')
955+
cha+='a'-'A';
956+
if (chb >='A'&&chb <='Z')
957+
chb+='a'-'A';
958+
if (cha!=chb)
959+
returncha-chb;
972960
}
973-
nameb[len]='\0';
974-
975-
returnstrcmp(namea,nameb);
961+
if (*namea)
962+
return1;/* a is longer */
963+
if (*nameb)
964+
return-1;/* b is longer */
965+
return0;
976966
}
977967

978968

@@ -1212,17 +1202,8 @@ ResetAllOptions(void)
12121202
break;
12131203
}
12141204

1215-
str=strdup(conf->reset_val);
1216-
if (str==NULL)
1217-
elog(ERROR,"out of memory");
1218-
1219-
/*
1220-
* Remember string in workspace, so that we can free it
1221-
* and avoid a permanent memory leak if hook elogs.
1222-
*/
1223-
if (guc_string_workspace)
1224-
free(guc_string_workspace);
1225-
guc_string_workspace=str;
1205+
/* We need not strdup here */
1206+
str=conf->reset_val;
12261207

12271208
if (conf->assign_hook)
12281209
{
@@ -1233,14 +1214,11 @@ ResetAllOptions(void)
12331214
elog(ERROR,"Failed to reset %s",conf->gen.name);
12341215
elseif (newstr!=str)
12351216
{
1236-
free(str);
12371217
/* See notes in set_config_option about casting */
12381218
str= (char*)newstr;
12391219
}
12401220
}
12411221

1242-
guc_string_workspace=NULL;
1243-
12441222
SET_STRING_VARIABLE(conf,str);
12451223
SET_STRING_TENTATIVE_VAL(conf,str);
12461224
conf->gen.source=conf->gen.reset_source;
@@ -1619,8 +1597,13 @@ set_config_option(const char *name, const char *value,
16191597
break;
16201598
}
16211599

1600+
/* Should we report errors interactively? */
16221601
interactive= (source >=PGC_S_SESSION);
1623-
makeDefault= (source <=PGC_S_OVERRIDE)&& (value!=NULL);
1602+
/*
1603+
* Should we set reset/session values? (If so, the behavior is not
1604+
* transactional.)
1605+
*/
1606+
makeDefault=DoIt&& (source <=PGC_S_OVERRIDE)&& (value!=NULL);
16241607

16251608
/*
16261609
* Ignore attempted set if overridden by previously processed setting.
@@ -1633,7 +1616,7 @@ set_config_option(const char *name, const char *value,
16331616
{
16341617
if (DoIt&& !makeDefault)
16351618
{
1636-
elog(DEBUG2,"setting %signored because previous source is higher",
1619+
elog(DEBUG2,"%s: settingignored because previous source is higher priority",
16371620
name);
16381621
return true;
16391622
}
@@ -1867,6 +1850,11 @@ set_config_option(const char *name, const char *value,
18671850
}
18681851
elseif (conf->reset_val)
18691852
{
1853+
/*
1854+
* We could possibly avoid strdup here, but easier to
1855+
* make this case work the same as the normal assignment
1856+
* case.
1857+
*/
18701858
newval=strdup(conf->reset_val);
18711859
if (newval==NULL)
18721860
{
@@ -2429,10 +2417,12 @@ ProcessGUCArray(ArrayType *array, GucSource source)
24292417
continue;
24302418

24312419
s=DatumGetCString(DirectFunctionCall1(textout,d));
2420+
24322421
ParseLongOption(s,&name,&value);
24332422
if (!value)
24342423
{
24352424
elog(WARNING,"cannot parse setting \"%s\"",name);
2425+
free(name);
24362426
continue;
24372427
}
24382428

@@ -2442,6 +2432,10 @@ ProcessGUCArray(ArrayType *array, GucSource source)
24422432
* checked when it was inserted.
24432433
*/
24442434
SetConfigOption(name,value,PGC_SUSET,source);
2435+
2436+
free(name);
2437+
if (value)
2438+
free(value);
24452439
}
24462440
}
24472441

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp