diff options
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/file/buffile.c | 18 | ||||
-rw-r--r-- | src/backend/storage/file/fd.c | 10 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index 9cdddba510e..d8a18dd3dcb 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -802,14 +802,24 @@ BufFileTellBlock(BufFile *file) #endif /* - * Return the current file size. Counts any holes left behind by - * BufFileViewAppend as part of the size. + * Return the current file size. + * + * Counts any holes left behind by BufFileAppend as part of the size. + * Returns -1 on error. */ off_t BufFileSize(BufFile *file) { + off_t lastFileSize; + + /* Get the size of the last physical file by seeking to end. */ + lastFileSize = FileSeek(file->files[file->numFiles - 1], 0, SEEK_END); + if (lastFileSize < 0) + return -1; + file->offsets[file->numFiles - 1] = lastFileSize; + return ((file->numFiles - 1) * (off_t) MAX_PHYSICAL_FILESIZE) + - FileGetSize(file->files[file->numFiles - 1]); + lastFileSize; } /* @@ -853,7 +863,7 @@ BufFileAppend(BufFile *target, BufFile *source) for (i = target->numFiles; i < newNumFiles; i++) { target->files[i] = source->files[i - target->numFiles]; - target->offsets[i] = 0L; + target->offsets[i] = source->offsets[i - target->numFiles]; } target->numFiles = newNumFiles; diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index afce5dadc09..441f18dcf56 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -2256,16 +2256,6 @@ FileGetRawMode(File file) } /* - * FileGetSize - returns the size of file - */ -off_t -FileGetSize(File file) -{ - Assert(FileIsValid(file)); - return VfdCache[file].fileSize; -} - -/* * Make room for another allocatedDescs[] array entry if needed and possible. * Returns true if an array element is available. */ |