summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorJeff Davis2023-03-28 23:15:59 +0000
committerJeff Davis2023-03-28 23:34:29 +0000
commit1671f990dd669c0b72e45c7bef0fd579a10676ed (patch)
tree002e9ca8c4cd35b2f641de6c308f78b701f3b21a /src/backend/commands
parentb7cea58822c67724effc711ae28e4077a01a7cd6 (diff)
Validate ICU locales.
For ICU collations, ensure that the locale's language exists in ICU, and that the locale can be opened. Basic validation helps avoid minor mistakes and misspellings, which often fall back to the root locale instead of the intended locale. It's even more important to avoid such mistakes in ICU versions 54 and earlier, where the same (misspelled) locale string could fall back to different locales depending on the environment. Discussion: https://postgr.es/m/11b1eeb7e7667fdd4178497aeb796c48d26e69b9.camel@j-davis.com Discussion: https://postgr.es/m/df2efad0cae7c65180df8e5ebb709e5eb4f2a82b.camel@j-davis.com Reviewed-by: Peter Eisentraut
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/collationcmds.c2
-rw-r--r--src/backend/commands/dbcommands.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index 13ad7dff42..45de78352c 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -258,6 +258,8 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("parameter \"locale\" must be specified")));
+
+ icu_validate_locale(colliculocale);
}
/*
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 9408dd6cc7..24bcc5adfe 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -1058,7 +1058,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("ICU locale must be specified")));
- check_icu_locale(dbiculocale);
+ icu_validate_locale(dbiculocale);
}
else
{