diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2023-01-16 09:20:44 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2023-01-16 11:01:31 +0100 |
commit | 20428d344a2964de6aaef9984fcd472f3c65d115 (patch) | |
tree | 12ec494bd3dd561e56417915bcf97da45eb1cb17 /src/backend/access/gist/gistbuildbuffers.c | |
parent | 1561612e3bf3264c31618b9455d0c1003b9271ec (diff) | |
download | postgresql-20428d344a2964de6aaef9984fcd472f3c65d115.tar.gz postgresql-20428d344a2964de6aaef9984fcd472f3c65d115.zip |
Add BufFileRead variants with short read and EOF detection
Most callers of BufFileRead() want to check whether they read the full
specified length. Checking this at every call site is very tedious.
This patch provides additional variants BufFileReadExact() and
BufFileReadMaybeEOF() that include the length checks.
I considered changing BufFileRead() itself, but this function is also
used in extensions, and so changing the behavior like this would
create a lot of problems there. The new names are analogous to the
existing LogicalTapeReadExact().
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/f3501945-c591-8cc3-5ef0-b72a2e0eaa9c@enterprisedb.com
Diffstat (limited to 'src/backend/access/gist/gistbuildbuffers.c')
-rw-r--r-- | src/backend/access/gist/gistbuildbuffers.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/backend/access/gist/gistbuildbuffers.c b/src/backend/access/gist/gistbuildbuffers.c index 1a732dd5cf1..3399a6ae685 100644 --- a/src/backend/access/gist/gistbuildbuffers.c +++ b/src/backend/access/gist/gistbuildbuffers.c @@ -753,14 +753,9 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate, static void ReadTempFileBlock(BufFile *file, long blknum, void *ptr) { - size_t nread; - if (BufFileSeekBlock(file, blknum) != 0) elog(ERROR, "could not seek to block %ld in temporary file", blknum); - nread = BufFileRead(file, ptr, BLCKSZ); - if (nread != BLCKSZ) - elog(ERROR, "could not read temporary file: read only %zu of %zu bytes", - nread, (size_t) BLCKSZ); + BufFileReadExact(file, ptr, BLCKSZ); } static void |