Cleaning up historical portability baggage
Hello,
I wonder how much dead code for ancient operating systems we could now
drop. Here are some easier cases, I think, and one tricky one that
might take some debate. I think it makes a lot of sense to say that
we expect at least POSIX-1:2001, because that corresponds to C99, with
the thread option because every targeted system has that.
0001-Remove-dead-pg_pread-and-pg_pwrite-replacement-code.patch
0002-Remove-dead-getrusage-replacement-code.patch
0003-Remove-dead-setenv-unsetenv-replacement-code.patch
0004-Remove-dead-handling-for-pre-POSIX-sigwait.patch
0005-Remove-dead-getpwuid_r-replacement-code.patch
0006-Remove-disable-thread-safety.patch
Clearly there is more stuff like this (eg more _r functions, they're
just a touch more complicated), but this is a start. I mention these
now in case it's helpful for the Meson work, and just generally
because I wanted to clean up after the retirement of ancient HP-UX.
The threads patch probably needs more polish and is extracted from
another series I'll propose in a later CF to do some more constructive
work on threads where it'd be helpful not to have to deal with 'no
threads' builds, but I figured it could also pitch this part along
with the other basic POSIX modernisation stuff.
I pulled the configure output from the oldest releases of each
supported target OS, namely:
* hornet, AIX 7.1
* wrasse, Solaris 11.3
* pollock, illumos rolling
* loach, FreeBSD 12.2
* conchuela, DragonflyBSD 6.0
* morepork, OpenBSD 6.9
* sidewinder, NetBSD 9.2
* prairiedog, macOS 10.4 (vintage system most likely to cause problems)
* clam, Linux 3.10/RHEL 7
* fairiewren, Windows/Mingw with configure
I checked for HAVE_PREAD HAVE_PWRITE HAVE_GETRUSAGE HAVE_SETENV
HAVE_UNSETENV HAVE_GETPWUID_R, and the only missing ones were:
HAVE_PREAD is missing on windows
HAVE_PWRITE is missing on windows
HAVE_GETRUSAGE is missing on windows
HAVE_GETPWUID_R is missing on windows
We either have completely separate code paths or replacement functions
for these.
The pwritev/preadv functions are unfortunately not standardised by
POSIX (I dunno why, it's the obvious combination of the p* and *v
functions) despite every OS in the list having them except for Solaris
and old macOS. Oh well.
Attachments:
0001-Remove-dead-pg_pread-and-pg_pwrite-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0001-Remove-dead-pg_pread-and-pg_pwrite-replacement-code.patchDownload
From 9d543f0cf5806625e5d823c18cf8a4d390ec7263 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 21:31:56 +1200
Subject: [PATCH 1/6] Remove dead pg_pread and pg_pwrite replacement code.
pread and pwrite were standardised in POSIX-1:2001.
Previously, we defined pg_pread and pg_pwrite to emulate these function
with lseek() on old Unixen. The names with a pg_ prefix were a reminder
of a portability hazard: they might change the current file position.
Since the replacement code for Windows doesn't suffer from the position
problem, we might as well start using the POSIX names directly.
---
.../pg_stat_statements/pg_stat_statements.c | 4 +-
src/backend/access/heap/rewriteheap.c | 2 +-
src/backend/access/transam/slru.c | 4 +-
src/backend/access/transam/xlog.c | 4 +-
src/backend/access/transam/xlogreader.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 2 +-
src/backend/replication/basebackup.c | 2 +-
src/backend/replication/walreceiver.c | 2 +-
src/backend/storage/file/fd.c | 4 +-
src/backend/utils/init/miscinit.c | 2 +-
src/bin/pg_test_fsync/pg_test_fsync.c | 50 +++++++++----------
src/include/access/xlogreader.h | 4 +-
src/include/port.h | 17 +++----
src/port/pread.c | 18 +------
src/port/preadv.c | 4 +-
src/port/pwrite.c | 18 +------
src/port/pwritev.c | 4 +-
17 files changed, 55 insertions(+), 88 deletions(-)
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 4acfddcdb8..e8a7666ed9 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -2096,9 +2096,9 @@ qtext_store(const char *query, int query_len,
if (fd < 0)
goto error;
- if (pg_pwrite(fd, query, query_len, off) != query_len)
+ if (pwrite(fd, query, query_len, off) != query_len)
goto error;
- if (pg_pwrite(fd, "\0", 1, off + query_len) != 1)
+ if (pwrite(fd, "\0", 1, off + query_len) != 1)
goto error;
CloseTransientFile(fd);
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index 197f06b5ec..9dd885d936 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -1149,7 +1149,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
/* write out tail end of mapping file (again) */
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
- if (pg_pwrite(fd, data, len, xlrec->offset) != len)
+ if (pwrite(fd, data, len, xlrec->offset) != len)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..c9a7b97949 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -718,7 +718,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
- if (pg_pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
slru_errcause = SLRU_READ_FAILED;
@@ -873,7 +873,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
- if (pg_pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index b809a2152c..80fe2ca5ab 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2189,7 +2189,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
INSTR_TIME_SET_CURRENT(start);
pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
- written = pg_pwrite(openLogFile, from, nleft, startoffset);
+ written = pwrite(openLogFile, from, nleft, startoffset);
pgstat_report_wait_end();
/*
@@ -3011,7 +3011,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
* enough.
*/
errno = 0;
- if (pg_pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
+ if (pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
{
/* if write didn't set errno, assume no disk space */
save_errno = errno ? errno : ENOSPC;
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index f3dc4b7797..06e91547dd 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -1514,7 +1514,7 @@ WALRead(XLogReaderState *state,
/* Reset errno first; eases reporting non-errno-affecting errors */
errno = 0;
- readbytes = pg_pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
+ readbytes = pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
#ifndef FRONTEND
pgstat_report_wait_end();
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 5d6f1b5e46..e25e055c77 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3210,7 +3210,7 @@ retry:
readOff = targetPageOff;
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
- r = pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
+ r = pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
if (r != XLOG_BLCKSZ)
{
char fname[MAXFNAMELEN];
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 95440013c0..c02b583976 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1827,7 +1827,7 @@ basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
int rc;
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
- rc = pg_pread(fd, buf, nbytes, offset);
+ rc = pread(fd, buf, nbytes, offset);
pgstat_report_wait_end();
if (rc < 0)
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3d37c1fe62..8604fd4bc2 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -915,7 +915,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
/* OK to write the logs */
errno = 0;
- byteswritten = pg_pwrite(recvFile, buf, segbytes, (off_t) startoff);
+ byteswritten = pwrite(recvFile, buf, segbytes, (off_t) startoff);
if (byteswritten <= 0)
{
char xlogfname[MAXFNAMELEN];
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index f904f60c08..07bd41aaa8 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2067,7 +2067,7 @@ FileRead(File file, char *buffer, int amount, off_t offset,
retry:
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pread(vfdP->fd, buffer, amount, offset);
+ returnCode = pread(vfdP->fd, buffer, amount, offset);
pgstat_report_wait_end();
if (returnCode < 0)
@@ -2149,7 +2149,7 @@ FileWrite(File file, char *buffer, int amount, off_t offset,
retry:
errno = 0;
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pwrite(VfdCache[file].fd, buffer, amount, offset);
+ returnCode = pwrite(VfdCache[file].fd, buffer, amount, offset);
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index eb43b2c5e5..bd973ba613 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -1429,7 +1429,7 @@ AddToDataDirLockFile(int target_line, const char *str)
len = strlen(destbuffer);
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE);
- if (pg_pwrite(fd, destbuffer, len, 0) != len)
+ if (pwrite(fd, destbuffer, len, 0) != len)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
index f7bc199a30..be8effe16b 100644
--- a/src/bin/pg_test_fsync/pg_test_fsync.c
+++ b/src/bin/pg_test_fsync/pg_test_fsync.c
@@ -312,10 +312,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
@@ -338,10 +338,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
fdatasync(tmpfile);
}
@@ -363,10 +363,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
@@ -387,10 +387,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (pg_fsync_writethrough(tmpfile) != 0)
die("fsync failed");
@@ -419,10 +419,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
/*
* This can generate write failures if the filesystem has
@@ -484,10 +484,10 @@ test_open_sync(const char *msg, int writes_size)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < 16 / writes_size; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- writes_size * 1024,
- writes * writes_size * 1024) !=
+ if (pwrite(tmpfile,
+ buf,
+ writes_size * 1024,
+ writes * writes_size * 1024) !=
writes_size * 1024)
die("write failed");
}
@@ -586,7 +586,7 @@ test_non_sync(void)
START_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
- if (pg_pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index 5395f155aa..87ff00feb7 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -375,11 +375,11 @@ extern bool XLogReaderValidatePageHeader(XLogReaderState *state,
/*
* Error information from WALRead that both backend and frontend caller can
- * process. Currently only errors from pg_pread can be reported.
+ * process. Currently only errors from pread can be reported.
*/
typedef struct WALReadError
{
- int wre_errno; /* errno set by the last pg_pread() */
+ int wre_errno; /* errno set by the last pread() */
int wre_off; /* Offset we tried to read from. */
int wre_req; /* Bytes requested to be read. */
int wre_read; /* Bytes read by the last read(). */
diff --git a/src/include/port.h b/src/include/port.h
index 12c05b5d9f..68101f7b16 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -421,20 +421,15 @@ extern int inet_aton(const char *cp, struct in_addr *addr);
#endif
/*
- * Windows and older Unix don't have pread(2) and pwrite(2). We have
- * replacement functions, but they have slightly different semantics so we'll
- * use a name with a pg_ prefix to avoid confusion.
+ * Windows doesn't have pread(2) and pwrite(2). We have replacement functions
+ * in src/port/pread.c and src/port/pwrite.c.
*/
-#ifdef HAVE_PREAD
-#define pg_pread pread
-#else
-extern ssize_t pg_pread(int fd, void *buf, size_t nbyte, off_t offset);
+#ifndef HAVE_PREAD
+extern ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset);
#endif
-#ifdef HAVE_PWRITE
-#define pg_pwrite pwrite
-#else
-extern ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
+#ifndef HAVE_PWRITE
+extern ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
#endif
/* For pg_pwritev() and pg_preadv(), see port/pg_iovec.h. */
diff --git a/src/port/pread.c b/src/port/pread.c
index 491605926f..bc522d60cd 100644
--- a/src/port/pread.c
+++ b/src/port/pread.c
@@ -1,32 +1,24 @@
/*-------------------------------------------------------------------------
*
* pread.c
- * Implementation of pread(2) for platforms that lack one.
+ * Implementation of pread(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/port/pread.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pread().
- *
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pread(int fd, void *buf, size_t size, off_t offset)
+pread(int fd, void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -49,10 +41,4 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return read(fd, buf, size);
-#endif
}
diff --git a/src/port/preadv.c b/src/port/preadv.c
index d12e5a122b..aa7537503f 100644
--- a/src/port/preadv.c
+++ b/src/port/preadv.c
@@ -30,7 +30,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_READV
if (iovcnt == 1)
- return pg_pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return readv(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
diff --git a/src/port/pwrite.c b/src/port/pwrite.c
index eeaffacc48..a8f3f69344 100644
--- a/src/port/pwrite.c
+++ b/src/port/pwrite.c
@@ -1,32 +1,24 @@
/*-------------------------------------------------------------------------
*
* pwrite.c
- * Implementation of pwrite(2) for platforms that lack one.
+ * Implementation of pwrite(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/port/pwrite.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pwrite().
- *
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
+pwrite(int fd, const void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -46,10 +38,4 @@ pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return write(fd, buf, size);
-#endif
}
diff --git a/src/port/pwritev.c b/src/port/pwritev.c
index 0bdd69fffc..cb7421381e 100644
--- a/src/port/pwritev.c
+++ b/src/port/pwritev.c
@@ -30,7 +30,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_WRITEV
if (iovcnt == 1)
- return pg_pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return writev(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
--
2.36.1
0002-Remove-dead-getrusage-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0002-Remove-dead-getrusage-replacement-code.patchDownload
From 80b57167c9149aeb60922530b79f7bd40d7130a1 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 22:01:26 +1200
Subject: [PATCH 2/6] Remove dead getrusage replacement code.
getrusage is in POSIX-1:2001. Note that POSIX only covers ru_utime and
ru_stime and we rely on many more fields unconditionally, but that
doesn't seem to cause a problem on any current system. If a system were
to appear that has minimal POSIX getrusage, we'd be better off doing a
configure test for the extended fields rather than carrying the ancient
replacement code.
The only supported system we need a replacement for now is Windows.
---
src/include/rusagestub.h | 3 ---
src/port/getrusage.c | 46 ++--------------------------------------
2 files changed, 2 insertions(+), 47 deletions(-)
diff --git a/src/include/rusagestub.h b/src/include/rusagestub.h
index b887effa3e..be26f849a5 100644
--- a/src/include/rusagestub.h
+++ b/src/include/rusagestub.h
@@ -15,9 +15,6 @@
#define RUSAGESTUB_H
#include <sys/time.h> /* for struct timeval */
-#ifndef WIN32
-#include <sys/times.h> /* for struct tms */
-#endif
#include <limits.h> /* for CLK_TCK */
#define RUSAGE_SELF 0
diff --git a/src/port/getrusage.c b/src/port/getrusage.c
index 02665f4032..41b3373953 100644
--- a/src/port/getrusage.c
+++ b/src/port/getrusage.c
@@ -17,11 +17,8 @@
#include "rusagestub.h"
-/* This code works on:
- * solaris_i386
- * solaris_sparc
- * win32
- * which currently is all the supported platforms that don't have a
+/*
+ * This code works on Windows, which is the only supported platform without a
* native version of getrusage(). So, if configure decides to compile
* this file at all, we just use this version unconditionally.
*/
@@ -29,7 +26,6 @@
int
getrusage(int who, struct rusage *rusage)
{
-#ifdef WIN32
FILETIME starttime;
FILETIME exittime;
FILETIME kerneltime;
@@ -66,44 +62,6 @@ getrusage(int who, struct rusage *rusage)
li.QuadPart /= 10L; /* Convert to microseconds */
rusage->ru_utime.tv_sec = li.QuadPart / 1000000L;
rusage->ru_utime.tv_usec = li.QuadPart % 1000000L;
-#else /* all but WIN32 */
-
- struct tms tms;
- int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u,
- s;
-
- if (rusage == (struct rusage *) NULL)
- {
- errno = EFAULT;
- return -1;
- }
- if (times(&tms) < 0)
- {
- /* errno set by times */
- return -1;
- }
- switch (who)
- {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return -1;
- }
-#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
-#endif /* WIN32 */
return 0;
}
--
2.36.1
0003-Remove-dead-setenv-unsetenv-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0003-Remove-dead-setenv-unsetenv-replacement-code.patchDownload
From a6fd1ddb7d92b2e37cba33022f07981954c6364e Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 23:00:49 +1200
Subject: [PATCH 3/6] Remove dead setenv, unsetenv replacement code.
setenv and unsetenv are in POSIX-1:2001. We still need special code for
these on Windows, but we don't need replacement code on any supported
Unix.
---
configure | 43 -------------------------
configure.ac | 13 --------
src/include/pg_config.h.in | 6 ----
src/include/port.h | 8 -----
src/port/setenv.c | 48 ----------------------------
src/port/unsetenv.c | 65 --------------------------------------
src/tools/msvc/Solution.pm | 2 --
7 files changed, 185 deletions(-)
delete mode 100644 src/port/setenv.c
delete mode 100644 src/port/unsetenv.c
diff --git a/configure b/configure
index a90be03821..e4cbd562ce 100755
--- a/configure
+++ b/configure
@@ -16824,49 +16824,6 @@ esac
$as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
fi
-case $host_os in
- # Windows uses a specialised env handler
- mingw*)
-
-$as_echo "#define HAVE_SETENV 1" >>confdefs.h
-
-
-$as_echo "#define HAVE_UNSETENV 1" >>confdefs.h
-
- ac_cv_func_setenv=yes
- ac_cv_func_unsetenv=yes
- ;;
- *)
- ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv"
-if test "x$ac_cv_func_setenv" = xyes; then :
- $as_echo "#define HAVE_SETENV 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" setenv.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS setenv.$ac_objext"
- ;;
-esac
-
-fi
-
-ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv"
-if test "x$ac_cv_func_unsetenv" = xyes; then :
- $as_echo "#define HAVE_UNSETENV 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" unsetenv.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS unsetenv.$ac_objext"
- ;;
-esac
-
-fi
-
-
- ;;
-esac
-
# System's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
diff --git a/configure.ac b/configure.ac
index 7fbfb6795f..1cb5994822 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1928,19 +1928,6 @@ if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
fi
-case $host_os in
- # Windows uses a specialised env handler
- mingw*)
- AC_DEFINE(HAVE_SETENV, 1, [Define to 1 because replacement version used.])
- AC_DEFINE(HAVE_UNSETENV, 1, [Define to 1 because replacement version used.])
- ac_cv_func_setenv=yes
- ac_cv_func_unsetenv=yes
- ;;
- *)
- AC_REPLACE_FUNCS([setenv unsetenv])
- ;;
-esac
-
# System's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 7133c3dc66..6268da407a 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -490,9 +490,6 @@
/* Define to 1 if you have the <security/pam_appl.h> header file. */
#undef HAVE_SECURITY_PAM_APPL_H
-/* Define to 1 if you have the `setenv' function. */
-#undef HAVE_SETENV
-
/* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE
@@ -679,9 +676,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
-/* Define to 1 if you have the `unsetenv' function. */
-#undef HAVE_UNSETENV
-
/* Define to 1 if you have the `uselocale' function. */
#undef HAVE_USELOCALE
diff --git a/src/include/port.h b/src/include/port.h
index 68101f7b16..2dfdd8674e 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -446,14 +446,6 @@ extern size_t strlcpy(char *dst, const char *src, size_t siz);
extern size_t strnlen(const char *str, size_t maxlen);
#endif
-#ifndef HAVE_SETENV
-extern int setenv(const char *name, const char *value, int overwrite);
-#endif
-
-#ifndef HAVE_UNSETENV
-extern int unsetenv(const char *name);
-#endif
-
#ifndef HAVE_DLOPEN
extern void *dlopen(const char *file, int mode);
extern void *dlsym(void *handle, const char *symbol);
diff --git a/src/port/setenv.c b/src/port/setenv.c
deleted file mode 100644
index d13c882467..0000000000
--- a/src/port/setenv.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * setenv.c
- * setenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/setenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-setenv(const char *name, const char *value, int overwrite)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL ||
- value == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- /* No work if variable exists and we're not to replace it */
- if (overwrite == 0 && getenv(name) != NULL)
- return 0;
-
- /*
- * Add or replace the value using putenv(). This will leak memory if the
- * same variable is repeatedly redefined, but there's little we can do
- * about that when sitting atop putenv().
- */
- envstr = (char *) malloc(strlen(name) + strlen(value) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- sprintf(envstr, "%s=%s", name, value);
-
- return putenv(envstr);
-}
diff --git a/src/port/unsetenv.c b/src/port/unsetenv.c
deleted file mode 100644
index 62b806d796..0000000000
--- a/src/port/unsetenv.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * unsetenv.c
- * unsetenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/unsetenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-unsetenv(const char *name)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- if (getenv(name) == NULL)
- return 0; /* no work */
-
- /*
- * The technique embodied here works if libc follows the Single Unix Spec
- * and actually uses the storage passed to putenv() to hold the environ
- * entry. When we clobber the entry in the second step we are ensuring
- * that we zap the actual environ member. However, there are some libc
- * implementations (notably recent BSDs) that do not obey SUS but copy the
- * presented string. This method fails on such platforms. Hopefully all
- * such platforms have unsetenv() and thus won't be using this hack. See:
- * http://www.greenend.org.uk/rjk/2008/putenv.html
- *
- * Note that repeatedly setting and unsetting a var using this code will
- * leak memory.
- */
-
- envstr = (char *) malloc(strlen(name) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- /* Override the existing setting by forcibly defining the var */
- sprintf(envstr, "%s=", name);
- if (putenv(envstr))
- return -1;
-
- /* Now we can clobber the variable definition this way: */
- strcpy(envstr, "=");
-
- /*
- * This last putenv cleans up if we have multiple zero-length names as a
- * result of unsetting multiple things.
- */
- return putenv(envstr);
-}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index b8b1728df7..17fe0d95ea 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -356,7 +356,6 @@ sub GenerateFiles
HAVE_RL_RESET_SCREEN_SIZE => undef,
HAVE_RL_VARIABLE_BIND => undef,
HAVE_SECURITY_PAM_APPL_H => undef,
- HAVE_SETENV => undef,
HAVE_SETPROCTITLE => undef,
HAVE_SETPROCTITLE_FAST => undef,
HAVE_SETSID => undef,
@@ -419,7 +418,6 @@ sub GenerateFiles
HAVE_UINT8 => undef,
HAVE_UNION_SEMUN => undef,
HAVE_UNISTD_H => 1,
- HAVE_UNSETENV => undef,
HAVE_USELOCALE => undef,
HAVE_UUID_BSD => undef,
HAVE_UUID_E2FS => undef,
--
2.36.1
0004-Remove-dead-handling-for-pre-POSIX-sigwait.patchtext/x-patch; charset=US-ASCII; name=0004-Remove-dead-handling-for-pre-POSIX-sigwait.patchDownload
From f57341a5ce5a2a53e6c78e0df423d943f00d7561 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 23:26:45 +1200
Subject: [PATCH 4/6] Remove dead handling for pre-POSIX sigwait().
sigwait is in POSIX-1:1996. It's now safe to assume that every
supported system has a conforming sigwait(). (sigwaitinfo() is another
story...).
---
configure | 64 ++------------------------------------
configure.ac | 27 ----------------
src/bin/psql/command.c | 10 +++---
src/bin/psql/startup.c | 4 +--
src/include/pg_config.h.in | 7 -----
src/tools/msvc/Solution.pm | 2 --
6 files changed, 10 insertions(+), 104 deletions(-)
diff --git a/configure b/configure
index e4cbd562ce..79d644d751 100755
--- a/configure
+++ b/configure
@@ -16242,11 +16242,9 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
fi
-# Make sure there's a declaration for sigwait(), then make sure
-# that it conforms to the POSIX standard (there seem to still be
-# some platforms out there with pre-POSIX sigwait()). On Solaris,
-# _POSIX_PTHREAD_SEMANTICS affects the result, but we already
-# added that to CPPFLAGS.
+# posix_fadvise() is a no-op on Solaris, so don't incur function overhead
+# by calling it, 2009-04-02
+# http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
# The Clang compiler raises a warning for an undeclared identifier that matches
# a compiler builtin function. All extant Clang versions are affected, as of
# Clang 3.6.0. Test a builtin known to every version. This problem affects the
@@ -16335,62 +16333,6 @@ case $ac_cv_c_decl_report in
*) ac_c_decl_warn_flag= ;;
esac
-ac_fn_c_check_decl "$LINENO" "sigwait" "ac_cv_have_decl_sigwait" "#include <signal.h>
-"
-if test "x$ac_cv_have_decl_sigwait" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_SIGWAIT $ac_have_decl
-_ACEOF
-
-if test "x$ac_cv_have_decl_sigwait" = xyes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for POSIX-conforming sigwait declaration" >&5
-$as_echo_n "checking for POSIX-conforming sigwait declaration... " >&6; }
-if ${pgac_cv_have_posix_decl_sigwait+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
- #include <signal.h>
- int sigwait(const sigset_t *set, int *sig);
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_have_posix_decl_sigwait=yes
-else
- pgac_cv_have_posix_decl_sigwait=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_have_posix_decl_sigwait" >&5
-$as_echo "$pgac_cv_have_posix_decl_sigwait" >&6; }
-fi
-if test "x$pgac_cv_have_posix_decl_sigwait" = xyes; then
-
-$as_echo "#define HAVE_POSIX_DECL_SIGWAIT 1" >>confdefs.h
-
-else
- # On non-Windows, libpq requires POSIX sigwait() for thread safety.
- if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then
- as_fn_error $? "POSIX-conforming sigwait is required to enable thread safety." "$LINENO" 5
- fi
-fi
-
-# posix_fadvise() is a no-op on Solaris, so don't incur function overhead
-# by calling it, 2009-04-02
-# http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
if test "$PORTNAME" != "solaris"; then :
for ac_func in posix_fadvise
diff --git a/configure.ac b/configure.ac
index 1cb5994822..59d108121d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1827,33 +1827,6 @@ PGAC_CHECK_BUILTIN_FUNC_PTR([__builtin_frame_address], [0])
# in case it finds that _LARGEFILE_SOURCE has to be #define'd for that.
AC_FUNC_FSEEKO
-# Make sure there's a declaration for sigwait(), then make sure
-# that it conforms to the POSIX standard (there seem to still be
-# some platforms out there with pre-POSIX sigwait()). On Solaris,
-# _POSIX_PTHREAD_SEMANTICS affects the result, but we already
-# added that to CPPFLAGS.
-AC_CHECK_DECLS(sigwait, [], [], [#include <signal.h>])
-if test "x$ac_cv_have_decl_sigwait" = xyes; then
- AC_CACHE_CHECK([for POSIX-conforming sigwait declaration],
- [pgac_cv_have_posix_decl_sigwait],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
- #include <signal.h>
- int sigwait(const sigset_t *set, int *sig);
- ],
- [])],
- [pgac_cv_have_posix_decl_sigwait=yes],
- [pgac_cv_have_posix_decl_sigwait=no])])
-fi
-if test "x$pgac_cv_have_posix_decl_sigwait" = xyes; then
- AC_DEFINE(HAVE_POSIX_DECL_SIGWAIT, 1,
- [Define to 1 if you have a POSIX-conforming sigwait declaration.])
-else
- # On non-Windows, libpq requires POSIX sigwait() for thread safety.
- if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then
- AC_MSG_ERROR([POSIX-conforming sigwait is required to enable thread safety.])
- fi
-fi
-
# posix_fadvise() is a no-op on Solaris, so don't incur function overhead
# by calling it, 2009-04-02
# http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c562c04afe..e38f165e4b 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4953,7 +4953,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
FILE *pagerpipe = NULL;
int title_len;
int res = 0;
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
sigset_t sigalrm_sigchld_sigint;
sigset_t sigalrm_sigchld;
sigset_t sigint;
@@ -4967,7 +4967,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
return false;
}
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
sigemptyset(&sigalrm_sigchld_sigint);
sigaddset(&sigalrm_sigchld_sigint, SIGCHLD);
sigaddset(&sigalrm_sigchld_sigint, SIGALRM);
@@ -5006,7 +5006,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
* PAGER environment variables, because traditional pagers probably won't
* be very useful for showing a stream of results.
*/
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
pagerprog = getenv("PSQL_WATCH_PAGER");
#endif
if (pagerprog && myopt.topt.pager)
@@ -5077,7 +5077,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
if (pagerpipe && ferror(pagerpipe))
break;
-#ifndef HAVE_POSIX_DECL_SIGWAIT
+#ifdef WIN32
/*
* Set up cancellation of 'watch' via SIGINT. We redo this each time
@@ -5146,7 +5146,7 @@ do_watch(PQExpBuffer query_buf, double sleep)
restore_sigpipe_trap();
}
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
/* Disable the interval timer. */
memset(&interval, 0, sizeof(interval));
setitimer(ITIMER_REAL, &interval, NULL);
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index 7c2f555f15..e2e5678e2d 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -110,7 +110,7 @@ log_locus_callback(const char **filename, uint64 *lineno)
}
}
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
static void
empty_signal_handler(SIGNAL_ARGS)
{
@@ -308,7 +308,7 @@ main(int argc, char *argv[])
psql_setup_cancel_handler();
-#ifdef HAVE_POSIX_DECL_SIGWAIT
+#ifndef WIN32
/*
* do_watch() needs signal handlers installed (otherwise sigwait() will
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 6268da407a..5b2a9db56d 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -149,10 +149,6 @@
don't. */
#undef HAVE_DECL_RTLD_NOW
-/* Define to 1 if you have the declaration of `sigwait', and to 0 if you
- don't. */
-#undef HAVE_DECL_SIGWAIT
-
/* Define to 1 if you have the declaration of `strlcat', and to 0 if you
don't. */
#undef HAVE_DECL_STRLCAT
@@ -412,9 +408,6 @@
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
-/* Define to 1 if you have a POSIX-conforming sigwait declaration. */
-#undef HAVE_POSIX_DECL_SIGWAIT
-
/* Define to 1 if you have the `posix_fadvise' function. */
#undef HAVE_POSIX_FADVISE
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 17fe0d95ea..9ad22333ee 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -246,7 +246,6 @@ sub GenerateFiles
HAVE_DECL_PWRITEV => 0,
HAVE_DECL_RTLD_GLOBAL => 0,
HAVE_DECL_RTLD_NOW => 0,
- HAVE_DECL_SIGWAIT => 0,
HAVE_DECL_STRLCAT => 0,
HAVE_DECL_STRLCPY => 0,
HAVE_DECL_STRNLEN => 1,
@@ -331,7 +330,6 @@ sub GenerateFiles
HAVE_PAM_PAM_APPL_H => undef,
HAVE_POLL => undef,
HAVE_POLL_H => undef,
- HAVE_POSIX_DECL_SIGWAIT => undef,
HAVE_POSIX_FADVISE => undef,
HAVE_POSIX_FALLOCATE => undef,
HAVE_PPC_LWARX_MUTEX_HINT => undef,
--
2.36.1
0005-Remove-dead-getpwuid_r-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0005-Remove-dead-getpwuid_r-replacement-code.patchDownload
From 8c1c344b298278ada2e4b70ac01218a6227e1616 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 10 Jul 2022 11:31:58 +1200
Subject: [PATCH 5/6] Remove dead getpwuid_r replacement code.
getpwuid_r is from POSIX-1:1996 and is present in all our supported Unix
systems.
---
configure | 2 +-
configure.ac | 2 +-
src/include/pg_config.h.in | 3 --
src/port/thread.c | 58 +++-----------------------------------
src/tools/msvc/Solution.pm | 1 -
5 files changed, 6 insertions(+), 60 deletions(-)
diff --git a/configure b/configure
index 79d644d751..5d9150fad2 100755
--- a/configure
+++ b/configure
@@ -11599,7 +11599,7 @@ fi
-for ac_func in strerror_r getpwuid_r gethostbyname_r
+for ac_func in strerror_r gethostbyname_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 59d108121d..6b7ac306a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1201,7 +1201,7 @@ LIBS="$LIBS $PTHREAD_LIBS"
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
pthread.h not found; use --disable-thread-safety to disable thread safety])])
-AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
+AC_CHECK_FUNCS([strerror_r gethostbyname_r])
# Do test here with the proper thread flags
PGAC_FUNC_STRERROR_R_INT
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 5b2a9db56d..716baf2e91 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -243,9 +243,6 @@
/* Define to 1 if you have the `getpeerucred' function. */
#undef HAVE_GETPEERUCRED
-/* Define to 1 if you have the `getpwuid_r' function. */
-#undef HAVE_GETPWUID_R
-
/* Define to 1 if you have the `getrlimit' function. */
#undef HAVE_GETRLIMIT
diff --git a/src/port/thread.c b/src/port/thread.c
index 23c3fbdf86..492e5a3b72 100644
--- a/src/port/thread.c
+++ b/src/port/thread.c
@@ -18,62 +18,12 @@
/*
- * Threading sometimes requires specially-named versions of functions
- * that return data in static buffers, like strerror_r() instead of
- * strerror(). Other operating systems use pthread_setspecific()
- * and pthread_getspecific() internally to allow standard library
- * functions to return static data to threaded applications. And some
- * operating systems have neither.
- *
- * Additional confusion exists because many operating systems that
- * use pthread_setspecific/pthread_getspecific() also have *_r versions
- * of standard library functions for compatibility with operating systems
- * that require them. However, internally, these *_r functions merely
- * call the thread-safe standard library functions.
- *
- * For example, BSD/OS 4.3 uses Bind 8.2.3 for getpwuid(). Internally,
- * getpwuid() calls pthread_setspecific/pthread_getspecific() to return
- * static data to the caller in a thread-safe manner. However, BSD/OS
- * also has getpwuid_r(), which merely calls getpwuid() and shifts
- * around the arguments to match the getpwuid_r() function declaration.
- * Therefore, while BSD/OS has getpwuid_r(), it isn't required. It also
- * doesn't have strerror_r(), so we can't fall back to only using *_r
- * functions for threaded programs.
- *
- * The current setup is to try threading in this order:
- *
- * use *_r function names if they exit
- * (*_THREADSAFE=yes)
- * use non-*_r functions if they are thread-safe
+ * Historically, the code in this module had to deal with operating systems
+ * that lacked getpwuid_r().
*/
#ifndef WIN32
-/*
- * Wrapper around getpwuid() or getpwuid_r() to mimic POSIX getpwuid_r()
- * behaviour, if that function is not available or required.
- *
- * Per POSIX, the possible cases are:
- * success: returns zero, *result is non-NULL
- * uid not found: returns zero, *result is NULL
- * error during lookup: returns an errno code, *result is NULL
- * (caller should *not* assume that the errno variable is set)
- */
-static int
-pqGetpwuid(uid_t uid, struct passwd *resultbuf, char *buffer,
- size_t buflen, struct passwd **result)
-{
-#if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETPWUID_R)
- return getpwuid_r(uid, resultbuf, buffer, buflen, result);
-#else
- /* no getpwuid_r() available, just use getpwuid() */
- errno = 0;
- *result = getpwuid(uid);
- /* paranoia: ensure we return zero on success */
- return (*result == NULL) ? errno : 0;
-#endif
-}
-
/*
* pg_get_user_name - get the name of the user with the given ID
*
@@ -89,7 +39,7 @@ pg_get_user_name(uid_t user_id, char *buffer, size_t buflen)
struct passwd *pw = NULL;
int pwerr;
- pwerr = pqGetpwuid(user_id, &pwdstr, pwdbuf, sizeof(pwdbuf), &pw);
+ pwerr = getpwuid_r(user_id, &pwdstr, pwdbuf, sizeof(pwdbuf), &pw);
if (pw != NULL)
{
strlcpy(buffer, pw->pw_name, buflen);
@@ -125,7 +75,7 @@ pg_get_user_home_dir(uid_t user_id, char *buffer, size_t buflen)
struct passwd *pw = NULL;
int pwerr;
- pwerr = pqGetpwuid(user_id, &pwdstr, pwdbuf, sizeof(pwdbuf), &pw);
+ pwerr = getpwuid_r(user_id, &pwdstr, pwdbuf, sizeof(pwdbuf), &pw);
if (pw != NULL)
{
strlcpy(buffer, pw->pw_dir, buflen);
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 9ad22333ee..1e83583e76 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -275,7 +275,6 @@ sub GenerateFiles
HAVE_GETOPT_LONG => undef,
HAVE_GETPEEREID => undef,
HAVE_GETPEERUCRED => undef,
- HAVE_GETPWUID_R => undef,
HAVE_GETRLIMIT => undef,
HAVE_GETRUSAGE => undef,
HAVE_GETTIMEOFDAY => undef,
--
2.36.1
0006-Remove-disable-thread-safety.patchtext/x-patch; charset=US-ASCII; name=0006-Remove-disable-thread-safety.patchDownload
From afe047827118a51996bd97dabdb29a57c5b93ff7 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Fri, 26 Mar 2021 22:58:06 +1300
Subject: [PATCH 6/6] Remove --disable-thread-safety.
All supported operating systems either have the POSIX threads option, or
Windows native threads. We no longer test --disable-thread-safety
builds, and it is unlikely that anyone makes use of that build option.
Future work to improve our use of threads will be simplified by not
having to cope with a no-threads build option.
---
configure | 56 ++-------------
configure.ac | 28 ++------
doc/src/sgml/installation.sgml | 13 ----
doc/src/sgml/libpq.sgml | 3 +-
src/Makefile.global.in | 1 -
src/bin/pgbench/pgbench.c | 22 +-----
src/include/pg_config.h.in | 4 --
src/interfaces/ecpg/ecpglib/connect.c | 40 -----------
src/interfaces/ecpg/ecpglib/descriptor.c | 9 ---
src/interfaces/ecpg/ecpglib/ecpglib_extern.h | 2 -
src/interfaces/ecpg/ecpglib/execute.c | 2 -
src/interfaces/ecpg/ecpglib/memory.c | 7 --
src/interfaces/ecpg/ecpglib/misc.c | 47 ------------
.../ecpg/include/ecpg-pthread-win32.h | 3 -
src/interfaces/ecpg/include/ecpg_config.h.in | 4 --
src/interfaces/ecpg/include/ecpglib.h | 2 -
.../ecpg/test/expected/thread-alloc.c | 43 +++++------
.../ecpg/test/expected/thread-alloc_2.stdout | 1 -
.../ecpg/test/expected/thread-descriptor.c | 22 +++---
.../ecpg/test/expected/thread-prep.c | 71 ++++++++-----------
.../ecpg/test/expected/thread-prep.stdout | 1 -
.../ecpg/test/expected/thread-prep_2.stdout | 0
.../ecpg/test/expected/thread-thread.c | 63 +++++++---------
.../ecpg/test/expected/thread-thread.stdout | 2 +-
.../ecpg/test/expected/thread-thread_2.stdout | 1 -
.../test/expected/thread-thread_implicit.c | 63 +++++++---------
.../expected/thread-thread_implicit.stdout | 2 +-
.../expected/thread-thread_implicit_2.stdout | 1 -
src/interfaces/ecpg/test/thread/alloc.pgc | 9 ---
.../ecpg/test/thread/descriptor.pgc | 8 +--
src/interfaces/ecpg/test/thread/prep.pgc | 9 ---
src/interfaces/ecpg/test/thread/thread.pgc | 9 ---
.../ecpg/test/thread/thread_implicit.pgc | 9 ---
src/interfaces/libpq/Makefile | 2 -
src/interfaces/libpq/fe-auth.c | 9 ++-
src/interfaces/libpq/fe-connect.c | 4 --
src/interfaces/libpq/fe-exec.c | 4 --
src/interfaces/libpq/fe-print.c | 13 +---
src/interfaces/libpq/fe-secure-openssl.c | 17 +----
src/interfaces/libpq/fe-secure.c | 26 +------
src/interfaces/libpq/legacy-pqsignal.c | 4 --
src/interfaces/libpq/libpq-int.h | 9 +--
src/port/getaddrinfo.c | 2 +-
src/tools/msvc/Solution.pm | 3 +-
src/tools/msvc/ecpg_regression.proj | 2 +-
45 files changed, 142 insertions(+), 510 deletions(-)
delete mode 100644 src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-prep_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-thread_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
diff --git a/configure b/configure
index 5d9150fad2..67bde08cf1 100755
--- a/configure
+++ b/configure
@@ -728,7 +728,6 @@ with_tcl
ICU_LIBS
ICU_CFLAGS
with_icu
-enable_thread_safety
INCLUDES
autodepend
PKG_CONFIG_LIBDIR
@@ -851,7 +850,6 @@ with_CC
with_llvm
enable_depend
enable_cassert
-enable_thread_safety
with_icu
with_tcl
with_tclconfig
@@ -1540,7 +1538,6 @@ Optional Features:
--enable-tap-tests enable TAP tests (requires Perl and IPC::Run)
--enable-depend turn on automatic dependency tracking
--enable-cassert enable assertion checks (for debugging)
- --disable-thread-safety disable thread-safety in client libraries
--disable-largefile omit support for large files
Optional Packages:
@@ -7820,43 +7817,6 @@ $as_echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
done
IFS=$ac_save_IFS
-#
-# Enable thread-safe client libraries
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking allow thread-safe client libraries" >&5
-$as_echo_n "checking allow thread-safe client libraries... " >&6; }
-
-
-# Check whether --enable-thread-safety was given.
-if test "${enable_thread_safety+set}" = set; then :
- enableval=$enable_thread_safety;
- case $enableval in
- yes)
- :
- ;;
- no)
- :
- ;;
- *)
- as_fn_error $? "no argument expected for --enable-thread-safety option" "$LINENO" 5
- ;;
- esac
-
-else
- enable_thread_safety=yes
-
-fi
-
-
-if test "$enable_thread_safety" = yes; then
-
-$as_echo "#define ENABLE_THREAD_SAFETY 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_thread_safety" >&5
-$as_echo "$enable_thread_safety" >&6; }
-
-
#
# ICU
#
@@ -10935,7 +10895,7 @@ fi
done
-if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then :
+if "$PORTNAME" != "win32"; then :
# then
@@ -11594,7 +11554,7 @@ if test "x$ac_cv_header_pthread_h" = xyes; then :
else
as_fn_error $? "
-pthread.h not found; use --disable-thread-safety to disable thread safety" "$LINENO" 5
+pthread.h not found" "$LINENO" 5
fi
@@ -12335,8 +12295,7 @@ if test "$ac_res" != no; then :
fi
-if test "$enable_thread_safety" = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
$as_echo_n "checking for library containing gethostbyname_r... " >&6; }
if ${ac_cv_search_gethostbyname_r+:} false; then :
$as_echo_n "(cached) " >&6
@@ -12392,7 +12351,7 @@ if test "$ac_res" != no; then :
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
$as_echo_n "checking for library containing pthread_barrier_wait... " >&6; }
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
$as_echo_n "(cached) " >&6
@@ -12448,7 +12407,6 @@ if test "$ac_res" != no; then :
fi
-fi
if test "$with_readline" = yes; then
@@ -13321,7 +13279,7 @@ else
thread_safe_libldap=no
fi
- if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
+ if test "$thread_safe_libldap" = no; then
# Use ldap_r for FE if available, else assume ldap is thread-safe.
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
LIBS="$_LIBS"
@@ -16732,8 +16690,7 @@ fi
-if test "$enable_thread_safety" = yes; then
- ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
+ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
if test "x$ac_cv_func_pthread_barrier_wait" = xyes; then :
$as_echo "#define HAVE_PTHREAD_BARRIER_WAIT 1" >>confdefs.h
@@ -16747,7 +16704,6 @@ esac
fi
-fi
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
diff --git a/configure.ac b/configure.ac
index 6b7ac306a2..bdf7d9e304 100644
--- a/configure.ac
+++ b/configure.ac
@@ -775,18 +775,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
done
IFS=$ac_save_IFS
-#
-# Enable thread-safe client libraries
-#
-AC_MSG_CHECKING([allow thread-safe client libraries])
-PGAC_ARG_BOOL(enable, thread-safety, yes, [disable thread-safety in client libraries])
-if test "$enable_thread_safety" = yes; then
- AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
- [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])
-fi
-AC_MSG_RESULT([$enable_thread_safety])
-AC_SUBST(enable_thread_safety)
-
#
# ICU
#
@@ -1184,7 +1172,7 @@ dnl note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
dnl invocation below is the first one in the script, and autoconf generates
dnl additional code for that, which must not be inside the if-block. AS_IF
dnl knows how to do that.
-AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
+AS_IF(["$PORTNAME" != "win32"],
[ # then
AX_PTHREAD # set thread flags
@@ -1199,7 +1187,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
-pthread.h not found; use --disable-thread-safety to disable thread safety])])
+pthread.h not found])])
AC_CHECK_FUNCS([strerror_r gethostbyname_r])
@@ -1247,10 +1235,8 @@ AC_SEARCH_LIBS(shmget, cygipc)
# *BSD:
AC_SEARCH_LIBS(backtrace_symbols, execinfo)
-if test "$enable_thread_safety" = yes; then
- AC_SEARCH_LIBS(gethostbyname_r, nsl)
- AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
-fi
+AC_SEARCH_LIBS(gethostbyname_r, nsl)
+AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
if test "$with_readline" = yes; then
PGAC_CHECK_READLINE
@@ -1375,7 +1361,7 @@ if test "$with_ldap" = yes ; then
AC_CHECK_FUNC([ldap_verify_credentials],
[thread_safe_libldap=yes],
[thread_safe_libldap=no])
- if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
+ if test "$thread_safe_libldap" = no; then
# Use ldap_r for FE if available, else assume ldap is thread-safe.
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
LIBS="$_LIBS"
@@ -1886,9 +1872,7 @@ AC_REPLACE_FUNCS(m4_normalize([
strtof
]))
-if test "$enable_thread_safety" = yes; then
- AC_REPLACE_FUNCS(pthread_barrier_wait)
-fi
+AC_REPLACE_FUNCS(pthread_barrier_wait)
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1a1343a008..8b4ca85c8a 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1285,19 +1285,6 @@ build-postgresql:
</listitem>
</varlistentry>
- <varlistentry>
- <term><option>--disable-thread-safety</option></term>
- <listitem>
- <para>
- Disable the thread-safety of client libraries. This prevents
- concurrent threads in <application>libpq</application> and
- <application>ECPG</application> programs from safely controlling
- their private connection handles. Use this only on platforms
- with deficient threading support.
- </para>
- </listitem>
- </varlistentry>
-
</variablelist>
</sect3>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 74456aa69d..655b4db31e 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -8837,7 +8837,8 @@ int PQisthreadsafe();
<para>
Returns 1 if the <application>libpq</application> is thread-safe
- and 0 if it is not.
+ and 0 if it is not. Since <productname>PostgreSQL</productname> version
+ 16, this function always returns 1.
</para>
</listitem>
</varlistentry>
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 138d66ac00..3d2e4ce90d 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -202,7 +202,6 @@ enable_debug = @enable_debug@
enable_dtrace = @enable_dtrace@
enable_coverage = @enable_coverage@
enable_tap_tests = @enable_tap_tests@
-enable_thread_safety = @enable_thread_safety@
python_includespec = @python_includespec@
python_libdir = @python_libdir@
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index bcaea8f5ea..dc1915fcfd 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -140,7 +140,7 @@ typedef struct socket_set
EnterSynchronizationBarrier((barrier), \
SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
#define THREAD_BARRIER_DESTROY(barrier)
-#elif defined(ENABLE_THREAD_SAFETY)
+#else
/* Use POSIX threads */
#include "port/pg_pthread.h"
#define THREAD_T pthread_t
@@ -156,16 +156,6 @@ typedef struct socket_set
pthread_barrier_init((barrier), NULL, (n))
#define THREAD_BARRIER_WAIT(barrier) pthread_barrier_wait((barrier))
#define THREAD_BARRIER_DESTROY(barrier) pthread_barrier_destroy((barrier))
-#else
-/* No threads implementation, use none (-j 1) */
-#define THREAD_T void *
-#define THREAD_FUNC_RETURN_TYPE void *
-#define THREAD_FUNC_RETURN return NULL
-#define THREAD_FUNC_CC
-#define THREAD_BARRIER_T int
-#define THREAD_BARRIER_INIT(barrier, n) (*(barrier) = 0)
-#define THREAD_BARRIER_WAIT(barrier)
-#define THREAD_BARRIER_DESTROY(barrier)
#endif
@@ -6684,10 +6674,6 @@ main(int argc, char **argv)
{
exit(1);
}
-#ifndef ENABLE_THREAD_SAFETY
- if (nthreads != 1)
- pg_fatal("threads are not supported on this platform; use -j1");
-#endif /* !ENABLE_THREAD_SAFETY */
break;
case 'C':
benchmarking_option_set = true;
@@ -7201,7 +7187,6 @@ main(int argc, char **argv)
if (errno != 0)
pg_fatal("could not initialize barrier: %m");
-#ifdef ENABLE_THREAD_SAFETY
/* start all threads but thread 0 which is executed directly later */
for (i = 1; i < nthreads; i++)
{
@@ -7213,9 +7198,6 @@ main(int argc, char **argv)
if (errno != 0)
pg_fatal("could not create thread: %m");
}
-#else
- Assert(nthreads == 1);
-#endif /* ENABLE_THREAD_SAFETY */
/* compute when to stop */
threads[0].create_time = pg_time_now();
@@ -7233,10 +7215,8 @@ main(int argc, char **argv)
{
TState *thread = &threads[i];
-#ifdef ENABLE_THREAD_SAFETY
if (i > 0)
THREAD_JOIN(thread->thread);
-#endif /* ENABLE_THREAD_SAFETY */
for (int j = 0; j < thread->nstate; j++)
if (thread->state[j].state != CSTATE_FINISHED)
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 716baf2e91..ad831ef3d9 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -51,10 +51,6 @@
/* Define to 1 if you want National Language Support. (--enable-nls) */
#undef ENABLE_NLS
-/* Define to 1 to build client libraries as thread-safe code.
- (--enable-thread-safety) */
-#undef ENABLE_THREAD_SAFETY
-
/* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index db0bae1fe0..8afb1f0a26 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -14,15 +14,12 @@
locale_t ecpg_clocale = (locale_t) 0;
#endif
-#ifdef ENABLE_THREAD_SAFETY
static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t actual_connection_key;
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
-#endif
static struct connection *actual_connection = NULL;
static struct connection *all_connections = NULL;
-#ifdef ENABLE_THREAD_SAFETY
static void
ecpg_actual_connection_init(void)
{
@@ -34,7 +31,6 @@ ecpg_pthreads_init(void)
{
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
}
-#endif
static struct connection *
ecpg_get_connection_nr(const char *connection_name)
@@ -43,7 +39,6 @@ ecpg_get_connection_nr(const char *connection_name)
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
{
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init(); /* ensure actual_connection_key is valid */
ret = pthread_getspecific(actual_connection_key);
@@ -56,9 +51,6 @@ ecpg_get_connection_nr(const char *connection_name)
if (ret == NULL)
/* no TSD connection, going for global */
ret = actual_connection;
-#else
- ret = actual_connection;
-#endif
}
else
{
@@ -82,7 +74,6 @@ ecpg_get_connection(const char *connection_name)
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
{
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init(); /* ensure actual_connection_key is valid */
ret = pthread_getspecific(actual_connection_key);
@@ -95,21 +86,14 @@ ecpg_get_connection(const char *connection_name)
if (ret == NULL)
/* no TSD connection here either, using global */
ret = actual_connection;
-#else
- ret = actual_connection;
-#endif
}
else
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
ret = ecpg_get_connection_nr(connection_name);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
}
return ret;
@@ -143,10 +127,8 @@ ecpg_finish(struct connection *act)
con->next = act->next;
}
-#ifdef ENABLE_THREAD_SAFETY
if (pthread_getspecific(actual_connection_key) == act)
pthread_setspecific(actual_connection_key, all_connections);
-#endif
if (actual_connection == act)
actual_connection = all_connections;
@@ -212,11 +194,7 @@ ECPGsetconn(int lineno, const char *connection_name)
if (!ecpg_init(con, connection_name, lineno))
return false;
-#ifdef ENABLE_THREAD_SAFETY
pthread_setspecific(actual_connection_key, con);
-#else
- actual_connection = con;
-#endif
return true;
}
@@ -326,9 +304,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (dbname == NULL && connection_name == NULL)
connection_name = "DEFAULT";
-#if ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
-#endif
/* check if the identifier is unique */
if (ecpg_get_connection(connection_name))
@@ -505,9 +481,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
/* add connection to our list */
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
/*
* ... but first, make certain we have created ecpg_clocale. Rely on
@@ -519,9 +493,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
ecpg_clocale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
if (!ecpg_clocale)
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY,
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
if (host)
@@ -558,9 +530,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
this->next = all_connections;
all_connections = this;
-#ifdef ENABLE_THREAD_SAFETY
pthread_setspecific(actual_connection_key, all_connections);
-#endif
actual_connection = all_connections;
ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s %s%s\n",
@@ -678,9 +648,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
ecpg_log("ECPGconnect: %s", errmsg);
ecpg_finish(this);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db);
if (realname)
@@ -692,9 +660,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (realname)
ecpg_free(realname);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
this->autocommit = autocommit;
@@ -716,9 +682,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
if (strcmp(connection_name, "ALL") == 0)
{
@@ -737,18 +701,14 @@ ECPGdisconnect(int lineno, const char *connection_name)
if (!ecpg_init(con, connection_name, lineno))
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
return false;
}
else
ecpg_finish(con);
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
return true;
}
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index 649a71c286..b47f422d92 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -19,7 +19,6 @@
static void descriptor_free(struct descriptor *desc);
/* We manage descriptors separately for each thread. */
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t descriptor_key;
static pthread_once_t descriptor_once = PTHREAD_ONCE_INIT;
@@ -49,12 +48,6 @@ set_descriptors(struct descriptor *value)
{
pthread_setspecific(descriptor_key, value);
}
-#else
-static struct descriptor *all_descriptors = NULL;
-
-#define get_descriptors() (all_descriptors)
-#define set_descriptors(value) do { all_descriptors = (value); } while(0)
-#endif
/* old internal convenience function that might go away later */
static PGresult *
@@ -782,7 +775,6 @@ ECPGdeallocate_desc(int line, const char *name)
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
/* Deallocate all descriptors in the list */
static void
@@ -796,7 +788,6 @@ descriptor_deallocate_all(struct descriptor *list)
list = next;
}
}
-#endif /* ENABLE_THREAD_SAFETY */
bool
ECPGallocate_desc(int line, const char *name)
diff --git a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
index c438cfb820..968f1211b8 100644
--- a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
+++ b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
@@ -169,9 +169,7 @@ bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum COMPAT_MODE, bool);
-#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
-#endif
struct connection *ecpg_get_connection(const char *);
char *ecpg_alloc(long, int);
char *ecpg_auto_alloc(long, int);
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index bd94bd4e6c..0b2716d921 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1961,9 +1961,7 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
-#endif
con = ecpg_get_connection(connection_name);
diff --git a/src/interfaces/ecpg/ecpglib/memory.c b/src/interfaces/ecpg/ecpglib/memory.c
index bd81251054..a83637ac75 100644
--- a/src/interfaces/ecpg/ecpglib/memory.c
+++ b/src/interfaces/ecpg/ecpglib/memory.c
@@ -68,7 +68,6 @@ struct auto_mem
struct auto_mem *next;
};
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t auto_mem_key;
static pthread_once_t auto_mem_once = PTHREAD_ONCE_INIT;
@@ -97,12 +96,6 @@ set_auto_allocs(struct auto_mem *am)
{
pthread_setspecific(auto_mem_key, am);
}
-#else
-static struct auto_mem *auto_allocs = NULL;
-
-#define get_auto_allocs() (auto_allocs)
-#define set_auto_allocs(am) do { auto_allocs = (am); } while(0)
-#endif
char *
ecpg_auto_alloc(long size, int lineno)
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 1eef1ec044..71f07c4e4f 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -55,42 +55,11 @@ static struct sqlca_t sqlca_init =
}
};
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t sqlca_key;
static pthread_once_t sqlca_key_once = PTHREAD_ONCE_INIT;
-#else
-static struct sqlca_t sqlca =
-{
- {
- 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
- },
- sizeof(struct sqlca_t),
- 0,
- {
- 0,
- {
- 0
- }
- },
- {
- 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
- },
- {
- 0, 0, 0, 0, 0, 0
- },
- {
- 0, 0, 0, 0, 0, 0, 0, 0
- },
- {
- '0', '0', '0', '0', '0'
- }
-};
-#endif
-#ifdef ENABLE_THREAD_SAFETY
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t debug_init_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
static int simple_debug = 0;
static FILE *debugstream = NULL;
@@ -123,7 +92,6 @@ ecpg_init(const struct connection *con, const char *connection_name, const int l
return true;
}
-#ifdef ENABLE_THREAD_SAFETY
static void
ecpg_sqlca_key_destructor(void *arg)
{
@@ -135,12 +103,10 @@ ecpg_sqlca_key_init(void)
{
pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
}
-#endif
struct sqlca_t *
ECPGget_sqlca(void)
{
-#ifdef ENABLE_THREAD_SAFETY
struct sqlca_t *sqlca;
pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);
@@ -155,9 +121,6 @@ ECPGget_sqlca(void)
pthread_setspecific(sqlca_key, sqlca);
}
return sqlca;
-#else
- return &sqlca;
-#endif
}
bool
@@ -240,9 +203,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
void
ECPGdebug(int n, FILE *dbgs)
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&debug_init_mutex);
-#endif
if (n > 100)
{
@@ -256,9 +217,7 @@ ECPGdebug(int n, FILE *dbgs)
ecpg_log("ECPGdebug: set to %d\n", simple_debug);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&debug_init_mutex);
-#endif
}
void
@@ -290,9 +249,7 @@ ecpg_log(const char *format,...)
else
snprintf(fmt, bufsize, "[%d]: %s", (int) getpid(), intl_format);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&debug_mutex);
-#endif
va_start(ap, format);
vfprintf(debugstream, fmt, ap);
@@ -307,9 +264,7 @@ ecpg_log(const char *format,...)
fflush(debugstream);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&debug_mutex);
-#endif
free(fmt);
}
@@ -451,7 +406,6 @@ ECPGis_noind_null(enum ECPGttype type, const void *ptr)
}
#ifdef WIN32
-#ifdef ENABLE_THREAD_SAFETY
void
win32_pthread_mutex(volatile pthread_mutex_t *mutex)
@@ -482,7 +436,6 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void))
pthread_mutex_unlock(&win32_pthread_once_lock);
}
}
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
#ifdef ENABLE_NLS
diff --git a/src/interfaces/ecpg/include/ecpg-pthread-win32.h b/src/interfaces/ecpg/include/ecpg-pthread-win32.h
index 33c897b633..8252a17809 100644
--- a/src/interfaces/ecpg/include/ecpg-pthread-win32.h
+++ b/src/interfaces/ecpg/include/ecpg-pthread-win32.h
@@ -5,8 +5,6 @@
#ifndef _ECPG_PTHREAD_WIN32_H
#define _ECPG_PTHREAD_WIN32_H
-#ifdef ENABLE_THREAD_SAFETY
-
#ifndef WIN32
#include <pthread.h>
@@ -53,6 +51,5 @@ void win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void));
win32_pthread_once((once), (fn)); \
} while(0)
#endif /* WIN32 */
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* _ECPG_PTHREAD_WIN32_H */
diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in
index cbd24f11a0..6d01608a49 100644
--- a/src/interfaces/ecpg/include/ecpg_config.h.in
+++ b/src/interfaces/ecpg/include/ecpg_config.h.in
@@ -1,7 +1,3 @@
-/* Define to 1 to build client libraries as thread-safe code.
- * (--enable-thread-safety) */
-#undef ENABLE_THREAD_SAFETY
-
/* Define to 1 if the system has the type `int64'. */
#undef HAVE_INT64
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 00240109a6..05433726ac 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -92,9 +92,7 @@ void *ECPGget_var(int number);
/* dynamic result allocation */
void ECPGfree_auto_mem(void);
-#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
-#endif
#ifdef __cplusplus
}
diff --git a/src/interfaces/ecpg/test/expected/thread-alloc.c b/src/interfaces/ecpg/test/expected/thread-alloc.c
index 37ef44ed94..3b31d27fd3 100644
--- a/src/interfaces/ecpg/test/expected/thread-alloc.c
+++ b/src/interfaces/ecpg/test/expected/thread-alloc.c
@@ -11,14 +11,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -101,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 26 "alloc.pgc"
+#line 18 "alloc.pgc"
#line 1 "regression.h"
@@ -111,14 +103,14 @@ struct sqlca_t *ECPGget_sqlca(void);
-#line 27 "alloc.pgc"
+#line 19 "alloc.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 29 "alloc.pgc"
+#line 21 "alloc.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 30 "alloc.pgc"
+#line 22 "alloc.pgc"
#ifdef WIN32
@@ -134,54 +126,54 @@ static void* fn(void* arg)
-#line 41 "alloc.pgc"
+#line 33 "alloc.pgc"
int value ;
-#line 42 "alloc.pgc"
+#line 34 "alloc.pgc"
char name [ 100 ] ;
-#line 43 "alloc.pgc"
+#line 35 "alloc.pgc"
char ** r = NULL ;
/* exec sql end declare section */
-#line 44 "alloc.pgc"
+#line 36 "alloc.pgc"
value = (intptr_t) arg;
sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
-#line 49 "alloc.pgc"
+#line 41 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "alloc.pgc"
+#line 41 "alloc.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 50 "alloc.pgc"
+#line 42 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 50 "alloc.pgc"
+#line 42 "alloc.pgc"
for (i = 1; i <= REPEATS; ++i)
{
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT,
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
free(r);
r = NULL;
}
{ ECPGdisconnect(__LINE__, name);
-#line 57 "alloc.pgc"
+#line 49 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 57 "alloc.pgc"
+#line 49 "alloc.pgc"
return 0;
@@ -215,4 +207,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout b/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
deleted file mode 100644
index 75fe16bb36..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-No threading enabled.
diff --git a/src/interfaces/ecpg/test/expected/thread-descriptor.c b/src/interfaces/ecpg/test/expected/thread-descriptor.c
index f56cc25ab0..e34f4708d1 100644
--- a/src/interfaces/ecpg/test/expected/thread-descriptor.c
+++ b/src/interfaces/ecpg/test/expected/thread-descriptor.c
@@ -7,7 +7,6 @@
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "descriptor.pgc"
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -16,7 +15,6 @@
#else
#include <pthread.h>
#endif
-#endif
#include <stdio.h>
#define THREADS 16
@@ -91,16 +89,16 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 16 "descriptor.pgc"
+#line 14 "descriptor.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 17 "descriptor.pgc"
+#line 15 "descriptor.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 18 "descriptor.pgc"
+#line 16 "descriptor.pgc"
-#if defined(ENABLE_THREAD_SAFETY) && defined(WIN32)
+#if defined(WIN32)
static unsigned __stdcall fn(void* arg)
#else
static void* fn(void* arg)
@@ -111,16 +109,16 @@ static void* fn(void* arg)
for (i = 1; i <= REPEATS; ++i)
{
ECPGallocate_desc(__LINE__, "mydesc");
-#line 30 "descriptor.pgc"
+#line 28 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
-#line 30 "descriptor.pgc"
+#line 28 "descriptor.pgc"
ECPGdeallocate_desc(__LINE__, "mydesc");
-#line 31 "descriptor.pgc"
+#line 29 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
-#line 31 "descriptor.pgc"
+#line 29 "descriptor.pgc"
}
@@ -129,7 +127,6 @@ if (sqlca.sqlcode < 0) sqlprint();
int main ()
{
-#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@@ -153,9 +150,6 @@ int main ()
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
-#else
- fn(NULL);
-#endif
return 0;
}
diff --git a/src/interfaces/ecpg/test/expected/thread-prep.c b/src/interfaces/ecpg/test/expected/thread-prep.c
index 7cdf2505d3..052e27b634 100644
--- a/src/interfaces/ecpg/test/expected/thread-prep.c
+++ b/src/interfaces/ecpg/test/expected/thread-prep.c
@@ -11,14 +11,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -101,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 26 "prep.pgc"
+#line 18 "prep.pgc"
#line 1 "regression.h"
@@ -111,14 +103,14 @@ struct sqlca_t *ECPGget_sqlca(void);
-#line 27 "prep.pgc"
+#line 19 "prep.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 29 "prep.pgc"
+#line 21 "prep.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 30 "prep.pgc"
+#line 22 "prep.pgc"
#ifdef WIN32
@@ -134,64 +126,64 @@ static void* fn(void* arg)
-#line 41 "prep.pgc"
+#line 33 "prep.pgc"
int value ;
-#line 42 "prep.pgc"
+#line 34 "prep.pgc"
char name [ 100 ] ;
-#line 43 "prep.pgc"
+#line 35 "prep.pgc"
char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
/* exec sql end declare section */
-#line 44 "prep.pgc"
+#line 36 "prep.pgc"
value = (intptr_t) arg;
sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
-#line 49 "prep.pgc"
+#line 41 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "prep.pgc"
+#line 41 "prep.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 50 "prep.pgc"
+#line 42 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 50 "prep.pgc"
+#line 42 "prep.pgc"
for (i = 1; i <= REPEATS; ++i)
{
{ ECPGprepare(__LINE__, NULL, 0, "i", query);
-#line 53 "prep.pgc"
+#line 45 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 53 "prep.pgc"
+#line 45 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i",
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
}
{ ECPGdeallocate(__LINE__, 0, NULL, "i");
-#line 56 "prep.pgc"
+#line 48 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 56 "prep.pgc"
+#line 48 "prep.pgc"
{ ECPGdisconnect(__LINE__, name);
-#line 57 "prep.pgc"
+#line 49 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 57 "prep.pgc"
+#line 49 "prep.pgc"
return 0;
@@ -207,34 +199,34 @@ int main ()
#endif
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
-#line 71 "prep.pgc"
+#line 63 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 71 "prep.pgc"
+#line 63 "prep.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 72 "prep.pgc"
+#line 64 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 72 "prep.pgc"
+#line 64 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
-#line 73 "prep.pgc"
+#line 65 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 73 "prep.pgc"
+#line 65 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
-#line 74 "prep.pgc"
+#line 66 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 74 "prep.pgc"
+#line 66 "prep.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 75 "prep.pgc"
+#line 67 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 75 "prep.pgc"
+#line 67 "prep.pgc"
#ifdef WIN32
@@ -256,4 +248,3 @@ if (sqlca.sqlcode < 0) sqlprint();}
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/expected/thread-prep.stdout b/src/interfaces/ecpg/test/expected/thread-prep.stdout
index 75fe16bb36..e69de29bb2 100644
--- a/src/interfaces/ecpg/test/expected/thread-prep.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-prep.stdout
@@ -1 +0,0 @@
-No threading enabled.
diff --git a/src/interfaces/ecpg/test/expected/thread-prep_2.stdout b/src/interfaces/ecpg/test/expected/thread-prep_2.stdout
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.c b/src/interfaces/ecpg/test/expected/thread-thread.c
index 0e75c47fab..95faa223c2 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread.c
@@ -15,14 +15,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -38,7 +30,7 @@ main(void)
-#line 24 "thread.pgc"
+#line 16 "thread.pgc"
void *test_thread(void *arg);
@@ -57,10 +49,10 @@ int main()
/* exec sql begin declare section */
-#line 40 "thread.pgc"
+#line 32 "thread.pgc"
int l_rows ;
/* exec sql end declare section */
-#line 41 "thread.pgc"
+#line 33 "thread.pgc"
/* Do not switch on debug output for regression tests. The threads get executed in
@@ -69,22 +61,22 @@ int main()
/* setup test_thread table */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 48 "thread.pgc"
+#line 40 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
-#line 49 "thread.pgc"
+#line 41 "thread.pgc"
/* DROP might fail */
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 50 "thread.pgc"
+#line 42 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
-#line 55 "thread.pgc"
+#line 47 "thread.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 56 "thread.pgc"
+#line 48 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 57 "thread.pgc"
+#line 49 "thread.pgc"
/* create, and start, threads */
@@ -116,18 +108,18 @@ int main()
/* and check results */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 87 "thread.pgc"
+#line 79 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 88 "thread.pgc"
+#line 80 "thread.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 89 "thread.pgc"
+#line 81 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 90 "thread.pgc"
+#line 82 "thread.pgc"
if( l_rows == (nthreads * iterations) )
printf("Success.\n");
@@ -145,13 +137,13 @@ void *test_thread(void *arg)
-#line 104 "thread.pgc"
+#line 96 "thread.pgc"
int l_i ;
-#line 105 "thread.pgc"
+#line 97 "thread.pgc"
char l_connection [ 128 ] ;
/* exec sql end declare section */
-#line 106 "thread.pgc"
+#line 98 "thread.pgc"
/* build up connection name, and connect to database */
@@ -161,13 +153,13 @@ void *test_thread(void *arg)
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
#endif
/* exec sql whenever sqlerror sqlprint ; */
-#line 114 "thread.pgc"
+#line 106 "thread.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
-#line 115 "thread.pgc"
+#line 107 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 115 "thread.pgc"
+#line 107 "thread.pgc"
if( sqlca.sqlcode != 0 )
{
@@ -175,10 +167,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
return NULL;
}
{ ECPGtrans(__LINE__, l_connection, "begin");
-#line 121 "thread.pgc"
+#line 113 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 121 "thread.pgc"
+#line 113 "thread.pgc"
/* insert into test_thread table */
@@ -189,10 +181,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 126 "thread.pgc"
+#line 118 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 126 "thread.pgc"
+#line 118 "thread.pgc"
if( sqlca.sqlcode != 0 )
printf("%s: ERROR: insert failed!\n", l_connection);
@@ -200,17 +192,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
/* all done */
{ ECPGtrans(__LINE__, l_connection, "commit");
-#line 132 "thread.pgc"
+#line 124 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 132 "thread.pgc"
+#line 124 "thread.pgc"
{ ECPGdisconnect(__LINE__, l_connection);
-#line 133 "thread.pgc"
+#line 125 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 133 "thread.pgc"
+#line 125 "thread.pgc"
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.stdout b/src/interfaces/ecpg/test/expected/thread-thread.stdout
index 75fe16bb36..a9d787cc55 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-thread.stdout
@@ -1 +1 @@
-No threading enabled.
+Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_2.stdout b/src/interfaces/ecpg/test/expected/thread-thread_2.stdout
deleted file mode 100644
index a9d787cc55..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-thread_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
index 0df2794530..7ac0297a23 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
@@ -15,14 +15,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -38,7 +30,7 @@ main(void)
-#line 24 "thread_implicit.pgc"
+#line 16 "thread_implicit.pgc"
void *test_thread(void *arg);
@@ -57,10 +49,10 @@ int main()
/* exec sql begin declare section */
-#line 40 "thread_implicit.pgc"
+#line 32 "thread_implicit.pgc"
int l_rows ;
/* exec sql end declare section */
-#line 41 "thread_implicit.pgc"
+#line 33 "thread_implicit.pgc"
/* Do not switch on debug output for regression tests. The threads get executed in
@@ -69,22 +61,22 @@ int main()
/* setup test_thread table */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 48 "thread_implicit.pgc"
+#line 40 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
-#line 49 "thread_implicit.pgc"
+#line 41 "thread_implicit.pgc"
/* DROP might fail */
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 50 "thread_implicit.pgc"
+#line 42 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
-#line 55 "thread_implicit.pgc"
+#line 47 "thread_implicit.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 56 "thread_implicit.pgc"
+#line 48 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 57 "thread_implicit.pgc"
+#line 49 "thread_implicit.pgc"
/* create, and start, threads */
@@ -116,18 +108,18 @@ int main()
/* and check results */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 87 "thread_implicit.pgc"
+#line 79 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 88 "thread_implicit.pgc"
+#line 80 "thread_implicit.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 89 "thread_implicit.pgc"
+#line 81 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 90 "thread_implicit.pgc"
+#line 82 "thread_implicit.pgc"
if( l_rows == (nthreads * iterations) )
printf("Success.\n");
@@ -145,13 +137,13 @@ void *test_thread(void *arg)
-#line 104 "thread_implicit.pgc"
+#line 96 "thread_implicit.pgc"
int l_i ;
-#line 105 "thread_implicit.pgc"
+#line 97 "thread_implicit.pgc"
char l_connection [ 128 ] ;
/* exec sql end declare section */
-#line 106 "thread_implicit.pgc"
+#line 98 "thread_implicit.pgc"
/* build up connection name, and connect to database */
@@ -161,13 +153,13 @@ void *test_thread(void *arg)
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
#endif
/* exec sql whenever sqlerror sqlprint ; */
-#line 114 "thread_implicit.pgc"
+#line 106 "thread_implicit.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
-#line 115 "thread_implicit.pgc"
+#line 107 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 115 "thread_implicit.pgc"
+#line 107 "thread_implicit.pgc"
if( sqlca.sqlcode != 0 )
{
@@ -175,10 +167,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
return NULL;
}
{ ECPGtrans(__LINE__, NULL, "begin");
-#line 121 "thread_implicit.pgc"
+#line 113 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 121 "thread_implicit.pgc"
+#line 113 "thread_implicit.pgc"
/* insert into test_thread table */
@@ -189,10 +181,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 126 "thread_implicit.pgc"
+#line 118 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 126 "thread_implicit.pgc"
+#line 118 "thread_implicit.pgc"
if( sqlca.sqlcode != 0 )
printf("%s: ERROR: insert failed!\n", l_connection);
@@ -200,17 +192,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
/* all done */
{ ECPGtrans(__LINE__, NULL, "commit");
-#line 132 "thread_implicit.pgc"
+#line 124 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 132 "thread_implicit.pgc"
+#line 124 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, l_connection);
-#line 133 "thread_implicit.pgc"
+#line 125 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 133 "thread_implicit.pgc"
+#line 125 "thread_implicit.pgc"
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout b/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
index 75fe16bb36..a9d787cc55 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
@@ -1 +1 @@
-No threading enabled.
+Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout b/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
deleted file mode 100644
index a9d787cc55..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-Success.
diff --git a/src/interfaces/ecpg/test/thread/alloc.pgc b/src/interfaces/ecpg/test/thread/alloc.pgc
index c0021a737e..d3d35493bf 100644
--- a/src/interfaces/ecpg/test/thread/alloc.pgc
+++ b/src/interfaces/ecpg/test/thread/alloc.pgc
@@ -2,14 +2,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -87,4 +79,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/thread/descriptor.pgc b/src/interfaces/ecpg/test/thread/descriptor.pgc
index 76a7a5dff5..30bce7c87b 100644
--- a/src/interfaces/ecpg/test/thread/descriptor.pgc
+++ b/src/interfaces/ecpg/test/thread/descriptor.pgc
@@ -1,4 +1,3 @@
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -7,7 +6,6 @@
#else
#include <pthread.h>
#endif
-#endif
#include <stdio.h>
#define THREADS 16
@@ -17,7 +15,7 @@ EXEC SQL include sqlca;
EXEC SQL whenever sqlerror sqlprint;
EXEC SQL whenever not found sqlprint;
-#if defined(ENABLE_THREAD_SAFETY) && defined(WIN32)
+#if defined(WIN32)
static unsigned __stdcall fn(void* arg)
#else
static void* fn(void* arg)
@@ -36,7 +34,6 @@ static void* fn(void* arg)
int main ()
{
-#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@@ -60,9 +57,6 @@ int main ()
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
-#else
- fn(NULL);
-#endif
return 0;
}
diff --git a/src/interfaces/ecpg/test/thread/prep.pgc b/src/interfaces/ecpg/test/thread/prep.pgc
index d7ecfd4855..f61b31ce10 100644
--- a/src/interfaces/ecpg/test/thread/prep.pgc
+++ b/src/interfaces/ecpg/test/thread/prep.pgc
@@ -2,14 +2,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -93,4 +85,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/thread/thread.pgc b/src/interfaces/ecpg/test/thread/thread.pgc
index e7d8c00af6..b9b9ebb441 100644
--- a/src/interfaces/ecpg/test/thread/thread.pgc
+++ b/src/interfaces/ecpg/test/thread/thread.pgc
@@ -6,14 +6,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -133,4 +125,3 @@ void *test_thread(void *arg)
EXEC SQL DISCONNECT :l_connection;
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/thread/thread_implicit.pgc b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
index b4cae7e1ae..ff9b12a943 100644
--- a/src/interfaces/ecpg/test/thread/thread_implicit.pgc
+++ b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
@@ -6,14 +6,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -133,4 +125,3 @@ void *test_thread(void *arg)
EXEC SQL DISCONNECT :l_connection;
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index b5fd72a4ac..bd43871c69 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -71,10 +71,8 @@ ifeq ($(PORTNAME), win32)
OBJS += \
win32.o
-ifeq ($(enable_thread_safety), yes)
OBJS += pthread-win32.o
endif
-endif
# Add libraries that libpq depends (or might depend) on into the
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 49a1c626f6..3504ab2c34 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -1116,11 +1116,10 @@ pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
#endif
/*
- * Some users are using configure --enable-thread-safety-force, so we
- * might as well do the locking within our library to protect getpwuid().
- * In fact, application developers can use getpwuid() in their application
- * if they use the locking call we provide, or install their own locking
- * function using PQregisterThreadLock().
+ * We do the locking within our library to protect getpwuid(). Application
+ * developers can use getpwuid() in their application if they use the
+ * locking call we provide, or install their own locking function using
+ * PQregisterThreadLock().
*/
pglock_thread();
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index dc49387d6c..7f14026777 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -55,13 +55,11 @@
#endif
#endif
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
#ifdef USE_LDAP
#ifdef WIN32
@@ -7364,7 +7362,6 @@ pqGetHomeDirectory(char *buf, int bufsize)
static void
default_threadlock(int acquire)
{
-#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
#else
@@ -7393,7 +7390,6 @@ default_threadlock(int acquire)
if (pthread_mutex_unlock(&singlethread_lock))
Assert(false);
}
-#endif
}
pgthreadlock_t
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index e20d6177fe..37dc81bf17 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -3923,11 +3923,7 @@ PQisnonblocking(const PGconn *conn)
int
PQisthreadsafe(void)
{
-#ifdef ENABLE_THREAD_SAFETY
return true;
-#else
- return false;
-#endif
}
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 783cd9b756..2dc0f1afb9 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -88,14 +88,11 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
bool usePipe = false;
char *pagerenv;
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
sigset_t osigset;
bool sigpipe_masked = false;
bool sigpipe_pending;
#endif
-#if !defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
- pqsigfunc oldsigpipehandler = NULL;
-#endif
#ifdef TIOCGWINSZ
struct winsize screen_size;
@@ -185,12 +182,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
{
usePipe = true;
#ifndef WIN32
-#ifdef ENABLE_THREAD_SAFETY
if (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0)
sigpipe_masked = true;
-#else
- oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN);
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
}
else
@@ -323,13 +316,9 @@ exit:
#else
pclose(fout);
-#ifdef ENABLE_THREAD_SAFETY
/* we can't easily verify if EPIPE occurred, so say it did */
if (sigpipe_masked)
pq_reset_sigpipe(&osigset, sigpipe_pending, true);
-#else
- pqsignal(SIGPIPE, oldsigpipehandler);
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
}
}
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 8117cbd40f..01b2494bb4 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -46,13 +46,11 @@
#include <sys/stat.h>
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
/*
* These SSL-related #includes must come after all system-provided headers.
@@ -93,7 +91,6 @@ static bool pq_init_crypto_lib = true;
static bool ssl_lib_initialized = false;
-#ifdef ENABLE_THREAD_SAFETY
static long crypto_open_connections = 0;
#ifndef WIN32
@@ -102,7 +99,6 @@ static pthread_mutex_t ssl_config_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t ssl_config_mutex = NULL;
static long win32_ssl_create_mutex = 0;
#endif
-#endif /* ENABLE_THREAD_SAFETY */
static PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook = NULL;
static int ssl_protocol_version_to_openssl(const char *protocol);
@@ -114,15 +110,12 @@ static int ssl_protocol_version_to_openssl(const char *protocol);
void
pgtls_init_library(bool do_ssl, int do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
-
/*
* Disallow changing the flags while we have open connections, else we'd
* get completely confused.
*/
if (crypto_open_connections != 0)
return;
-#endif
pq_init_ssl_lib = do_ssl;
pq_init_crypto_lib = do_crypto;
@@ -709,7 +702,7 @@ pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn,
return rc;
}
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/*
* Callback functions for OpenSSL internal locking. (OpenSSL 1.1.0
* does its own locking, and doesn't need these anymore. The
@@ -750,7 +743,7 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
Assert(false);
}
}
-#endif /* ENABLE_THREAD_SAFETY && HAVE_CRYPTO_LOCK */
+#endif /* HAVE_CRYPTO_LOCK */
/*
* Initialize SSL library.
@@ -765,7 +758,6 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
int
pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
/* Also see similar code in fe-connect.c, default_threadlock() */
if (ssl_config_mutex == NULL)
@@ -831,7 +823,6 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
}
}
#endif /* HAVE_CRYPTO_LOCK */
-#endif /* ENABLE_THREAD_SAFETY */
if (!ssl_lib_initialized && do_ssl)
{
@@ -848,9 +839,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
ssl_lib_initialized = true;
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&ssl_config_mutex);
-#endif
return 0;
}
@@ -869,7 +858,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
static void
destroy_ssl_system(void)
{
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/* Mutex is created in pgtls_init() */
if (pthread_mutex_lock(&ssl_config_mutex))
return;
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index a1dc7b796d..88607fb65b 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -37,13 +37,11 @@
#include <sys/stat.h>
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
#include "fe-auth.h"
#include "libpq-fe.h"
@@ -58,8 +56,6 @@
#define SIGPIPE_MASKED(conn) ((conn)->sigpipe_so || (conn)->sigpipe_flag)
-#ifdef ENABLE_THREAD_SAFETY
-
struct sigpipe_info
{
sigset_t oldsigmask;
@@ -92,24 +88,6 @@ struct sigpipe_info
pq_reset_sigpipe(&(spinfo).oldsigmask, (spinfo).sigpipe_pending, \
(spinfo).got_epipe); \
} while (0)
-#else /* !ENABLE_THREAD_SAFETY */
-
-#define DECLARE_SIGPIPE_INFO(spinfo) pqsigfunc spinfo = NULL
-
-#define DISABLE_SIGPIPE(conn, spinfo, failaction) \
- do { \
- if (!SIGPIPE_MASKED(conn)) \
- spinfo = pqsignal(SIGPIPE, SIG_IGN); \
- } while (0)
-
-#define REMEMBER_EPIPE(spinfo, cond)
-
-#define RESTORE_SIGPIPE(conn, spinfo) \
- do { \
- if (!SIGPIPE_MASKED(conn)) \
- pqsignal(SIGPIPE, spinfo); \
- } while (0)
-#endif /* ENABLE_THREAD_SAFETY */
#else /* WIN32 */
#define DECLARE_SIGPIPE_INFO(spinfo)
@@ -524,7 +502,7 @@ PQgssEncInUse(PGconn *conn)
#endif /* ENABLE_GSS */
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
/*
* Block SIGPIPE for this thread. This prevents send()/write() from exiting
@@ -608,4 +586,4 @@ pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
SOCK_ERRNO_SET(save_errno);
}
-#endif /* ENABLE_THREAD_SAFETY && !WIN32 */
+#endif /* !WIN32 */
diff --git a/src/interfaces/libpq/legacy-pqsignal.c b/src/interfaces/libpq/legacy-pqsignal.c
index db470df9ea..1b4424eabb 100644
--- a/src/interfaces/libpq/legacy-pqsignal.c
+++ b/src/interfaces/libpq/legacy-pqsignal.c
@@ -27,10 +27,6 @@
* Because it is only intended for backwards compatibility, we freeze it
* with the semantics it had in 9.2; in particular, this has different
* behavior for SIGALRM than the version in src/port/pqsignal.c.
- *
- * libpq itself uses this only for SIGPIPE (and even then, only in
- * non-ENABLE_THREAD_SAFETY builds), so the incompatibility isn't
- * troublesome for internal references.
*/
pqsigfunc
pqsignal(int signo, pqsigfunc func)
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 51ab51f9f9..99c40af8cf 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -28,14 +28,12 @@
#include <sys/time.h>
#endif
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
#include <signal.h>
-#endif
/* include stuff common to fe and be */
#include "getaddrinfo.h"
@@ -649,15 +647,10 @@ extern int pqPacketSend(PGconn *conn, char pack_type,
const void *buf, size_t buf_len);
extern bool pqGetHomeDirectory(char *buf, int bufsize);
-#ifdef ENABLE_THREAD_SAFETY
extern pgthreadlock_t pg_g_threadlock;
#define pglock_thread() pg_g_threadlock(true)
#define pgunlock_thread() pg_g_threadlock(false)
-#else
-#define pglock_thread() ((void) 0)
-#define pgunlock_thread() ((void) 0)
-#endif
/* === in fe-exec.c === */
@@ -732,7 +725,7 @@ extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
extern ssize_t pqsecure_raw_read(PGconn *, void *ptr, size_t len);
extern ssize_t pqsecure_raw_write(PGconn *, const void *ptr, size_t len);
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending);
extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
bool got_epipe);
diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c
index bea7b520f0..8cb3a4db2f 100644
--- a/src/port/getaddrinfo.c
+++ b/src/port/getaddrinfo.c
@@ -414,7 +414,7 @@ pqGethostbyname(const char *name,
struct hostent **result,
int *herrno)
{
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETHOSTBYNAME_R)
+#if defined(HAVE_GETHOSTBYNAME_R)
/*
* broken (well early POSIX draft) gethostbyname_r() which returns 'struct
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 1e83583e76..b64720f1c6 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -219,7 +219,6 @@ sub GenerateFiles
DLSUFFIX => '".dll"',
ENABLE_GSS => $self->{options}->{gss} ? 1 : undef,
ENABLE_NLS => $self->{options}->{nls} ? 1 : undef,
- ENABLE_THREAD_SAFETY => 1,
GETTIMEOFDAY_1ARG => undef,
HAVE_APPEND_HISTORY => undef,
HAVE_ASN1_STRING_GET0_DATA => undef,
@@ -1235,7 +1234,7 @@ sub GetFakeConfigure
{
my $self = shift;
- my $cfg = '--enable-thread-safety';
+ my $cfg = '';
$cfg .= ' --enable-cassert' if ($self->{options}->{asserts});
$cfg .= ' --enable-nls' if ($self->{options}->{nls});
$cfg .= ' --enable-tap-tests' if ($self->{options}->{tap_tests});
diff --git a/src/tools/msvc/ecpg_regression.proj b/src/tools/msvc/ecpg_regression.proj
index ec2760b1f6..0ec60a275e 100644
--- a/src/tools/msvc/ecpg_regression.proj
+++ b/src/tools/msvc/ecpg_regression.proj
@@ -54,7 +54,7 @@
<!-- Run ECPG and the Visual C++ compiler on the files. Don't bother with dependency check between the steps -->
<Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="$(OUTDIR)ecpg\ecpg -I ../../include --regression $(ECPGPARAM) -o %(Pgc.Filename).c %(Pgc.Filename).pgc" />
- <Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="cl /nologo %(Pgc.FileName).c /TC /MD$(DEBUGLIB) /DENABLE_THREAD_SAFETY /DWIN32 /I. /I..\..\include /I..\..\..\libpq /I..\..\..\..\include /link /defaultlib:$(OUTDIR)libecpg\libecpg.lib /defaultlib:$(OUTDIR)libecpg_compat\libecpg_compat.lib /defaultlib:$(OUTDIR)libpgtypes\libpgtypes.lib" />
+ <Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="cl /nologo %(Pgc.FileName).c /TC /MD$(DEBUGLIB) /DWIN32 /I. /I..\..\include /I..\..\..\libpq /I..\..\..\..\include /link /defaultlib:$(OUTDIR)libecpg\libecpg.lib /defaultlib:$(OUTDIR)libecpg_compat\libecpg_compat.lib /defaultlib:$(OUTDIR)libpgtypes\libpgtypes.lib" />
</Target>
<!-- Clean up all output files -->
--
2.36.1
Thomas Munro <thomas.munro@gmail.com> writes:
I wonder how much dead code for ancient operating systems we could now
drop.
+1, it seems like this is the cycle for some housecleaning.
* prairiedog, macOS 10.4 (vintage system most likely to cause problems)
FWIW, I am expecting to retire prairiedog once the meson stuff drops.
macOS 10.4 is incapable of running ninja (for lack of <spawn.h>).
While I could keep it working for awhile with the autoconf build system,
I'm not sure I see the point. The hardware is still chugging along,
but I think it'd be more useful to run up-to-date NetBSD or the like
on it.
Having said that, I'll be happy to try out this patch series on
that platform and see if it burps.
regards, tom lane
I wrote:
Having said that, I'll be happy to try out this patch series on
that platform and see if it burps.
HEAD + patches 0001-0006 seems fine on prairiedog's host.
Builds clean (or as clean as HEAD does anyway), passes make check.
I did not trouble with check-world.
(I haven't actually read the patches, so this isn't a review,
just a quick smoke-test.)
regards, tom lane
On Sat, 9 Jul 2022 at 21:46, Thomas Munro <thomas.munro@gmail.com> wrote:
Hello,
I wonder how much dead code for ancient operating systems we could now
drop.
0002-Remove-dead-getrusage-replacement-code.patch
I thought the getrusage replacement code was for Windows. Does
getrusage on Windows actually do anything useful?
More generally I think there is a question about whether some of these
things are "supported" in only a minimal way to satisfy standards but
maybe not in a way that we actually want to use. Getrusage might exist
on Windows but not actually report the metrics we need, reentrant
library functions may be implemented by simply locking instead of
actually avoiding static storage, etc.
--
greg
(Reading the patch it seems both those points are already addressed)
On Sat, Jul 9, 2022 at 9:46 PM Thomas Munro <thomas.munro@gmail.com> wrote:
The pwritev/preadv functions are unfortunately not standardised by
POSIX (I dunno why, it's the obvious combination of the p* and *v
functions) despite every OS in the list having them except for Solaris
and old macOS. Oh well.
I don't think that 0001 is buying us a whole lot, really. I prefer the
style where we have PG-specific functions that behave differently on
different platforms to the one where we call something that looks like
a native OS function call on all platforms but on some of them it is
secretly invoking a replacement implementation in src/port. The
problem with the latter is it looks like you're using something that's
universally supported and works the same way everywhere, but you're
really not. If it were up to me, we'd have more pg_whatever() that
calls whatever() on non-Windows and something else on Windows, rather
than going in the direction that this patch takes us.
I like all of the other patches. Reducing the number of configure
tests that we need seems like a really good idea.
--
Robert Haas
EDB: http://www.enterprisedb.com
On Tue, Jul 12, 2022 at 4:46 AM Robert Haas <robertmhaas@gmail.com> wrote:
I don't think that 0001 is buying us a whole lot, really. I prefer the
style where we have PG-specific functions that behave differently on
different platforms to the one where we call something that looks like
a native OS function call on all platforms but on some of them it is
secretly invoking a replacement implementation in src/port. The
problem with the latter is it looks like you're using something that's
universally supported and works the same way everywhere, but you're
really not. If it were up to me, we'd have more pg_whatever() that
calls whatever() on non-Windows and something else on Windows, rather
than going in the direction that this patch takes us.
Hmm, but that's not what we're doing in general. For example, on
Windows we're redirecting open() to a replacement function of our own,
we're not using "pg_open()" in our code. That's not an example based
on AC_REPLACE_FUNCS, but there are plenty of those too. Isn't this
quite well established?
AFAIK we generally only use pg_whatever() when there's a good reason,
such as an incompatibility, a complication or a different abstraction
that you want to highlight to a reader. The reason here was
temporary: we couldn't implement standard pread/pwrite perfectly on
ancient HP-UX, but we *can* implement it on Windows, so the reason is
gone.
These particular pg_ prefixes have only been in our tree for a few
years and I was hoping to boot them out again before they stick, like
"Size". I like using standard interfaces where possible for the very
basic stuff, to de-weird our stuff.
I like all of the other patches. Reducing the number of configure
tests that we need seems like a really good idea.
Thanks for looking. Yeah, we could also be a little more aggressive
about removing configure tests, in the cases where it's just Windows
vs !Windows. "HAVE_XXX" tests that are always true on POSIX systems
at the level we require would then be unnecessary.
On 12.07.22 03:10, Thomas Munro wrote:
AFAIK we generally only use pg_whatever() when there's a good reason,
such as an incompatibility, a complication or a different abstraction
that you want to highlight to a reader. The reason here was
temporary: we couldn't implement standard pread/pwrite perfectly on
ancient HP-UX, but we*can* implement it on Windows, so the reason is
gone.These particular pg_ prefixes have only been in our tree for a few
years and I was hoping to boot them out again before they stick, like
"Size". I like using standard interfaces where possible for the very
basic stuff, to de-weird our stuff.
I agree. That's been the established approach.
On Mon, Jul 11, 2022 at 9:11 PM Thomas Munro <thomas.munro@gmail.com> wrote:
Hmm, but that's not what we're doing in general. For example, on
Windows we're redirecting open() to a replacement function of our own,
we're not using "pg_open()" in our code. That's not an example based
on AC_REPLACE_FUNCS, but there are plenty of those too. Isn't this
quite well established?
Yes. I just don't care for it.
Sounds like I'm in the minority, though.
--
Robert Haas
EDB: http://www.enterprisedb.com
Robert Haas <robertmhaas@gmail.com> writes:
On Mon, Jul 11, 2022 at 9:11 PM Thomas Munro <thomas.munro@gmail.com> wrote:
Hmm, but that's not what we're doing in general. For example, on
Windows we're redirecting open() to a replacement function of our own,
we're not using "pg_open()" in our code. That's not an example based
on AC_REPLACE_FUNCS, but there are plenty of those too. Isn't this
quite well established?
Yes. I just don't care for it.
Sounds like I'm in the minority, though.
I concur with your point that it's not great to use the standard name
for a function that doesn't have exactly the standard semantics.
But if it does, using a nonstandard name is not better. It's just one
more thing that readers of our code have to learn about.
Note that "exactly" only needs to mean "satisfies all the promises
made by POSIX". If some caller is depending on behavior details not
specified in the standard, that's the caller's bug not the wrapper
function's. Otherwise, yeah, we couldn't ever be sure whether a
wrapper function is close enough.
regards, tom lane
Hi,
On 2022-07-12 08:01:40 -0400, Robert Haas wrote:
On Mon, Jul 11, 2022 at 9:11 PM Thomas Munro <thomas.munro@gmail.com> wrote:
Hmm, but that's not what we're doing in general. For example, on
Windows we're redirecting open() to a replacement function of our own,
we're not using "pg_open()" in our code. That's not an example based
on AC_REPLACE_FUNCS, but there are plenty of those too. Isn't this
quite well established?Yes. I just don't care for it.
Sounds like I'm in the minority, though.
I agree with you, at least largely.
Redefining functions, be it by linking in something or by redefining function
names via macros, is a mess. There's places where we then have to undefine
some of these things to be able to include external headers etc. Some
functions are only replaced in backends, others in frontend too. It makes it
hard to know what exactly the assumed set of platform primitives is. Etc.
Greetings,
Andres Freund
Andres Freund <andres@anarazel.de> writes:
Redefining functions, be it by linking in something or by redefining function
names via macros, is a mess. There's places where we then have to undefine
some of these things to be able to include external headers etc. Some
functions are only replaced in backends, others in frontend too. It makes it
hard to know what exactly the assumed set of platform primitives is. Etc.
In the cases at hand, we aren't doing that, are we? The replacement
function is only used on platforms that lack the relevant POSIX function,
so it's hard to argue that we're replacing anything.
regards, tom lane
I have committed the first few:
* "Remove dead getrusage replacement code."
* "Remove dead handling for pre-POSIX sigwait()."
* "Remove dead getpwuid_r replacement code."
Here are some more, a couple of which I posted before but I've now
gone a bit further with them in terms of removing configure checks
etc:
* "Remove dlopen configure probe."
* "Remove configure probe and extra tests for getrlimit."
* "Remove configure probe for shm_open."
* "Remove configure probe for setsid."
* "Remove configure probes for readlink, and dead code and docs."
* "Remove configure probe for symlink, and dead code."
* "Remove configure probe for link."
* "Remove dead replacement code for clock_gettime()."
* "Remove configure probes for poll and poll.h."
* "Remove dead setenv, unsetenv replacement code."
* "Remove dead pread and pwrite replacement code."
* "Simplify replacement code for preadv and pwritev."
* "Remove --disable-thread-safety."
Some of these depend on SUSv2 options (not just "base"), but we
already do that (fsync, ...) and they're all features that are by now
ubiquitous, which means the fallback code is untested and the probes
are pointless.
<archeology-mode>I'd guess the last system we ran on that didn't have
symlinks would have been SVr3-based SCO, HP-UX, DG/UX etc from the
1980s, since they were invented in 4.2BSD in 1983 and adopted by SVr4
in 1988. The RLIMIT_OFILE stuff seems to be referring to 1BSD or 2BSD
on a PDP, whereas RLIMIT_NOFILE was already used in 4.3BSD in 1986,
which I'd have guessed would be the oldest OS POSTGRES ever actually
ran on, so that must have been cargo culting from something older?</>
The clock_gettime() one only becomes committable once prairiedog's
host switched to NetBSD, so that'll be committed at the same time as
the fdatasync one from a nearby thread.
The setenv/unsetenv one levels up to SUSv3 (= POSIX issue 6, 2001).
That'd be the first time we don't point at SUSv2 (= POSIX issue 5,
199x) to justify a change like this.
I expect there to be further clean-up after the removal of
--disable-thread-safety.
Attachments:
0001-Remove-dlopen-configure-probe.patchtext/x-patch; charset=US-ASCII; name=0001-Remove-dlopen-configure-probe.patchDownload
From b2701bf5e9421ac6301697c56a45f5248351e063 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Tue, 19 Jul 2022 18:07:51 +1200
Subject: [PATCH 01/13] Remove dlopen configure probe.
dlopen() is in SUSv2 and all targeted Unix systems have it. We still
need replacement functions for Windows, but we don't need a configure
probe for that.
---
configure | 19 ++++++-------------
configure.ac | 2 +-
src/backend/utils/fmgr/dfmgr.c | 4 ++--
src/include/pg_config.h.in | 3 ---
src/include/port.h | 3 ++-
src/port/dlopen.c | 6 +-----
src/tools/msvc/Solution.pm | 1 -
7 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/configure b/configure
index c5bc382395..a2706684e3 100755
--- a/configure
+++ b/configure
@@ -16687,19 +16687,6 @@ $as_echo "#define HAVE_PS_STRINGS 1" >>confdefs.h
fi
-ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
-if test "x$ac_cv_func_dlopen" = xyes; then :
- $as_echo "#define HAVE_DLOPEN 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" dlopen.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS dlopen.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "explicit_bzero" "ac_cv_func_explicit_bzero"
if test "x$ac_cv_func_explicit_bzero" = xyes; then :
$as_echo "#define HAVE_EXPLICIT_BZERO 1" >>confdefs.h
@@ -17048,6 +17035,12 @@ fi
;;
esac
+ case " $LIBOBJS " in
+ *" dlopen.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS dlopen.$ac_objext"
+ ;;
+esac
+
case " $LIBOBJS " in
*" fdatasync.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS fdatasync.$ac_objext"
diff --git a/configure.ac b/configure.ac
index 61d0dd5d58..0861a10ec3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1880,7 +1880,6 @@ if test "$pgac_cv_var_PS_STRINGS" = yes ; then
fi
AC_REPLACE_FUNCS(m4_normalize([
- dlopen
explicit_bzero
getopt
getpeereid
@@ -1957,6 +1956,7 @@ if test "$PORTNAME" = "win32"; then
AC_CHECK_FUNCS(_configthreadlocale)
AC_REPLACE_FUNCS(gettimeofday)
AC_LIBOBJ(dirmod)
+ AC_LIBOBJ(dlopen)
AC_LIBOBJ(fdatasync)
AC_LIBOBJ(getrusage)
AC_LIBOBJ(kill)
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index 7f9ea97280..08fd7e1264 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -16,7 +16,7 @@
#include <sys/stat.h>
-#ifdef HAVE_DLOPEN
+#ifndef WIN32
#include <dlfcn.h>
/*
@@ -28,7 +28,7 @@
#undef bool
#endif
#endif
-#endif /* HAVE_DLOPEN */
+#endif /* !WIN32 */
#include "fmgr.h"
#include "lib/stringinfo.h"
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f9618e1986..c213f31273 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -169,9 +169,6 @@
don't. */
#undef HAVE_DECL_STRTOULL
-/* Define to 1 if you have the `dlopen' function. */
-#undef HAVE_DLOPEN
-
/* Define to 1 if you have the <editline/history.h> header file. */
#undef HAVE_EDITLINE_HISTORY_H
diff --git a/src/include/port.h b/src/include/port.h
index d39b04141f..4532608bb3 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -455,7 +455,8 @@ extern int setenv(const char *name, const char *value, int overwrite);
extern int unsetenv(const char *name);
#endif
-#ifndef HAVE_DLOPEN
+#ifdef WIN32
+/* src/port/dlopen.c has an implementation of dlopen for Windows */
extern void *dlopen(const char *file, int mode);
extern void *dlsym(void *handle, const char *symbol);
extern int dlclose(void *handle);
diff --git a/src/port/dlopen.c b/src/port/dlopen.c
index 6ff9f4bf64..48aa37129d 100644
--- a/src/port/dlopen.c
+++ b/src/port/dlopen.c
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* dlopen.c
- * dynamic loader for platforms without dlopen()
+ * dynamic loader for Windows
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
@@ -15,8 +15,6 @@
#include "c.h"
-#if defined(WIN32)
-
static char last_dyn_error[512];
static void
@@ -93,5 +91,3 @@ dlopen(const char *file, int mode)
last_dyn_error[0] = 0;
return (void *) h;
}
-
-#endif
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index b09872e018..ce56b23bba 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -251,7 +251,6 @@ sub GenerateFiles
HAVE_DECL_STRNLEN => 1,
HAVE_DECL_STRTOLL => 1,
HAVE_DECL_STRTOULL => 1,
- HAVE_DLOPEN => undef,
HAVE_EDITLINE_HISTORY_H => undef,
HAVE_EDITLINE_READLINE_H => undef,
HAVE_EXECINFO_H => undef,
--
2.30.2
0002-Remove-configure-probe-and-extra-tests-for-getrlimit.patchtext/x-patch; charset=US-ASCII; name=0002-Remove-configure-probe-and-extra-tests-for-getrlimit.patchDownload
From 29e9f6e44be1f9187c4ca661104794af2ee5a380 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 23 Jul 2022 21:34:14 +1200
Subject: [PATCH 02/13] Remove configure probe and extra tests for getrlimit.
getrlimit() is in SUSv2 and all targeted systems have it.
Furthermore, it's not necessary to test for RLIMIT_CORE, RLIMIT_STACK or
RLIMIT_NOFILE macros, since SUSv2 requires those and all targeted
systems have them.
Windows doesn't have getrlimit(), but we can just test WIN32 when doing
Unix-only stuff.
---
configure | 2 +-
configure.ac | 1 -
src/backend/storage/file/fd.c | 12 ++++--------
src/backend/tcop/postgres.c | 10 +++-------
src/bin/pg_ctl/pg_ctl.c | 8 ++++----
src/bin/pgbench/pgbench.c | 10 +++-------
src/include/pg_config.h.in | 3 ---
src/test/regress/pg_regress.c | 4 ++--
src/tools/msvc/Solution.pm | 1 -
9 files changed, 17 insertions(+), 34 deletions(-)
diff --git a/configure b/configure
index a2706684e3..3abc028412 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred getrlimit inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 0861a10ec3..73242d76a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1797,7 +1797,6 @@ AC_CHECK_FUNCS(m4_normalize([
fdatasync
getifaddrs
getpeerucred
- getrlimit
inet_pton
kqueue
mbstowcs_l
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index f904f60c08..28401a8881 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -886,7 +886,7 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
int highestfd = 0;
int j;
-#ifdef HAVE_GETRLIMIT
+#ifndef WIN32
struct rlimit rlim;
int getrlimit_status;
#endif
@@ -894,22 +894,18 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
size = 1024;
fd = (int *) palloc(size * sizeof(int));
-#ifdef HAVE_GETRLIMIT
-#ifdef RLIMIT_NOFILE /* most platforms use RLIMIT_NOFILE */
+#ifndef WIN32
getrlimit_status = getrlimit(RLIMIT_NOFILE, &rlim);
-#else /* but BSD doesn't ... */
- getrlimit_status = getrlimit(RLIMIT_OFILE, &rlim);
-#endif /* RLIMIT_NOFILE */
if (getrlimit_status != 0)
ereport(WARNING, (errmsg("getrlimit failed: %m")));
-#endif /* HAVE_GETRLIMIT */
+#endif /* !WIN32 */
/* dup until failure or probe limit reached */
for (;;)
{
int thisfd;
-#ifdef HAVE_GETRLIMIT
+#ifndef WIN32
/*
* don't go beyond RLIMIT_NOFILE; causes irritating kernel logs on
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index bdb11f430f..e4e972cce0 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -4765,12 +4765,12 @@ forbidden_in_wal_sender(char firstchar)
/*
* Obtain platform stack depth limit (in bytes)
*
- * Return -1 if unknown
+ * -1 for error, and errno is set.
*/
long
get_stack_depth_rlimit(void)
{
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_STACK)
+#ifndef WIN32
static long val = 0;
/* This won't change after process launch, so check just once */
@@ -4789,13 +4789,9 @@ get_stack_depth_rlimit(void)
val = rlim.rlim_cur;
}
return val;
-#else /* no getrlimit */
-#if defined(WIN32) || defined(__CYGWIN__)
+#else
/* On Windows we set the backend stack size in src/backend/Makefile */
return WIN32_STACK_RLIMIT;
-#else /* not windows ... give up */
- return -1;
-#endif
#endif
}
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index ef58883a5c..3157d51918 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -160,7 +160,7 @@ static bool wait_for_postmaster_stop(void);
static bool wait_for_postmaster_promote(void);
static bool postmaster_is_alive(pid_t pid);
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
static void unlimit_core_size(void);
#endif
@@ -776,7 +776,7 @@ wait_for_postmaster_promote(void)
}
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
static void
unlimit_core_size(void)
{
@@ -949,7 +949,7 @@ do_start(void)
if (exec_path == NULL)
exec_path = find_other_exec_or_die(argv0, "postgres", PG_BACKEND_VERSIONSTR);
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
if (allow_core_files)
unlimit_core_size();
#endif
@@ -2069,7 +2069,7 @@ do_help(void)
printf(_("If the -D option is omitted, the environment variable PGDATA is used.\n"));
printf(_("\nOptions for start or restart:\n"));
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
printf(_(" -c, --core-files allow postgres to produce core files\n"));
#else
printf(_(" -c, --core-files not applicable on this platform\n"));
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index bcaea8f5ea..71682a3300 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6583,7 +6583,7 @@ main(int argc, char **argv)
int i;
int nclients_dealt;
-#ifdef HAVE_GETRLIMIT
+#ifndef WIN32
struct rlimit rlim;
#endif
@@ -6661,12 +6661,8 @@ main(int argc, char **argv)
{
exit(1);
}
-#ifdef HAVE_GETRLIMIT
-#ifdef RLIMIT_NOFILE /* most platforms use RLIMIT_NOFILE */
+#ifndef WIN32
if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
-#else /* but BSD doesn't ... */
- if (getrlimit(RLIMIT_OFILE, &rlim) == -1)
-#endif /* RLIMIT_NOFILE */
pg_fatal("getrlimit failed: %m");
if (rlim.rlim_cur < nclients + 3)
{
@@ -6675,7 +6671,7 @@ main(int argc, char **argv)
pg_log_error_hint("Reduce number of clients, or use limit/ulimit to increase the system limit.");
exit(1);
}
-#endif /* HAVE_GETRLIMIT */
+#endif /* !WIN32 */
break;
case 'j': /* jobs */
benchmarking_option_set = true;
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index c213f31273..8e9318904f 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -237,9 +237,6 @@
/* Define to 1 if you have the `getpeerucred' function. */
#undef HAVE_GETPEERUCRED
-/* Define to 1 if you have the `getrlimit' function. */
-#undef HAVE_GETRLIMIT
-
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 982801e029..d3505cd13b 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -129,7 +129,7 @@ static void psql_end_command(StringInfo buf, const char *database);
/*
* allow core files if possible.
*/
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
static void
unlimit_core_size(void)
{
@@ -2229,7 +2229,7 @@ regression_main(int argc, char *argv[],
initialize_environment();
-#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+#ifndef WIN32
unlimit_core_size();
#endif
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index ce56b23bba..1018b57f00 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -273,7 +273,6 @@ sub GenerateFiles
HAVE_GETOPT_LONG => undef,
HAVE_GETPEEREID => undef,
HAVE_GETPEERUCRED => undef,
- HAVE_GETRLIMIT => undef,
HAVE_GETTIMEOFDAY => undef,
HAVE_GSSAPI_GSSAPI_H => undef,
HAVE_GSSAPI_H => undef,
--
2.30.2
0003-Remove-configure-probe-for-shm_open.patchtext/x-patch; charset=US-ASCII; name=0003-Remove-configure-probe-for-shm_open.patchDownload
From f313527fbbb455c11f6853f5f8fa034d4dbb32d2 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 23 Jul 2022 23:49:27 +1200
Subject: [PATCH 03/13] Remove configure probe for shm_open.
shm_open() is in SUSv2 (realtime) and all targeted Unix systems have it.
---
configure | 2 +-
configure.ac | 1 -
src/bin/initdb/initdb.c | 4 ++--
src/include/pg_config.h.in | 3 ---
src/include/storage/dsm_impl.h | 5 -----
src/tools/msvc/Solution.pm | 1 -
6 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/configure b/configure
index 3abc028412..276fcb647c 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid shm_open strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 73242d76a6..7ec30a7486 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1810,7 +1810,6 @@ AC_CHECK_FUNCS(m4_normalize([
setproctitle
setproctitle_fast
setsid
- shm_open
strchrnul
strsignal
symlink
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 89b888eaa5..85fc95503a 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -55,7 +55,7 @@
#include <signal.h>
#include <time.h>
-#ifdef HAVE_SHM_OPEN
+#ifndef WIN32
#include "sys/mman.h"
#endif
@@ -849,7 +849,7 @@ set_null_conf(void)
static const char *
choose_dsm_implementation(void)
{
-#if defined(HAVE_SHM_OPEN) && !defined(__sun__)
+#if !defined(WIN32) && !defined(__sun__)
int ntries = 10;
pg_prng_state prng_state;
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 8e9318904f..922756568e 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -480,9 +480,6 @@
/* Define to 1 if you have the `setsid' function. */
#undef HAVE_SETSID
-/* Define to 1 if you have the `shm_open' function. */
-#undef HAVE_SHM_OPEN
-
/* Define to 1 if the system has the type `socklen_t'. */
#undef HAVE_SOCKLEN_T
diff --git a/src/include/storage/dsm_impl.h b/src/include/storage/dsm_impl.h
index c51584dc6a..223d4d05bc 100644
--- a/src/include/storage/dsm_impl.h
+++ b/src/include/storage/dsm_impl.h
@@ -27,14 +27,9 @@
#define USE_DSM_WINDOWS
#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS
#else
-#ifdef HAVE_SHM_OPEN
#define USE_DSM_POSIX
#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX
-#endif
#define USE_DSM_SYSV
-#ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE
-#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV
-#endif
#define USE_DSM_MMAP
#endif
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 1018b57f00..893feb6eaf 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -353,7 +353,6 @@ sub GenerateFiles
HAVE_SETPROCTITLE => undef,
HAVE_SETPROCTITLE_FAST => undef,
HAVE_SETSID => undef,
- HAVE_SHM_OPEN => undef,
HAVE_SOCKLEN_T => 1,
HAVE_SPINLOCKS => 1,
HAVE_STDBOOL_H => 1,
--
2.30.2
0004-Remove-configure-probe-for-setsid.patchtext/x-patch; charset=US-ASCII; name=0004-Remove-configure-probe-for-setsid.patchDownload
From 57de5d03ef3b610d68783b975bab3f3c4f979020 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 00:54:07 +1200
Subject: [PATCH 04/13] Remove configure probe for setsid.
setsid() is in SUSv2 and all targeted Unix systems have it. This can be
replaced with a test that we're not on Windows.
---
configure | 2 +-
configure.ac | 1 -
src/backend/postmaster/postmaster.c | 4 ++--
src/backend/storage/ipc/procarray.c | 2 +-
src/backend/storage/ipc/signalfuncs.c | 2 +-
src/backend/utils/init/miscinit.c | 2 +-
src/backend/utils/init/postinit.c | 4 ++--
src/bin/pg_ctl/pg_ctl.c | 2 +-
src/include/pg_config.h.in | 3 ---
src/tools/msvc/Solution.pm | 1 -
10 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/configure b/configure
index 276fcb647c..62ff8250d4 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast setsid strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 7ec30a7486..eb29046398 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1809,7 +1809,6 @@ AC_CHECK_FUNCS(m4_normalize([
readv
setproctitle
setproctitle_fast
- setsid
strchrnul
strsignal
symlink
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 1c25457526..b67e82a969 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -4024,7 +4024,7 @@ PostmasterStateMachine(void)
/*
* Send a signal to a postmaster child process
*
- * On systems that have setsid(), each child process sets itself up as a
+ * On Unix systems, each child process uses setsid() to set itself up as a
* process group leader. For signals that are generally interpreted in the
* appropriate fashion, we signal the entire process group not just the
* direct child process. This allows us to, for example, SIGQUIT a blocked
@@ -4042,7 +4042,7 @@ signal_child(pid_t pid, int signal)
{
if (kill(pid, signal) < 0)
elog(DEBUG3, "kill(%ld,%d) failed: %m", (long) pid, signal);
-#ifdef HAVE_SETSID
+#ifndef WIN32
switch (signal)
{
case SIGINT:
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index dadaa958a8..b680c14748 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -3869,7 +3869,7 @@ TerminateOtherDBBackends(Oid databaseId)
* If we have setsid(), signal the backend's whole process
* group
*/
-#ifdef HAVE_SETSID
+#ifndef WIN32
(void) kill(-pid, SIGTERM);
#else
(void) kill(pid, SIGTERM);
diff --git a/src/backend/storage/ipc/signalfuncs.c b/src/backend/storage/ipc/signalfuncs.c
index 6e310b14eb..e2dfb4ff00 100644
--- a/src/backend/storage/ipc/signalfuncs.c
+++ b/src/backend/storage/ipc/signalfuncs.c
@@ -93,7 +93,7 @@ pg_signal_backend(int pid, int sig)
*/
/* If we have setsid(), signal the backend's whole process group */
-#ifdef HAVE_SETSID
+#ifndef WIN32
if (kill(-pid, sig))
#else
if (kill(pid, sig))
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index eb43b2c5e5..70018ca5d0 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -145,7 +145,7 @@ InitPostmasterChild(void)
* children, but for consistency we make all postmaster child processes do
* this.
*/
-#ifdef HAVE_SETSID
+#ifndef WIN32
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index a5c208a20a..3c77b1aa60 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -1249,7 +1249,7 @@ StatementTimeoutHandler(void)
if (ClientAuthInProgress)
sig = SIGTERM;
-#ifdef HAVE_SETSID
+#ifndef WIN32
/* try to signal whole process group */
kill(-MyProcPid, sig);
#endif
@@ -1262,7 +1262,7 @@ StatementTimeoutHandler(void)
static void
LockTimeoutHandler(void)
{
-#ifdef HAVE_SETSID
+#ifndef WIN32
/* try to signal whole process group */
kill(-MyProcPid, SIGINT);
#endif
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 3157d51918..bb46723e3b 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -478,7 +478,7 @@ start_postmaster(void)
* group and make it a group leader, so that it doesn't get signaled along
* with the current group that launched it.
*/
-#ifdef HAVE_SETSID
+#ifndef WIN32
if (setsid() < 0)
{
write_stderr(_("%s: could not start server due to setsid() failure: %s\n"),
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 922756568e..9a3372f7de 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -477,9 +477,6 @@
/* Define to 1 if you have the `setproctitle_fast' function. */
#undef HAVE_SETPROCTITLE_FAST
-/* Define to 1 if you have the `setsid' function. */
-#undef HAVE_SETSID
-
/* Define to 1 if the system has the type `socklen_t'. */
#undef HAVE_SOCKLEN_T
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 893feb6eaf..e3b60a773a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -352,7 +352,6 @@ sub GenerateFiles
HAVE_SETENV => undef,
HAVE_SETPROCTITLE => undef,
HAVE_SETPROCTITLE_FAST => undef,
- HAVE_SETSID => undef,
HAVE_SOCKLEN_T => 1,
HAVE_SPINLOCKS => 1,
HAVE_STDBOOL_H => 1,
--
2.30.2
0005-Remove-configure-probes-for-readlink-and-dead-code-a.patchtext/x-patch; charset=US-ASCII; name=0005-Remove-configure-probes-for-readlink-and-dead-code-a.patchDownload
From 20df3fb6b0f2ab7f0391738a99958da91a22a114 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 01:03:11 +1200
Subject: [PATCH 05/13] Remove configure probes for readlink, and dead code and
docs.
readlink() is in SUSv2 and all targeted Unix systems have it.
---
configure | 2 +-
configure.ac | 1 -
doc/src/sgml/ref/create_tablespace.sgml | 4 ----
src/backend/access/transam/xlog.c | 12 ------------
src/backend/replication/basebackup.c | 13 -------------
src/backend/utils/adt/misc.c | 8 --------
src/bin/initdb/findtimezone.c | 2 +-
src/bin/pg_rewind/file_ops.c | 5 -----
src/common/exec.c | 4 ++--
src/include/pg_config.h.in | 3 ---
src/tools/msvc/Solution.pm | 1 -
11 files changed, 4 insertions(+), 51 deletions(-)
diff --git a/configure b/configure
index 62ff8250d4..6e10773263 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readlink readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index eb29046398..b4015aebb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1805,7 +1805,6 @@ AC_CHECK_FUNCS(m4_normalize([
posix_fallocate
ppoll
pthread_is_threaded_np
- readlink
readv
setproctitle
setproctitle_fast
diff --git a/doc/src/sgml/ref/create_tablespace.sgml b/doc/src/sgml/ref/create_tablespace.sgml
index 84fa7ee5e2..9d5ab02526 100644
--- a/doc/src/sgml/ref/create_tablespace.sgml
+++ b/doc/src/sgml/ref/create_tablespace.sgml
@@ -127,10 +127,6 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
<refsect1>
<title>Notes</title>
- <para>
- Tablespaces are only supported on systems that support symbolic links.
- </para>
-
<para>
<command>CREATE TABLESPACE</command> cannot be executed inside a transaction
block.
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 15ab8d90d4..26fbed00a4 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8305,7 +8305,6 @@ do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p,
if (get_dirent_type(fullpath, de, false, ERROR) != PGFILETYPE_LNK)
continue;
-#if defined(HAVE_READLINK) || defined(WIN32)
rllen = readlink(fullpath, linkpath, sizeof(linkpath));
if (rllen < 0)
{
@@ -8358,17 +8357,6 @@ do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p,
ti->oid, escapedpath.data);
pfree(escapedpath.data);
-#else
-
- /*
- * If the platform does not have symbolic links, it should not be
- * possible to have tablespaces - clearly somebody else created
- * them. Warn about it and ignore.
- */
- ereport(WARNING,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("tablespaces are not supported on this platform")));
-#endif
}
FreeDir(tblspcdir);
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 637c0ce459..1a569e2582 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1328,7 +1328,6 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
#endif
)
{
-#if defined(HAVE_READLINK) || defined(WIN32)
char linkpath[MAXPGPATH];
int rllen;
@@ -1347,18 +1346,6 @@ sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly,
size += _tarWriteHeader(sink, pathbuf + basepathlen + 1, linkpath,
&statbuf, sizeonly);
-#else
-
- /*
- * If the platform does not have symbolic links, it should not be
- * possible to have tablespaces - clearly somebody else created
- * them. Warn about it and ignore.
- */
- ereport(WARNING,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("tablespaces are not supported on this platform")));
- continue;
-#endif /* HAVE_READLINK */
}
else if (S_ISDIR(statbuf.st_mode))
{
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 89690be2ed..af0d924459 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -302,8 +302,6 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
tablespaceOid == GLOBALTABLESPACE_OID)
PG_RETURN_TEXT_P(cstring_to_text(""));
-#if defined(HAVE_READLINK) || defined(WIN32)
-
/*
* Find the location of the tablespace by reading the symbolic link that
* is in pg_tblspc/<oid>.
@@ -349,12 +347,6 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
targetpath[rllen] = '\0';
PG_RETURN_TEXT_P(cstring_to_text(targetpath));
-#else
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("tablespaces are not supported on this platform")));
- PG_RETURN_NULL();
-#endif
}
/*
diff --git a/src/bin/initdb/findtimezone.c b/src/bin/initdb/findtimezone.c
index ddb65e6489..dc1d4e9a49 100644
--- a/src/bin/initdb/findtimezone.c
+++ b/src/bin/initdb/findtimezone.c
@@ -544,7 +544,7 @@ static bool
check_system_link_file(const char *linkname, struct tztry *tt,
char *bestzonename)
{
-#ifdef HAVE_READLINK
+#ifndef WIN32
char link_target[MAXPGPATH];
int len;
const char *cur_name;
diff --git a/src/bin/pg_rewind/file_ops.c b/src/bin/pg_rewind/file_ops.c
index 6cb288f099..5e6d8b89c4 100644
--- a/src/bin/pg_rewind/file_ops.c
+++ b/src/bin/pg_rewind/file_ops.c
@@ -437,7 +437,6 @@ recurse_dir(const char *datadir, const char *parentpath,
else if (pgwin32_is_junction(fullpath))
#endif
{
-#if defined(HAVE_READLINK) || defined(WIN32)
char link_target[MAXPGPATH];
int len;
@@ -460,10 +459,6 @@ recurse_dir(const char *datadir, const char *parentpath,
if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
strcmp(path, "pg_wal") == 0)
recurse_dir(datadir, path, callback);
-#else
- pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform",
- fullpath);
-#endif /* HAVE_READLINK */
}
}
diff --git a/src/common/exec.c b/src/common/exec.c
index f7d44b0956..2a398f1eb1 100644
--- a/src/common/exec.c
+++ b/src/common/exec.c
@@ -254,7 +254,7 @@ find_my_exec(const char *argv0, char *retpath)
static int
resolve_symlinks(char *path)
{
-#ifdef HAVE_READLINK
+#ifndef WIN32
struct stat buf;
char orig_wd[MAXPGPATH],
link_buf[MAXPGPATH];
@@ -333,7 +333,7 @@ resolve_symlinks(char *path)
_("could not change directory to \"%s\": %m"), orig_wd);
return -1;
}
-#endif /* HAVE_READLINK */
+#endif /* !WIN32 */
return 0;
}
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 9a3372f7de..9fc0298f7d 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -435,9 +435,6 @@
/* Define to 1 if you have the <readline/readline.h> header file. */
#undef HAVE_READLINE_READLINE_H
-/* Define to 1 if you have the `readlink' function. */
-#undef HAVE_READLINK
-
/* Define to 1 if you have the `readv' function. */
#undef HAVE_READV
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index e3b60a773a..f9aec9494e 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -339,7 +339,6 @@ sub GenerateFiles
HAVE_READLINE_H => undef,
HAVE_READLINE_HISTORY_H => undef,
HAVE_READLINE_READLINE_H => undef,
- HAVE_READLINK => undef,
HAVE_READV => undef,
HAVE_RL_COMPLETION_MATCHES => undef,
HAVE_RL_COMPLETION_SUPPRESS_QUOTE => undef,
--
2.30.2
0006-Remove-configure-probe-for-symlink-and-dead-code.patchtext/x-patch; charset=US-ASCII; name=0006-Remove-configure-probe-for-symlink-and-dead-code.patchDownload
From 1c5a70717e6d20139d77fe1cba1f6c82da4d079e Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 01:12:31 +1200
Subject: [PATCH 06/13] Remove configure probe for symlink, and dead code.
symlink() is in SUSv2 and all targeted Unix systems have it. Windows
doesn't have it, but we have replacement code that doesn't need a
configure probe.
---
configure | 5 +----
configure.ac | 3 ---
src/backend/commands/tablespace.c | 13 -------------
src/bin/initdb/initdb.c | 4 ----
src/bin/pg_basebackup/pg_basebackup.c | 4 ----
src/include/pg_config.h.in | 3 ---
src/timezone/zic.c | 10 ----------
src/tools/msvc/Solution.pm | 1 -
8 files changed, 1 insertion(+), 42 deletions(-)
diff --git a/configure b/configure
index 6e10773263..b18198bf5f 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal symlink syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -17107,9 +17107,6 @@ esac
;;
esac
-
-$as_echo "#define HAVE_SYMLINK 1" >>confdefs.h
-
ac_fn_c_check_type "$LINENO" "MINIDUMP_TYPE" "ac_cv_type_MINIDUMP_TYPE" "
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
diff --git a/configure.ac b/configure.ac
index b4015aebb4..a89992caf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1810,7 +1810,6 @@ AC_CHECK_FUNCS(m4_normalize([
setproctitle_fast
strchrnul
strsignal
- symlink
syncfs
sync_file_range
uselocale
@@ -1964,8 +1963,6 @@ if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(win32security)
AC_LIBOBJ(win32setlocale)
AC_LIBOBJ(win32stat)
- AC_DEFINE([HAVE_SYMLINK], 1,
- [Define to 1 if you have the `symlink' function.])
AC_CHECK_TYPES(MINIDUMP_TYPE, [pgac_minidump_type=yes], [pgac_minidump_type=no], [
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index cb7d46089a..7ab6ec6d68 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -235,7 +235,6 @@ TablespaceCreateDbspace(Oid spcOid, Oid dbOid, bool isRedo)
Oid
CreateTableSpace(CreateTableSpaceStmt *stmt)
{
-#ifdef HAVE_SYMLINK
Relation rel;
Datum values[Natts_pg_tablespace];
bool nulls[Natts_pg_tablespace] = {0};
@@ -413,12 +412,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
table_close(rel, NoLock);
return tablespaceoid;
-#else /* !HAVE_SYMLINK */
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("tablespaces are not supported on this platform")));
- return InvalidOid; /* keep compiler quiet */
-#endif /* HAVE_SYMLINK */
}
/*
@@ -429,7 +422,6 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
void
DropTableSpace(DropTableSpaceStmt *stmt)
{
-#ifdef HAVE_SYMLINK
char *tablespacename = stmt->tablespacename;
TableScanDesc scandesc;
Relation rel;
@@ -595,11 +587,6 @@ DropTableSpace(DropTableSpaceStmt *stmt)
/* We keep the lock on pg_tablespace until commit */
table_close(rel, NoLock);
-#else /* !HAVE_SYMLINK */
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("tablespaces are not supported on this platform")));
-#endif /* HAVE_SYMLINK */
}
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 85fc95503a..3e607b824f 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2646,13 +2646,9 @@ create_xlog_or_symlink(void)
pg_fatal("could not access directory \"%s\": %m", xlog_dir);
}
-#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, subdirloc) != 0)
pg_fatal("could not create symbolic link \"%s\": %m",
subdirloc);
-#else
- pg_fatal("symlinks are not supported on this platform");
-#endif
}
else
{
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 1a877ba54e..8694b05e68 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -2763,12 +2763,8 @@ main(int argc, char **argv)
PQserverVersion(conn) < MINIMUM_VERSION_FOR_PG_WAL ?
"pg_xlog" : "pg_wal");
-#ifdef HAVE_SYMLINK
if (symlink(xlog_dir, linkloc) != 0)
pg_fatal("could not create symbolic link \"%s\": %m", linkloc);
-#else
- pg_fatal("symlinks are not supported on this platform");
-#endif
free(linkloc);
}
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 9fc0298f7d..61634347d5 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -561,9 +561,6 @@
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
#undef HAVE_STRUCT_TM_TM_ZONE
-/* Define to 1 if you have the `symlink' function. */
-#undef HAVE_SYMLINK
-
/* Define to 1 if you have the `syncfs' function. */
#undef HAVE_SYNCFS
diff --git a/src/timezone/zic.c b/src/timezone/zic.c
index 0ea6ead2db..2c55a009a8 100644
--- a/src/timezone/zic.c
+++ b/src/timezone/zic.c
@@ -944,7 +944,6 @@ namecheck(const char *name)
* is relative to the global variable DIRECTORY. TO can be either
* relative or absolute.
*/
-#ifdef HAVE_SYMLINK
static char *
relname(char const *target, char const *linkname)
{
@@ -986,7 +985,6 @@ relname(char const *target, char const *linkname)
}
return result;
}
-#endif /* HAVE_SYMLINK */
/* Hard link FROM to TO, following any symbolic links.
Return 0 if successful, an error number otherwise. */
@@ -1038,7 +1036,6 @@ dolink(char const *target, char const *linkname, bool staysymlink)
}
if (link_errno != 0)
{
-#ifdef HAVE_SYMLINK
bool absolute = *target == '/';
char *linkalloc = absolute ? NULL : relname(target, linkname);
char const *contents = absolute ? target : linkalloc;
@@ -1059,7 +1056,6 @@ dolink(char const *target, char const *linkname, bool staysymlink)
strerror(link_errno));
}
else
-#endif /* HAVE_SYMLINK */
{
FILE *fp,
*tp;
@@ -1090,11 +1086,9 @@ dolink(char const *target, char const *linkname, bool staysymlink)
if (link_errno != ENOTSUP)
warning(_("copy used because hard link failed: %s"),
strerror(link_errno));
-#ifdef HAVE_SYMLINK
else if (symlink_errno != ENOTSUP)
warning(_("copy used because symbolic link failed: %s"),
strerror(symlink_errno));
-#endif
}
}
}
@@ -1128,13 +1122,9 @@ itsdir(char const *name)
static bool
itssymlink(char const *name)
{
-#ifdef HAVE_SYMLINK
char c;
return 0 <= readlink(name, &c, 1);
-#else
- return false;
-#endif
}
/*
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index f9aec9494e..5030f63e9a 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -381,7 +381,6 @@ sub GenerateFiles
HAVE_STRUCT_SOCKADDR_UN => undef,
HAVE_STRUCT_TM_TM_ZONE => undef,
HAVE_SYNC_FILE_RANGE => undef,
- HAVE_SYMLINK => 1,
HAVE_SYNCFS => undef,
HAVE_SYSLOG => undef,
HAVE_SYS_EPOLL_H => undef,
--
2.30.2
0007-Remove-configure-probe-for-link.patchtext/x-patch; charset=US-ASCII; name=0007-Remove-configure-probe-for-link.patchDownload
From 66dc6f1601da55342702b604fc0e90adbdc99d83 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 01:19:05 +1200
Subject: [PATCH 07/13] Remove configure probe for link.
link() is in SUSv2 and all targeted Unix systems have it. We have
replacement code for Windows that doesn't require a configure probe.
---
configure | 19 ++++++-------------
configure.ac | 2 +-
src/include/pg_config.h.in | 3 ---
src/include/port.h | 3 ++-
src/port/link.c | 4 ----
src/tools/msvc/Solution.pm | 1 -
6 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/configure b/configure
index b18198bf5f..85efc8984d 100755
--- a/configure
+++ b/configure
@@ -16739,19 +16739,6 @@ esac
fi
-ac_fn_c_check_func "$LINENO" "link" "ac_cv_func_link"
-if test "x$ac_cv_func_link" = xyes; then :
- $as_echo "#define HAVE_LINK 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" link.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS link.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "mkdtemp" "ac_cv_func_mkdtemp"
if test "x$ac_cv_func_mkdtemp" = xyes; then :
$as_echo "#define HAVE_MKDTEMP 1" >>confdefs.h
@@ -17059,6 +17046,12 @@ esac
;;
esac
+ case " $LIBOBJS " in
+ *" link.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS link.$ac_objext"
+ ;;
+esac
+
case " $LIBOBJS " in
*" open.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS open.$ac_objext"
diff --git a/configure.ac b/configure.ac
index a89992caf6..0fb7396669 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1879,7 +1879,6 @@ AC_REPLACE_FUNCS(m4_normalize([
getopt
getpeereid
inet_aton
- link
mkdtemp
pread
pwrite
@@ -1955,6 +1954,7 @@ if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(fdatasync)
AC_LIBOBJ(getrusage)
AC_LIBOBJ(kill)
+ AC_LIBOBJ(link)
AC_LIBOBJ(open)
AC_LIBOBJ(system)
AC_LIBOBJ(win32env)
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 61634347d5..ba9d702101 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -342,9 +342,6 @@
/* Define to 1 if you have the `zstd' library (-lzstd). */
#undef HAVE_LIBZSTD
-/* Define to 1 if you have the `link' function. */
-#undef HAVE_LINK
-
/* Define to 1 if the system has the type `locale_t'. */
#undef HAVE_LOCALE_T
diff --git a/src/include/port.h b/src/include/port.h
index 4532608bb3..666f6b04f9 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -402,7 +402,8 @@ extern float pg_strtof(const char *nptr, char **endptr);
#define strtof(a,b) (pg_strtof((a),(b)))
#endif
-#ifndef HAVE_LINK
+#ifdef WIN32
+/* replacement in src/port/link.c */
extern int link(const char *src, const char *dst);
#endif
diff --git a/src/port/link.c b/src/port/link.c
index 1e0ccd4648..45517280db 100644
--- a/src/port/link.c
+++ b/src/port/link.c
@@ -14,8 +14,6 @@
#include "c.h"
-#ifdef WIN32
-
int
link(const char *src, const char *dst)
{
@@ -31,5 +29,3 @@ link(const char *src, const char *dst)
else
return 0;
}
-
-#endif
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 5030f63e9a..d904f42d53 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -308,7 +308,6 @@ sub GenerateFiles
HAVE_LIBXSLT => undef,
HAVE_LIBZ => $self->{options}->{zlib} ? 1 : undef,
HAVE_LIBZSTD => undef,
- HAVE_LINK => undef,
HAVE_LOCALE_T => 1,
HAVE_LONG_INT_64 => undef,
HAVE_LONG_LONG_INT_64 => 1,
--
2.30.2
0008-Remove-dead-replacement-code-for-clock_gettime.patchtext/x-patch; charset=US-ASCII; name=0008-Remove-dead-replacement-code-for-clock_gettime.patchDownload
From 7b15e84052c24baaa31404320058c4978fd566f2 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 00:12:37 +1200
Subject: [PATCH 08/13] Remove dead replacement code for clock_gettime().
clock_gettime() is in SUSv2 (realtime) and all targeted Unix systems
have it. Fallback code for old Unix is no longer reachable on modern
systems, though we still need Windows-specific code.
XXX This will only be true once prairedog is decommissioned!
---
configure | 2 +-
configure.ac | 1 -
src/include/pg_config.h.in | 3 --
src/include/portability/instr_time.h | 68 ----------------------------
src/tools/msvc/Solution.pm | 1 -
5 files changed, 1 insertion(+), 74 deletions(-)
diff --git a/configure b/configure
index 85efc8984d..b6094c1a62 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols clock_gettime copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 0fb7396669..27552e949e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1792,7 +1792,6 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
AC_CHECK_FUNCS(m4_normalize([
backtrace_symbols
- clock_gettime
copyfile
fdatasync
getifaddrs
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index ba9d702101..9c426ca8a0 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -83,9 +83,6 @@
/* Define to 1 if you have the `BIO_meth_new' function. */
#undef HAVE_BIO_METH_NEW
-/* Define to 1 if you have the `clock_gettime' function. */
-#undef HAVE_CLOCK_GETTIME
-
/* Define to 1 if your compiler handles computed gotos. */
#undef HAVE_COMPUTED_GOTO
diff --git a/src/include/portability/instr_time.h b/src/include/portability/instr_time.h
index ca09a1608f..8faeca8b49 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -57,8 +57,6 @@
#ifndef WIN32
-#ifdef HAVE_CLOCK_GETTIME
-
/* Use clock_gettime() */
#include <time.h>
@@ -141,72 +139,6 @@ typedef struct timespec instr_time;
#define INSTR_TIME_GET_MICROSEC(t) \
(((uint64) (t).tv_sec * (uint64) 1000000) + (uint64) ((t).tv_nsec / 1000))
-#else /* !HAVE_CLOCK_GETTIME */
-
-/* Use gettimeofday() */
-
-#include <sys/time.h>
-
-typedef struct timeval instr_time;
-
-#define INSTR_TIME_IS_ZERO(t) ((t).tv_usec == 0 && (t).tv_sec == 0)
-
-#define INSTR_TIME_SET_ZERO(t) ((t).tv_sec = 0, (t).tv_usec = 0)
-
-#define INSTR_TIME_SET_CURRENT(t) gettimeofday(&(t), NULL)
-
-#define INSTR_TIME_ADD(x,y) \
- do { \
- (x).tv_sec += (y).tv_sec; \
- (x).tv_usec += (y).tv_usec; \
- /* Normalize */ \
- while ((x).tv_usec >= 1000000) \
- { \
- (x).tv_usec -= 1000000; \
- (x).tv_sec++; \
- } \
- } while (0)
-
-#define INSTR_TIME_SUBTRACT(x,y) \
- do { \
- (x).tv_sec -= (y).tv_sec; \
- (x).tv_usec -= (y).tv_usec; \
- /* Normalize */ \
- while ((x).tv_usec < 0) \
- { \
- (x).tv_usec += 1000000; \
- (x).tv_sec--; \
- } \
- } while (0)
-
-#define INSTR_TIME_ACCUM_DIFF(x,y,z) \
- do { \
- (x).tv_sec += (y).tv_sec - (z).tv_sec; \
- (x).tv_usec += (y).tv_usec - (z).tv_usec; \
- /* Normalize after each add to avoid overflow/underflow of tv_usec */ \
- while ((x).tv_usec < 0) \
- { \
- (x).tv_usec += 1000000; \
- (x).tv_sec--; \
- } \
- while ((x).tv_usec >= 1000000) \
- { \
- (x).tv_usec -= 1000000; \
- (x).tv_sec++; \
- } \
- } while (0)
-
-#define INSTR_TIME_GET_DOUBLE(t) \
- (((double) (t).tv_sec) + ((double) (t).tv_usec) / 1000000.0)
-
-#define INSTR_TIME_GET_MILLISEC(t) \
- (((double) (t).tv_sec * 1000.0) + ((double) (t).tv_usec) / 1000.0)
-
-#define INSTR_TIME_GET_MICROSEC(t) \
- (((uint64) (t).tv_sec * (uint64) 1000000) + (uint64) (t).tv_usec)
-
-#endif /* HAVE_CLOCK_GETTIME */
-
#else /* WIN32 */
/* Use QueryPerformanceCounter() */
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index d904f42d53..8ccd9d6ab0 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -228,7 +228,6 @@ sub GenerateFiles
HAVE_BACKTRACE_SYMBOLS => undef,
HAVE_BIO_GET_DATA => undef,
HAVE_BIO_METH_NEW => undef,
- HAVE_CLOCK_GETTIME => undef,
HAVE_COMPUTED_GOTO => undef,
HAVE_COPYFILE => undef,
HAVE_COPYFILE_H => undef,
--
2.30.2
0009-Remove-configure-probes-for-poll-and-poll.h.patchtext/x-patch; charset=US-ASCII; name=0009-Remove-configure-probes-for-poll-and-poll.h.patchDownload
From 195cde040271967c6566d327cef1e01f9f4d178c Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 24 Jul 2022 00:03:41 +1200
Subject: [PATCH 09/13] Remove configure probes for poll and poll.h.
poll() and <poll.h> are in SUSv2 (XSI) and all targeted Unix systems
have them. Wherever we test HAVE_POLL or HAVE_POLL_H, we really mean
'not Windows' and alternative paths are not being tested on Unix.
---
configure | 4 ++--
configure.ac | 2 --
src/backend/libpq/pqcomm.c | 2 +-
src/backend/storage/ipc/latch.c | 8 +++-----
src/backend/utils/misc/guc.c | 2 +-
src/bin/pgbench/pgbench.c | 2 --
src/include/pg_config.h.in | 6 ------
src/interfaces/libpq/fe-misc.c | 8 ++++----
src/tools/msvc/Solution.pm | 2 --
9 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/configure b/configure
index b6094c1a62..98affa21dd 100755
--- a/configure
+++ b/configure
@@ -13875,7 +13875,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
fi
-for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h poll.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/uio.h sys/un.h termios.h ucred.h
+for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h sys/epoll.h sys/event.h sys/ipc.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/signalfd.h sys/sockio.h sys/uio.h sys/un.h termios.h ucred.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"
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s poll posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index 27552e949e..18233608da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1452,7 +1452,6 @@ AC_CHECK_HEADERS(m4_normalize([
ifaddrs.h
langinfo.h
mbarrier.h
- poll.h
sys/epoll.h
sys/event.h
sys/ipc.h
@@ -1800,7 +1799,6 @@ AC_CHECK_FUNCS(m4_normalize([
kqueue
mbstowcs_l
memset_s
- poll
posix_fallocate
ppoll
pthread_is_threaded_np
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 75392a8bb7..74ceb7e5f5 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -54,7 +54,7 @@
*/
#include "postgres.h"
-#ifdef HAVE_POLL_H
+#ifndef WIN32
#include <poll.h>
#endif
#include <signal.h>
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index eb3a569aae..d0e05eefb6 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -46,7 +46,7 @@
#ifdef HAVE_SYS_SIGNALFD_H
#include <sys/signalfd.h>
#endif
-#ifdef HAVE_POLL_H
+#ifndef WIN32
#include <poll.h>
#endif
@@ -76,12 +76,10 @@
#define WAIT_USE_EPOLL
#elif defined(HAVE_KQUEUE)
#define WAIT_USE_KQUEUE
-#elif defined(HAVE_POLL)
-#define WAIT_USE_POLL
-#elif WIN32
+#elif defined(WIN32)
#define WAIT_USE_WIN32
#else
-#error "no wait set implementation available"
+#define WAIT_USE_POLL
#endif
/*
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index af4a1c3068..7c42c74ed8 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -20,7 +20,7 @@
#include <float.h>
#include <math.h>
#include <limits.h>
-#ifdef HAVE_POLL_H
+#ifndef WIN32
#include <poll.h>
#endif
#ifndef WIN32
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 71682a3300..e48d4f5053 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -47,9 +47,7 @@
/* For testing, PGBENCH_USE_SELECT can be defined to force use of that code */
#if defined(HAVE_PPOLL) && !defined(PGBENCH_USE_SELECT)
#define POLL_USING_PPOLL
-#ifdef HAVE_POLL_H
#include <poll.h>
-#endif
#else /* no ppoll(), so use select() */
#define POLL_USING_SELECT
#ifdef HAVE_SYS_SELECT_H
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 9c426ca8a0..be96c292be 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -381,12 +381,6 @@
/* Define to 1 if you have the <pam/pam_appl.h> header file. */
#undef HAVE_PAM_PAM_APPL_H
-/* Define to 1 if you have the `poll' function. */
-#undef HAVE_POLL
-
-/* Define to 1 if you have the <poll.h> header file. */
-#undef HAVE_POLL_H
-
/* Define to 1 if you have the `posix_fadvise' function. */
#undef HAVE_POSIX_FADVISE
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index d76bb3957a..86a36cb60c 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -40,7 +40,7 @@
#include <sys/time.h>
#endif
-#ifdef HAVE_POLL_H
+#ifndef WIN32
#include <poll.h>
#endif
#ifdef HAVE_SYS_SELECT_H
@@ -1095,7 +1095,7 @@ static int
pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
{
/* We use poll(2) if available, otherwise select(2) */
-#ifdef HAVE_POLL
+#ifndef WIN32
struct pollfd input_fd;
int timeout_ms;
@@ -1125,7 +1125,7 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
}
return poll(&input_fd, 1, timeout_ms);
-#else /* !HAVE_POLL */
+#else /* WIN32 */
fd_set input_mask;
fd_set output_mask;
@@ -1163,7 +1163,7 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
return select(sock + 1, &input_mask, &output_mask,
&except_mask, ptr_timeout);
-#endif /* HAVE_POLL */
+#endif /* WIN32 */
}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 8ccd9d6ab0..6e6c7126d4 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -321,8 +321,6 @@ sub GenerateFiles
HAVE_OPENSSL_INIT_SSL => undef,
HAVE_OSSP_UUID_H => undef,
HAVE_PAM_PAM_APPL_H => undef,
- HAVE_POLL => undef,
- HAVE_POLL_H => undef,
HAVE_POSIX_FADVISE => undef,
HAVE_POSIX_FALLOCATE => undef,
HAVE_PPC_LWARX_MUTEX_HINT => undef,
--
2.30.2
0010-Remove-dead-setenv-unsetenv-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0010-Remove-dead-setenv-unsetenv-replacement-code.patchDownload
From 1b99146ceff694ad4422388a90639ace08d774ea Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 23:00:49 +1200
Subject: [PATCH 10/13] Remove dead setenv, unsetenv replacement code.
setenv() and unsetenv() are in SUSv3 and targeted Unix systems have
them. We still need special code for these on Windows, but that doesn't
require a configure probe.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Greg Stark <stark@mit.edu>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
---
configure | 43 -------------------------
configure.ac | 13 --------
src/include/pg_config.h.in | 6 ----
src/include/port.h | 6 ++--
src/port/setenv.c | 48 ----------------------------
src/port/unsetenv.c | 65 --------------------------------------
src/tools/msvc/Solution.pm | 2 --
7 files changed, 2 insertions(+), 181 deletions(-)
delete mode 100644 src/port/setenv.c
delete mode 100644 src/port/unsetenv.c
diff --git a/configure b/configure
index 98affa21dd..82443d3edb 100755
--- a/configure
+++ b/configure
@@ -16865,49 +16865,6 @@ esac
$as_echo "$as_me: On $host_os we will use our strtof wrapper." >&6;}
fi
-case $host_os in
- # Windows uses a specialised env handler
- mingw*)
-
-$as_echo "#define HAVE_SETENV 1" >>confdefs.h
-
-
-$as_echo "#define HAVE_UNSETENV 1" >>confdefs.h
-
- ac_cv_func_setenv=yes
- ac_cv_func_unsetenv=yes
- ;;
- *)
- ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv"
-if test "x$ac_cv_func_setenv" = xyes; then :
- $as_echo "#define HAVE_SETENV 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" setenv.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS setenv.$ac_objext"
- ;;
-esac
-
-fi
-
-ac_fn_c_check_func "$LINENO" "unsetenv" "ac_cv_func_unsetenv"
-if test "x$ac_cv_func_unsetenv" = xyes; then :
- $as_echo "#define HAVE_UNSETENV 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" unsetenv.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS unsetenv.$ac_objext"
- ;;
-esac
-
-fi
-
-
- ;;
-esac
-
# System's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
diff --git a/configure.ac b/configure.ac
index 18233608da..c1a93dff20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1899,19 +1899,6 @@ if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
fi
-case $host_os in
- # Windows uses a specialised env handler
- mingw*)
- AC_DEFINE(HAVE_SETENV, 1, [Define to 1 because replacement version used.])
- AC_DEFINE(HAVE_UNSETENV, 1, [Define to 1 because replacement version used.])
- ac_cv_func_setenv=yes
- ac_cv_func_unsetenv=yes
- ;;
- *)
- AC_REPLACE_FUNCS([setenv unsetenv])
- ;;
-esac
-
# System's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
# We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index be96c292be..6ea38998f8 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -453,9 +453,6 @@
/* Define to 1 if you have the <security/pam_appl.h> header file. */
#undef HAVE_SECURITY_PAM_APPL_H
-/* Define to 1 if you have the `setenv' function. */
-#undef HAVE_SETENV
-
/* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE
@@ -630,9 +627,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
-/* Define to 1 if you have the `unsetenv' function. */
-#undef HAVE_UNSETENV
-
/* Define to 1 if you have the `uselocale' function. */
#undef HAVE_USELOCALE
diff --git a/src/include/port.h b/src/include/port.h
index 666f6b04f9..a8d9a64799 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -448,11 +448,9 @@ extern size_t strlcpy(char *dst, const char *src, size_t siz);
extern size_t strnlen(const char *str, size_t maxlen);
#endif
-#ifndef HAVE_SETENV
+#ifdef WIN32
+/* src/port/win32env.c has these for Windows */
extern int setenv(const char *name, const char *value, int overwrite);
-#endif
-
-#ifndef HAVE_UNSETENV
extern int unsetenv(const char *name);
#endif
diff --git a/src/port/setenv.c b/src/port/setenv.c
deleted file mode 100644
index d13c882467..0000000000
--- a/src/port/setenv.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * setenv.c
- * setenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/setenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-setenv(const char *name, const char *value, int overwrite)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL ||
- value == NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- /* No work if variable exists and we're not to replace it */
- if (overwrite == 0 && getenv(name) != NULL)
- return 0;
-
- /*
- * Add or replace the value using putenv(). This will leak memory if the
- * same variable is repeatedly redefined, but there's little we can do
- * about that when sitting atop putenv().
- */
- envstr = (char *) malloc(strlen(name) + strlen(value) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- sprintf(envstr, "%s=%s", name, value);
-
- return putenv(envstr);
-}
diff --git a/src/port/unsetenv.c b/src/port/unsetenv.c
deleted file mode 100644
index 62b806d796..0000000000
--- a/src/port/unsetenv.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * unsetenv.c
- * unsetenv() emulation for machines without it
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/port/unsetenv.c
- *
- *-------------------------------------------------------------------------
- */
-
-#include "c.h"
-
-
-int
-unsetenv(const char *name)
-{
- char *envstr;
-
- /* Error conditions, per POSIX */
- if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL)
- {
- errno = EINVAL;
- return -1;
- }
-
- if (getenv(name) == NULL)
- return 0; /* no work */
-
- /*
- * The technique embodied here works if libc follows the Single Unix Spec
- * and actually uses the storage passed to putenv() to hold the environ
- * entry. When we clobber the entry in the second step we are ensuring
- * that we zap the actual environ member. However, there are some libc
- * implementations (notably recent BSDs) that do not obey SUS but copy the
- * presented string. This method fails on such platforms. Hopefully all
- * such platforms have unsetenv() and thus won't be using this hack. See:
- * http://www.greenend.org.uk/rjk/2008/putenv.html
- *
- * Note that repeatedly setting and unsetting a var using this code will
- * leak memory.
- */
-
- envstr = (char *) malloc(strlen(name) + 2);
- if (!envstr) /* not much we can do if no memory */
- return -1;
-
- /* Override the existing setting by forcibly defining the var */
- sprintf(envstr, "%s=", name);
- if (putenv(envstr))
- return -1;
-
- /* Now we can clobber the variable definition this way: */
- strcpy(envstr, "=");
-
- /*
- * This last putenv cleans up if we have multiple zero-length names as a
- * result of unsetting multiple things.
- */
- return putenv(envstr);
-}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 6e6c7126d4..0d4ca94e7f 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -344,7 +344,6 @@ sub GenerateFiles
HAVE_RL_RESET_SCREEN_SIZE => undef,
HAVE_RL_VARIABLE_BIND => undef,
HAVE_SECURITY_PAM_APPL_H => undef,
- HAVE_SETENV => undef,
HAVE_SETPROCTITLE => undef,
HAVE_SETPROCTITLE_FAST => undef,
HAVE_SOCKLEN_T => 1,
@@ -403,7 +402,6 @@ sub GenerateFiles
HAVE_UINT8 => undef,
HAVE_UNION_SEMUN => undef,
HAVE_UNISTD_H => 1,
- HAVE_UNSETENV => undef,
HAVE_USELOCALE => undef,
HAVE_UUID_BSD => undef,
HAVE_UUID_E2FS => undef,
--
2.30.2
0011-Remove-dead-pread-and-pwrite-replacement-code.patchtext/x-patch; charset=US-ASCII; name=0011-Remove-dead-pread-and-pwrite-replacement-code.patchDownload
From 057674c17f6db4591da1cdf7a4a5cde3c6f98ec1 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 9 Jul 2022 21:31:56 +1200
Subject: [PATCH 11/13] Remove dead pread and pwrite replacement code.
pread() and pwrite() are in SUSv2 (XSI option) and SUSv4 (base), and all
targeted Unix systems have them.
Previously, we defined pg_pread and pg_pwrite to emulate these function
with lseek() on old Unixen. The names with a pg_ prefix were a reminder
of a portability hazard: they might change the current file position.
That hazard is gone, so we can drop the prefixes.
We still have replacement code for Windows, but the configure probes are
no longer needed.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Greg Stark <stark@mit.edu>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
---
configure | 38 +++++---------
configure.ac | 4 +-
.../pg_stat_statements/pg_stat_statements.c | 4 +-
src/backend/access/heap/rewriteheap.c | 2 +-
src/backend/access/transam/slru.c | 4 +-
src/backend/access/transam/xlog.c | 4 +-
src/backend/access/transam/xlogreader.c | 2 +-
src/backend/access/transam/xlogrecovery.c | 2 +-
src/backend/replication/basebackup.c | 2 +-
src/backend/replication/walreceiver.c | 2 +-
src/backend/storage/file/fd.c | 4 +-
src/backend/utils/init/miscinit.c | 2 +-
src/bin/pg_test_fsync/pg_test_fsync.c | 50 +++++++++----------
src/include/access/xlogreader.h | 4 +-
src/include/pg_config.h.in | 6 ---
src/include/port.h | 18 ++-----
src/port/pread.c | 18 +------
src/port/preadv.c | 4 +-
src/port/pwrite.c | 18 +------
src/port/pwritev.c | 4 +-
src/tools/msvc/Solution.pm | 2 -
21 files changed, 68 insertions(+), 126 deletions(-)
diff --git a/configure b/configure
index 82443d3edb..3c7ae744ca 100755
--- a/configure
+++ b/configure
@@ -16752,32 +16752,6 @@ esac
fi
-ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
-if test "x$ac_cv_func_pread" = xyes; then :
- $as_echo "#define HAVE_PREAD 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" pread.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS pread.$ac_objext"
- ;;
-esac
-
-fi
-
-ac_fn_c_check_func "$LINENO" "pwrite" "ac_cv_func_pwrite"
-if test "x$ac_cv_func_pwrite" = xyes; then :
- $as_echo "#define HAVE_PWRITE 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" pwrite.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS pwrite.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
@@ -17015,6 +16989,18 @@ esac
;;
esac
+ case " $LIBOBJS " in
+ *" pread.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS pread.$ac_objext"
+ ;;
+esac
+
+ case " $LIBOBJS " in
+ *" pwrite.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS pwrite.$ac_objext"
+ ;;
+esac
+
case " $LIBOBJS " in
*" system.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS system.$ac_objext"
diff --git a/configure.ac b/configure.ac
index c1a93dff20..bc8534717d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1877,8 +1877,6 @@ AC_REPLACE_FUNCS(m4_normalize([
getpeereid
inet_aton
mkdtemp
- pread
- pwrite
strlcat
strlcpy
strnlen
@@ -1940,6 +1938,8 @@ if test "$PORTNAME" = "win32"; then
AC_LIBOBJ(kill)
AC_LIBOBJ(link)
AC_LIBOBJ(open)
+ AC_LIBOBJ(pread)
+ AC_LIBOBJ(pwrite)
AC_LIBOBJ(system)
AC_LIBOBJ(win32env)
AC_LIBOBJ(win32error)
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 049da9fe6d..0d72ea212e 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -2091,9 +2091,9 @@ qtext_store(const char *query, int query_len,
if (fd < 0)
goto error;
- if (pg_pwrite(fd, query, query_len, off) != query_len)
+ if (pwrite(fd, query, query_len, off) != query_len)
goto error;
- if (pg_pwrite(fd, "\0", 1, off + query_len) != 1)
+ if (pwrite(fd, "\0", 1, off + query_len) != 1)
goto error;
CloseTransientFile(fd);
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index 197f06b5ec..9dd885d936 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -1149,7 +1149,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
/* write out tail end of mapping file (again) */
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
- if (pg_pwrite(fd, data, len, xlrec->offset) != len)
+ if (pwrite(fd, data, len, xlrec->offset) != len)
{
/* if write didn't set errno, assume problem is no disk space */
if (errno == 0)
diff --git a/src/backend/access/transam/slru.c b/src/backend/access/transam/slru.c
index b65cb49d7f..c9a7b97949 100644
--- a/src/backend/access/transam/slru.c
+++ b/src/backend/access/transam/slru.c
@@ -718,7 +718,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_READ);
- if (pg_pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pread(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
slru_errcause = SLRU_READ_FAILED;
@@ -873,7 +873,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruWriteAll fdata)
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_SLRU_WRITE);
- if (pg_pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
+ if (pwrite(fd, shared->page_buffer[slotno], BLCKSZ, offset) != BLCKSZ)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 26fbed00a4..eb5115fd5a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2189,7 +2189,7 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
INSTR_TIME_SET_CURRENT(start);
pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
- written = pg_pwrite(openLogFile, from, nleft, startoffset);
+ written = pwrite(openLogFile, from, nleft, startoffset);
pgstat_report_wait_end();
/*
@@ -3011,7 +3011,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
* enough.
*/
errno = 0;
- if (pg_pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
+ if (pwrite(fd, zbuffer.data, 1, wal_segment_size - 1) != 1)
{
/* if write didn't set errno, assume no disk space */
save_errno = errno ? errno : ENOSPC;
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index f3dc4b7797..06e91547dd 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -1514,7 +1514,7 @@ WALRead(XLogReaderState *state,
/* Reset errno first; eases reporting non-errno-affecting errors */
errno = 0;
- readbytes = pg_pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
+ readbytes = pread(state->seg.ws_file, p, segbytes, (off_t) startoff);
#ifndef FRONTEND
pgstat_report_wait_end();
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 5d6f1b5e46..e25e055c77 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3210,7 +3210,7 @@ retry:
readOff = targetPageOff;
pgstat_report_wait_start(WAIT_EVENT_WAL_READ);
- r = pg_pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
+ r = pread(readFile, readBuf, XLOG_BLCKSZ, (off_t) readOff);
if (r != XLOG_BLCKSZ)
{
char fname[MAXFNAMELEN];
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 1a569e2582..3c375b131f 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1820,7 +1820,7 @@ basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
int rc;
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
- rc = pg_pread(fd, buf, nbytes, offset);
+ rc = pread(fd, buf, nbytes, offset);
pgstat_report_wait_end();
if (rc < 0)
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 3d37c1fe62..8604fd4bc2 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -915,7 +915,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr, TimeLineID tli)
/* OK to write the logs */
errno = 0;
- byteswritten = pg_pwrite(recvFile, buf, segbytes, (off_t) startoff);
+ byteswritten = pwrite(recvFile, buf, segbytes, (off_t) startoff);
if (byteswritten <= 0)
{
char xlogfname[MAXFNAMELEN];
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 28401a8881..71e7f2e143 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2063,7 +2063,7 @@ FileRead(File file, char *buffer, int amount, off_t offset,
retry:
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pread(vfdP->fd, buffer, amount, offset);
+ returnCode = pread(vfdP->fd, buffer, amount, offset);
pgstat_report_wait_end();
if (returnCode < 0)
@@ -2145,7 +2145,7 @@ FileWrite(File file, char *buffer, int amount, off_t offset,
retry:
errno = 0;
pgstat_report_wait_start(wait_event_info);
- returnCode = pg_pwrite(VfdCache[file].fd, buffer, amount, offset);
+ returnCode = pwrite(VfdCache[file].fd, buffer, amount, offset);
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 70018ca5d0..c65b596d1b 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -1429,7 +1429,7 @@ AddToDataDirLockFile(int target_line, const char *str)
len = strlen(destbuffer);
errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOCK_FILE_ADDTODATADIR_WRITE);
- if (pg_pwrite(fd, destbuffer, len, 0) != len)
+ if (pwrite(fd, destbuffer, len, 0) != len)
{
pgstat_report_wait_end();
/* if write didn't set errno, assume problem is no disk space */
diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
index 6739214eb8..8f0ef8e66b 100644
--- a/src/bin/pg_test_fsync/pg_test_fsync.c
+++ b/src/bin/pg_test_fsync/pg_test_fsync.c
@@ -312,10 +312,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
@@ -338,10 +338,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
fdatasync(tmpfile);
}
@@ -363,10 +363,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (fsync(tmpfile) != 0)
die("fsync failed");
@@ -387,10 +387,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
die("write failed");
if (pg_fsync_writethrough(tmpfile) != 0)
die("fsync failed");
@@ -419,10 +419,10 @@ test_sync(int writes_per_op)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < writes_per_op; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- XLOG_BLCKSZ,
- writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile,
+ buf,
+ XLOG_BLCKSZ,
+ writes * XLOG_BLCKSZ) != XLOG_BLCKSZ)
/*
* This can generate write failures if the filesystem has
@@ -484,10 +484,10 @@ test_open_sync(const char *msg, int writes_size)
for (ops = 0; alarm_triggered == false; ops++)
{
for (writes = 0; writes < 16 / writes_size; writes++)
- if (pg_pwrite(tmpfile,
- buf,
- writes_size * 1024,
- writes * writes_size * 1024) !=
+ if (pwrite(tmpfile,
+ buf,
+ writes_size * 1024,
+ writes * writes_size * 1024) !=
writes_size * 1024)
die("write failed");
}
@@ -586,7 +586,7 @@ test_non_sync(void)
START_TIMER;
for (ops = 0; alarm_triggered == false; ops++)
{
- if (pg_pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
+ if (pwrite(tmpfile, buf, XLOG_BLCKSZ, 0) != XLOG_BLCKSZ)
die("write failed");
}
STOP_TIMER;
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h
index 5395f155aa..87ff00feb7 100644
--- a/src/include/access/xlogreader.h
+++ b/src/include/access/xlogreader.h
@@ -375,11 +375,11 @@ extern bool XLogReaderValidatePageHeader(XLogReaderState *state,
/*
* Error information from WALRead that both backend and frontend caller can
- * process. Currently only errors from pg_pread can be reported.
+ * process. Currently only errors from pread can be reported.
*/
typedef struct WALReadError
{
- int wre_errno; /* errno set by the last pg_pread() */
+ int wre_errno; /* errno set by the last pread() */
int wre_off; /* Offset we tried to read from. */
int wre_req; /* Bytes requested to be read. */
int wre_read; /* Bytes read by the last read(). */
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 6ea38998f8..e8633878d2 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -393,9 +393,6 @@
/* Define to 1 if you have the `ppoll' function. */
#undef HAVE_PPOLL
-/* Define to 1 if you have the `pread' function. */
-#undef HAVE_PREAD
-
/* Define to 1 if the PS_STRINGS thing exists. */
#undef HAVE_PS_STRINGS
@@ -411,9 +408,6 @@
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
-/* Define to 1 if you have the `pwrite' function. */
-#undef HAVE_PWRITE
-
/* Define to 1 if you have the <readline.h> header file. */
#undef HAVE_READLINE_H
diff --git a/src/include/port.h b/src/include/port.h
index a8d9a64799..21c441136b 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -418,20 +418,12 @@ extern int inet_aton(const char *cp, struct in_addr *addr);
#endif
/*
- * Windows and older Unix don't have pread(2) and pwrite(2). We have
- * replacement functions, but they have slightly different semantics so we'll
- * use a name with a pg_ prefix to avoid confusion.
+ * Windows doesn't have pread(2) and pwrite(2). We have replacement functions
+ * in src/port/pread.c and src/port/pwrite.c.
*/
-#ifdef HAVE_PREAD
-#define pg_pread pread
-#else
-extern ssize_t pg_pread(int fd, void *buf, size_t nbyte, off_t offset);
-#endif
-
-#ifdef HAVE_PWRITE
-#define pg_pwrite pwrite
-#else
-extern ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
+#ifdef WIN32
+extern ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset);
+extern ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
#endif
/* For pg_pwritev() and pg_preadv(), see port/pg_iovec.h. */
diff --git a/src/port/pread.c b/src/port/pread.c
index 491605926f..bc522d60cd 100644
--- a/src/port/pread.c
+++ b/src/port/pread.c
@@ -1,32 +1,24 @@
/*-------------------------------------------------------------------------
*
* pread.c
- * Implementation of pread(2) for platforms that lack one.
+ * Implementation of pread(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/port/pread.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pread().
- *
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pread(int fd, void *buf, size_t size, off_t offset)
+pread(int fd, void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -49,10 +41,4 @@ pg_pread(int fd, void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return read(fd, buf, size);
-#endif
}
diff --git a/src/port/preadv.c b/src/port/preadv.c
index d12e5a122b..aa7537503f 100644
--- a/src/port/preadv.c
+++ b/src/port/preadv.c
@@ -30,7 +30,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_READV
if (iovcnt == 1)
- return pg_pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return readv(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pread(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
diff --git a/src/port/pwrite.c b/src/port/pwrite.c
index eeaffacc48..a8f3f69344 100644
--- a/src/port/pwrite.c
+++ b/src/port/pwrite.c
@@ -1,32 +1,24 @@
/*-------------------------------------------------------------------------
*
* pwrite.c
- * Implementation of pwrite(2) for platforms that lack one.
+ * Implementation of pwrite(2) for Windows.
*
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
*
* IDENTIFICATION
* src/port/pwrite.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX function, so we use the name pg_pwrite().
- *
*-------------------------------------------------------------------------
*/
#include "postgres.h"
-#ifdef WIN32
#include <windows.h>
-#else
-#include <unistd.h>
-#endif
ssize_t
-pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
+pwrite(int fd, const void *buf, size_t size, off_t offset)
{
-#ifdef WIN32
OVERLAPPED overlapped = {0};
HANDLE handle;
DWORD result;
@@ -46,10 +38,4 @@ pg_pwrite(int fd, const void *buf, size_t size, off_t offset)
}
return result;
-#else
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
-
- return write(fd, buf, size);
-#endif
}
diff --git a/src/port/pwritev.c b/src/port/pwritev.c
index 0bdd69fffc..cb7421381e 100644
--- a/src/port/pwritev.c
+++ b/src/port/pwritev.c
@@ -30,7 +30,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
#ifdef HAVE_WRITEV
if (iovcnt == 1)
- return pg_pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
+ return pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
return writev(fd, iov, iovcnt);
@@ -40,7 +40,7 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (int i = 0; i < iovcnt; ++i)
{
- part = pg_pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
+ part = pwrite(fd, iov[i].iov_base, iov[i].iov_len, offset);
if (part < 0)
{
if (i == 0)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 0d4ca94e7f..811cfe1ff3 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -325,13 +325,11 @@ sub GenerateFiles
HAVE_POSIX_FALLOCATE => undef,
HAVE_PPC_LWARX_MUTEX_HINT => undef,
HAVE_PPOLL => undef,
- HAVE_PREAD => undef,
HAVE_PS_STRINGS => undef,
HAVE_PTHREAD => undef,
HAVE_PTHREAD_BARRIER_WAIT => undef,
HAVE_PTHREAD_IS_THREADED_NP => undef,
HAVE_PTHREAD_PRIO_INHERIT => undef,
- HAVE_PWRITE => undef,
HAVE_READLINE_H => undef,
HAVE_READLINE_HISTORY_H => undef,
HAVE_READLINE_READLINE_H => undef,
--
2.30.2
0012-Simplify-replacement-code-for-preadv-and-pwritev.patchtext/x-patch; charset=US-ASCII; name=0012-Simplify-replacement-code-for-preadv-and-pwritev.patchDownload
From 887ce3b4b7f0457dc70f85fa16c64ee22a494d52 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sat, 23 Jul 2022 23:24:14 +1200
Subject: [PATCH 12/13] Simplify replacement code for preadv and pwritev.
preadv and pwritev are not standardized by POSIX, but all targeted Unix
systems have them except for Solaris (illumos has them since 2015). We
had two replacement implementations, one based on lseek() +
readv()/writev() and another based on a simple loop. The former was
used by Solaris only, and the latter by Windows only.
Supporting the extra path only for Solaris, at the cost of having a
pg_preadv/pg_pwritev that could never be used in a multi-threaded
program accessing the same file descriptor from two threads does not
sound like a good trade.
Drop the readv()/writev() variant, and also the pg_ prefix, now that the
file position portability hazard is gone.
---
configure | 2 +-
configure.ac | 2 --
src/backend/storage/file/fd.c | 4 ++--
src/include/pg_config.h.in | 6 ------
src/include/port/pg_iovec.h | 12 ++++--------
src/port/preadv.c | 13 +------------
src/port/pwritev.c | 13 +------------
src/tools/msvc/Solution.pm | 2 --
8 files changed, 9 insertions(+), 45 deletions(-)
diff --git a/configure b/configure
index 3c7ae744ca..531161182a 100755
--- a/configure
+++ b/configure
@@ -16039,7 +16039,7 @@ fi
LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
-for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np readv setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l writev
+for ac_func in backtrace_symbols copyfile fdatasync getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.ac b/configure.ac
index bc8534717d..56ec5a0b08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1802,7 +1802,6 @@ AC_CHECK_FUNCS(m4_normalize([
posix_fallocate
ppoll
pthread_is_threaded_np
- readv
setproctitle
setproctitle_fast
strchrnul
@@ -1811,7 +1810,6 @@ AC_CHECK_FUNCS(m4_normalize([
sync_file_range
uselocale
wcstombs_l
- writev
]))
# These typically are compiler builtins, for which AC_CHECK_FUNCS fails.
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 71e7f2e143..7d72b842c3 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -3762,7 +3762,7 @@ data_sync_elevel(int elevel)
}
/*
- * A convenience wrapper for pg_pwritev() that retries on partial write. If an
+ * A convenience wrapper for pwritev() that retries on partial write. If an
* error is returned, it is unspecified how much has been written.
*/
ssize_t
@@ -3782,7 +3782,7 @@ pg_pwritev_with_retry(int fd, const struct iovec *iov, int iovcnt, off_t offset)
for (;;)
{
/* Write as much as we can. */
- part = pg_pwritev(fd, iov, iovcnt, offset);
+ part = pwritev(fd, iov, iovcnt, offset);
if (part < 0)
return -1;
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index e8633878d2..f7a7b8116c 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -417,9 +417,6 @@
/* Define to 1 if you have the <readline/readline.h> header file. */
#undef HAVE_READLINE_READLINE_H
-/* Define to 1 if you have the `readv' function. */
-#undef HAVE_READV
-
/* Define to 1 if you have the `rl_completion_matches' function. */
#undef HAVE_RL_COMPLETION_MATCHES
@@ -648,9 +645,6 @@
/* Define to 1 if you have the <winldap.h> header file. */
#undef HAVE_WINLDAP_H
-/* Define to 1 if you have the `writev' function. */
-#undef HAVE_WRITEV
-
/* Define to 1 if you have the `X509_get_signature_nid' function. */
#undef HAVE_X509_GET_SIGNATURE_NID
diff --git a/src/include/port/pg_iovec.h b/src/include/port/pg_iovec.h
index f0b1a71bcb..f0a50c0e01 100644
--- a/src/include/port/pg_iovec.h
+++ b/src/include/port/pg_iovec.h
@@ -39,16 +39,12 @@ struct iovec
/* Define a reasonable maximum that is safe to use on the stack. */
#define PG_IOV_MAX Min(IOV_MAX, 32)
-#if HAVE_DECL_PREADV
-#define pg_preadv preadv
-#else
-extern ssize_t pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
+#if !HAVE_DECL_PREADV
+extern ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
#endif
-#if HAVE_DECL_PWRITEV
-#define pg_pwritev pwritev
-#else
-extern ssize_t pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
+#if !HAVE_DECL_PWRITEV
+extern ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
#endif
#endif /* PG_IOVEC_H */
diff --git a/src/port/preadv.c b/src/port/preadv.c
index aa7537503f..0aaf99222f 100644
--- a/src/port/preadv.c
+++ b/src/port/preadv.c
@@ -8,9 +8,6 @@
* IDENTIFICATION
* src/port/preadv.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX-like function, so we use the name pg_preadv().
- *
*-------------------------------------------------------------------------
*/
@@ -26,15 +23,8 @@
#include "port/pg_iovec.h"
ssize_t
-pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
+preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
-#ifdef HAVE_READV
- if (iovcnt == 1)
- return pread(fd, iov[0].iov_base, iov[0].iov_len, offset);
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
- return readv(fd, iov, iovcnt);
-#else
ssize_t sum = 0;
ssize_t part;
@@ -54,5 +44,4 @@ pg_preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset)
return sum;
}
return sum;
-#endif
}
diff --git a/src/port/pwritev.c b/src/port/pwritev.c
index cb7421381e..a0fa4b8edd 100644
--- a/src/port/pwritev.c
+++ b/src/port/pwritev.c
@@ -8,9 +8,6 @@
* IDENTIFICATION
* src/port/pwritev.c
*
- * Note that this implementation changes the current file position, unlike
- * the POSIX-like function, so we use the name pg_pwritev().
- *
*-------------------------------------------------------------------------
*/
@@ -26,15 +23,8 @@
#include "port/pg_iovec.h"
ssize_t
-pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
+pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
{
-#ifdef HAVE_WRITEV
- if (iovcnt == 1)
- return pwrite(fd, iov[0].iov_base, iov[0].iov_len, offset);
- if (lseek(fd, offset, SEEK_SET) < 0)
- return -1;
- return writev(fd, iov, iovcnt);
-#else
ssize_t sum = 0;
ssize_t part;
@@ -54,5 +44,4 @@ pg_pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset)
return sum;
}
return sum;
-#endif
}
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 811cfe1ff3..a4cebdcf96 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -333,7 +333,6 @@ sub GenerateFiles
HAVE_READLINE_H => undef,
HAVE_READLINE_HISTORY_H => undef,
HAVE_READLINE_READLINE_H => undef,
- HAVE_READV => undef,
HAVE_RL_COMPLETION_MATCHES => undef,
HAVE_RL_COMPLETION_SUPPRESS_QUOTE => undef,
HAVE_RL_FILENAME_COMPLETION_FUNCTION => undef,
@@ -409,7 +408,6 @@ sub GenerateFiles
HAVE_WINLDAP_H => undef,
HAVE_WCSTOMBS_L => 1,
HAVE_VISIBILITY_ATTRIBUTE => undef,
- HAVE_WRITEV => undef,
HAVE_X509_GET_SIGNATURE_NID => 1,
HAVE_X86_64_POPCNTQ => undef,
HAVE__BOOL => undef,
--
2.30.2
0013-Remove-disable-thread-safety.patchtext/x-patch; charset=US-ASCII; name=0013-Remove-disable-thread-safety.patchDownload
From fb697af651fb4a5c8b74deefdce360a2334ac791 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Fri, 26 Mar 2021 22:58:06 +1300
Subject: [PATCH 13/13] Remove --disable-thread-safety.
Threads are in SUSv2 and all targeted Unix systems have the option.
There are no known Unix systems that don't choose to implement the
threading option, and we're no longer testing such builds.
Future work to improve our use of threads will be simplified by not
having to cope with a no-threads build option.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Greg Stark <stark@mit.edu>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
---
configure | 56 ++-------------
configure.ac | 28 ++------
doc/src/sgml/installation.sgml | 13 ----
doc/src/sgml/libpq.sgml | 3 +-
src/Makefile.global.in | 1 -
src/bin/pgbench/pgbench.c | 22 +-----
src/include/pg_config.h.in | 4 --
src/interfaces/ecpg/ecpglib/connect.c | 40 -----------
src/interfaces/ecpg/ecpglib/descriptor.c | 9 ---
src/interfaces/ecpg/ecpglib/ecpglib_extern.h | 2 -
src/interfaces/ecpg/ecpglib/execute.c | 2 -
src/interfaces/ecpg/ecpglib/memory.c | 7 --
src/interfaces/ecpg/ecpglib/misc.c | 47 ------------
.../ecpg/include/ecpg-pthread-win32.h | 3 -
src/interfaces/ecpg/include/ecpg_config.h.in | 4 --
src/interfaces/ecpg/include/ecpglib.h | 2 -
.../ecpg/test/expected/thread-alloc.c | 43 +++++------
.../ecpg/test/expected/thread-alloc_2.stdout | 1 -
.../ecpg/test/expected/thread-descriptor.c | 22 +++---
.../ecpg/test/expected/thread-prep.c | 71 ++++++++-----------
.../ecpg/test/expected/thread-prep.stdout | 1 -
.../ecpg/test/expected/thread-prep_2.stdout | 0
.../ecpg/test/expected/thread-thread.c | 63 +++++++---------
.../ecpg/test/expected/thread-thread.stdout | 2 +-
.../ecpg/test/expected/thread-thread_2.stdout | 1 -
.../test/expected/thread-thread_implicit.c | 63 +++++++---------
.../expected/thread-thread_implicit.stdout | 2 +-
.../expected/thread-thread_implicit_2.stdout | 1 -
src/interfaces/ecpg/test/thread/alloc.pgc | 9 ---
.../ecpg/test/thread/descriptor.pgc | 8 +--
src/interfaces/ecpg/test/thread/prep.pgc | 9 ---
src/interfaces/ecpg/test/thread/thread.pgc | 9 ---
.../ecpg/test/thread/thread_implicit.pgc | 9 ---
src/interfaces/libpq/Makefile | 2 -
src/interfaces/libpq/fe-auth.c | 9 ++-
src/interfaces/libpq/fe-connect.c | 4 --
src/interfaces/libpq/fe-exec.c | 4 --
src/interfaces/libpq/fe-print.c | 13 +---
src/interfaces/libpq/fe-secure-openssl.c | 17 +----
src/interfaces/libpq/fe-secure.c | 26 +------
src/interfaces/libpq/legacy-pqsignal.c | 4 --
src/interfaces/libpq/libpq-int.h | 9 +--
src/port/getaddrinfo.c | 2 +-
src/tools/msvc/Solution.pm | 3 +-
src/tools/msvc/ecpg_regression.proj | 2 +-
45 files changed, 142 insertions(+), 510 deletions(-)
delete mode 100644 src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-prep_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-thread_2.stdout
delete mode 100644 src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
diff --git a/configure b/configure
index 531161182a..53dd6bb6e4 100755
--- a/configure
+++ b/configure
@@ -728,7 +728,6 @@ with_tcl
ICU_LIBS
ICU_CFLAGS
with_icu
-enable_thread_safety
INCLUDES
autodepend
PKG_CONFIG_LIBDIR
@@ -853,7 +852,6 @@ with_CC
with_llvm
enable_depend
enable_cassert
-enable_thread_safety
with_icu
with_tcl
with_tclconfig
@@ -1542,7 +1540,6 @@ Optional Features:
--enable-tap-tests enable TAP tests (requires Perl and IPC::Run)
--enable-depend turn on automatic dependency tracking
--enable-cassert enable assertion checks (for debugging)
- --disable-thread-safety disable thread-safety in client libraries
--disable-largefile omit support for large files
Optional Packages:
@@ -7972,43 +7969,6 @@ $as_echo "$as_me: WARNING: *** Library directory $dir does not exist." >&2;}
done
IFS=$ac_save_IFS
-#
-# Enable thread-safe client libraries
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking allow thread-safe client libraries" >&5
-$as_echo_n "checking allow thread-safe client libraries... " >&6; }
-
-
-# Check whether --enable-thread-safety was given.
-if test "${enable_thread_safety+set}" = set; then :
- enableval=$enable_thread_safety;
- case $enableval in
- yes)
- :
- ;;
- no)
- :
- ;;
- *)
- as_fn_error $? "no argument expected for --enable-thread-safety option" "$LINENO" 5
- ;;
- esac
-
-else
- enable_thread_safety=yes
-
-fi
-
-
-if test "$enable_thread_safety" = yes; then
-
-$as_echo "#define ENABLE_THREAD_SAFETY 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_thread_safety" >&5
-$as_echo "$enable_thread_safety" >&6; }
-
-
#
# ICU
#
@@ -11087,7 +11047,7 @@ fi
done
-if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then :
+if "$PORTNAME" != "win32"; then :
# then
@@ -11746,7 +11706,7 @@ if test "x$ac_cv_header_pthread_h" = xyes; then :
else
as_fn_error $? "
-pthread.h not found; use --disable-thread-safety to disable thread safety" "$LINENO" 5
+pthread.h not found" "$LINENO" 5
fi
@@ -12487,8 +12447,7 @@ if test "$ac_res" != no; then :
fi
-if test "$enable_thread_safety" = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname_r" >&5
$as_echo_n "checking for library containing gethostbyname_r... " >&6; }
if ${ac_cv_search_gethostbyname_r+:} false; then :
$as_echo_n "(cached) " >&6
@@ -12544,7 +12503,7 @@ if test "$ac_res" != no; then :
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
$as_echo_n "checking for library containing pthread_barrier_wait... " >&6; }
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
$as_echo_n "(cached) " >&6
@@ -12600,7 +12559,6 @@ if test "$ac_res" != no; then :
fi
-fi
if test "$with_readline" = yes; then
@@ -13473,7 +13431,7 @@ else
thread_safe_libldap=no
fi
- if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
+ if test "$thread_safe_libldap" = no; then
# Use ldap_r for FE if available, else assume ldap is thread-safe.
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
LIBS="$_LIBS"
@@ -16806,8 +16764,7 @@ fi
-if test "$enable_thread_safety" = yes; then
- ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
+ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
if test "x$ac_cv_func_pthread_barrier_wait" = xyes; then :
$as_echo "#define HAVE_PTHREAD_BARRIER_WAIT 1" >>confdefs.h
@@ -16821,7 +16778,6 @@ esac
fi
-fi
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
diff --git a/configure.ac b/configure.ac
index 56ec5a0b08..bfbe13c9a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -788,18 +788,6 @@ for dir in $LIBRARY_DIRS $SRCH_LIB; do
done
IFS=$ac_save_IFS
-#
-# Enable thread-safe client libraries
-#
-AC_MSG_CHECKING([allow thread-safe client libraries])
-PGAC_ARG_BOOL(enable, thread-safety, yes, [disable thread-safety in client libraries])
-if test "$enable_thread_safety" = yes; then
- AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
- [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])
-fi
-AC_MSG_RESULT([$enable_thread_safety])
-AC_SUBST(enable_thread_safety)
-
#
# ICU
#
@@ -1197,7 +1185,7 @@ dnl note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
dnl invocation below is the first one in the script, and autoconf generates
dnl additional code for that, which must not be inside the if-block. AS_IF
dnl knows how to do that.
-AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
+AS_IF(["$PORTNAME" != "win32"],
[ # then
AX_PTHREAD # set thread flags
@@ -1212,7 +1200,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
-pthread.h not found; use --disable-thread-safety to disable thread safety])])
+pthread.h not found])])
AC_CHECK_FUNCS([strerror_r gethostbyname_r])
@@ -1260,10 +1248,8 @@ AC_SEARCH_LIBS(shmget, cygipc)
# *BSD:
AC_SEARCH_LIBS(backtrace_symbols, execinfo)
-if test "$enable_thread_safety" = yes; then
- AC_SEARCH_LIBS(gethostbyname_r, nsl)
- AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
-fi
+AC_SEARCH_LIBS(gethostbyname_r, nsl)
+AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
if test "$with_readline" = yes; then
PGAC_CHECK_READLINE
@@ -1388,7 +1374,7 @@ if test "$with_ldap" = yes ; then
AC_CHECK_FUNC([ldap_verify_credentials],
[thread_safe_libldap=yes],
[thread_safe_libldap=no])
- if test "$enable_thread_safety" = yes -a "$thread_safe_libldap" = no; then
+ if test "$thread_safe_libldap" = no; then
# Use ldap_r for FE if available, else assume ldap is thread-safe.
# On some platforms ldap_r fails to link without PTHREAD_LIBS.
LIBS="$_LIBS"
@@ -1881,9 +1867,7 @@ AC_REPLACE_FUNCS(m4_normalize([
strtof
]))
-if test "$enable_thread_safety" = yes; then
- AC_REPLACE_FUNCS(pthread_barrier_wait)
-fi
+AC_REPLACE_FUNCS(pthread_barrier_wait)
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
# Cygwin and (apparently, based on test results) Mingw both
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 70d188e2bc..f31e1f9160 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1285,19 +1285,6 @@ build-postgresql:
</listitem>
</varlistentry>
- <varlistentry>
- <term><option>--disable-thread-safety</option></term>
- <listitem>
- <para>
- Disable the thread-safety of client libraries. This prevents
- concurrent threads in <application>libpq</application> and
- <application>ECPG</application> programs from safely controlling
- their private connection handles. Use this only on platforms
- with deficient threading support.
- </para>
- </listitem>
- </varlistentry>
-
</variablelist>
</sect3>
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 74456aa69d..655b4db31e 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -8837,7 +8837,8 @@ int PQisthreadsafe();
<para>
Returns 1 if the <application>libpq</application> is thread-safe
- and 0 if it is not.
+ and 0 if it is not. Since <productname>PostgreSQL</productname> version
+ 16, this function always returns 1.
</para>
</listitem>
</varlistentry>
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 14fdd4ef7b..cb35cd9eba 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -202,7 +202,6 @@ enable_debug = @enable_debug@
enable_dtrace = @enable_dtrace@
enable_coverage = @enable_coverage@
enable_tap_tests = @enable_tap_tests@
-enable_thread_safety = @enable_thread_safety@
python_includespec = @python_includespec@
python_libdir = @python_libdir@
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index e48d4f5053..bd46a83463 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -138,7 +138,7 @@ typedef struct socket_set
EnterSynchronizationBarrier((barrier), \
SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY)
#define THREAD_BARRIER_DESTROY(barrier)
-#elif defined(ENABLE_THREAD_SAFETY)
+#else
/* Use POSIX threads */
#include "port/pg_pthread.h"
#define THREAD_T pthread_t
@@ -154,16 +154,6 @@ typedef struct socket_set
pthread_barrier_init((barrier), NULL, (n))
#define THREAD_BARRIER_WAIT(barrier) pthread_barrier_wait((barrier))
#define THREAD_BARRIER_DESTROY(barrier) pthread_barrier_destroy((barrier))
-#else
-/* No threads implementation, use none (-j 1) */
-#define THREAD_T void *
-#define THREAD_FUNC_RETURN_TYPE void *
-#define THREAD_FUNC_RETURN return NULL
-#define THREAD_FUNC_CC
-#define THREAD_BARRIER_T int
-#define THREAD_BARRIER_INIT(barrier, n) (*(barrier) = 0)
-#define THREAD_BARRIER_WAIT(barrier)
-#define THREAD_BARRIER_DESTROY(barrier)
#endif
@@ -6678,10 +6668,6 @@ main(int argc, char **argv)
{
exit(1);
}
-#ifndef ENABLE_THREAD_SAFETY
- if (nthreads != 1)
- pg_fatal("threads are not supported on this platform; use -j1");
-#endif /* !ENABLE_THREAD_SAFETY */
break;
case 'C':
benchmarking_option_set = true;
@@ -7195,7 +7181,6 @@ main(int argc, char **argv)
if (errno != 0)
pg_fatal("could not initialize barrier: %m");
-#ifdef ENABLE_THREAD_SAFETY
/* start all threads but thread 0 which is executed directly later */
for (i = 1; i < nthreads; i++)
{
@@ -7207,9 +7192,6 @@ main(int argc, char **argv)
if (errno != 0)
pg_fatal("could not create thread: %m");
}
-#else
- Assert(nthreads == 1);
-#endif /* ENABLE_THREAD_SAFETY */
/* compute when to stop */
threads[0].create_time = pg_time_now();
@@ -7227,10 +7209,8 @@ main(int argc, char **argv)
{
TState *thread = &threads[i];
-#ifdef ENABLE_THREAD_SAFETY
if (i > 0)
THREAD_JOIN(thread->thread);
-#endif /* ENABLE_THREAD_SAFETY */
for (int j = 0; j < thread->nstate; j++)
if (thread->state[j].state != CSTATE_FINISHED)
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f7a7b8116c..a9f7ebd8ad 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -51,10 +51,6 @@
/* Define to 1 if you want National Language Support. (--enable-nls) */
#undef ENABLE_NLS
-/* Define to 1 to build client libraries as thread-safe code.
- (--enable-thread-safety) */
-#undef ENABLE_THREAD_SAFETY
-
/* Define to 1 if gettimeofday() takes only 1 argument. */
#undef GETTIMEOFDAY_1ARG
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index db0bae1fe0..8afb1f0a26 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -14,15 +14,12 @@
locale_t ecpg_clocale = (locale_t) 0;
#endif
-#ifdef ENABLE_THREAD_SAFETY
static pthread_mutex_t connections_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_key_t actual_connection_key;
static pthread_once_t actual_connection_key_once = PTHREAD_ONCE_INIT;
-#endif
static struct connection *actual_connection = NULL;
static struct connection *all_connections = NULL;
-#ifdef ENABLE_THREAD_SAFETY
static void
ecpg_actual_connection_init(void)
{
@@ -34,7 +31,6 @@ ecpg_pthreads_init(void)
{
pthread_once(&actual_connection_key_once, ecpg_actual_connection_init);
}
-#endif
static struct connection *
ecpg_get_connection_nr(const char *connection_name)
@@ -43,7 +39,6 @@ ecpg_get_connection_nr(const char *connection_name)
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
{
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init(); /* ensure actual_connection_key is valid */
ret = pthread_getspecific(actual_connection_key);
@@ -56,9 +51,6 @@ ecpg_get_connection_nr(const char *connection_name)
if (ret == NULL)
/* no TSD connection, going for global */
ret = actual_connection;
-#else
- ret = actual_connection;
-#endif
}
else
{
@@ -82,7 +74,6 @@ ecpg_get_connection(const char *connection_name)
if ((connection_name == NULL) || (strcmp(connection_name, "CURRENT") == 0))
{
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init(); /* ensure actual_connection_key is valid */
ret = pthread_getspecific(actual_connection_key);
@@ -95,21 +86,14 @@ ecpg_get_connection(const char *connection_name)
if (ret == NULL)
/* no TSD connection here either, using global */
ret = actual_connection;
-#else
- ret = actual_connection;
-#endif
}
else
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
ret = ecpg_get_connection_nr(connection_name);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
}
return ret;
@@ -143,10 +127,8 @@ ecpg_finish(struct connection *act)
con->next = act->next;
}
-#ifdef ENABLE_THREAD_SAFETY
if (pthread_getspecific(actual_connection_key) == act)
pthread_setspecific(actual_connection_key, all_connections);
-#endif
if (actual_connection == act)
actual_connection = all_connections;
@@ -212,11 +194,7 @@ ECPGsetconn(int lineno, const char *connection_name)
if (!ecpg_init(con, connection_name, lineno))
return false;
-#ifdef ENABLE_THREAD_SAFETY
pthread_setspecific(actual_connection_key, con);
-#else
- actual_connection = con;
-#endif
return true;
}
@@ -326,9 +304,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (dbname == NULL && connection_name == NULL)
connection_name = "DEFAULT";
-#if ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
-#endif
/* check if the identifier is unique */
if (ecpg_get_connection(connection_name))
@@ -505,9 +481,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
}
/* add connection to our list */
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
/*
* ... but first, make certain we have created ecpg_clocale. Rely on
@@ -519,9 +493,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
ecpg_clocale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
if (!ecpg_clocale)
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
ecpg_raise(lineno, ECPG_OUT_OF_MEMORY,
ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
if (host)
@@ -558,9 +530,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
this->next = all_connections;
all_connections = this;
-#ifdef ENABLE_THREAD_SAFETY
pthread_setspecific(actual_connection_key, all_connections);
-#endif
actual_connection = all_connections;
ecpg_log("ECPGconnect: opening database %s on %s port %s %s%s %s%s\n",
@@ -678,9 +648,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
ecpg_log("ECPGconnect: %s", errmsg);
ecpg_finish(this);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
ecpg_raise(lineno, ECPG_CONNECT, ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, db);
if (realname)
@@ -692,9 +660,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
if (realname)
ecpg_free(realname);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
this->autocommit = autocommit;
@@ -716,9 +682,7 @@ ECPGdisconnect(int lineno, const char *connection_name)
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
-#endif
if (strcmp(connection_name, "ALL") == 0)
{
@@ -737,18 +701,14 @@ ECPGdisconnect(int lineno, const char *connection_name)
if (!ecpg_init(con, connection_name, lineno))
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
return false;
}
else
ecpg_finish(con);
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&connections_mutex);
-#endif
return true;
}
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c
index 649a71c286..b47f422d92 100644
--- a/src/interfaces/ecpg/ecpglib/descriptor.c
+++ b/src/interfaces/ecpg/ecpglib/descriptor.c
@@ -19,7 +19,6 @@
static void descriptor_free(struct descriptor *desc);
/* We manage descriptors separately for each thread. */
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t descriptor_key;
static pthread_once_t descriptor_once = PTHREAD_ONCE_INIT;
@@ -49,12 +48,6 @@ set_descriptors(struct descriptor *value)
{
pthread_setspecific(descriptor_key, value);
}
-#else
-static struct descriptor *all_descriptors = NULL;
-
-#define get_descriptors() (all_descriptors)
-#define set_descriptors(value) do { all_descriptors = (value); } while(0)
-#endif
/* old internal convenience function that might go away later */
static PGresult *
@@ -782,7 +775,6 @@ ECPGdeallocate_desc(int line, const char *name)
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
/* Deallocate all descriptors in the list */
static void
@@ -796,7 +788,6 @@ descriptor_deallocate_all(struct descriptor *list)
list = next;
}
}
-#endif /* ENABLE_THREAD_SAFETY */
bool
ECPGallocate_desc(int line, const char *name)
diff --git a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
index c438cfb820..968f1211b8 100644
--- a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
+++ b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h
@@ -169,9 +169,7 @@ bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum COMPAT_MODE, bool);
-#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
-#endif
struct connection *ecpg_get_connection(const char *);
char *ecpg_alloc(long, int);
char *ecpg_auto_alloc(long, int);
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index bd94bd4e6c..0b2716d921 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1961,9 +1961,7 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
return false;
}
-#ifdef ENABLE_THREAD_SAFETY
ecpg_pthreads_init();
-#endif
con = ecpg_get_connection(connection_name);
diff --git a/src/interfaces/ecpg/ecpglib/memory.c b/src/interfaces/ecpg/ecpglib/memory.c
index bd81251054..a83637ac75 100644
--- a/src/interfaces/ecpg/ecpglib/memory.c
+++ b/src/interfaces/ecpg/ecpglib/memory.c
@@ -68,7 +68,6 @@ struct auto_mem
struct auto_mem *next;
};
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t auto_mem_key;
static pthread_once_t auto_mem_once = PTHREAD_ONCE_INIT;
@@ -97,12 +96,6 @@ set_auto_allocs(struct auto_mem *am)
{
pthread_setspecific(auto_mem_key, am);
}
-#else
-static struct auto_mem *auto_allocs = NULL;
-
-#define get_auto_allocs() (auto_allocs)
-#define set_auto_allocs(am) do { auto_allocs = (am); } while(0)
-#endif
char *
ecpg_auto_alloc(long size, int lineno)
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 1eef1ec044..71f07c4e4f 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -55,42 +55,11 @@ static struct sqlca_t sqlca_init =
}
};
-#ifdef ENABLE_THREAD_SAFETY
static pthread_key_t sqlca_key;
static pthread_once_t sqlca_key_once = PTHREAD_ONCE_INIT;
-#else
-static struct sqlca_t sqlca =
-{
- {
- 'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '
- },
- sizeof(struct sqlca_t),
- 0,
- {
- 0,
- {
- 0
- }
- },
- {
- 'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '
- },
- {
- 0, 0, 0, 0, 0, 0
- },
- {
- 0, 0, 0, 0, 0, 0, 0, 0
- },
- {
- '0', '0', '0', '0', '0'
- }
-};
-#endif
-#ifdef ENABLE_THREAD_SAFETY
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t debug_init_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
static int simple_debug = 0;
static FILE *debugstream = NULL;
@@ -123,7 +92,6 @@ ecpg_init(const struct connection *con, const char *connection_name, const int l
return true;
}
-#ifdef ENABLE_THREAD_SAFETY
static void
ecpg_sqlca_key_destructor(void *arg)
{
@@ -135,12 +103,10 @@ ecpg_sqlca_key_init(void)
{
pthread_key_create(&sqlca_key, ecpg_sqlca_key_destructor);
}
-#endif
struct sqlca_t *
ECPGget_sqlca(void)
{
-#ifdef ENABLE_THREAD_SAFETY
struct sqlca_t *sqlca;
pthread_once(&sqlca_key_once, ecpg_sqlca_key_init);
@@ -155,9 +121,6 @@ ECPGget_sqlca(void)
pthread_setspecific(sqlca_key, sqlca);
}
return sqlca;
-#else
- return &sqlca;
-#endif
}
bool
@@ -240,9 +203,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
void
ECPGdebug(int n, FILE *dbgs)
{
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&debug_init_mutex);
-#endif
if (n > 100)
{
@@ -256,9 +217,7 @@ ECPGdebug(int n, FILE *dbgs)
ecpg_log("ECPGdebug: set to %d\n", simple_debug);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&debug_init_mutex);
-#endif
}
void
@@ -290,9 +249,7 @@ ecpg_log(const char *format,...)
else
snprintf(fmt, bufsize, "[%d]: %s", (int) getpid(), intl_format);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&debug_mutex);
-#endif
va_start(ap, format);
vfprintf(debugstream, fmt, ap);
@@ -307,9 +264,7 @@ ecpg_log(const char *format,...)
fflush(debugstream);
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&debug_mutex);
-#endif
free(fmt);
}
@@ -451,7 +406,6 @@ ECPGis_noind_null(enum ECPGttype type, const void *ptr)
}
#ifdef WIN32
-#ifdef ENABLE_THREAD_SAFETY
void
win32_pthread_mutex(volatile pthread_mutex_t *mutex)
@@ -482,7 +436,6 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void))
pthread_mutex_unlock(&win32_pthread_once_lock);
}
}
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
#ifdef ENABLE_NLS
diff --git a/src/interfaces/ecpg/include/ecpg-pthread-win32.h b/src/interfaces/ecpg/include/ecpg-pthread-win32.h
index 33c897b633..8252a17809 100644
--- a/src/interfaces/ecpg/include/ecpg-pthread-win32.h
+++ b/src/interfaces/ecpg/include/ecpg-pthread-win32.h
@@ -5,8 +5,6 @@
#ifndef _ECPG_PTHREAD_WIN32_H
#define _ECPG_PTHREAD_WIN32_H
-#ifdef ENABLE_THREAD_SAFETY
-
#ifndef WIN32
#include <pthread.h>
@@ -53,6 +51,5 @@ void win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void));
win32_pthread_once((once), (fn)); \
} while(0)
#endif /* WIN32 */
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* _ECPG_PTHREAD_WIN32_H */
diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in
index cbd24f11a0..6d01608a49 100644
--- a/src/interfaces/ecpg/include/ecpg_config.h.in
+++ b/src/interfaces/ecpg/include/ecpg_config.h.in
@@ -1,7 +1,3 @@
-/* Define to 1 to build client libraries as thread-safe code.
- * (--enable-thread-safety) */
-#undef ENABLE_THREAD_SAFETY
-
/* Define to 1 if the system has the type `int64'. */
#undef HAVE_INT64
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 00240109a6..05433726ac 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -92,9 +92,7 @@ void *ECPGget_var(int number);
/* dynamic result allocation */
void ECPGfree_auto_mem(void);
-#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
-#endif
#ifdef __cplusplus
}
diff --git a/src/interfaces/ecpg/test/expected/thread-alloc.c b/src/interfaces/ecpg/test/expected/thread-alloc.c
index 37ef44ed94..3b31d27fd3 100644
--- a/src/interfaces/ecpg/test/expected/thread-alloc.c
+++ b/src/interfaces/ecpg/test/expected/thread-alloc.c
@@ -11,14 +11,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -101,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 26 "alloc.pgc"
+#line 18 "alloc.pgc"
#line 1 "regression.h"
@@ -111,14 +103,14 @@ struct sqlca_t *ECPGget_sqlca(void);
-#line 27 "alloc.pgc"
+#line 19 "alloc.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 29 "alloc.pgc"
+#line 21 "alloc.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 30 "alloc.pgc"
+#line 22 "alloc.pgc"
#ifdef WIN32
@@ -134,54 +126,54 @@ static void* fn(void* arg)
-#line 41 "alloc.pgc"
+#line 33 "alloc.pgc"
int value ;
-#line 42 "alloc.pgc"
+#line 34 "alloc.pgc"
char name [ 100 ] ;
-#line 43 "alloc.pgc"
+#line 35 "alloc.pgc"
char ** r = NULL ;
/* exec sql end declare section */
-#line 44 "alloc.pgc"
+#line 36 "alloc.pgc"
value = (intptr_t) arg;
sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
-#line 49 "alloc.pgc"
+#line 41 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "alloc.pgc"
+#line 41 "alloc.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 50 "alloc.pgc"
+#line 42 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 50 "alloc.pgc"
+#line 42 "alloc.pgc"
for (i = 1; i <= REPEATS; ++i)
{
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select relname from pg_class where relname = 'pg_class'", ECPGt_EOIT,
ECPGt_char,&(r),(long)0,(long)0,(1)*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 53 "alloc.pgc"
+#line 45 "alloc.pgc"
free(r);
r = NULL;
}
{ ECPGdisconnect(__LINE__, name);
-#line 57 "alloc.pgc"
+#line 49 "alloc.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 57 "alloc.pgc"
+#line 49 "alloc.pgc"
return 0;
@@ -215,4 +207,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout b/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
deleted file mode 100644
index 75fe16bb36..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-alloc_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-No threading enabled.
diff --git a/src/interfaces/ecpg/test/expected/thread-descriptor.c b/src/interfaces/ecpg/test/expected/thread-descriptor.c
index f56cc25ab0..e34f4708d1 100644
--- a/src/interfaces/ecpg/test/expected/thread-descriptor.c
+++ b/src/interfaces/ecpg/test/expected/thread-descriptor.c
@@ -7,7 +7,6 @@
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
#line 1 "descriptor.pgc"
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -16,7 +15,6 @@
#else
#include <pthread.h>
#endif
-#endif
#include <stdio.h>
#define THREADS 16
@@ -91,16 +89,16 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 16 "descriptor.pgc"
+#line 14 "descriptor.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 17 "descriptor.pgc"
+#line 15 "descriptor.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 18 "descriptor.pgc"
+#line 16 "descriptor.pgc"
-#if defined(ENABLE_THREAD_SAFETY) && defined(WIN32)
+#if defined(WIN32)
static unsigned __stdcall fn(void* arg)
#else
static void* fn(void* arg)
@@ -111,16 +109,16 @@ static void* fn(void* arg)
for (i = 1; i <= REPEATS; ++i)
{
ECPGallocate_desc(__LINE__, "mydesc");
-#line 30 "descriptor.pgc"
+#line 28 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
-#line 30 "descriptor.pgc"
+#line 28 "descriptor.pgc"
ECPGdeallocate_desc(__LINE__, "mydesc");
-#line 31 "descriptor.pgc"
+#line 29 "descriptor.pgc"
if (sqlca.sqlcode < 0) sqlprint();
-#line 31 "descriptor.pgc"
+#line 29 "descriptor.pgc"
}
@@ -129,7 +127,6 @@ if (sqlca.sqlcode < 0) sqlprint();
int main ()
{
-#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@@ -153,9 +150,6 @@ int main ()
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
-#else
- fn(NULL);
-#endif
return 0;
}
diff --git a/src/interfaces/ecpg/test/expected/thread-prep.c b/src/interfaces/ecpg/test/expected/thread-prep.c
index 7cdf2505d3..052e27b634 100644
--- a/src/interfaces/ecpg/test/expected/thread-prep.c
+++ b/src/interfaces/ecpg/test/expected/thread-prep.c
@@ -11,14 +11,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -101,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void);
#endif
-#line 26 "prep.pgc"
+#line 18 "prep.pgc"
#line 1 "regression.h"
@@ -111,14 +103,14 @@ struct sqlca_t *ECPGget_sqlca(void);
-#line 27 "prep.pgc"
+#line 19 "prep.pgc"
/* exec sql whenever sqlerror sqlprint ; */
-#line 29 "prep.pgc"
+#line 21 "prep.pgc"
/* exec sql whenever not found sqlprint ; */
-#line 30 "prep.pgc"
+#line 22 "prep.pgc"
#ifdef WIN32
@@ -134,64 +126,64 @@ static void* fn(void* arg)
-#line 41 "prep.pgc"
+#line 33 "prep.pgc"
int value ;
-#line 42 "prep.pgc"
+#line 34 "prep.pgc"
char name [ 100 ] ;
-#line 43 "prep.pgc"
+#line 35 "prep.pgc"
char query [ 256 ] = "INSERT INTO T VALUES ( ? )" ;
/* exec sql end declare section */
-#line 44 "prep.pgc"
+#line 36 "prep.pgc"
value = (intptr_t) arg;
sprintf(name, "Connection: %d", value);
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , name, 0);
-#line 49 "prep.pgc"
+#line 41 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 49 "prep.pgc"
+#line 41 "prep.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 50 "prep.pgc"
+#line 42 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 50 "prep.pgc"
+#line 42 "prep.pgc"
for (i = 1; i <= REPEATS; ++i)
{
{ ECPGprepare(__LINE__, NULL, 0, "i", query);
-#line 53 "prep.pgc"
+#line 45 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 53 "prep.pgc"
+#line 45 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i",
ECPGt_int,&(value),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 54 "prep.pgc"
+#line 46 "prep.pgc"
}
{ ECPGdeallocate(__LINE__, 0, NULL, "i");
-#line 56 "prep.pgc"
+#line 48 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 56 "prep.pgc"
+#line 48 "prep.pgc"
{ ECPGdisconnect(__LINE__, name);
-#line 57 "prep.pgc"
+#line 49 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 57 "prep.pgc"
+#line 49 "prep.pgc"
return 0;
@@ -207,34 +199,34 @@ int main ()
#endif
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
-#line 71 "prep.pgc"
+#line 63 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 71 "prep.pgc"
+#line 63 "prep.pgc"
{ ECPGsetcommit(__LINE__, "on", NULL);
-#line 72 "prep.pgc"
+#line 64 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 72 "prep.pgc"
+#line 64 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table if exists T", ECPGt_EOIT, ECPGt_EORT);
-#line 73 "prep.pgc"
+#line 65 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 73 "prep.pgc"
+#line 65 "prep.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( i int )", ECPGt_EOIT, ECPGt_EORT);
-#line 74 "prep.pgc"
+#line 66 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 74 "prep.pgc"
+#line 66 "prep.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");
-#line 75 "prep.pgc"
+#line 67 "prep.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 75 "prep.pgc"
+#line 67 "prep.pgc"
#ifdef WIN32
@@ -256,4 +248,3 @@ if (sqlca.sqlcode < 0) sqlprint();}
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/expected/thread-prep.stdout b/src/interfaces/ecpg/test/expected/thread-prep.stdout
index 75fe16bb36..e69de29bb2 100644
--- a/src/interfaces/ecpg/test/expected/thread-prep.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-prep.stdout
@@ -1 +0,0 @@
-No threading enabled.
diff --git a/src/interfaces/ecpg/test/expected/thread-prep_2.stdout b/src/interfaces/ecpg/test/expected/thread-prep_2.stdout
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.c b/src/interfaces/ecpg/test/expected/thread-thread.c
index 0e75c47fab..95faa223c2 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread.c
@@ -15,14 +15,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -38,7 +30,7 @@ main(void)
-#line 24 "thread.pgc"
+#line 16 "thread.pgc"
void *test_thread(void *arg);
@@ -57,10 +49,10 @@ int main()
/* exec sql begin declare section */
-#line 40 "thread.pgc"
+#line 32 "thread.pgc"
int l_rows ;
/* exec sql end declare section */
-#line 41 "thread.pgc"
+#line 33 "thread.pgc"
/* Do not switch on debug output for regression tests. The threads get executed in
@@ -69,22 +61,22 @@ int main()
/* setup test_thread table */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 48 "thread.pgc"
+#line 40 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
-#line 49 "thread.pgc"
+#line 41 "thread.pgc"
/* DROP might fail */
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 50 "thread.pgc"
+#line 42 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
-#line 55 "thread.pgc"
+#line 47 "thread.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 56 "thread.pgc"
+#line 48 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 57 "thread.pgc"
+#line 49 "thread.pgc"
/* create, and start, threads */
@@ -116,18 +108,18 @@ int main()
/* and check results */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 87 "thread.pgc"
+#line 79 "thread.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 88 "thread.pgc"
+#line 80 "thread.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 89 "thread.pgc"
+#line 81 "thread.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 90 "thread.pgc"
+#line 82 "thread.pgc"
if( l_rows == (nthreads * iterations) )
printf("Success.\n");
@@ -145,13 +137,13 @@ void *test_thread(void *arg)
-#line 104 "thread.pgc"
+#line 96 "thread.pgc"
int l_i ;
-#line 105 "thread.pgc"
+#line 97 "thread.pgc"
char l_connection [ 128 ] ;
/* exec sql end declare section */
-#line 106 "thread.pgc"
+#line 98 "thread.pgc"
/* build up connection name, and connect to database */
@@ -161,13 +153,13 @@ void *test_thread(void *arg)
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
#endif
/* exec sql whenever sqlerror sqlprint ; */
-#line 114 "thread.pgc"
+#line 106 "thread.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
-#line 115 "thread.pgc"
+#line 107 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 115 "thread.pgc"
+#line 107 "thread.pgc"
if( sqlca.sqlcode != 0 )
{
@@ -175,10 +167,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
return NULL;
}
{ ECPGtrans(__LINE__, l_connection, "begin");
-#line 121 "thread.pgc"
+#line 113 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 121 "thread.pgc"
+#line 113 "thread.pgc"
/* insert into test_thread table */
@@ -189,10 +181,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 126 "thread.pgc"
+#line 118 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 126 "thread.pgc"
+#line 118 "thread.pgc"
if( sqlca.sqlcode != 0 )
printf("%s: ERROR: insert failed!\n", l_connection);
@@ -200,17 +192,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
/* all done */
{ ECPGtrans(__LINE__, l_connection, "commit");
-#line 132 "thread.pgc"
+#line 124 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 132 "thread.pgc"
+#line 124 "thread.pgc"
{ ECPGdisconnect(__LINE__, l_connection);
-#line 133 "thread.pgc"
+#line 125 "thread.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 133 "thread.pgc"
+#line 125 "thread.pgc"
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/expected/thread-thread.stdout b/src/interfaces/ecpg/test/expected/thread-thread.stdout
index 75fe16bb36..a9d787cc55 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-thread.stdout
@@ -1 +1 @@
-No threading enabled.
+Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_2.stdout b/src/interfaces/ecpg/test/expected/thread-thread_2.stdout
deleted file mode 100644
index a9d787cc55..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-thread_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
index 0df2794530..7ac0297a23 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
+++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.c
@@ -15,14 +15,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -38,7 +30,7 @@ main(void)
-#line 24 "thread_implicit.pgc"
+#line 16 "thread_implicit.pgc"
void *test_thread(void *arg);
@@ -57,10 +49,10 @@ int main()
/* exec sql begin declare section */
-#line 40 "thread_implicit.pgc"
+#line 32 "thread_implicit.pgc"
int l_rows ;
/* exec sql end declare section */
-#line 41 "thread_implicit.pgc"
+#line 33 "thread_implicit.pgc"
/* Do not switch on debug output for regression tests. The threads get executed in
@@ -69,22 +61,22 @@ int main()
/* setup test_thread table */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 48 "thread_implicit.pgc"
+#line 40 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test_thread", ECPGt_EOIT, ECPGt_EORT);}
-#line 49 "thread_implicit.pgc"
+#line 41 "thread_implicit.pgc"
/* DROP might fail */
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 50 "thread_implicit.pgc"
+#line 42 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test_thread ( tstamp timestamp not null default cast ( timeofday ( ) as timestamp ) , thread text not null , iteration integer not null , primary key ( thread , iteration ) )", ECPGt_EOIT, ECPGt_EORT);}
-#line 55 "thread_implicit.pgc"
+#line 47 "thread_implicit.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 56 "thread_implicit.pgc"
+#line 48 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 57 "thread_implicit.pgc"
+#line 49 "thread_implicit.pgc"
/* create, and start, threads */
@@ -116,18 +108,18 @@ int main()
/* and check results */
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
-#line 87 "thread_implicit.pgc"
+#line 79 "thread_implicit.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from test_thread", ECPGt_EOIT,
ECPGt_int,&(l_rows),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
-#line 88 "thread_implicit.pgc"
+#line 80 "thread_implicit.pgc"
{ ECPGtrans(__LINE__, NULL, "commit");}
-#line 89 "thread_implicit.pgc"
+#line 81 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, "CURRENT");}
-#line 90 "thread_implicit.pgc"
+#line 82 "thread_implicit.pgc"
if( l_rows == (nthreads * iterations) )
printf("Success.\n");
@@ -145,13 +137,13 @@ void *test_thread(void *arg)
-#line 104 "thread_implicit.pgc"
+#line 96 "thread_implicit.pgc"
int l_i ;
-#line 105 "thread_implicit.pgc"
+#line 97 "thread_implicit.pgc"
char l_connection [ 128 ] ;
/* exec sql end declare section */
-#line 106 "thread_implicit.pgc"
+#line 98 "thread_implicit.pgc"
/* build up connection name, and connect to database */
@@ -161,13 +153,13 @@ void *test_thread(void *arg)
_snprintf(l_connection, sizeof(l_connection), "thread_%03ld", threadnum);
#endif
/* exec sql whenever sqlerror sqlprint ; */
-#line 114 "thread_implicit.pgc"
+#line 106 "thread_implicit.pgc"
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , l_connection, 0);
-#line 115 "thread_implicit.pgc"
+#line 107 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 115 "thread_implicit.pgc"
+#line 107 "thread_implicit.pgc"
if( sqlca.sqlcode != 0 )
{
@@ -175,10 +167,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
return NULL;
}
{ ECPGtrans(__LINE__, NULL, "begin");
-#line 121 "thread_implicit.pgc"
+#line 113 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 121 "thread_implicit.pgc"
+#line 113 "thread_implicit.pgc"
/* insert into test_thread table */
@@ -189,10 +181,10 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_int,&(l_i),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
-#line 126 "thread_implicit.pgc"
+#line 118 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 126 "thread_implicit.pgc"
+#line 118 "thread_implicit.pgc"
if( sqlca.sqlcode != 0 )
printf("%s: ERROR: insert failed!\n", l_connection);
@@ -200,17 +192,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
/* all done */
{ ECPGtrans(__LINE__, NULL, "commit");
-#line 132 "thread_implicit.pgc"
+#line 124 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 132 "thread_implicit.pgc"
+#line 124 "thread_implicit.pgc"
{ ECPGdisconnect(__LINE__, l_connection);
-#line 133 "thread_implicit.pgc"
+#line 125 "thread_implicit.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
-#line 133 "thread_implicit.pgc"
+#line 125 "thread_implicit.pgc"
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout b/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
index 75fe16bb36..a9d787cc55 100644
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
+++ b/src/interfaces/ecpg/test/expected/thread-thread_implicit.stdout
@@ -1 +1 @@
-No threading enabled.
+Success.
diff --git a/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout b/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
deleted file mode 100644
index a9d787cc55..0000000000
--- a/src/interfaces/ecpg/test/expected/thread-thread_implicit_2.stdout
+++ /dev/null
@@ -1 +0,0 @@
-Success.
diff --git a/src/interfaces/ecpg/test/thread/alloc.pgc b/src/interfaces/ecpg/test/thread/alloc.pgc
index c0021a737e..d3d35493bf 100644
--- a/src/interfaces/ecpg/test/thread/alloc.pgc
+++ b/src/interfaces/ecpg/test/thread/alloc.pgc
@@ -2,14 +2,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -87,4 +79,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/thread/descriptor.pgc b/src/interfaces/ecpg/test/thread/descriptor.pgc
index 76a7a5dff5..30bce7c87b 100644
--- a/src/interfaces/ecpg/test/thread/descriptor.pgc
+++ b/src/interfaces/ecpg/test/thread/descriptor.pgc
@@ -1,4 +1,3 @@
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -7,7 +6,6 @@
#else
#include <pthread.h>
#endif
-#endif
#include <stdio.h>
#define THREADS 16
@@ -17,7 +15,7 @@ EXEC SQL include sqlca;
EXEC SQL whenever sqlerror sqlprint;
EXEC SQL whenever not found sqlprint;
-#if defined(ENABLE_THREAD_SAFETY) && defined(WIN32)
+#if defined(WIN32)
static unsigned __stdcall fn(void* arg)
#else
static void* fn(void* arg)
@@ -36,7 +34,6 @@ static void* fn(void* arg)
int main ()
{
-#ifdef ENABLE_THREAD_SAFETY
int i;
#ifdef WIN32
HANDLE threads[THREADS];
@@ -60,9 +57,6 @@ int main ()
for (i = 0; i < THREADS; ++i)
pthread_join(threads[i], NULL);
#endif
-#else
- fn(NULL);
-#endif
return 0;
}
diff --git a/src/interfaces/ecpg/test/thread/prep.pgc b/src/interfaces/ecpg/test/thread/prep.pgc
index d7ecfd4855..f61b31ce10 100644
--- a/src/interfaces/ecpg/test/thread/prep.pgc
+++ b/src/interfaces/ecpg/test/thread/prep.pgc
@@ -2,14 +2,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -93,4 +85,3 @@ int main ()
return 0;
}
-#endif
diff --git a/src/interfaces/ecpg/test/thread/thread.pgc b/src/interfaces/ecpg/test/thread/thread.pgc
index e7d8c00af6..b9b9ebb441 100644
--- a/src/interfaces/ecpg/test/thread/thread.pgc
+++ b/src/interfaces/ecpg/test/thread/thread.pgc
@@ -6,14 +6,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -133,4 +125,3 @@ void *test_thread(void *arg)
EXEC SQL DISCONNECT :l_connection;
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/ecpg/test/thread/thread_implicit.pgc b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
index b4cae7e1ae..ff9b12a943 100644
--- a/src/interfaces/ecpg/test/thread/thread_implicit.pgc
+++ b/src/interfaces/ecpg/test/thread/thread_implicit.pgc
@@ -6,14 +6,6 @@
#include <stdlib.h>
#include "ecpg_config.h"
-#ifndef ENABLE_THREAD_SAFETY
-int
-main(void)
-{
- printf("No threading enabled.\n");
- return 0;
-}
-#else
#ifndef WIN32
#include <pthread.h>
#else
@@ -133,4 +125,3 @@ void *test_thread(void *arg)
EXEC SQL DISCONNECT :l_connection;
return NULL;
}
-#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 8abdb092c2..6af1dbfe8e 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -71,10 +71,8 @@ ifeq ($(PORTNAME), win32)
OBJS += \
win32.o
-ifeq ($(enable_thread_safety), yes)
OBJS += pthread-win32.o
endif
-endif
# Add libraries that libpq depends (or might depend) on into the
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 49a1c626f6..3504ab2c34 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -1116,11 +1116,10 @@ pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
#endif
/*
- * Some users are using configure --enable-thread-safety-force, so we
- * might as well do the locking within our library to protect getpwuid().
- * In fact, application developers can use getpwuid() in their application
- * if they use the locking call we provide, or install their own locking
- * function using PQregisterThreadLock().
+ * We do the locking within our library to protect getpwuid(). Application
+ * developers can use getpwuid() in their application if they use the
+ * locking call we provide, or install their own locking function using
+ * PQregisterThreadLock().
*/
pglock_thread();
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index dc49387d6c..7f14026777 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -55,13 +55,11 @@
#endif
#endif
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
#ifdef USE_LDAP
#ifdef WIN32
@@ -7364,7 +7362,6 @@ pqGetHomeDirectory(char *buf, int bufsize)
static void
default_threadlock(int acquire)
{
-#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
#else
@@ -7393,7 +7390,6 @@ default_threadlock(int acquire)
if (pthread_mutex_unlock(&singlethread_lock))
Assert(false);
}
-#endif
}
pgthreadlock_t
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index a36f5eb310..41861e6a11 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -3924,11 +3924,7 @@ PQisnonblocking(const PGconn *conn)
int
PQisthreadsafe(void)
{
-#ifdef ENABLE_THREAD_SAFETY
return true;
-#else
- return false;
-#endif
}
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 783cd9b756..2dc0f1afb9 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -88,14 +88,11 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
bool usePipe = false;
char *pagerenv;
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
sigset_t osigset;
bool sigpipe_masked = false;
bool sigpipe_pending;
#endif
-#if !defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
- pqsigfunc oldsigpipehandler = NULL;
-#endif
#ifdef TIOCGWINSZ
struct winsize screen_size;
@@ -185,12 +182,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
{
usePipe = true;
#ifndef WIN32
-#ifdef ENABLE_THREAD_SAFETY
if (pq_block_sigpipe(&osigset, &sigpipe_pending) == 0)
sigpipe_masked = true;
-#else
- oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN);
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
}
else
@@ -323,13 +316,9 @@ exit:
#else
pclose(fout);
-#ifdef ENABLE_THREAD_SAFETY
/* we can't easily verify if EPIPE occurred, so say it did */
if (sigpipe_masked)
pq_reset_sigpipe(&osigset, sigpipe_pending, true);
-#else
- pqsignal(SIGPIPE, oldsigpipehandler);
-#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
}
}
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 8117cbd40f..01b2494bb4 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -46,13 +46,11 @@
#include <sys/stat.h>
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
/*
* These SSL-related #includes must come after all system-provided headers.
@@ -93,7 +91,6 @@ static bool pq_init_crypto_lib = true;
static bool ssl_lib_initialized = false;
-#ifdef ENABLE_THREAD_SAFETY
static long crypto_open_connections = 0;
#ifndef WIN32
@@ -102,7 +99,6 @@ static pthread_mutex_t ssl_config_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t ssl_config_mutex = NULL;
static long win32_ssl_create_mutex = 0;
#endif
-#endif /* ENABLE_THREAD_SAFETY */
static PQsslKeyPassHook_OpenSSL_type PQsslKeyPassHook = NULL;
static int ssl_protocol_version_to_openssl(const char *protocol);
@@ -114,15 +110,12 @@ static int ssl_protocol_version_to_openssl(const char *protocol);
void
pgtls_init_library(bool do_ssl, int do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
-
/*
* Disallow changing the flags while we have open connections, else we'd
* get completely confused.
*/
if (crypto_open_connections != 0)
return;
-#endif
pq_init_ssl_lib = do_ssl;
pq_init_crypto_lib = do_crypto;
@@ -709,7 +702,7 @@ pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn,
return rc;
}
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/*
* Callback functions for OpenSSL internal locking. (OpenSSL 1.1.0
* does its own locking, and doesn't need these anymore. The
@@ -750,7 +743,7 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
Assert(false);
}
}
-#endif /* ENABLE_THREAD_SAFETY && HAVE_CRYPTO_LOCK */
+#endif /* HAVE_CRYPTO_LOCK */
/*
* Initialize SSL library.
@@ -765,7 +758,6 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
int
pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
{
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
/* Also see similar code in fe-connect.c, default_threadlock() */
if (ssl_config_mutex == NULL)
@@ -831,7 +823,6 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
}
}
#endif /* HAVE_CRYPTO_LOCK */
-#endif /* ENABLE_THREAD_SAFETY */
if (!ssl_lib_initialized && do_ssl)
{
@@ -848,9 +839,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
ssl_lib_initialized = true;
}
-#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_unlock(&ssl_config_mutex);
-#endif
return 0;
}
@@ -869,7 +858,7 @@ pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
static void
destroy_ssl_system(void)
{
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_CRYPTO_LOCK)
+#if defined(HAVE_CRYPTO_LOCK)
/* Mutex is created in pgtls_init() */
if (pthread_mutex_lock(&ssl_config_mutex))
return;
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index a1dc7b796d..88607fb65b 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -37,13 +37,11 @@
#include <sys/stat.h>
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
-#endif
#include "fe-auth.h"
#include "libpq-fe.h"
@@ -58,8 +56,6 @@
#define SIGPIPE_MASKED(conn) ((conn)->sigpipe_so || (conn)->sigpipe_flag)
-#ifdef ENABLE_THREAD_SAFETY
-
struct sigpipe_info
{
sigset_t oldsigmask;
@@ -92,24 +88,6 @@ struct sigpipe_info
pq_reset_sigpipe(&(spinfo).oldsigmask, (spinfo).sigpipe_pending, \
(spinfo).got_epipe); \
} while (0)
-#else /* !ENABLE_THREAD_SAFETY */
-
-#define DECLARE_SIGPIPE_INFO(spinfo) pqsigfunc spinfo = NULL
-
-#define DISABLE_SIGPIPE(conn, spinfo, failaction) \
- do { \
- if (!SIGPIPE_MASKED(conn)) \
- spinfo = pqsignal(SIGPIPE, SIG_IGN); \
- } while (0)
-
-#define REMEMBER_EPIPE(spinfo, cond)
-
-#define RESTORE_SIGPIPE(conn, spinfo) \
- do { \
- if (!SIGPIPE_MASKED(conn)) \
- pqsignal(SIGPIPE, spinfo); \
- } while (0)
-#endif /* ENABLE_THREAD_SAFETY */
#else /* WIN32 */
#define DECLARE_SIGPIPE_INFO(spinfo)
@@ -524,7 +502,7 @@ PQgssEncInUse(PGconn *conn)
#endif /* ENABLE_GSS */
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
/*
* Block SIGPIPE for this thread. This prevents send()/write() from exiting
@@ -608,4 +586,4 @@ pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
SOCK_ERRNO_SET(save_errno);
}
-#endif /* ENABLE_THREAD_SAFETY && !WIN32 */
+#endif /* !WIN32 */
diff --git a/src/interfaces/libpq/legacy-pqsignal.c b/src/interfaces/libpq/legacy-pqsignal.c
index db470df9ea..1b4424eabb 100644
--- a/src/interfaces/libpq/legacy-pqsignal.c
+++ b/src/interfaces/libpq/legacy-pqsignal.c
@@ -27,10 +27,6 @@
* Because it is only intended for backwards compatibility, we freeze it
* with the semantics it had in 9.2; in particular, this has different
* behavior for SIGALRM than the version in src/port/pqsignal.c.
- *
- * libpq itself uses this only for SIGPIPE (and even then, only in
- * non-ENABLE_THREAD_SAFETY builds), so the incompatibility isn't
- * troublesome for internal references.
*/
pqsigfunc
pqsignal(int signo, pqsigfunc func)
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 51ab51f9f9..99c40af8cf 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -28,14 +28,12 @@
#include <sys/time.h>
#endif
-#ifdef ENABLE_THREAD_SAFETY
#ifdef WIN32
#include "pthread-win32.h"
#else
#include <pthread.h>
#endif
#include <signal.h>
-#endif
/* include stuff common to fe and be */
#include "getaddrinfo.h"
@@ -649,15 +647,10 @@ extern int pqPacketSend(PGconn *conn, char pack_type,
const void *buf, size_t buf_len);
extern bool pqGetHomeDirectory(char *buf, int bufsize);
-#ifdef ENABLE_THREAD_SAFETY
extern pgthreadlock_t pg_g_threadlock;
#define pglock_thread() pg_g_threadlock(true)
#define pgunlock_thread() pg_g_threadlock(false)
-#else
-#define pglock_thread() ((void) 0)
-#define pgunlock_thread() ((void) 0)
-#endif
/* === in fe-exec.c === */
@@ -732,7 +725,7 @@ extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
extern ssize_t pqsecure_raw_read(PGconn *, void *ptr, size_t len);
extern ssize_t pqsecure_raw_write(PGconn *, const void *ptr, size_t len);
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#if !defined(WIN32)
extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending);
extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
bool got_epipe);
diff --git a/src/port/getaddrinfo.c b/src/port/getaddrinfo.c
index bea7b520f0..8cb3a4db2f 100644
--- a/src/port/getaddrinfo.c
+++ b/src/port/getaddrinfo.c
@@ -414,7 +414,7 @@ pqGethostbyname(const char *name,
struct hostent **result,
int *herrno)
{
-#if defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETHOSTBYNAME_R)
+#if defined(HAVE_GETHOSTBYNAME_R)
/*
* broken (well early POSIX draft) gethostbyname_r() which returns 'struct
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index a4cebdcf96..22ee155cd1 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -219,7 +219,6 @@ sub GenerateFiles
DLSUFFIX => '".dll"',
ENABLE_GSS => $self->{options}->{gss} ? 1 : undef,
ENABLE_NLS => $self->{options}->{nls} ? 1 : undef,
- ENABLE_THREAD_SAFETY => 1,
GETTIMEOFDAY_1ARG => undef,
HAVE_APPEND_HISTORY => undef,
HAVE_ASN1_STRING_GET0_DATA => undef,
@@ -1211,7 +1210,7 @@ sub GetFakeConfigure
{
my $self = shift;
- my $cfg = '--enable-thread-safety';
+ my $cfg = '';
$cfg .= ' --enable-cassert' if ($self->{options}->{asserts});
$cfg .= ' --enable-nls' if ($self->{options}->{nls});
$cfg .= ' --enable-tap-tests' if ($self->{options}->{tap_tests});
diff --git a/src/tools/msvc/ecpg_regression.proj b/src/tools/msvc/ecpg_regression.proj
index ec2760b1f6..0ec60a275e 100644
--- a/src/tools/msvc/ecpg_regression.proj
+++ b/src/tools/msvc/ecpg_regression.proj
@@ -54,7 +54,7 @@
<!-- Run ECPG and the Visual C++ compiler on the files. Don't bother with dependency check between the steps -->
<Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="$(OUTDIR)ecpg\ecpg -I ../../include --regression $(ECPGPARAM) -o %(Pgc.Filename).c %(Pgc.Filename).pgc" />
- <Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="cl /nologo %(Pgc.FileName).c /TC /MD$(DEBUGLIB) /DENABLE_THREAD_SAFETY /DWIN32 /I. /I..\..\include /I..\..\..\libpq /I..\..\..\..\include /link /defaultlib:$(OUTDIR)libecpg\libecpg.lib /defaultlib:$(OUTDIR)libecpg_compat\libecpg_compat.lib /defaultlib:$(OUTDIR)libpgtypes\libpgtypes.lib" />
+ <Exec WorkingDirectory="%(Pgc.RelativeDir)" Command="cl /nologo %(Pgc.FileName).c /TC /MD$(DEBUGLIB) /DWIN32 /I. /I..\..\include /I..\..\..\libpq /I..\..\..\..\include /link /defaultlib:$(OUTDIR)libecpg\libecpg.lib /defaultlib:$(OUTDIR)libecpg_compat\libecpg_compat.lib /defaultlib:$(OUTDIR)libpgtypes\libpgtypes.lib" />
</Target>
<!-- Clean up all output files -->
--
2.30.2
Thomas Munro <thomas.munro@gmail.com> writes:
Some of these depend on SUSv2 options (not just "base"), but we
already do that (fsync, ...) and they're all features that are by now
ubiquitous, which means the fallback code is untested and the probes
are pointless.
Reading this, it occurred to me that it'd be interesting to scrape
all of the latest configure results from the buildfarm, and see which
tests actually produce more than one answer among the set of tested
platforms. Those that don't could be targets for further simplification,
or else an indicator that we'd better go find some more animals.
Before I go off and do that, though, I wonder if you already did.
regards, tom lane
On Sun, Jul 24, 2022 at 11:11 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Thomas Munro <thomas.munro@gmail.com> writes:
Some of these depend on SUSv2 options (not just "base"), but we
already do that (fsync, ...) and they're all features that are by now
ubiquitous, which means the fallback code is untested and the probes
are pointless.Reading this, it occurred to me that it'd be interesting to scrape
all of the latest configure results from the buildfarm, and see which
tests actually produce more than one answer among the set of tested
platforms. Those that don't could be targets for further simplification,
or else an indicator that we'd better go find some more animals.Before I go off and do that, though, I wonder if you already did.
Yeah, here are the macros I scraped yesterday, considering the latest
results from machines that did something in the past week.
Attachments:
scrape.sql.gzapplication/gzip; name=scrape.sql.gzDownload
����b scrape.sql �]yo������B�}�"[�GA�+���]CQ�,@P%qL�q�>�V���.:��y�<�UU������3���f�1�x:�?����+;r��p������Mc�J��Fn�7���'�znw{Z�x���F��sp�����$q�S��1ey��Q����\��C���u�����ZYx��L��������q�4GW�����n�u�o�� V��W�������d�_�"�`w9q*��~;�;\����O�5N����E����{��M�l�+�����2������4��
��YX��K�|�C&�����{��n��f��~�vt�l�����W�����}Jq-{��0F�6 �w��Gv��������ym?6��#�n������v���c��������w�~#>$~�24���e���S���M��As#v~����I�������y3��A<:�:e�Y>���^�W�3��O�����qSE3�n{����3uu���j���mv�f`^����A�i6�wloo����\����Wnp���c�??_%���������|��w�����m�\�<�3C��-f�G�����L�?6��N��i��7;���_[����h��yI:o� �+�=�1s-����~�����A�'������HC�>�{W�^
���]pH���8l�H^��~�}�s��~t��}���K=�����~�
����8n��Z/�Tou�@�NT�7�B�TL
��O{m��+���&����4d�w�`����R+E�j/����v<;:+H������*j������L:�\_q�R����V
|m7t�M�S�RD��w��'a���%j��������7�!p#��T�G���>���������8p�������W���tP[!��S�����1T�[�b�9����MB�Y)�O�}�'�3�������j�w��K����W4S�����i��o���*Z��������:QL�l�W,w��F��������P#����+�<=��wU+��PUE�RNy�
�Aw�^�dj� x�"�8vX��$�G�]�4Q� ����*�c'�z�[7R���.r���.��+w�wU�+S"�����(<$���������;�>;jiX���#�
��#�"���x� t�A���B
Y�_��
�������Q��J���o�[�G��V-"s5����a�/P�� k�K���[�FOuP��� _��v�x�a2SB����l��o��r�]9*�i?+_��I�!�`vA��ve2%��pI����
�S>HN�0x�Y,��A���(�UA�D�T�g�'�U"�V�/J=T5�~����D��������o���W�8~���M���������C� �!W�x9M���+9��B7R��3%�AAj�b�=�QdGv�S��JQM�@��P�9T���\��.� �k��O����#\�������/�f��p����*V^�������]�[��Y)����
��t����r1�)!=�B��mB{�_�55�G��7Nt~<����RT74�����s�D�2-Sq���X���*!��p���5P�82%��@���X��=X+R��L�=�v{�����)��&����rB�DP���R�B���.z�Al�_�xU��/�x�9=���ZQ�z���N+*lTiY��T��PSw�<��8�,7�^[*"���[�[�Q��2%�]��dw�2�*�+������T�8�1HT�F���JA���R�����1SB��=�8$��SAB�-���E�/�B^:?���m�O�+g��L� ����/Xn������6����c����\p� t*�eR%��&�(zt����
}���8��h�z�_')�P���xk�G;Vu�T5`���W����p��r=��B(�+�z�w��������WEz*���;�mW��K=�}�]+q����R.��Y�w�4�K�m���58��|�17���z�mm����8p�^�r����C�
P�@�p<)�Q���#w'�;��3������J49����^�fZ(�Pq����]C��Z��Z����Kov��B+����A%��r��)!cq[���>?��2�U����n����W�( ���V�!�,T�R;.�j����!�R�OBf��~��`� �����H��O������a�Z%���S�
j�^G��=�����5��@�O v�������S���}b��L �y��=���`G���?��m�?���!s-d�����{B�@s5d
qI���=�����
=5E�T�>���SN��jP�] i��]1�I����*��mD������(wN5�
�C�`A���x�A��S������*@�i�)b�/��V���H5�V��+H�'���}���5�����K�������{�E��+�:r'�c��)�bR-��������V������,}������$���o���������������yE��4?n5k:�h'o��bs`d2��H2_4c���'o��` �,�0
}z�����^��|f�0�k��]�?��:���1>y[����>����l:�o��f
������i�y�"����>88����a�g�e�0��;mps��Q|��}r�}��;a������������[�s^��^g����x�l���j��O����Z��5�sfp'P�����I����S�����gz����mzBl�2����[�+��?/��\�?t
��������i'�n������g������������n>X��zi���$���h����=��rtm���2��Jk1i�C����qm-�/`����O/����6�z*���aa�sma���90e�y3�� 2s�<�&3��FZU��5�1o�'��S8y�����g��N3t��������������~C1�f�����;5�Il��>�d�7<��>���}`�&�S���l,o�J[��kC}:�IX�l.��>������[R�|6�GeV��r������pg�A�3$���FC[���P��;}���5��w5t��7�-�1���;)}*�M���3y���[H��f��Pd����\>��d�gFX/q���B
���q�k�'\,�x+�-���'���������b��5�Rg#���������l2
,*��$!I�05j%�S����H�����X�3s&�%��9a?�f�/�a���~���/��?`�e������
&����g��Q�����Z*r�.�:>�����u�Y/p�� ���+�uui]� 2��S����R�ld�F#����1
p�(���=,S�h��\C�e�!����l�C��EY����7b���A2b�����0��D�9�S�Mi_X@�H��s����3�O���� ���]J}�fs�����1]�y�����&�,�����c:�F:X�I��9�M
!�kxE�G_/����������^m@��\��Z3��r�����%�i�E���}�.{�
�,�|�UMj6? ��2�l��O��!����k�P���%���C�o�!
!�"���x�N��0����k�x+�t�;��6��1�0��|�u�������������p1���_��7�6�ynNT�����L PM)����0t�����M��,�$�^���:t<�k�T;���� �;�
)Z���D.��x�b��
�`7E���E�<e�<
y8J���c��� �^sx��X 2������YuE�Z��20���x�O��mM���v����X'�?�����f���F�����.�b<�����Gc���d�eW�����_D�O��$B�;e�w����d��Ii
7�%��J�dp�O�+�W�lC���lG,�>a}H�jQd�<ZY��J�� xbK/@K��
���pL5���e-���9�5�/�"-�Zt�ngh}��;��US�lm�Y^N����n[�9�*o�����8���Y#���g(p�`ny������+�Bi/Gn�5��#�G��u�s��Gn2���pt���g�[���8+����Y�����=������j�[��c��o����U�)��H�}K,A6.�����/�.����]�g��,����7b���ftt}��Ny�w��?%�x�<i��tE���7<��%�}l�p���.�z���x��g�]�8x�������(��.'�����x�=����#D�Q�6!I��'�������S��{��s�� ���j�5c���~��{��jI]������sM{7�b��>���������h�v���m4�~������>8�c q� ��������8��o�J�$r6���3�F��o2G�C'��(r����6M�wc���9!���|�M��~�fx��a���n6�t�D�9�l2���r~Fu�k�E��g��r�[F���4�2D�����gq�1+U|K��]��%��F��j���L�FzAfi%k:eiIO�K�V�g���K����9��x^��f0G�!�A�Q�������h������dLc������Zl�K���/r* �K@�s !O-� x����z
@���� �#@��� �������������b1����w?OZ?�PY����C�a�v.1t`��E�CZ���%��.�H1}
�[B�5�1S��o�cM���7XL�����-R��d ��yO)(y#C��?��&�|�C�E�)��]32�����"�M:��s�-��c���`�* �M8DF����^ /��k������J\Fb ��x*d��Mjwu���:#3�2��g�t��t��%4#`4���f�X�P��% 3^9�������~��$�G� ����[ ?��^B~hQ��ED�G���N�#
p������(Q@� ���&�B�t
�)x5(5b ���@e�"A�����"����lD�A� 4H�p��u�aN �YV���e��D6��
I�/����H��!|�%2�%4�����K IT#����h�� ��]�2 ���3�V�3�yJD`�H��'�"���$���D�� �����E$/�+�9���#b�d$�E�����F��g�����r' 7"�@*���WD\��������E%|�=�:�@"/eA��(��D���tD���E�5^#Iy���������HK���X��,h�����[,g����P*�b��I\��,�oq��x'���x��A�^XFi������8�����7��F��P��#_\1AA_����(-�_��)�/D/�/D�����0L�0L�QRb`C����Q0�R��DW�p� {Qd����E,�%!Z������a��x���������A�F� ��}�=k5/~���1bP��Y�!C2rW ���!����G���P�����
p�8� Da�J�D�%Lx a�l���P�&{c���5�V^����+�PU���@��3�P�W�,W�X*f�1
KN�Q����;
W�*�I��s$p��5�J1 Z��4�".+"7CQ�
�An��)�S
L���nND��p��"�K4�'s`�,-�*@!h� ����kpBD�W���A����A$A�ox>��<�z"��-A��` �g�O��Jx!)��(�,'�X��2%!Y9H�9H����� �
�TPE_��>�s�v����8����F���aF<2"X�~`��j9,����%(�9&"��
�Y�~WC���,��>��<"T���9(�$���@)�� ��H0�d��'H��t��qa�
�Ct��PRR 9H ��E0�����p|� ����*x�R�A�s ��+l#'S�E��A6��J`C�"�_��5������=��S3,{�x��b���TB�@��mD0���uvQD�@�(1q~�C�D� �������_���@��d%���%�!� 1���D��;� =��7��]�� p������8�$[�~���25@�HQ�LfB"��CR��c�hE�Haxq��/�o��2#���ZYh��g���&|yDFfFxF�����!�� mH��
�#���r
oh�=d����;��u| Z���J�����*�nb�$G���e�q:���~(�q����P)E�=�b(�7[��i ���
_��R@/ ���"��ci��BLm����.0�7nAgA����E d!������E��E�q��"��IpE~F+��hX��U���8u�����
TUp
s#��s�F)��A�h.x�Q�y$`�54>Q��'�a:�1��M� ���D�c���py.���z���2 /��W}�� ����
�E������������W'�v���w?]\�r��3�t����a�����������b��tv;��}j����h���;'�IR���^�����>B����D"�e6���?�vs{���������������p���`.`�}��tv;��"�������d���_����`1X��^|�|�.{���������e�8/�>�7Z��\��<aD�n�(��gH�#
��!�3��T�N�h�8|�"�p�F|w������n,�4�Y���V@x�k(��
o��Js�R�%w��T����(%�#q��5�b� B���C"B}����j�G�2�H�a&�PHq :
d�.�M��� ]��� �T.F��q�h,��I�����l����H�������s��Z��
��GTT9����(
)��i$E�����gDE�G����y��*a����<iA���qR�.�k��zy��r�S
J����h@�B�bG=��z��|��!fB-��pKR>"�)'�.+z���qY,��`��@�������Y�o��z�C��g�^�?�v��)V8�h[�%�u�.4P\�Yx�/Bl ��mFExiFCIIe��Zu�
gH0@#�F�4Bk����Q��l��
�P��^�i�1��w�N����� ���W]����iu�J|P ����JNw�1Vr��B A�<��L.@B71'@�t��.��.#%�`2�"*v�T"Fz����J�dH��!-�F���$?M&���*e�T�,�P8b$��J�2%?
i���6�g]#N�,e�w)��II$P���S(��#QS�@���&)�%�P��Y���O�)QB*����gx��qU�5!�j��������� ��nb� _YJ�@h i�ZB�k�+�=�9�
e��r'���������^�kM�����������kk�@�w��d^�h�{�
�kv�����{�g��~|����~�_��-Jn�nln<������������������O��b ���i ��0{��rq�i�ee�
�Xc��_Ts5��[D�Y6�����c����������ydj?^�g��7�����r��~��zv2��������������;R7~�n��oK
6"��g������]���|��f>t�U���A���l?]�{�j�Y�kR���]�<���K��*��x76�**,l]�^���������������O��^��On/�_�{y�qv��H���������~rw}v������'��������?_���/����x�������k�O�~�������1���v��un|*6��MF&�A����%��XR)�J����Y�4���I��/!��MH��!n4�p]���d�����,�F�������Sq�y\zbv��p��=���'j=Ii��<e�� <��w��3� JB;��l��N��d
H'8��V�9Y|#Z�('H9M�`�|��8Y��S� ~�o��M�:�����Mp���m��gd���j/������
BF����s��F���ZM���j��P��W��C�Tl��8+!���'Vz*$�����S!t����S����\��T���*�X)�����)(����)���R��q)v0Z��g|������]��e�I����M=t���L���O^.��7�O������&�@�#b\�m���0�A��90��)"\�B��OL�����.���������E\n���[S�55������)]��$P8'(�s,�d��*�,v ���
����X�����eE���#�By��O��h7�7�QX����~�����G���X|T\���]�1��5�U�b��5Sy�\�b/���@Te�[��x�:�*>�q�5U������%�h�lt���#���cD�(F����P$�*��:RU��"���Tz�b�^��6���C���W�"MW9����q�D��-��S����U����T$wX4���2U�a�3&�& �d� ��M��C�0iP���A���"kd�4ai��HiK�H)k�����C�=��F�0��uv\1/��a�(e��!�����SC��I����-_}:H*SD��2
$�}[�GV��:������w�}:�����C;y;�8�8��up$�HI^L ���"��>(���0�:�([���
����_���������j�U^���n}k���&XKL8[������������?�]�.���bh�����������s�
G��?="�T����I�7�W���vN5mD+����i����;�, �f��r-����\_,��j����(`f��e����LkN$���V�I#��G��EF��������#��pf<�����T�I���43�Lx���Z� �D�a�(8��J���I��.��($ S:�6��R��$��za�dt���7�6.�b���'�%�QKRFd�)��nYF �,:` ������2���`%]��$����1�v�Q�Ij
9F%G��8��s�Z�q#��
9�t��YA�(<id-�F��3*�(S�����,W�(�c!x����" /FU��L|<\��DlQtk�4���u��T�t��8�zL0�
H0��D0:!�G�@�p8P��4��b0p%��e ����a$� ��51����
��
� ��R��h��K��f0���L B����;lA��� I
b[�
rlF$���R�����N��ts�#��?�G�����9b?]��A���& ��z;<��/�D�<M����%H��OV����TOZ��(��}�|� �����i�0#�0������'"��F�c}�{P��e
pOM#e��hO��=g��4�]B�PkT����A�������(6���q"D�'����,q�y�hi0O������N,K!����_I����}gX ��'�o��&���`b�.��_-�$'��8K����?ml���I\���=
5��H#
�63rFF�H������.#F�� #T3��>�S>�
�^I]a��&���Xp� �X���v75~����`l}���������������|Tv��f��qz��e=$yD'N��G�;��}�#�������g�b�
h�z�������m V8U]����>+l+�=��bvu���������ow<K�G0��u���g����[����p�X!����95���U�_P��4�^�n-�[U=H�6A��D��
�"ao�%�U�&op��@!��x���C��z0U`��1A_����%������b��
��#e�_:p2<t�d��(Y�'�L���"J d� r�chsx�7�*��`l��'���1F<�)^��i��SM�Xp$��B���1 ����02��V�0^G3�� �d,�����H��
���r,��c�86*���p�K�����#) 0T���v�O3��/R+�b����|���`w��{�� ��i�b�!����['�V(LP+v|dZ�V���G��k Z�%����8�D����Y�ddY]CY����
�$^�����]a��%K�A��PA��&0a��&,�Yx~9_� �*�p���hl�
�����F�(�
�U�UG�����IeV�j���-n(�F� t��4�E����<�Q�n+����VG���� XI�9���+�9|��^�>Y�U���i���W=����V�6P+�&"�${6 +��@�X��*�G^���b�C5�V����+Uq\�qE�?�T����J�R��W7�1*�K
F�D�1���O�r�S8��=7���������������P�E�����N4����$�c��V������L�{#<`/`�Z���}�;hM*ip�
�v��a��U2��]\����s�����K#1�"�N�I��NUV#:��tB�����q����i(g{s{{sk���� s6���F�����^-��\�1;�t�?>�n�������G�?�^��~g�h��������oc@�����dv�[| �g������>��N��R���[$=�d'�5W��..��K�2���G_��.>�x���v-]��xV�����|�v�\o?����#�~�0��_����|>�{�h��*�p*�
�NHE���B�?fs]'���a=r(&A)�B������0��C��vQ�sDBaWG�Wu�`�����S��4�C����7;���|�����6x��
�\��`z�u���[��X'���l���N"�eH���r���I*��@&^J%�:������4<ZC�+��1w�e�������%i�y������e"�KS.44S�^l��x��D��yP�����!���q��K�+x����w������EJ������
S�5���.Xc7��$D"������������V.����-��1�AjKJ.�%uLl�T�Z��V�,���p���-)��!'������)����RM�(�}:*������d�Co�dZ6��dN(Ws6��*�1]��8��2�Pv9b�]�]
-�&���������4>[���!?mZ.Gu
QS@�)�[�XLI�
).j�9�bJ%F��Q���P����G1b:�c6�����j)v���������,�{�4�v�Y���~��eF�C�X:>���`q�����s�����!��*�U���Y���BR����>�]|�eg�r*�_�kz1�������;;�]���>����/�s~r�������_���R%�?�]\���/{/�
'�2~��U8�R'��>�Q|:��
�Ai���
/��{���Hx1v2��w�������7�'�k���v|�u}x�����b������B�&�D�[���_��D�n�
�g��&����p>���"��T��8����
���:E�b�2`:�=�wF���8|y
�5�#��oi'@2/PL�(�%uH��K-���K��R�%!�#ZR�=(��J����n��f�bx�T���)z���0�WN��F����P���S&�W���
T��� ��:�U/_i�wyK5��t�Rh�T�G������D��(�D���-��ZxITt������^�F��E����BU8����Q�������<�����Q�
���r�iG���*��:�����_*E��,Qr��
)�]����J���1�^G���q�D~��+
&���5��V��|k�r��W��R���x��K���r�I��*���%sW� ���K�R���R����NN����[���7���s���*+�),&,>��zc����i��w���^]b{{��m i���f|��<���eV%�V����J���*�F{�Uh��V��GI���J�/������JO��>ce�]v��G`�<���$��Tv� �AL@����W�Wr�7]�1Vr��B��<0�L.�{��l������IH���l�2�)K�d�T�0�
^��U���kOG�d����/��z�5Y?����J����t#O����_�M~5#f�����Q���<K��zvRQ
=�z��O�L���^�4��������w|{�������/�
_��gXq>�^v��`�h5L�RCU,�7w���JH#�B^[�SNcFEW�9���Y�^��r'�������s�^�_M�������X��.�U�7��}�x+��?������tmw������������w���t���v����~j�K7�Q��������������%�$���L
�[�v���]��i���������p��C�Xx�x���f�Y���������W��1�WBb�>+(���X�|���D'p,(������AW$:a��Q7e���M�2ua�)��������QR�l��L*#�3�h�i��3!@SbCh,:�����@�lSEi,:��b��R�����XPM������5)8�&�7����j�-h�M�A6�������x����ms���9�$y��=����Cy���By�
"�� US1f��OM'���x ����_����
�V{.(Fle:�L��j�`����#L"�Q�����>���j�J�8=1d�1C5�b�����a���C�?�&��� ���C�)����#�!�#���;~�&�#�D�(%�(�SL��Tq�������,��\nS���AT�08$�1mEc�"R.B���{/~x{��;?,F��������bo9�Z�w �T�z���B*��\�J�!V�A�@�|z��rC��Z��W" �Tw4+���_��\��a��� �T�T����
ej)�L����L�x����iN9�������|����6;nv�o�Q'K@/�������H+��G0�����;s�����c�gv{&N|��F�)��?E��t��7��i~$+%M��^$��`�Tt���|��2T�7�1�<� �T���`u�#;M_z*g�#?���FP��N�2��&-�$U<��,U�����SE~ �����0���3��o�����"������z��9�W�� ���S\-�&�
�*��X%�$D�R���zu60TF���2��G`<+��=7�h���W�kX5��v�S�9��X>�}����}\��r�PX�Rq�x[5��{�����e~}u�h�|�~w����/]*�r�������k�o�_q�z��������>_�v=����lq����om��6e�t���R�\���i�GBZvcx�>=<���a�\z�ZEeO�n�zsuvq~y�S�f����2��nn�O�pwwv��|��k���]��/n,���������]�����=A���D�,�|������w�Xn]���vY������"F;i��� RZh;�3������~{<�!���d�~;����px*W��H7����cI�|���r��=�6���&�6ix�%���)�n4���G�+x���*4��p�5�����'�����`- ����/�HC�la����!"b���'�qP
�ed#�FT���8( ��^���A��5@��Px7[�f�
[
d�0A�����Y)-�Sx
~�\�`k�:f��� kpZ��U�!f���L��B�AY��@l*B����4HIs��<�����FO�q�T�,��AO� ZHH��KC�B�Y�9��R=J����Y��+hV��R<b��eP\f%�e�5V��<S�F@Yux���t�O'83�B�Gf��/�(����9���)Re�B��O(����`�.I���a��C�E\����cS65����
����)Vd�$P�&��s�z�(8/v��8"����]����OeE������By-:T��h7���\����}������Gh���[����e�Xm�cG�W�Mc�����Tg3$���+�;�V��V�1����Og��M���&j�s�u�h �*�����5�y+��b�C= �����T��H�'#���U���_���r��7�����*�T�o#(��q�)������t$��y���:;��L��.��}N��=H:�
��"�� �����N�4�
���P��y&9�������� 2P�`5 JJ���Liv�������iU
w�����N��)'c�8S�7'��'��TNk������S�V[|�;�*V���Z�;����7�������\�i��LyXG/��gg�g���|)�$�~��S�`
�� LQ|�a�B
b�������t~S�~^�������o-��?(r����BZ��w�*I �]^����u���-�p3���B������ng�]X�US��]��6�)0m����6���;��Z�W�L��C���"R)�%����0g����6��������n~[t��(���C���5���������w/ba�$�4�\X*R.�6�E�q.��B��.]J�$�.��
�����3^�b V�r�Bo�uX��*av�J�oT��L��e9ef��6�%���?f
����>q��7�����P�=�A�A��^$��3��"��Q-������
���z�"�c)y���C)(9�"���&jA]�����"4q����x�r�#�����g{�� ��� �B�=b�zdB#h���CD�\����;V58Z��q�����=0�G�1�4Y`����E��8�Z��?��sP4�� �I���
E���{��!+Ch�
jq���Z\��LK}������p�o��������|���h��o�~��Q��������,3��P;V��%�V������������p���Q�5U�G�C5�
����>�A( W�P����:pc/��7��-)�#kh��<�����f_Zm~��;��>B��e�4\G�A��^������8���c0�t�H���9}���1j�[����ED��?�S)B�d^������C�^3���C�=;;q��BR�?�i{�8L�8snj�3~Z�����JN^Ie72'`V^HcZ^ymq3�Rr�A��}�u6�4��}�Y:@��7C'���\}Y����j�j�]�rv�xckk�F� g���<����Ez�
���������������k�.N6��<������O����=f�u{]�����������r��i�����R��|��4�NK�"����
_4< ��=���i�zeW����9�^���\:������a�F�b�Y>��d�.nF�fn%���K1[s�Z�f��e<i�,�>.��Rg��a�+��V�W�u|���!�/F�:��r� Y���o���6���!�L��y�(�,s�%�I���Q
�i�`9E�K���.=M�n�KMG���>������4)cn9���M������E��N9Y\�`mE"��axYV�.HYX�v���cz�������=�����JXRA����a���>����a��d>����V���Z
���R� ��j� �x�)OS���`�&��r,����K�G�%�II����~�����h�����<�:"�d>
\W�f�q(����oH�&>q]DtB@�� �����lL��],���_H��.y��R�MP��&&�uy��[������n:�n���|G;FfZ?A��|�qb�t$X<���MQ�r�$�L>�������M��Q�\j�����jZ������L������d��j 6��07u�}�5���[)�s����X'�E�C�ZHDGd�Y+�fH��.����}�����$X����-�7�U�t�����a]�p�� s� ��@�C9��SS�"���#�%����_o-�O�^�����? a�E�1�#�8b�_N�K����c��*-�/�J�]����T��$>D���r��n�;���1�k��^���w.��!o�^�@�j]9���VyJ�gjQC����$p�%
8�i+PhP(��� #� sVO[��^� ��W2P����Z����e}��)���@��5]/�+GE���0!V�x��&M����|���Ox4,O�z�����w[������>�|����+��8t:�xyv3??�w`�p�8H�q�]8���p�����+�7��]?9�]|��l��UW|dw`
|���H�^1x0H���`��#N��J���!gP�����6��,��E��
��2 ^b�0���$��Z1����m'