Index: pgsql/src/interfaces/libpq/fe-exec.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v retrieving revision 1.178 diff -c -r1.178 fe-exec.c *** pgsql/src/interfaces/libpq/fe-exec.c 11 Jan 2006 08:43:13 -0000 1.178 --- pgsql/src/interfaces/libpq/fe-exec.c 24 Jan 2006 07:55:29 -0000 *************** *** 1475,1492 **** 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) { /* * Try to flush any previously sent data in preference to growing the * output buffer. If we can't enlarge the buffer enough to hold the --- 1475,1484 ---- return -1; } 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 hold the *************** *** 1516,1521 **** --- 1508,1527 ---- 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; /* I/O failure */ + parseInput(conn); + } } return 1; }