Remove unnecessary PQconsumeInput call from PQputCopyData; it's redundant
authorTom Lane <[email protected]>
Wed, 25 Jan 2006 20:44:49 +0000 (20:44 +0000)
committerTom Lane <[email protected]>
Wed, 25 Jan 2006 20:44:49 +0000 (20:44 +0000)
because pqSendSome will absorb input data anytime it'd be forced to block.
Avoiding a kernel call per PQputCopyData call helps COPY speed materially.

Alon Goldshuv

src/interfaces/libpq/fe-exec.c

index eb4cd4dce70a7d6af66d3ed78503d0ffbfdd3c7e..5e5a0792839b5b13e0a8d625ba098849dd955273 100644 (file)
@@ -1476,13 +1476,13 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
        }
 
        /*
-        * 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.
+        * Process any NOTICE or NOTIFY messages that might be pending in the
+        * input buffer.  Since the server might generate many notices during
+        * the COPY, we want to clean those out reasonably promptly to prevent
+        * indefinite expansion of the input buffer.  (Note: the actual read
+        * of input data into the input buffer happens down inside pqSendSome,
+        * but it's not authorized to get rid of the data again.)
         */
-       if (!PQconsumeInput(conn))
-               return -1;                              /* I/O failure */
        parseInput(conn);
 
        if (nbytes > 0)