On 8/1/17 08:28, Victor Wagner wrote: > On Tue, 1 Aug 2017 08:16:54 -0400 > Peter Eisentraut <peter.eisentr...@2ndquadrant.com> wrote: > >> On 8/1/17 02:12, Victor Wagner wrote: >>>> We are only calling uloc_toLanguageTag() with keyword/value >>>> combinations that ICU itself previously told us were supported. So >>>> just ignoring errors doesn't seem proper in this case. >>>> >>> We know that this version of ICU is broken. But what choice we >>> have? >> I don't know that we can already reach that conclusion. Maybe the > Because it was fixed in subsequent versions.
I propose the attached patch to address this. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From a9c89b7b1b98f0a0e3dc6d7571dfc7e7f146ed8d Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Tue, 1 Aug 2017 10:49:55 -0400 Subject: [PATCH] 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 <vi...@wagner.pp.ru> --- doc/src/sgml/installation.sgml | 22 +++++++++++++++++++--- src/backend/commands/collationcmds.c | 11 +++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index fa0d05efe6..12866b4bf7 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -774,10 +774,26 @@ <title>Configuration</title> Build with support for the <productname>ICU</productname><indexterm><primary>ICU</></> library. This requires the <productname>ICU4C</productname> package - as well - as <productname>pkg-config</productname><indexterm><primary>pkg-config</></> to be installed. The minimum required version - of <productname>ICU4C</productname> is currently 4.6. + of <productname>ICU4C</productname> is currently 4.2. + </para> + + <para> + By default, + <productname>pkg-config</productname><indexterm><primary>pkg-config</></> + will be used to find the required compilation options. This is + supported for <productname>ICU4C</productname> version 4.6 and later. + For older versions, or if <productname>pkg-config</productname> is + not available, the variables <envar>ICU_CFLAGS</envar> + and <envar>ICU_LIBS</envar> can be specified + to <filename>configure</filename>, like in this example: +<programlisting> +./configure ... --with-icu ICU_CFLAGS='-I/some/where/include' ICU_LIBS='-L/some/where/lib -licui18n -licuuc -licudata' +</programlisting> + (If <productname>ICU4C</productname> is in the default search path + for the compiler, then you still need to specify a nonempty string in + order to avoid use of <productname>pkg-config</productname>, for + example, <literal>ICU_CFLAGS=' '</literal>.) </para> </listitem> </varlistentry> diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index b6c14c920d..a7b5871466 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -718,7 +718,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)) @@ -765,6 +775,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 */ -- 2.13.3
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers