postgresql/src
Tom Lane db6e8e1624 Fix unwanted flushing of libpq's input buffer when socket EOF is seen.
In commit 210eb9b743 I centralized libpq's logic for closing down
the backend communication socket, and made the new pqDropConnection
routine always reset the I/O buffers to empty.  Many of the call sites
previously had not had such code, and while that amounted to an oversight
in some cases, there was one place where it was intentional and necessary
*not* to flush the input buffer: pqReadData should never cause that to
happen, since we probably still want to process whatever data we read.

This is the true cause of the problem Robert was attempting to fix in
c3e7c24a1d, namely that libpq no longer reported the backend's final
ERROR message before reporting "server closed the connection unexpectedly".
But that only accidentally fixed it, by invoking parseInput before the
input buffer got flushed; and very likely there are timing scenarios
where we'd still lose the message before processing it.

To fix, pass a flag to pqDropConnection to tell it whether to flush the
input buffer or not.  On review I think flushing is actually correct for
every other call site.

Back-patch to 9.3 where the problem was introduced.  In HEAD, also improve
the comments added by c3e7c24a1d.
2015-11-12 13:03:53 -05:00
..
backend Fix enforcement of restrictions inside regexp lookaround constraints. 2015-11-07 12:43:24 -05:00
bin Don't connect() to a wildcard address in test_postmaster_connection(). 2015-11-08 17:31:22 -05:00
common Unlink static libraries before rebuilding them. 2015-03-01 13:06:39 -05:00
include Improve memory-usage accounting in regular-expression compiler. 2015-10-16 15:36:17 -04:00
interfaces Fix unwanted flushing of libpq's input buffer when socket EOF is seen. 2015-11-12 13:03:53 -05:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:13:32 -05:00
pl Translation updates 2015-10-05 11:01:00 -04:00
port Stamp 9.3.10. 2015-10-05 15:14:02 -04:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:02:03 -04:00
test Fix enforcement of restrictions inside regexp lookaround constraints. 2015-11-07 12:43:24 -05:00
timezone Update time zone data files to tzdata release 2015g. 2015-10-02 19:16:06 -04:00
tools Turn install.bat into a pure one line wrapper fort he perl script. 2015-07-07 16:37:16 +03:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Make numeric form of PG version number readily available in Makefiles. 2015-07-05 12:01:01 -04:00
Makefile.shlib Unlink static libraries before rebuilding them. 2015-03-01 13:06:39 -05:00
nls-global.mk NLS: Use msgmerge --previous option 2012-12-13 23:12:12 -05:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00