Index: cdb-pg/src/interfaces/libpq/fe-exec.c =================================================================== RCS file: /opt/cvsroot/cdb2/cdb-pg/src/interfaces/libpq/fe-exec.c,v diff -u -N -r1.2 -r1.3 --- cdb-pg/src/interfaces/libpq/fe-exec.c 30 Jan 2005 03:27:47 -0000 1.2 +++ cdb-pg/src/interfaces/libpq/fe-exec.c 28 Oct 2005 14:30:50 -0000 1.3 @@ -1465,18 +1465,10 @@ return -1; } - /* - * Check for NOTICE messages coming back from the server. Since the - * server might generate multiple notices during the COPY, we have to - * consume those in a reasonably prompt fashion to prevent the comm - * buffers from filling up and possibly blocking the server. - */ - if (!PQconsumeInput(conn)) - return -1; /* I/O failure */ - parseInput(conn); - if (nbytes > 0) { + int oc = conn->outCount + nbytes; + /* * Try to flush any previously sent data in preference to growing * the output buffer. If we can't enlarge the buffer enough to @@ -1485,9 +1477,10 @@ * protocol 2.0 case.) */ if ((conn->outBufSize - conn->outCount - 5) < nbytes) - { + { if (pqFlush(conn) < 0) return -1; + if (pqCheckOutBufferSpace(conn->outCount + 5 + nbytes, conn)) return pqIsnonblocking(conn) ? 0 : -1; } @@ -1506,6 +1499,21 @@ pqPutMsgEnd(conn) < 0) return -1; } + + /* if some data was sent to the server */ + if (oc > conn->outCount) + { + /* + * Check for NOTICE messages coming back from the server. Since the + * server might generate multiple notices during the COPY, we have to + * consume those in a reasonably prompt fashion to prevent the comm + * buffers from filling up and possibly blocking the server. + */ + if (!PQconsumeInput(conn)) + return -1; + parseInput(conn); + } + } return 1; }