From 20428d344a2964de6aaef9984fcd472f3c65d115 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 16 Jan 2023 09:20:44 +0100 Subject: 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 Discussion: https://www.postgresql.org/message-id/flat/f3501945-c591-8cc3-5ef0-b72a2e0eaa9c@enterprisedb.com --- src/backend/backup/backup_manifest.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/backend/backup') diff --git a/src/backend/backup/backup_manifest.c b/src/backend/backup/backup_manifest.c index d325ef047ae..fabd2ca2992 100644 --- a/src/backend/backup/backup_manifest.c +++ b/src/backend/backup/backup_manifest.c @@ -362,17 +362,10 @@ SendBackupManifest(backup_manifest_info *manifest, bbsink *sink) while (manifest_bytes_done < manifest->manifest_size) { size_t bytes_to_read; - size_t rc; bytes_to_read = Min(sink->bbs_buffer_length, manifest->manifest_size - manifest_bytes_done); - rc = BufFileRead(manifest->buffile, sink->bbs_buffer, - bytes_to_read); - if (rc != bytes_to_read) - ereport(ERROR, - (errcode_for_file_access(), - errmsg("could not read from temporary file: read only %zu of %zu bytes", - rc, bytes_to_read))); + BufFileReadExact(manifest->buffile, sink->bbs_buffer, bytes_to_read); bbsink_manifest_contents(sink, bytes_to_read); manifest_bytes_done += bytes_to_read; } -- cgit v1.2.3