mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Support language tags in older ICU versions (53 and earlier).
By calling uloc_canonicalize() before parsing the attributes, the existing locale attribute parsing logic works on language tags as well. Fix a small memory leak, too. Discussion: http://postgr.es/m/60da0cecfb512a78b8666b31631a636215d8ce73.camel@j-davis.com Reviewed-by: Peter Eisentraut
This commit is contained in:
@ -950,7 +950,6 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
const char *name;
|
||||
char *langtag;
|
||||
char *icucomment;
|
||||
const char *iculocstr;
|
||||
Oid collid;
|
||||
|
||||
if (i == -1)
|
||||
@ -959,20 +958,19 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
||||
name = uloc_getAvailable(i);
|
||||
|
||||
langtag = get_icu_language_tag(name);
|
||||
iculocstr = U_ICU_VERSION_MAJOR_NUM >= 54 ? langtag : name;
|
||||
|
||||
/*
|
||||
* Be paranoid about not allowing any non-ASCII strings into
|
||||
* pg_collation
|
||||
*/
|
||||
if (!pg_is_ascii(langtag) || !pg_is_ascii(iculocstr))
|
||||
if (!pg_is_ascii(langtag))
|
||||
continue;
|
||||
|
||||
collid = CollationCreate(psprintf("%s-x-icu", langtag),
|
||||
nspid, GetUserId(),
|
||||
COLLPROVIDER_ICU, true, -1,
|
||||
NULL, NULL, iculocstr, NULL,
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, iculocstr),
|
||||
NULL, NULL, langtag, NULL,
|
||||
get_collation_actual_version(COLLPROVIDER_ICU, langtag),
|
||||
true, true);
|
||||
if (OidIsValid(collid))
|
||||
{
|
||||
|
Reference in New Issue
Block a user