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

Commitfce2ce7

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 parenta0b808b commitfce2ce7

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
@@ -484,6 +484,7 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value,
484484
for (i=0;lines[i];i++)
485485
{
486486
constchar*where;
487+
constchar*namestart;
487488

488489
/*
489490
* Look for a line assigning to guc_name. Typically it will be
@@ -494,15 +495,19 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value,
494495
where=lines[i];
495496
while (*where=='#'||isspace((unsignedchar)*where))
496497
where++;
497-
if (strncmp(where,guc_name,namelen)!=0)
498+
if (pg_strncasecmp(where,guc_name,namelen)!=0)
498499
continue;
500+
namestart=where;
499501
where+=namelen;
500502
while (isspace((unsignedchar)*where))
501503
where++;
502504
if (*where!='=')
503505
continue;
504506

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

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

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

202+
# Make sure multiple invocations of -c parameters are added case insensitive
203+
command_ok(
204+
[
205+
'initdb','-cwork_mem=128',
206+
'-cWork_Mem=256','-cWORK_MEM=512',
207+
"$tempdir/dataY"
208+
],
209+
'multiple -c options with different case');
210+
211+
my$conf = slurp_file("$tempdir/dataY/postgresql.conf");
212+
ok($conf !~qr/^WORK_MEM =/m,"WORK_MEM should not be configured");
213+
ok($conf !~qr/^Work_Mem =/m,"Work_Mem should not be configured");
214+
ok($conf =~qr/^work_mem = 512/m,"work_mem should be in config");
215+
202216
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp