Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fa2ceac

Browse files
committed
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 9da0cc3. 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
1 parent b8182d6 commit fa2ceac

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/backend/storage/file/buffile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,18 +798,18 @@ BufFileTellBlock(BufFile *file)
798798
* Counts any holes left behind by BufFileAppend as part of the size.
799799
* Returns -1 on error.
800800
*/
801-
off_t
801+
int64
802802
BufFileSize(BufFile *file)
803803
{
804-
off_t lastFileSize;
804+
int64 lastFileSize;
805805

806806
/* Get the size of the last physical file by seeking to end. */
807807
lastFileSize = FileSeek(file->files[file->numFiles - 1], 0, SEEK_END);
808808
if (lastFileSize < 0)
809809
return -1;
810810
file->offsets[file->numFiles - 1] = lastFileSize;
811811

812-
return ((file->numFiles - 1) * (off_t) MAX_PHYSICAL_FILESIZE) +
812+
return ((file->numFiles - 1) * (int64) MAX_PHYSICAL_FILESIZE) +
813813
lastFileSize;
814814
}
815815

src/backend/utils/sort/logtape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ ltsConcatWorkerTapes(LogicalTapeSet *lts, TapeShare *shared,
426426
{
427427
char filename[MAXPGPATH];
428428
BufFile *file;
429-
off_t filesize;
429+
int64 filesize;
430430

431431
lt = &lts->tapes[i];
432432

src/include/storage/buffile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern size_t BufFileWrite(BufFile *file, void *ptr, size_t size);
4343
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
4444
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
4545
extern int BufFileSeekBlock(BufFile *file, long blknum);
46-
extern off_t BufFileSize(BufFile *file);
46+
extern int64 BufFileSize(BufFile *file);
4747
extern long BufFileAppend(BufFile *target, BufFile *source);
4848

4949
extern BufFile *BufFileCreateShared(SharedFileSet *fileset, const char *name);

0 commit comments

Comments
 (0)