summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2020-11-20 21:49:57 +1300
committerThomas Munro <tmunro@postgresql.org>2020-11-20 21:49:57 +1300
commitca051d8b101d3205f1c5faf0d1da8a523ffc95a1 (patch)
tree58ebdd4f80cdff1d6f7c6406adeb9123201c0fd2 /src
parenta4ef0329c27156dca81714854599e7d82becb17f (diff)
Add collation versions for FreeBSD.
On FreeBSD 13, use querylocale() to read the current version of libc collations. Similar to commits 352f6f2d for Windows and d5ac14f9 for GNU/Linux. Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/pg_locale.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index cc4bf3b5009..b6d05ac98dd 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1684,6 +1684,26 @@ get_collation_actual_version(char collprovider, const char *collcollate)
/* Use the glibc version because we don't have anything better. */
collversion = pstrdup(gnu_get_libc_version());
+#elif defined(LC_VERSION_MASK)
+ locale_t loc;
+
+ /* C[.encoding] and POSIX never change. */
+ if (strcmp("C", collcollate) == 0 ||
+ strncmp("C.", collcollate, 2) == 0 ||
+ strcmp("POSIX", collcollate) == 0)
+ return NULL;
+
+ /* Look up FreeBSD collation version. */
+ loc = newlocale(LC_COLLATE, collcollate, NULL);
+ if (loc)
+ {
+ collversion =
+ pstrdup(querylocale(LC_COLLATE_MASK | LC_VERSION_MASK, loc));
+ freelocale(loc);
+ }
+ else
+ ereport(ERROR,
+ (errmsg("could not load locale \"%s\"", collcollate)));
#elif defined(WIN32) && _WIN32_WINNT >= 0x0600
/*
* If we are targeting Windows Vista and above, we can ask for a name