Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d6391b0

Browse files
committed
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 <daniel@manitou-mail.org>, Peter Geoghegan <pg@bowt.ie>, Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/f1438ec6-22aa-4029-9a3b-26f79d330e72%40manitou-mail.org
1 parent b83e545 commit d6391b0

File tree

5 files changed

+13
-60
lines changed

5 files changed

+13
-60
lines changed

configure

-38
Original file line numberDiff line numberDiff line change
@@ -13923,44 +13923,6 @@ fi
1392313923

1392413924

1392513925

13926-
# ucol_strcollUTF8() appeared in ICU 50, so check if we have it.
13927-
# ICU functions are macros, so we need to do this the long way.
13928-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucol_strcollUTF8" >&5
13929-
$as_echo_n "checking for ucol_strcollUTF8... " >&6; }
13930-
if ${pgac_cv_func_ucol_strcollUTF8+:} false; then :
13931-
$as_echo_n "(cached) " >&6
13932-
else
13933-
ac_save_LIBS=$LIBS
13934-
LIBS="$ICU_LIBS $LIBS"
13935-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13936-
/* end confdefs.h. */
13937-
#include <unicode/ucol.h>
13938-
13939-
int
13940-
main ()
13941-
{
13942-
ucol_strcollUTF8(NULL, NULL, 0, NULL, 0, NULL);
13943-
;
13944-
return 0;
13945-
}
13946-
_ACEOF
13947-
if ac_fn_c_try_link "$LINENO"; then :
13948-
pgac_cv_func_ucol_strcollUTF8=yes
13949-
else
13950-
pgac_cv_func_ucol_strcollUTF8=no
13951-
fi
13952-
rm -f core conftest.err conftest.$ac_objext \
13953-
conftest$ac_exeext conftest.$ac_ext
13954-
LIBS=$ac_save_LIBS
13955-
fi
13956-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_func_ucol_strcollUTF8" >&5
13957-
$as_echo "$pgac_cv_func_ucol_strcollUTF8" >&6; }
13958-
if test "$pgac_cv_func_ucol_strcollUTF8" = yes ; then
13959-
13960-
$as_echo "#define HAVE_UCOL_STRCOLLUTF8 1" >>confdefs.h
13961-
13962-
fi
13963-
1396413926
CPPFLAGS=$ac_save_CPPFLAGS
1396513927
fi
1396613928

configure.in

-16
Original file line numberDiff line numberDiff line change
@@ -1662,22 +1662,6 @@ if test "$with_icu" = yes; then
16621662
AC_CHECK_HEADER(unicode/ucol.h, [],
16631663
[AC_MSG_ERROR([header file <unicode/ucol.h> is required for ICU])])
16641664

1665-
# ucol_strcollUTF8() appeared in ICU 50, so check if we have it.
1666-
# ICU functions are macros, so we need to do this the long way.
1667-
AC_CACHE_CHECK([for ucol_strcollUTF8], [pgac_cv_func_ucol_strcollUTF8],
1668-
[ac_save_LIBS=$LIBS
1669-
LIBS="$ICU_LIBS $LIBS"
1670-
AC_LINK_IFELSE([AC_LANG_PROGRAM(
1671-
[#include <unicode/ucol.h>
1672-
],
1673-
[ucol_strcollUTF8(NULL, NULL, 0, NULL, 0, NULL);])],
1674-
[pgac_cv_func_ucol_strcollUTF8=yes],
1675-
[pgac_cv_func_ucol_strcollUTF8=no])
1676-
LIBS=$ac_save_LIBS])
1677-
if test "$pgac_cv_func_ucol_strcollUTF8" = yes ; then
1678-
AC_DEFINE([HAVE_UCOL_STRCOLLUTF8], 1, [Define to 1 if you have the `ucol_strcollUTF8' function.])
1679-
fi
1680-
16811665
CPPFLAGS=$ac_save_CPPFLAGS
16821666
fi
16831667

src/include/pg_config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,6 @@
606606
/* Define to 1 if you have the external array `tzname'. */
607607
#undef HAVE_TZNAME
608608

609-
/* Define to 1 if you have the `ucol_strcollUTF8' function. */
610-
#undef HAVE_UCOL_STRCOLLUTF8
611-
612609
/* Define to 1 if you have the <ucred.h> header file. */
613610
#undef HAVE_UCRED_H
614611

src/include/pg_config.h.win32

-3
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,6 @@
457457
/* Define to 1 if you have the external array `tzname'. */
458458
/* #undef HAVE_TZNAME */
459459

460-
/* Define to 1 if you have the `ucol_strcollUTF8' function. */
461-
#define HAVE_UCOL_STRCOLLUTF8 1
462-
463460
/* Define to 1 if the system has the type `uint64'. */
464461
/* #undef HAVE_UINT64 */
465462

src/include/utils/pg_locale.h

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121

2222
#include "utils/guc.h"
2323

24+
#ifdef USE_ICU
25+
/*
26+
* ucol_strcollUTF8() was introduced in ICU 50, but it is buggy before ICU 53.
27+
* (see
28+
* <https://www.postgresql.org/message-id/flat/f1438ec6-22aa-4029-9a3b-26f79d330e72%40manitou-mail.org>)
29+
*/
30+
#if U_ICU_VERSION_MAJOR_NUM >= 53
31+
#define HAVE_UCOL_STRCOLLUTF8 1
32+
#else
33+
#undef HAVE_UCOL_STRCOLLUTF8
34+
#endif
35+
#endif
36+
2437

2538
/* GUC settings */
2639
extern char *locale_messages;

0 commit comments

Comments
 (0)