aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-01-21 23:18:58 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2019-01-21 23:18:58 -0500
commit844d91fd64961e02a5a4034badcd8f8caef85b4a (patch)
treeae4fa4bcf8e8e3843543fe7b38e707828d7febb7 /src/include
parent7990922413cab67b34780bd3454f0881b1fd8397 (diff)
downloadpostgresql-844d91fd64961e02a5a4034badcd8f8caef85b4a.tar.gz
postgresql-844d91fd64961e02a5a4034badcd8f8caef85b4a.zip
Avoid thread-safety problem in ecpglib.
ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/pg_config.h.in6
-rw-r--r--src/include/pg_config.h.win326
2 files changed, 12 insertions, 0 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 9a9f22e4497..a4442db53a6 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -659,6 +659,9 @@
/* Define to 1 if the system has the type `unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
+/* Define to 1 if you have the `uselocale' function. */
+#undef HAVE_USELOCALE
+
/* Define to 1 if you have the `utime' function. */
#undef HAVE_UTIME
@@ -713,6 +716,9 @@
/* Define to 1 if your compiler understands __builtin_unreachable. */
#undef HAVE__BUILTIN_UNREACHABLE
+/* Define to 1 if you have the `_configthreadlocale' function. */
+#undef HAVE__CONFIGTHREADLOCALE
+
/* Define to 1 if you have __cpuid. */
#undef HAVE__CPUID
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 519bd2f9ec0..8c9758b8990 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -509,6 +509,9 @@
/* Define to 1 if you have the `unsetenv' function. */
/* #undef HAVE_UNSETENV */
+/* Define to 1 if you have the `uselocale' function. */
+/* #undef HAVE_USELOCALE */
+
/* Define to 1 if you have the `utime' function. */
#define HAVE_UTIME 1
@@ -548,6 +551,9 @@
/* Define to 1 if your compiler understands __builtin_unreachable. */
/* #undef HAVE__BUILTIN_UNREACHABLE */
+/* Define to 1 if you have the `_configthreadlocale' function. */
+#define HAVE__CONFIGTHREADLOCALE 1
+
/* Define to 1 if you have __cpuid. */
#define HAVE__CPUID 1