Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa2ceac

Browse files
committed
Use 64 bit type for BufFileSize().
BufFileSize() can't use off_t, because it's only 32 bits wide onsome systems. BufFile objects can have many 1GB segments so thetotal size can exceed 2^31. The only known client of the functionis parallel CREATE INDEX, which was reported to fail when buildinglarge indexes on Windows.Though this is technically an ABI break on platforms with a 32 bitoff_t and we might normally avoid back-patching it, the function isbrand new and thus unlikely to have been discovered by extensionauthors yet, and it's fairly thoroughly broken on those platformsanyway, so just fix it.Defect in9da0cc3. Bug #15460. Back-patch to 11, where thisfunction landed.Author: Thomas MunroReported-by: Paul van der Linden, Pavel OskinReviewed-by: Peter GeogheganDiscussion:https://postgr.es/m/15460-b6db80de822fa0ad%40postgresql.orgDiscussion:https://postgr.es/m/CAHDGBJP_GsESbTt4P3FZA8kMUKuYxjg57XHF7NRBoKnR%3DCAR-g%40mail.gmail.com
1 parentb8182d6 commitfa2ceac

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_tlastFileSize;
804+
int64lastFileSize;
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
charfilename[MAXPGPATH];
428428
BufFile*file;
429-
off_tfilesize;
429+
int64filesize;
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
externintBufFileSeek(BufFile*file,intfileno,off_toffset,intwhence);
4444
externvoidBufFileTell(BufFile*file,int*fileno,off_t*offset);
4545
externintBufFileSeekBlock(BufFile*file,longblknum);
46-
externoff_tBufFileSize(BufFile*file);
46+
externint64BufFileSize(BufFile*file);
4747
externlongBufFileAppend(BufFile*target,BufFile*source);
4848

4949
externBufFile*BufFileCreateShared(SharedFileSet*fileset,constchar*name);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp