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

Commit2cc018b

Browse files
committed
Disallow creating an ICU collation if the DB encoding won't support it.
Previously this was allowed, but the collation effectively vanishedinto the ether because of the way lookup_collation() works: you couldnot use the collation, nor even drop it. Seems better to give anerror up front than to leave the user wondering why it doesn't work.(Because this test is in DefineCollation not CreateCollation, it doesnot prevent pg_import_system_collations from creating ICU collations,regardless of the initially-chosen encoding.)Per bug #17170 from Andrew Bille. Back-patch to v10 where ICU supportwas added.Discussion:https://postgr.es/m/17170-95845cf3f0a9c36d@postgresql.org
1 parent67c33a1 commit2cc018b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎src/backend/commands/collationcmds.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,26 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
208208
if (!fromEl)
209209
{
210210
if (collprovider==COLLPROVIDER_ICU)
211+
{
212+
#ifdefUSE_ICU
213+
/*
214+
* We could create ICU collations with collencoding == database
215+
* encoding, but it seems better to use -1 so that it matches the
216+
* way initdb would create ICU collations. However, only allow
217+
* one to be created when the current database's encoding is
218+
* supported. Otherwise the collation is useless, plus we get
219+
* surprising behaviors like not being able to drop the collation.
220+
*
221+
* Skip this test when !USE_ICU, because the error we want to
222+
* throw for that isn't thrown till later.
223+
*/
224+
if (!is_encoding_supported_by_icu(GetDatabaseEncoding()))
225+
ereport(ERROR,
226+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
227+
errmsg("current database's encoding is not supported with this provider")));
228+
#endif
211229
collencoding=-1;
230+
}
212231
else
213232
{
214233
collencoding=GetDatabaseEncoding();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp