From edfcaa8f9982ca54d5ff75a2a054827b16906051 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 6 Sep 2018 09:05:57 +1200 Subject: [PATCH 5/6] Use glibc version in lieu of collation version on Linux. On systems using glibc (most GNU/Linux distributions), we can warn users about possible index corruption due to collation changes by using the glibc version string. Major operating system upgrades and streaming replication between different operating system major releases will result in warnings about the need to REINDEX, though it's not a 100% reliable indicator, and there is no guarantee that the collation definitions can't change without a change in the glibc version (hopefully most distributions don't do that.) Author: Thomas Munro Reviewed-by: Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com --- configure | 2 +- configure.in | 2 +- src/backend/utils/adt/pg_locale.c | 13 +++++++++++++ src/include/pg_config.h.in | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 9b304023d3d..7949f721b72 100755 --- a/configure +++ b/configure @@ -12704,7 +12704,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi -for ac_header in atomic.h crypt.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h +for ac_header in atomic.h crypt.h fp_class.h getopt.h gnu/libc-version.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/configure.in b/configure.in index 2e60a89502c..d978438318c 100644 --- a/configure.in +++ b/configure.in @@ -1283,7 +1283,7 @@ AC_SUBST(UUID_LIBS) AC_HEADER_STDBOOL -AC_CHECK_HEADERS([atomic.h crypt.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h]) +AC_CHECK_HEADERS([atomic.h crypt.h fp_class.h getopt.h gnu/libc-version.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/ipc.h sys/prctl.h sys/procctl.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/sockio.h sys/tas.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h]) # On BSD, test for net/if.h will fail unless sys/socket.h # is included first. diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index da651344e14..45faf088c1a 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -68,6 +68,10 @@ #include #endif +#ifdef HAVE_GNU_LIBC_VERSION_H +#include +#endif + #ifdef WIN32 /* * This Windows file defines StrNCpy. We don't need it here, so we undefine @@ -1438,6 +1442,15 @@ get_collation_actual_version(char collprovider, const char *collcollate) } else #endif + if (collprovider == COLLPROVIDER_LIBC) + { +#ifdef HAVE_GNU_LIBC_VERSION_H + collversion = gnu_get_libc_version(); +#else + collversion = NULL; +#endif + } + else collversion = NULL; return collversion; diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 4094e22776c..9f05c24f7bc 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -290,6 +290,9 @@ /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY +/* Define to 1 if you have the header file. */ +#undef HAVE_GNU_LIBC_VERSION_H + /* Define to 1 if you have the header file. */ #undef HAVE_GSSAPI_GSSAPI_H -- 2.17.0