Fix small error in COPY FROM progress reporting.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 4 Feb 2021 15:40:33 +0000 (17:40 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 4 Feb 2021 15:40:33 +0000 (17:40 +0200)
The # of bytes processed was accumulated slightly incorrectly. After
loading more data to the input buffer, we added the number of bytes in
the buffer to the sum. But in case of multi-byte characters or escapes,
there can be a few unprocessed bytes left over from previous load in the
buffer. Those bytes got counted twice.

src/backend/commands/copyfromparse.c

index 4c74067f849ccda40470b0ea752f351ff7b6212e..b843d315b175d2e9663ec569b860fd3a0384c063 100644 (file)
@@ -386,7 +386,7 @@ CopyLoadRawBuf(CopyFromState cstate)
    cstate->raw_buf[nbytes] = '\0';
    cstate->raw_buf_index = 0;
    cstate->raw_buf_len = nbytes;
-   cstate->bytes_processed += nbytes;
+   cstate->bytes_processed += inbytes;
    pgstat_progress_update_param(PROGRESS_COPY_BYTES_PROCESSED, cstate->bytes_processed);
    return (inbytes > 0);
 }