aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/sort/logtape.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/sort/logtape.c')
-rw-r--r--src/backend/utils/sort/logtape.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index 138da0c1b42..5517e59c50f 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -262,12 +262,12 @@ ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
}
/* Write the requested block */
- if (BufFileSeekBlock(lts->pfile, blocknum) != 0 ||
- BufFileWrite(lts->pfile, buffer, BLCKSZ) != BLCKSZ)
+ if (BufFileSeekBlock(lts->pfile, blocknum) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write block %ld of temporary file: %m",
+ errmsg("could not seek to block %ld of temporary file",
blocknum)));
+ BufFileWrite(lts->pfile, buffer, BLCKSZ);
/* Update nBlocksWritten, if we extended the file */
if (blocknum == lts->nBlocksWritten)
@@ -283,12 +283,19 @@ ltsWriteBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
static void
ltsReadBlock(LogicalTapeSet *lts, long blocknum, void *buffer)
{
- if (BufFileSeekBlock(lts->pfile, blocknum) != 0 ||
- BufFileRead(lts->pfile, buffer, BLCKSZ) != BLCKSZ)
+ size_t nread;
+
+ if (BufFileSeekBlock(lts->pfile, blocknum) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read block %ld of temporary file: %m",
+ errmsg("could not seek to block %ld of temporary file",
blocknum)));
+ nread = BufFileRead(lts->pfile, buffer, BLCKSZ);
+ if (nread != BLCKSZ)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read block %ld of temporary file: read only %zu of %zu bytes",
+ blocknum, nread, (size_t) BLCKSZ)));
}
/*