]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix aboriginal bug in BufFileDumpBuffer that would cause it to write the
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Jun 2007 23:43:34 +0000 (23:43 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Jun 2007 23:43:34 +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 45ee4b0326a94f753b9aa79186dffe47d71000c8..957d033efd09a85ae9dcc95a4268ce14a7b3b132 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.18 2003/08/04 02:40:03 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/file/buffile.c,v 1.18.4.1 2007/06/01 23:43:34 tgl Exp $
  *
  * NOTES:
  *
@@ -292,7 +292,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;