0001-Collation-version-tracking-for-macOS.patch
text/plain
Filename: 0001-Collation-version-tracking-for-macOS.patch
Type: text/plain
Part: 0
Message:
Collation version tracking for macOS
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Collation version tracking for macOS
| File | + | − |
|---|---|---|
| src/backend/utils/adt/pg_locale.c | 26 | 0 |
From 5e6f1a94a839981755f0380960511e60aba2b8d2 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 1 Feb 2022 16:07:29 +0100
Subject: [PATCH] Collation version tracking for macOS
---
src/backend/utils/adt/pg_locale.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 871a710967..f8e57ee236 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -74,6 +74,10 @@
#include <gnu/libc-version.h>
#endif
+#ifdef __APPLE__
+#include <sys/sysctl.h>
+#endif
+
#ifdef WIN32
#include <shlwapi.h>
#endif
@@ -1696,6 +1700,28 @@ get_collation_actual_version(char collprovider, const char *collcollate)
else
ereport(ERROR,
(errmsg("could not load locale \"%s\"", collcollate)));
+#elif defined(__APPLE__)
+ /*
+ * The POSIX-level locales on macOS are mostly useless for real work,
+ * and they also don't appear to change much or at all. However, at
+ * least for development it is useful to have some version tracking
+ * mechanism on this platform. For lack of better ideas, we just
+ * record the internal major operating system version.
+ */
+ {
+ char str[256];
+ size_t len = sizeof(str);
+ char *p;
+
+ if (sysctlbyname("kern.osrelease", str, &len, NULL, 0) != 0)
+ ereport(ERROR,
+ (errmsg("could not get OS release: %m")));
+ /* value is three numbers like "12.3.4", we take only the first one */
+ p = strchr(str, '.');
+ if (p)
+ *p = '\0';
+ collversion = pstrdup(str);
+ }
#elif defined(WIN32) && _WIN32_WINNT >= 0x0600
/*
* If we are targeting Windows Vista and above, we can ask for a name
--
2.35.1