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

Commit276b788

Browse files
committed
createdb: compare strategy case-insensitive
When specifying the createdb strategy, the documentation suggests validoptions are FILE_COPY and WAL_LOG, but the code does case-sensitivecomparison and accepts only "file_copy" and "wal_log" as valid.Fixed by doing a case-insensitive comparison using pg_strcasecmp(), sameas for other string parameters nearby.While at it, apply fmtId() to a nearby "locale_provider". This alreadydid the comparison in case-insensitive way, but the value would not bedouble-quoted, confusing the parser and the error message.Backpatch to 15, where the strategy was introduced.Backpatch-through: 15Reviewed-by: Tom LaneDiscussion:https://postgr.es/m/90c6913a-1dd2-42b4-8365-ce3b09c39b17@enterprisedb.com
1 parent6c85e33 commit276b788

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,15 +994,15 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
994994
char*strategy;
995995

996996
strategy=defGetString(dstrategy);
997-
if (strcmp(strategy,"wal_log")==0)
997+
if (pg_strcasecmp(strategy,"wal_log")==0)
998998
dbstrategy=CREATEDB_WAL_LOG;
999-
elseif (strcmp(strategy,"file_copy")==0)
999+
elseif (pg_strcasecmp(strategy,"file_copy")==0)
10001000
dbstrategy=CREATEDB_FILE_COPY;
10011001
else
10021002
ereport(ERROR,
10031003
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
10041004
errmsg("invalid create database strategy \"%s\"",strategy),
1005-
errhint("Valid strategies are \"wal_log\", and \"file_copy\".")));
1005+
errhint("Valid strategies are \"wal_log\" and \"file_copy\".")));
10061006
}
10071007

10081008
/* If encoding or locales are defaulted, use source's setting */

‎src/bin/scripts/createdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ main(int argc, char *argv[])
225225
appendStringLiteralConn(&sql,lc_ctype,conn);
226226
}
227227
if (locale_provider)
228-
appendPQExpBuffer(&sql," LOCALE_PROVIDER %s",locale_provider);
228+
appendPQExpBuffer(&sql," LOCALE_PROVIDER %s",fmtId(locale_provider));
229229
if (icu_locale)
230230
{
231231
appendPQExpBufferStr(&sql," ICU_LOCALE ");

‎src/bin/scripts/t/020_createdb.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,19 @@
153153
qr/statement: CREATE DATABASE foobar6 STRATEGY wal_log TEMPLATE foobar2/,
154154
'create database with WAL_LOG strategy');
155155

156+
$node->issues_sql_like(
157+
['createdb','-T','foobar2','-S','WAL_LOG','foobar6s' ],
158+
qr/statement: CREATE DATABASE foobar6s STRATEGY "WAL_LOG" TEMPLATE foobar2/,
159+
'create database with WAL_LOG strategy');
160+
156161
$node->issues_sql_like(
157162
['createdb','-T','foobar2','-S','file_copy','foobar7' ],
158163
qr/statement: CREATE DATABASE foobar7 STRATEGY file_copy TEMPLATE foobar2/,
159164
'create database with FILE_COPY strategy');
160165

166+
$node->issues_sql_like(
167+
['createdb','-T','foobar2','-S','FILE_COPY','foobar7s' ],
168+
qr/statement: CREATE DATABASE foobar7s STRATEGY "FILE_COPY" TEMPLATE foobar2/,
169+
'create database with FILE_COPY strategy');
170+
161171
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp