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

Commitf3a01af

Browse files
committed
ICU: do not convert locale 'C' to 'en-US-u-va-posix'.
Older versions of ICU canonicalize "C" to "en-US-u-va-posix"; butstarting in ICU version 64, the "C" locale is consideredobsolete. Postgres commitea1db8a introduced code to alwayscanonicalize "C" to "en-US-u-va-posix" for consistency andconvenience, but it was deemed too confusing.This commit removes that code, so that "C" is treated like other ICUlocale names: canonicalization is attempted, and if it fails, thebehavior is controlled by icu_validation_level.A similar change was previously committed asf7faa99, then reverteddue to an ICU-version-dependent test failure. This commit un-revertsit, omitting the test because we now expect the behavior to depend onthe version of ICU being used.Discussion:https://postgr.es/m/3a200aca-4672-4b37-fc91-5d198a323503%40eisentraut.orgDiscussion:https://postgr.es/m/f83f089ee1e9acd5dbbbf3353294d24e1f196e95.camel@j-davis.comDiscussion:https://postgr.es/m/37520ec1ae9591f83132f82dbd625f3fc2d69c16.camel@j-davis.com
1 parent2535c74 commitf3a01af

File tree

4 files changed

+6
-34
lines changed

4 files changed

+6
-34
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,26 +2784,10 @@ icu_language_tag(const char *loc_str, int elevel)
27842784
{
27852785
#ifdefUSE_ICU
27862786
UErrorCodestatus;
2787-
charlang[ULOC_LANG_CAPACITY];
27882787
char*langtag;
27892788
size_tbuflen=32;/* arbitrary starting buffer size */
27902789
constboolstrict= true;
27912790

2792-
status=U_ZERO_ERROR;
2793-
uloc_getLanguage(loc_str,lang,ULOC_LANG_CAPACITY,&status);
2794-
if (U_FAILURE(status)||status==U_STRING_NOT_TERMINATED_WARNING)
2795-
{
2796-
if (elevel>0)
2797-
ereport(elevel,
2798-
(errmsg("could not get language from locale \"%s\": %s",
2799-
loc_str,u_errorName(status))));
2800-
returnNULL;
2801-
}
2802-
2803-
/* C/POSIX locales aren't handled by uloc_getLanguageTag() */
2804-
if (strcmp(lang,"c")==0||strcmp(lang,"posix")==0)
2805-
returnpstrdup("en-US-u-va-posix");
2806-
28072791
/*
28082792
* A BCP47 language tag doesn't have a clearly-defined upper limit (cf.
28092793
* RFC5646 section 4.4). Additionally, in older ICU versions,
@@ -2884,8 +2868,7 @@ icu_validate_locale(const char *loc_str)
28842868

28852869
/* check for special language name */
28862870
if (strcmp(lang,"")==0||
2887-
strcmp(lang,"root")==0||strcmp(lang,"und")==0||
2888-
strcmp(lang,"c")==0||strcmp(lang,"posix")==0)
2871+
strcmp(lang,"root")==0||strcmp(lang,"und")==0)
28892872
found= true;
28902873

28912874
/* search for matching language within ICU */

‎src/bin/initdb/initdb.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,24 +2244,10 @@ icu_language_tag(const char *loc_str)
22442244
{
22452245
#ifdefUSE_ICU
22462246
UErrorCodestatus;
2247-
charlang[ULOC_LANG_CAPACITY];
22482247
char*langtag;
22492248
size_tbuflen=32;/* arbitrary starting buffer size */
22502249
constboolstrict= true;
22512250

2252-
status=U_ZERO_ERROR;
2253-
uloc_getLanguage(loc_str,lang,ULOC_LANG_CAPACITY,&status);
2254-
if (U_FAILURE(status)||status==U_STRING_NOT_TERMINATED_WARNING)
2255-
{
2256-
pg_fatal("could not get language from locale \"%s\": %s",
2257-
loc_str,u_errorName(status));
2258-
returnNULL;
2259-
}
2260-
2261-
/* C/POSIX locales aren't handled by uloc_getLanguageTag() */
2262-
if (strcmp(lang,"c")==0||strcmp(lang,"posix")==0)
2263-
returnpstrdup("en-US-u-va-posix");
2264-
22652251
/*
22662252
* A BCP47 language tag doesn't have a clearly-defined upper limit (cf.
22672253
* RFC5646 section 4.4). Additionally, in older ICU versions,
@@ -2326,8 +2312,7 @@ icu_validate_locale(const char *loc_str)
23262312

23272313
/* check for special language name */
23282314
if (strcmp(lang,"")==0||
2329-
strcmp(lang,"root")==0||strcmp(lang,"und")==0||
2330-
strcmp(lang,"c")==0||strcmp(lang,"posix")==0)
2315+
strcmp(lang,"root")==0||strcmp(lang,"und")==0)
23312316
found= true;
23322317

23332318
/* search for matching language within ICU */

‎src/test/regress/expected/collate.icu.utf8.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ CREATE ROLE regress_test_role;
10201020
CREATE SCHEMA test_schema;
10211021
-- We need to do this this way to cope with varying names for encodings:
10221022
SET client_min_messages TO WARNING;
1023+
SET icu_validation_level = disabled;
10231024
do $$
10241025
BEGIN
10251026
EXECUTE 'CREATE COLLATION test0 (provider = icu, locale = ' ||
@@ -1034,6 +1035,7 @@ BEGIN
10341035
quote_literal((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) || ');';
10351036
END
10361037
$$;
1038+
RESET icu_validation_level;
10371039
RESET client_min_messages;
10381040
CREATE COLLATION test3 (provider = icu, lc_collate = 'en_US.utf8'); -- fail, needs "locale"
10391041
ERROR: parameter "locale" must be specified

‎src/test/regress/sql/collate.icu.utf8.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ CREATE SCHEMA test_schema;
358358

359359
-- We need to do this this way to cope with varying names for encodings:
360360
SET client_min_messages TO WARNING;
361+
SET icu_validation_level= disabled;
361362

362363
do $$
363364
BEGIN
@@ -373,6 +374,7 @@ BEGIN
373374
END
374375
$$;
375376

377+
RESET icu_validation_level;
376378
RESET client_min_messages;
377379

378380
CREATE COLLATION test3 (provider= icu, lc_collate='en_US.utf8');-- fail, needs "locale"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp