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

Commitaa55183

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 parenteaf746a commitaa55183

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
@@ -768,17 +768,17 @@ BufFileTellBlock(BufFile *file)
768768
* Counts any holes left behind by BufFileAppend as part of the size.
769769
* Returns -1 on error.
770770
*/
771-
off_t
771+
int64
772772
BufFileSize(BufFile*file)
773773
{
774-
off_tlastFileSize;
774+
int64lastFileSize;
775775

776776
/* Get the size of the last physical file. */
777777
lastFileSize=FileSize(file->files[file->numFiles-1]);
778778
if (lastFileSize<0)
779779
return-1;
780780

781-
return ((file->numFiles-1)* (off_t)MAX_PHYSICAL_FILESIZE)+
781+
return ((file->numFiles-1)* (int64)MAX_PHYSICAL_FILESIZE)+
782782
lastFileSize;
783783
}
784784

‎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