v20251001-0011-BufFileLoadBuffer-simpler-FileRead-handlin.patch
text/x-patch
Filename: v20251001-0011-BufFileLoadBuffer-simpler-FileRead-handlin.patch
Type: text/x-patch
Part: 10
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v20251001-0011
Subject: BufFileLoadBuffer - simpler FileRead handling
| File | + | − |
|---|---|---|
| src/backend/storage/file/buffile.c | 6 | 7 |
From d9ad495364d70f9e91425786f3ed4691475ae693 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@vondra.me>
Date: Mon, 29 Sep 2025 22:56:48 +0200
Subject: [PATCH v20251001 11/25] BufFileLoadBuffer - simpler FileRead handling
---
src/backend/storage/file/buffile.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index 12c2e974783..932c10351bc 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -620,20 +620,19 @@ BufFileLoadBuffer(BufFile *file)
file->curOffset + sizeof(nbytes),
WAIT_EVENT_BUFFILE_READ);
- /* Check if second read succeeded */
- if (nread_orig != sizeof(original_size) && nread_orig > 0)
+ /*
+ * Did we read the second (raw) length? We should not get an
+ * EOF here, we've already read the first length.
+ */
+ if ((nread_orig == 0) || (nread_orig != sizeof(original_size)))
{
+ /* also covers (nread_orig < 0) */
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not read file \"%s\": %m",
FilePathName(thisfile))));
}
- if (nread_orig <= 0)
- {
- file->nbytes = 0;
- return;
- }
/* Check if data is uncompressed (marker = -1) */
if (original_size == -1)
--
2.51.0