aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/pg_locale.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2019-10-16 16:51:40 +1300
committerThomas Munro <tmunro@postgresql.org>2019-10-16 17:28:24 +1300
commitd5ac14f9ccdda036358c9059d4a29836ebc0c440 (patch)
tree3d7e1242ce542914a89467af88099bdccf116fbe /src/backend/utils/adt/pg_locale.c
parent4351142e5843dc9fcb080a51aa082d63be59a5ab (diff)
downloadpostgresql-d5ac14f9ccdda036358c9059d4a29836ebc0c440.tar.gz
postgresql-d5ac14f9ccdda036358c9059d4a29836ebc0c440.zip
Use libc version as a collation version on glibc systems.
Using glibc's version string to detect potential collation definition changes is not 100% reliable, but it's better than nothing. Currently this affects only collations explicitly provided by "libc". More work will be needed to handle the default collation. Author: Thomas Munro, based on a suggestion from Christoph Berg Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/4b76c6d4-ae5e-0dc6-7d0d-b5c796a07e34%402ndquadrant.com
Diffstat (limited to 'src/backend/utils/adt/pg_locale.c')
-rw-r--r--src/backend/utils/adt/pg_locale.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 2a076a3dfd1..fcdbaae37b9 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -70,6 +70,10 @@
#include <unicode/ucnv.h>
#endif
+#ifdef __GLIBC__
+#include <gnu/libc-version.h>
+#endif
+
#ifdef WIN32
/*
* This Windows file defines StrNCpy. We don't need it here, so we undefine
@@ -1499,7 +1503,7 @@ pg_newlocale_from_collation(Oid collid)
char *
get_collation_actual_version(char collprovider, const char *collcollate)
{
- char *collversion;
+ char *collversion = NULL;
#ifdef USE_ICU
if (collprovider == COLLPROVIDER_ICU)
@@ -1523,7 +1527,13 @@ get_collation_actual_version(char collprovider, const char *collcollate)
}
else
#endif
- collversion = NULL;
+ if (collprovider == COLLPROVIDER_LIBC)
+ {
+#if defined(__GLIBC__)
+ /* Use the glibc version because we don't have anything better. */
+ collversion = pstrdup(gnu_get_libc_version());
+#endif
+ }
return collversion;
}