summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2017-08-10 00:34:51 +0000
committerPeter Eisentraut2017-08-11 02:14:00 +0000
commitd6391b03b3025372620925e5746e65c288a1e371 (patch)
treeee2b9a7402b148127194b70c6b6c4766e7c17bd7
parentb83e54564ad0733f5382b20c04695ee9fb4cf451 (diff)
Reject use of ucol_strcollUTF8() before ICU 53
Various bugs can cause crashes, so don't use that function before ICU 53. It will fall back to the code path used for other encodings. Since we now tie the function availability to an ICU version, we don't need the configure test anymore. That also resolves the issue that the test result was previously hardcoded for Windows. researched by Daniel Verite <[email protected]>, Peter Geoghegan <[email protected]>, Tom Lane <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/f1438ec6-22aa-4029-9a3b-26f79d330e72%40manitou-mail.org
-rwxr-xr-xconfigure38
-rw-r--r--configure.in16
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/pg_config.h.win323
-rw-r--r--src/include/utils/pg_locale.h13
5 files changed, 13 insertions, 60 deletions
diff --git a/configure b/configure
index 7218a31407..cc6471bba6 100755
--- a/configure
+++ b/configure
@@ -13923,44 +13923,6 @@ fi
- # ucol_strcollUTF8() appeared in ICU 50, so check if we have it.
- # ICU functions are macros, so we need to do this the long way.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucol_strcollUTF8" >&5
-$as_echo_n "checking for ucol_strcollUTF8... " >&6; }
-if ${pgac_cv_func_ucol_strcollUTF8+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_save_LIBS=$LIBS
-LIBS="$ICU_LIBS $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <unicode/ucol.h>
-
-int
-main ()
-{
-ucol_strcollUTF8(NULL, NULL, 0, NULL, 0, NULL);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- pgac_cv_func_ucol_strcollUTF8=yes
-else
- pgac_cv_func_ucol_strcollUTF8=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_ucol_strcollUTF8" >&5
-$as_echo "$pgac_cv_func_ucol_strcollUTF8" >&6; }
- if test "$pgac_cv_func_ucol_strcollUTF8" = yes ; then
-
-$as_echo "#define HAVE_UCOL_STRCOLLUTF8 1" >>confdefs.h
-
- fi
-
CPPFLAGS=$ac_save_CPPFLAGS
fi
diff --git a/configure.in b/configure.in
index 44987cdc1e..5c036e7f42 100644
--- a/configure.in
+++ b/configure.in
@@ -1662,22 +1662,6 @@ if test "$with_icu" = yes; then
AC_CHECK_HEADER(unicode/ucol.h, [],
[AC_MSG_ERROR([header file <unicode/ucol.h> is required for ICU])])
- # ucol_strcollUTF8() appeared in ICU 50, so check if we have it.
- # ICU functions are macros, so we need to do this the long way.
- AC_CACHE_CHECK([for ucol_strcollUTF8], [pgac_cv_func_ucol_strcollUTF8],
-[ac_save_LIBS=$LIBS
-LIBS="$ICU_LIBS $LIBS"
-AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[#include <unicode/ucol.h>
-],
-[ucol_strcollUTF8(NULL, NULL, 0, NULL, 0, NULL);])],
-[pgac_cv_func_ucol_strcollUTF8=yes],
-[pgac_cv_func_ucol_strcollUTF8=no])
-LIBS=$ac_save_LIBS])
- if test "$pgac_cv_func_ucol_strcollUTF8" = yes ; then
- AC_DEFINE([HAVE_UCOL_STRCOLLUTF8], 1, [Define to 1 if you have the `ucol_strcollUTF8' function.])
- fi
-
CPPFLAGS=$ac_save_CPPFLAGS
fi
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 7a05c7e5b8..dcb7a1a320 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -606,9 +606,6 @@
/* Define to 1 if you have the external array `tzname'. */
#undef HAVE_TZNAME
-/* Define to 1 if you have the `ucol_strcollUTF8' function. */
-#undef HAVE_UCOL_STRCOLLUTF8
-
/* Define to 1 if you have the <ucred.h> header file. */
#undef HAVE_UCRED_H
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 9d3021ced8..7f60670fa6 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -457,9 +457,6 @@
/* Define to 1 if you have the external array `tzname'. */
/* #undef HAVE_TZNAME */
-/* Define to 1 if you have the `ucol_strcollUTF8' function. */
-#define HAVE_UCOL_STRCOLLUTF8 1
-
/* Define to 1 if the system has the type `uint64'. */
/* #undef HAVE_UINT64 */
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index a02d27ba26..f3e04d4d8c 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -21,6 +21,19 @@
#include "utils/guc.h"
+#ifdef USE_ICU
+/*
+ * ucol_strcollUTF8() was introduced in ICU 50, but it is buggy before ICU 53.
+ * (see
+ * <https://www.postgresql.org/message-id/flat/f1438ec6-22aa-4029-9a3b-26f79d330e72%40manitou-mail.org>)
+ */
+#if U_ICU_VERSION_MAJOR_NUM >= 53
+#define HAVE_UCOL_STRCOLLUTF8 1
+#else
+#undef HAVE_UCOL_STRCOLLUTF8
+#endif
+#endif
+
/* GUC settings */
extern char *locale_messages;