This is an automated email from the git hooks/post-receive script. ebourg-guest pushed a commit to tag REL8_4_703 in repository libpostgresql-jdbc-java.
commit c79d86830bb5ce75a092177c35068817ad1dcebe Author: Kris Jurka <[email protected]> Date: Tue Aug 31 18:08:20 2010 +0000 Work around a bug in the server's implementation of the copy protocol. It returns command complete immediately upon receiving the EOF marker in a binary copy, potentially before we've issued CopyDone/Fail. Fix this by simply not processing the command complete message until we believe that we are done with the copy as well. Issue originally reported by Matthew Wakeling. --- org/postgresql/core/PGStream.java | 17 ++++++++++++++++- org/postgresql/core/VisibleBufferedInputStream.java | 12 +++++++++++- org/postgresql/core/v3/QueryExecutorImpl.java | 21 ++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/org/postgresql/core/PGStream.java b/org/postgresql/core/PGStream.java index 41a2a2e..9b5d113 100644 --- a/org/postgresql/core/PGStream.java +++ b/org/postgresql/core/PGStream.java @@ -3,7 +3,7 @@ * Copyright (c) 2003-2008, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/core/PGStream.java,v 1.21 2007/02/28 06:10:59 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/core/PGStream.java,v 1.22 2008/01/08 06:56:27 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -249,6 +249,21 @@ public class PGStream } /** + * Receives a single character from the backend, without + * advancing the current protocol stream position. + * + * @return the character received + * @exception IOException if an I/O Error occurs + */ + public int PeekChar() throws IOException + { + int c = pg_input.peek(); + if (c < 0) + throw new EOFException(); + return c; + } + + /** * Receives a single character from the backend * * @return the character received diff --git a/org/postgresql/core/VisibleBufferedInputStream.java b/org/postgresql/core/VisibleBufferedInputStream.java index 0db6523..1843828 100644 --- a/org/postgresql/core/VisibleBufferedInputStream.java +++ b/org/postgresql/core/VisibleBufferedInputStream.java @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgjdbc/org/postgresql/core/VisibleBufferedInputStream.java,v 1.2 2007/12/15 15:32:37 jurka Exp $ + * $PostgreSQL: pgjdbc/org/postgresql/core/VisibleBufferedInputStream.java,v 1.3 2008/01/08 06:56:27 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -77,6 +77,16 @@ public class VisibleBufferedInputStream extends InputStream { } /** + * Reads a byte from the buffer without advancing the index pointer. + */ + public int peek() throws IOException { + if (ensureBytes(1)) { + return buffer[index] & 0xFF; + } + return -1; + } + + /** * Reads byte from the buffer without any checks. This method never * reads from the underlaying stream. * Before calling this method the {@link #ensureBytes} method must diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java index 0415c2d..547dcac 100644 --- a/org/postgresql/core/v3/QueryExecutorImpl.java +++ b/org/postgresql/core/v3/QueryExecutorImpl.java @@ -4,7 +4,7 @@ * Copyright (c) 2004, Open Cloud Limited. * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v 1.45.2.1 2009/12/04 19:53:27 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v 1.45.2.2 2009/12/07 22:03:14 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -900,6 +900,25 @@ public class QueryExecutorImpl implements QueryExecutor { int len; while( !endReceiving && (block || pgStream.hasMessagePending()) ) { + + // There is a bug in the server's implementation of the copy + // protocol. It returns command complete immediately upon + // receiving the EOF marker in the binary protocol, + // potentially before we've issued CopyDone. When we are not + // blocking, we don't think we are done, so we hold off on + // processing command complete and any subsequent messages + // until we actually are done with the copy. + // + if (!block) { + int c = pgStream.PeekChar(); + if (c == 'C') // CommandComplete + { + if (logger.logDebug()) + logger.debug(" <=BE CommandStatus, Ignored until CopyDone"); + break; + } + } + int c = pgStream.ReceiveChar(); switch(c) { -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

