]> granicus.if.org Git - postgresql/commit
Have BufFileSize() ereport() on FileSize() failure.
authorPeter Geoghegan <pg@bowt.ie>
Wed, 28 Nov 2018 22:42:54 +0000 (14:42 -0800)
committerPeter Geoghegan <pg@bowt.ie>
Wed, 28 Nov 2018 22:42:54 +0000 (14:42 -0800)
commit1a990b207b86967cc323c00adda21fef3b2cd63e
treecbbd8f43563ca62202bec8b6484f1d3eadbe2647
parentf2cbffc7a6183a359b339cfed65e9d609de756f0
Have BufFileSize() ereport() on FileSize() failure.

Move the responsibility for checking for and reporting a failure from
the only current BufFileSize() caller, logtape.c, to BufFileSize()
itself.  Code within buffile.c is generally responsible for interfacing
with fd.c to report irrecoverable failures.  This seems like a
convention that's worth sticking to.

Reorganizing things this way makes it easy to make the error message
raised in the event of BufFileSize() failure descriptive of the
underlying problem.  We're now clear on the distinction between
temporary file name and BufFile name, and can show errno, confident that
its value actually relates to the error being reported.  In passing, an
existing, similar buffile.c ereport() + errcode_for_file_access() site
is changed to follow the same conventions.

The API of the function BufFileSize() is changed by this commit, despite
already being in a stable release (Postgres 11).  This seems acceptable,
since the BufFileSize() ABI was changed by commit aa551830421, which
hasn't made it into a point release yet.  Besides, it's difficult to
imagine a third party BufFileSize() caller not just raising an error
anyway, since BufFile state should be considered corrupt when
BufFileSize() fails.

Per complaint from Tom Lane.

Discussion: https://postgr.es/m/26974.1540826748@sss.pgh.pa.us
Backpatch: 11-, where shared BufFiles were introduced.
src/backend/storage/file/buffile.c
src/backend/utils/sort/logtape.c