Add support for ICU 4.2
authorPeter Eisentraut
Tue, 1 Aug 2017 14:49:55 +0000 (10:49 -0400)
committerPeter Eisentraut
Sat, 5 Aug 2017 13:32:42 +0000 (09:32 -0400)
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
doc/src/sgml/installation.sgml
src/backend/commands/collationcmds.c

index fa0d05efe661750080e92d140d681c866aacb936..12866b4bf7b6f278b8113c53f8921ee9d1d2cb19 100644 (file)
@@ -774,10 +774,26 @@ su - postgres
          Build with support for
          the ICUICU
          library.  This requires the ICU4C package
-         as well
-         as pkg-configpkg-config
          to be installed.  The minimum required version
-         of ICU4C is currently 4.6.
+         of ICU4C is currently 4.2.
+        
+
+        
+         By default,
+         pkg-configpkg-config
+         will be used to find the required compilation options.  This is
+         supported for ICU4C version 4.6 and later.
+         For older versions, or if pkg-config is
+         not available, the variables ICU_CFLAGS
+         and ICU_LIBS can be specified
+         to configure, like in this example:
+
+./configure ... --with-icu ICU_CFLAGS='-I/some/where/include' ICU_LIBS='-L/some/where/lib -licui18n -licuuc -licudata'
+
+         (If ICU4C is in the default search path
+         for the compiler, then you still need to specify a nonempty string in
+         order to avoid use of pkg-config, for
+         example, ICU_CFLAGS=' '.)
         
        
       
index d19a384f9c12894d2700c81fa6bf58c9ca721ca7..ea257a378643a1dfc52ed091ef8bc5f9c9e50b15 100644 (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 */