]> granicus.if.org Git - postgresql/commit
Convert elog.c's useful_strerror() into a globally-used strerror wrapper.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 26 Sep 2018 15:06:42 +0000 (11:06 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 26 Sep 2018 15:06:42 +0000 (11:06 -0400)
commit26e9d4d4ef16b5e2be96319f89ea6ba7f63a4d73
tree99ad7fa2f1784ce775cbf6ed50026367d6990da4
parenta49ceda6a044c2fc104b3d1397fe0bef8679d1aa
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
19 files changed:
configure
configure.in
src/backend/port/win32/socket.c
src/backend/utils/error/elog.c
src/include/pg_config.h.in
src/include/pg_config.h.win32
src/include/port.h
src/include/port/win32_port.h
src/interfaces/ecpg/compatlib/.gitignore
src/interfaces/ecpg/compatlib/Makefile
src/interfaces/ecpg/ecpglib/.gitignore
src/interfaces/ecpg/ecpglib/Makefile
src/interfaces/ecpg/pgtypeslib/.gitignore
src/interfaces/ecpg/pgtypeslib/Makefile
src/interfaces/libpq/Makefile
src/pl/plpython/plpython.h
src/port/Makefile
src/port/strerror.c
src/tools/msvc/Mkvcbuild.pm