1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Add support for ICU 4.2

Supporting ICU 4.2 seems useful because it ships with CentOS 6.

Versions before ICU 4.6 don't support pkg-config, so document an
installation method without using pkg-config.

In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns values that
will not be accepted by uloc_toLanguageTag().  Skip loading keyword
variants in that version.

Reported-by: Victor Wagner <vitus@wagner.pp.ru>
This commit is contained in:
Peter Eisentraut
2017-08-01 10:49:55 -04:00
parent f85f88bcc2
commit eccead9ed4
2 changed files with 30 additions and 3 deletions

View File

@ -722,7 +722,17 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
/*
* Add keyword variants
*
* In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns
* values that will not be accepted by uloc_toLanguageTag(). Skip
* loading keyword variants in that version. (Both
* ucol_getKeywordValuesForLocale() and uloc_toLanguageTag() are
* new in ICU 4.2, so older versions are not supported at all.)
*
* XXX We have no information about ICU 4.3 through 4.7, but we
* know the below works with 4.8.
*/
#if U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM > 2)
status = U_ZERO_ERROR;
en = ucol_getKeywordValuesForLocale("collation", name, TRUE, &status);
if (U_FAILURE(status))
@ -769,6 +779,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
(errmsg("could not get keyword values for locale \"%s\": %s",
name, u_errorName(status))));
uenum_close(en);
#endif /* ICU >4.2 */
}
}
#endif /* USE_ICU */