Fix aboriginal bug in BufFileDumpBuffer that would cause it to write the
authorTom Lane <[email protected]>
Fri, 1 Jun 2007 23:43:39 +0000 (23:43 +0000)
committerTom Lane <[email protected]>
Fri, 1 Jun 2007 23:43:39 +0000 (23:43 +0000)
wrong data when dumping a bufferload that crosses a component-file boundary.
This probably has not been seen in the wild because (a) component files are
normally 1GB apiece and (b) non-block-aligned buffer usage is relatively
rare.  But it's fairly easy to reproduce a problem if one reduces RELSEG_SIZE
in a test build.  Kudos to Kurt Harriman for spotting the bug.

src/backend/storage/file/buffile.c

index d2455d3731d5157b8e0d3a80b1e8885098966d09..9958cd3e0555d3b1ee9d5b0d5d6697edd0586322 100644 (file)
@@ -287,7 +287,7 @@ BufFileDumpBuffer(BufFile *file)
                                return;                 /* seek failed, give up */
                        file->offsets[file->curFile] = file->curOffset;
                }
-               bytestowrite = FileWrite(thisfile, file->buffer, bytestowrite);
+               bytestowrite = FileWrite(thisfile, file->buffer + wpos, bytestowrite);
                if (bytestowrite <= 0)
                        return;                         /* failed to write */
                file->offsets[file->curFile] += bytestowrite;