summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorTom Lane2018-09-26 15:06:42 +0000
committerTom Lane2018-09-26 15:06:42 +0000
commit26e9d4d4ef16b5e2be96319f89ea6ba7f63a4d73 (patch)
tree99ad7fa2f1784ce775cbf6ed50026367d6990da4 /src/interfaces
parenta49ceda6a044c2fc104b3d1397fe0bef8679d1aa (diff)
Convert elog.c's useful_strerror() into a globally-used strerror wrapper.
elog.c has long had a private strerror wrapper that handles assorted possible failures or deficiencies of the platform's strerror. On Windows, it also knows how to translate Winsock error codes, which the native strerror does not. Move all this code into src/port/strerror.c and define strerror() as a macro that invokes it, so that both our frontend and backend code will have all of this behavior. I believe this constitutes an actual bug fix on Windows, since AFAICS our frontend code did not report Winsock error codes properly before this. However, the main point is to lay the groundwork for implementing %m in src/port/snprintf.c: the behavior we want %m to have is this one, not the native strerror's. Note that this throws away the prior use of src/port/strerror.c, which was to implement strerror() on platforms lacking it. That's been dead code for nigh twenty years now, since strerror() was already required by C89. We should likewise cause strerror_r to use this behavior, but I'll tackle that separately. Patch by me, reviewed by Michael Paquier Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/ecpg/compatlib/.gitignore1
-rw-r--r--src/interfaces/ecpg/compatlib/Makefile6
-rw-r--r--src/interfaces/ecpg/ecpglib/.gitignore1
-rw-r--r--src/interfaces/ecpg/ecpglib/Makefile6
-rw-r--r--src/interfaces/ecpg/pgtypeslib/.gitignore1
-rw-r--r--src/interfaces/ecpg/pgtypeslib/Makefile6
-rw-r--r--src/interfaces/libpq/Makefile4
7 files changed, 14 insertions, 11 deletions
diff --git a/src/interfaces/ecpg/compatlib/.gitignore b/src/interfaces/ecpg/compatlib/.gitignore
index ad5ba1354ca..8b9aa950afe 100644
--- a/src/interfaces/ecpg/compatlib/.gitignore
+++ b/src/interfaces/ecpg/compatlib/.gitignore
@@ -2,4 +2,5 @@
/blibecpg_compatdll.def
/exports.list
/snprintf.c
+/strerror.c
/strnlen.c
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index ebfd89544aa..b7bd1629027 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -31,7 +31,7 @@ SHLIB_EXPORTS = exports.txt
# Need to recompile any libpgport object files
LIBS := $(filter-out -lpgport, $(LIBS))
-OBJS= informix.o $(filter snprintf.o strnlen.o, $(LIBOBJS)) $(WIN32RES)
+OBJS= informix.o strerror.o $(filter snprintf.o strnlen.o, $(LIBOBJS)) $(WIN32RES)
PKG_CONFIG_REQUIRES_PRIVATE = libecpg libpgtypes
@@ -48,7 +48,7 @@ submake-pgtypeslib:
# Shared library stuff
include $(top_srcdir)/src/Makefile.shlib
-snprintf.c strnlen.c: % : $(top_srcdir)/src/port/%
+snprintf.c strerror.c strnlen.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
install: all installdirs install-lib
@@ -58,6 +58,6 @@ installdirs: installdirs-lib
uninstall: uninstall-lib
clean distclean: clean-lib
- rm -f $(OBJS) snprintf.c strnlen.c
+ rm -f $(OBJS) snprintf.c strerror.c strnlen.c
maintainer-clean: distclean maintainer-clean-lib
diff --git a/src/interfaces/ecpg/ecpglib/.gitignore b/src/interfaces/ecpg/ecpglib/.gitignore
index 1619e970c29..545c106a9ed 100644
--- a/src/interfaces/ecpg/ecpglib/.gitignore
+++ b/src/interfaces/ecpg/ecpglib/.gitignore
@@ -4,6 +4,7 @@
/path.c
/pgstrcasecmp.c
/snprintf.c
+/strerror.c
/strlcpy.c
/strnlen.c
/thread.c
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index d25d248616d..005d25a2bcd 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -26,7 +26,7 @@ override CFLAGS += $(PTHREAD_CFLAGS)
LIBS := $(filter-out -lpgport, $(LIBS))
OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
- connect.o misc.o path.o pgstrcasecmp.o \
+ connect.o misc.o path.o pgstrcasecmp.o strerror.o \
$(filter snprintf.o strlcpy.o strnlen.o win32setlocale.o isinf.o, $(LIBOBJS)) \
$(WIN32RES)
@@ -57,7 +57,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file.
-path.c pgstrcasecmp.c snprintf.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c: % : $(top_srcdir)/src/port/%
+path.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
misc.o: misc.c $(top_builddir)/src/port/pg_config_paths.h
@@ -74,6 +74,6 @@ uninstall: uninstall-lib
clean distclean: clean-lib
rm -f $(OBJS)
- rm -f path.c pgstrcasecmp.c snprintf.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c
+ rm -f path.c pgstrcasecmp.c snprintf.c strerror.c strlcpy.c strnlen.c thread.c win32setlocale.c isinf.c
maintainer-clean: distclean maintainer-clean-lib
diff --git a/src/interfaces/ecpg/pgtypeslib/.gitignore b/src/interfaces/ecpg/pgtypeslib/.gitignore
index d5f0fae445a..b3fae08d2f4 100644
--- a/src/interfaces/ecpg/pgtypeslib/.gitignore
+++ b/src/interfaces/ecpg/pgtypeslib/.gitignore
@@ -4,5 +4,6 @@
/pgstrcasecmp.c
/rint.c
/snprintf.c
+/strerror.c
/string.c
/strnlen.c
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index 29264ce7b7b..18b2402d0f3 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -30,7 +30,7 @@ SHLIB_LINK += $(filter -lm, $(LIBS))
SHLIB_EXPORTS = exports.txt
OBJS= numeric.o datetime.o common.o dt_common.o timestamp.o interval.o \
- pgstrcasecmp.o \
+ pgstrcasecmp.o strerror.o \
$(filter rint.o snprintf.o strnlen.o, $(LIBOBJS)) \
string.o \
$(WIN32RES)
@@ -45,7 +45,7 @@ include $(top_srcdir)/src/Makefile.shlib
# necessarily use the same object files as the backend uses. Instead,
# symlink the source files in here and build our own object file.
-pgstrcasecmp.c rint.c snprintf.c strnlen.c: % : $(top_srcdir)/src/port/%
+pgstrcasecmp.c rint.c snprintf.c strerror.c strnlen.c: % : $(top_srcdir)/src/port/%
rm -f $@ && $(LN_S) $< .
string.c: % : $(top_srcdir)/src/common/%
@@ -58,6 +58,6 @@ installdirs: installdirs-lib
uninstall: uninstall-lib
clean distclean: clean-lib
- rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c strnlen.c string.c
+ rm -f $(OBJS) pgstrcasecmp.c rint.c snprintf.c strerror.c strnlen.c string.c
maintainer-clean: distclean maintainer-clean-lib
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index ec0122a9012..8324f4f057d 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -36,9 +36,9 @@ OBJS= fe-auth.o fe-auth-scram.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-l
libpq-events.o
# libpgport C files we always use
OBJS += chklocale.o inet_net_ntop.o noblock.o pgstrcasecmp.o pqsignal.o \
- thread.o
+ strerror.o thread.o
# libpgport C files that are needed if identified by configure
-OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o system.o snprintf.o strerror.o strlcpy.o strnlen.o win32error.o win32setlocale.o, $(LIBOBJS))
+OBJS += $(filter crypt.o getaddrinfo.o getpeereid.o inet_aton.o open.o system.o snprintf.o strlcpy.o strnlen.o win32error.o win32setlocale.o, $(LIBOBJS))
ifeq ($(enable_strong_random), yes)
OBJS += pg_strong_random.o