diff options
author | David Rowley <drowley@postgresql.org> | 2024-07-04 09:44:34 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2024-07-04 09:44:34 +1200 |
commit | 4331a11c62eca7426ad4472be051fe512a04fc80 (patch) | |
tree | cce4c15fb2fb0d08c0a573d258f8a5d241bc3f41 | |
parent | 2329cad1b93f268c0ec6848732c6db43eb46156c (diff) | |
download | postgresql-4331a11c62eca7426ad4472be051fe512a04fc80.tar.gz postgresql-4331a11c62eca7426ad4472be051fe512a04fc80.zip |
Remove incorrect Asserts in buffile.c
Both BufFileSize() and BufFileAppend() contained Asserts to ensure the
given BufFile(s) had a valid fileset. A valid fileset isn't required in
either of these functions, so remove the Asserts and adjust the
comments accordingly.
This was noticed while work was being done on a new patch to call
BufFileSize() on a BufFile without a valid fileset. It seems there's
currently no code in the tree which could trigger these Asserts, so no
need to backpatch this, for now.
Reviewed-by: Peter Geoghegan, Matthias van de Meent, Tom Lane
Discussion: https://postgr.es/m/CAApHDvofgZT0VzydhyGH5MMb-XZzNDqqAbzf1eBZV5HDm3%2BosQ%40mail.gmail.com
-rw-r--r-- | src/backend/storage/file/buffile.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c index a263875fd5a..a27f51f6220 100644 --- a/src/backend/storage/file/buffile.c +++ b/src/backend/storage/file/buffile.c @@ -857,9 +857,9 @@ BufFileSeekBlock(BufFile *file, int64 blknum) } /* - * Return the current fileset based BufFile size. + * Returns the amount of data in the given BufFile, in bytes. * - * Counts any holes left behind by BufFileAppend as part of the size. + * Returned value includes the size of any holes left behind by BufFileAppend. * ereport()s on failure. */ int64 @@ -867,8 +867,6 @@ BufFileSize(BufFile *file) { int64 lastFileSize; - Assert(file->fileset != NULL); - /* Get the size of the last physical file. */ lastFileSize = FileSize(file->files[file->numFiles - 1]); if (lastFileSize < 0) @@ -883,8 +881,7 @@ BufFileSize(BufFile *file) } /* - * Append the contents of source file (managed within fileset) to - * end of target file (managed within same fileset). + * Append the contents of the source file to the end of the target file. * * Note that operation subsumes ownership of underlying resources from * "source". Caller should never call BufFileClose against source having @@ -908,10 +905,8 @@ BufFileAppend(BufFile *target, BufFile *source) int newNumFiles = target->numFiles + source->numFiles; int i; - Assert(target->fileset != NULL); Assert(source->readOnly); Assert(!source->dirty); - Assert(source->fileset != NULL); if (target->resowner != source->resowner) elog(ERROR, "could not append BufFile with non-matching resource owner"); |