aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2018-11-15 12:34:04 +1300
committerThomas Munro <tmunro@postgresql.org>2018-11-15 13:13:57 +1300
commitaa5518304213a762b62ebe3dbb057d220d8976eb (patch)
tree122ccb8d03151063d2563076c4f3298674fd2043 /src
parenteaf746a5b85a6a794e659f0954cf0015e42213f4 (diff)
downloadpostgresql-aa5518304213a762b62ebe3dbb057d220d8976eb.tar.gz
postgresql-aa5518304213a762b62ebe3dbb057d220d8976eb.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')
-rw-r--r--src/backend/storage/file/buffile.c6
-rw-r--r--src/backend/utils/sort/logtape.c2
-rw-r--r--src/include/storage/buffile.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index dd687dfe71f..d3722616bba 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -768,17 +768,17 @@ 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. */
lastFileSize = FileSize(file->files[file->numFiles - 1]);
if (lastFileSize < 0)
return -1;
- return ((file->numFiles - 1) * (off_t) MAX_PHYSICAL_FILESIZE) +
+ return ((file->numFiles - 1) * (int64) MAX_PHYSICAL_FILESIZE) +
lastFileSize;
}
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index 50a150b7136..269523d5f6a 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -426,7 +426,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
{
char filename[MAXPGPATH];
BufFile *file;
- off_t filesize;
+ int64 filesize;
lt = &lts->tapes[i];
diff --git a/src/include/storage/buffile.h b/src/include/storage/buffile.h
index a6cdeb451c1..a4043bd69d1 100644
--- a/src/include/storage/buffile.h
+++ b/src/include/storage/buffile.h
@@ -43,7 +43,7 @@ extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size);
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
extern int BufFileSeekBlock(BufFile *file, long blknum);
-extern off_t BufFileSize(BufFile *file);
+extern int64 BufFileSize(BufFile *file);
extern long BufFileAppend(BufFile *target, BufFile *source);
extern BufFile *BufFileCreateShared(SharedFileSet *fileset, const char *name);