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

Commitb78f4d2

Browse files
committed
Fix initdb's -c option to treat the GUC name case-insensitively.
The backend treats GUC names case-insensitively, so this code shouldtoo. This avoids ending up with a confusing set of redundant entriesin the generated postgresql.conf file.Per report from Kyotaro Horiguchi. Back-patch to v16 where thisfeature was added (in commit3e51b27).Discussion:https://postgr.es/m/20230928.164904.2153358973162534034.horikyota.ntt@gmail.com
1 parent896bd6d commitb78f4d2

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value,
482482
for (i=0;lines[i];i++)
483483
{
484484
constchar*where;
485+
constchar*namestart;
485486

486487
/*
487488
* Look for a line assigning to guc_name. Typically it will be
@@ -492,15 +493,19 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value,
492493
where=lines[i];
493494
while (*where=='#'||isspace((unsignedchar)*where))
494495
where++;
495-
if (strncmp(where,guc_name,namelen)!=0)
496+
if (pg_strncasecmp(where,guc_name,namelen)!=0)
496497
continue;
498+
namestart=where;
497499
where+=namelen;
498500
while (isspace((unsignedchar)*where))
499501
where++;
500502
if (*where!='=')
501503
continue;
502504

503-
/* found it -- append the original comment if any */
505+
/* found it -- let's use the canonical casing shown in the file */
506+
memcpy(&newline->data[mark_as_comment ?1 :0],namestart,namelen);
507+
508+
/* now append the original comment if any */
504509
where=strrchr(where,'#');
505510
if (where)
506511
{

‎src/bin/initdb/t/001_initdb.pl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,18 @@
187187
command_fails(['initdb','--no-sync','--set','foo=bar',"$tempdir/dataX" ],
188188
'fails for invalid --set option');
189189

190+
# Make sure multiple invocations of -c parameters are added case insensitive
191+
command_ok(
192+
[
193+
'initdb','-cwork_mem=128',
194+
'-cWork_Mem=256','-cWORK_MEM=512',
195+
"$tempdir/dataY"
196+
],
197+
'multiple -c options with different case');
198+
199+
my$conf = slurp_file("$tempdir/dataY/postgresql.conf");
200+
ok($conf !~qr/^WORK_MEM =/m,"WORK_MEM should not be configured");
201+
ok($conf !~qr/^Work_Mem =/m,"Work_Mem should not be configured");
202+
ok($conf =~qr/^work_mem = 512/m,"work_mem should be in config");
203+
190204
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp