diff options
author | Thomas Munro <tmunro@postgresql.org> | 2018-11-15 12:34:04 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2018-11-15 13:40:06 +1300 |
commit | fa2ceaca435889119f8a40ae7b000cd5229a0dd0 (patch) | |
tree | 5671119232391eb4c1a5b224a9d118181fe6762f /src/backend/storage/file/buffile.c | |
parent | b8182d6293d930da527be4ae38bca8e20c47b8a8 (diff) | |
download | postgresql-fa2ceaca435889119f8a40ae7b000cd5229a0dd0.tar.gz postgresql-fa2ceaca435889119f8a40ae7b000cd5229a0dd0.zip |
Use 64 bit type for BufFileSize().
BufFileSize() can't use off_t, because it's only 32 bits wide on
some systems. BufFile objects can have many 1GB segments so the
total size can exceed 2^31. The only known client of the function
is parallel CREATE INDEX, which was reported to fail when building
large indexes on Windows.
Though this is technically an ABI break on platforms with a 32 bit
off_t and we might normally avoid back-patching it, the function is
brand new and thus unlikely to have been discovered by extension
authors yet, and it's fairly thoroughly broken on those platforms
anyway, so just fix it.
Defect in 9da0cc35. Bug #15460. Back-patch to 11, where this
function landed.
Author: Thomas Munro
Reported-by: Paul van der Linden, Pavel Oskin
Reviewed-by: Peter Geoghegan
Discussion: https://postgr.es/m/15460-b6db80de822fa0ad%40postgresql.org
Discussion: https://postgr.es/m/CAHDGBJP_GsESbTt4P3FZA8kMUKuYxjg57XHF7NRBoKnR%3DCAR-g%40mail.gmail.com
Diffstat (limited to 'src/backend/storage/file/buffile.c')
-rw-r--r-- | src/backend/storage/file/buffile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index e93813d9737..8c7d8bcb91d 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -798,10 +798,10 @@ BufFileTellBlock(BufFile *file) * Counts any holes left behind by BufFileAppend as part of the size. * Returns -1 on error. */ -off_t +int64 BufFileSize(BufFile *file) { - off_t lastFileSize; + int64 lastFileSize; /* Get the size of the last physical file by seeking to end. */ lastFileSize = FileSeek(file->files[file->numFiles - 1], 0, SEEK_END); @@ -809,7 +809,7 @@ BufFileSize(BufFile *file) return -1; file->offsets[file->numFiles - 1] = lastFileSize; - return ((file->numFiles - 1) * (off_t) MAX_PHYSICAL_FILESIZE) + + return ((file->numFiles - 1) * (int64) MAX_PHYSICAL_FILESIZE) + lastFileSize; } |