From: Tom Lane Date: Fri, 1 Jun 2007 23:43:34 +0000 (+0000) Subject: Fix aboriginal bug in BufFileDumpBuffer that would cause it to write the X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=3efcb407f8315f8ce90e94148b1fe7ac299e73fc;p=users%2Fbernd%2Fpostgres.git Fix aboriginal bug in BufFileDumpBuffer that would cause it to write the 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. --- diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index 77dbdcd8f1..3b25dfadeb 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -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;