postgresql/src/interfaces/libpq
Tom Lane fa4440f516 Improve libpq's error recovery for connection loss during COPY.
In pqSendSome, if the connection is already closed at entry, discard any
queued output data before returning.  There is no possibility of ever
sending the data, and anyway this corresponds to what we'd do if we'd
detected a hard error while trying to send().  This avoids possible
indefinite bloat of the output buffer if the application keeps trying
to send data (or even just keeps trying to do PQputCopyEnd, as psql
indeed will).

Because PQputCopyEnd won't transition out of PGASYNC_COPY_IN state
until it's successfully queued the COPY END message, and pqPutMsgEnd
doesn't distinguish a queuing failure from a pqSendSome failure,
this omission allowed an infinite loop in psql if the connection closure
occurred when we had at least 8K queued to send.  It might be worth
refactoring so that we can make that distinction, but for the moment
the other changes made here seem to offer adequate defenses.

To guard against other variants of this scenario, do not allow
PQgetResult to return a PGRES_COPY_XXX result if the connection is
already known dead.  Make sure it returns PGRES_FATAL_ERROR instead.

Per report from Stephen Frost.  Back-patch to all active branches.
2014-02-12 17:50:57 -05:00
..
po Translation updates 2013-12-02 00:17:07 -05:00
test Update copyright for 2014 2014-01-07 16:05:30 -05:00
.gitignore Re-include pqsignal() in libpq. 2013-03-17 15:45:31 -04:00
Makefile Fix makefile syntax. 2014-02-01 19:52:39 -05:00
README Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
bcc32.mak Re-include pqsignal() in libpq. 2013-03-17 15:45:31 -04:00
exports.txt Add libpq function PQhostaddr(). 2014-01-24 02:32:39 +09:00
fe-auth.c Remove support for native krb5 authentication 2014-01-19 17:05:01 +01:00
fe-auth.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
fe-connect.c Add libpq function PQhostaddr(). 2014-01-24 02:32:39 +09:00
fe-exec.c Improve libpq's error recovery for connection loss during COPY. 2014-02-12 17:50:57 -05:00
fe-lobj.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
fe-misc.c Improve libpq's error recovery for connection loss during COPY. 2014-02-12 17:50:57 -05:00
fe-print.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
fe-protocol2.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
fe-protocol3.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
fe-secure.c Disallow use of SSL v3 protocol in the server as well as in libpq. 2014-01-31 17:51:18 -05:00
libpq-events.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
libpq-events.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
libpq-fe.h Add libpq function PQhostaddr(). 2014-01-24 02:32:39 +09:00
libpq-int.h Remove support for native krb5 authentication 2014-01-19 17:05:01 +01:00
libpq.rc.in Update copyright for 2014 2014-01-07 16:05:30 -05:00
nls.mk Translation updates 2013-09-02 02:43:18 -04:00
pg_service.conf.sample Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
pqexpbuffer.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
pqexpbuffer.h Update copyright for 2014 2014-01-07 16:05:30 -05:00
pthread-win32.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
win32.c Update copyright for 2014 2014-01-07 16:05:30 -05:00
win32.h Enable compiling with the mingw-w64 32 bit compiler. 2011-12-10 15:35:41 -05:00
win32.mak Re-include pqsignal() in libpq. 2013-03-17 15:45:31 -04:00

README

src/interfaces/libpq/README

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