Re: Incorrect Assert in BufFileSize()? - Mailing list pgsql-hackers

From David Rowley
Subject Re: Incorrect Assert in BufFileSize()?
Date
Msg-id CAApHDvo7Kfe7Swx9M2PH5P21AaN65EuP+3oG5E9tX0bkM912xg@mail.gmail.com
Whole thread Raw
In response to Re: Incorrect Assert in BufFileSize()?  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
On Thu, 16 May 2024 at 07:20, Peter Geoghegan <pg@bowt.ie> wrote:
>
> On Tue, May 14, 2024 at 6:58 AM David Rowley <dgrowleyml@gmail.com> wrote:
> > On Fri, 3 May 2024 at 16:03, David Rowley <dgrowleyml@gmail.com> wrote:
> > > I'm trying to figure out why BufFileSize() Asserts that file->fileset
> > > isn't NULL, per 1a990b207.
> >
> > I was hoping to get some feedback here.
>
> Notice that comments above BufFileSize() say "Return the current
> fileset based BufFile size". There are numerous identical assertions
> at the start of several other functions within the same file.

hmm, unfortunately the comment and existence of numerous other
assertions does not answer my question. It just leads to more.  The
only Assert I see that looks like it might be useful is
BufFileExportFileSet() as fileset is looked at inside extendBufFile().
It kinda looks to me that it was left over fragments from the
development of a patch when it was written some other way?

Looking at the other similar Asserts in BufFileAppend(), I can't
figure out what those ones are for either.

> I'm not sure what it would take for this function to support
> OpenTemporaryFile()-based BufFiles -- possibly not very much at all. I
> assume that that's what you're actually interested in doing here (you
> didn't say). If it is, you'll need to update the function's contract
> -- just removing the assertion isn't enough.

I should have explained, I just wasn't quite done with what I was
working on when I sent the original email. In [1] I was working on
adding additional output in EXPLAIN for the "Material" node to show
the memory or disk space used by the tuplestore.  The use case there
uses a BufFile with no fileset.  Calling BufFileSize(state->myfile)
from tuplestore.c results in an Assert failure.

David

[1] https://commitfest.postgresql.org/48/4968/



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: commitfest.postgresql.org is no longer fit for purpose
Next
From: Yasir
Date:
Subject: Re: commitfest.postgresql.org is no longer fit for purpose