postgresql/src/interfaces/libpq
Tom Lane 1f39a1c064 Restructure libpq's handling of send failures.
Originally, if libpq got a failure (e.g., ECONNRESET) while trying to
send data to the server, it would just report that and wash its hands
of the matter.  It was soon found that that wasn't a very pleasant way
of coping with server-initiated disconnections, so we introduced a hack
(pqHandleSendFailure) in the code that sends queries to make it peek
ahead for server error reports before reporting the send failure.

It now emerges that related cases can occur during connection setup;
in particular, as of TLS 1.3 it's unsafe to assume that SSL connection
failures will be reported by SSL_connect rather than during our first
send attempt.  We could have fixed that in a hacky way by applying
pqHandleSendFailure after a startup packet send failure, but
(a) pqHandleSendFailure explicitly disclaims suitability for use in any
state except query startup, and (b) the problem still potentially exists
for other send attempts in libpq.

Instead, let's fix this in a more general fashion by eliminating
pqHandleSendFailure altogether, and instead arranging to postpone
all reports of send failures in libpq until after we've made an
attempt to read and process server messages.  The send failure won't
be reported at all if we find a server message or detect input EOF.

(Note: this removes one of the reasons why libpq typically overwrites,
rather than appending to, conn->errorMessage: pqHandleSendFailure needed
that behavior so that the send failure report would be replaced if we
got a server message or read failure report.  Eventually I'd like to get
rid of that overwrite behavior altogether, but today is not that day.
For the moment, pqSendSome is assuming that its callees will overwrite
not append to conn->errorMessage.)

Possibly this change should get back-patched someday; but it needs
testing first, so let's not consider that till after v12 beta.

Discussion: https://postgr.es/m/CAEepm=2n6Nv+5tFfe8YnkUm1fXgvxR0Mm1FoD+QKG-vLNGLyKg@mail.gmail.com
2019-03-19 16:20:28 -04:00
..
po Translation updates 2018-06-25 12:37:18 +02:00
test Update copyright for 2019 2019-01-02 12:44:25 -05:00
.gitignore Add .gitignore entry for a derived file created by "make distprep". 2019-01-10 14:20:28 -05:00
Makefile Update copyright for 2019 2019-01-02 12:44:25 -05:00
README Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
exports.txt psql: Show IP address in \conninfo 2018-11-19 14:34:12 -03:00
fe-auth-scram.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-auth.c Fix SCRAM authentication via SSL when mixing versions of OpenSSL 2019-02-28 09:40:28 +09:00
fe-auth.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-connect.c Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
fe-exec.c Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
fe-lobj.c More unconstify use 2019-02-13 11:50:16 +01:00
fe-misc.c Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
fe-print.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-protocol2.c Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
fe-protocol3.c Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
fe-secure-common.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-secure-common.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-secure-openssl.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
fe-secure.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
libpq-events.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
libpq-events.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
libpq-fe.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
libpq-int.h Restructure libpq's handling of send failures. 2019-03-19 16:20:28 -04:00
libpq.rc.in Update copyright for 2019 2019-01-02 12:44:25 -05:00
nls.mk Refactor client-side SSL certificate checking code 2018-01-30 22:56:24 -05:00
pg_service.conf.sample Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
pqexpbuffer.c More unconstify use 2019-02-13 11:50:16 +01:00
pqexpbuffer.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pthread-win32.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
win32.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
win32.h Remove support for bcc and msvc standalone libpq builds 2017-04-11 15:22:21 +02:00

README

src/interfaces/libpq/README

This directory contains the C version of Libpq, the POSTGRES frontend library.