Skip to content

Commit 4331a11

Browse files
committed
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
1 parent 2329cad commit 4331a11

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/backend/storage/file/buffile.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -857,18 +857,16 @@ BufFileSeekBlock(BufFile *file, int64 blknum)
857857
}
858858

859859
/*
860-
* Return the current fileset based BufFile size.
860+
* Returns the amount of data in the given BufFile, in bytes.
861861
*
862-
* Counts any holes left behind by BufFileAppend as part of the size.
862+
* Returned value includes the size of any holes left behind by BufFileAppend.
863863
* ereport()s on failure.
864864
*/
865865
int64
866866
BufFileSize(BufFile *file)
867867
{
868868
int64 lastFileSize;
869869

870-
Assert(file->fileset != NULL);
871-
872870
/* Get the size of the last physical file. */
873871
lastFileSize = FileSize(file->files[file->numFiles - 1]);
874872
if (lastFileSize < 0)
@@ -883,8 +881,7 @@ BufFileSize(BufFile *file)
883881
}
884882

885883
/*
886-
* Append the contents of source file (managed within fileset) to
887-
* end of target file (managed within same fileset).
884+
* Append the contents of the source file to the end of the target file.
888885
*
889886
* Note that operation subsumes ownership of underlying resources from
890887
* "source". Caller should never call BufFileClose against source having
@@ -908,10 +905,8 @@ BufFileAppend(BufFile *target, BufFile *source)
908905
int newNumFiles = target->numFiles + source->numFiles;
909906
int i;
910907

911-
Assert(target->fileset != NULL);
912908
Assert(source->readOnly);
913909
Assert(!source->dirty);
914-
Assert(source->fileset != NULL);
915910

916911
if (target->resowner != source->resowner)
917912
elog(ERROR, "could not append BufFile with non-matching resource owner");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy