nchanges = 0;
while (true)
{
- int nbytes;
+ size_t nbytes;
int len;
CHECK_FOR_INTERRUPTS();
if (nbytes != sizeof(len))
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from streaming transaction's changes file \"%s\": %m",
- path)));
+ errmsg("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes",
+ path, nbytes, sizeof(len))));
if (len <= 0)
elog(ERROR, "incorrect length %d in streaming transaction's changes file \"%s\"",
buffer = repalloc(buffer, len);
/* and finally read the data into the buffer */
- if (BufFileRead(stream_fd, buffer, len) != len)
+ nbytes = BufFileRead(stream_fd, buffer, len);
+ if (nbytes != len)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from streaming transaction's changes file \"%s\": %m",
- path)));
+ errmsg("could not read from streaming transaction's changes file \"%s\": read only %zu of %zu bytes",
+ path, nbytes, (size_t) len)));
BufFileTell(stream_fd, &fileno, &offset);
subxact_info_read(Oid subid, TransactionId xid)
{
char path[MAXPGPATH];
+ size_t nread;
Size len;
BufFile *fd;
MemoryContext oldctx;
return;
/* read number of subxact items */
- if (BufFileRead(fd, &subxact_data.nsubxacts,
- sizeof(subxact_data.nsubxacts)) !=
- sizeof(subxact_data.nsubxacts))
+ nread = BufFileRead(fd, &subxact_data.nsubxacts, sizeof(subxact_data.nsubxacts));
+ if (nread != sizeof(subxact_data.nsubxacts))
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from streaming transaction's subxact file \"%s\": %m",
- path)));
+ errmsg("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes",
+ path, nread, sizeof(subxact_data.nsubxacts))));
len = sizeof(SubXactInfo) * subxact_data.nsubxacts;
sizeof(SubXactInfo));
MemoryContextSwitchTo(oldctx);
- if ((len > 0) && ((BufFileRead(fd, subxact_data.subxacts, len)) != len))
+ if (len > 0)
+ {
+ nread = BufFileRead(fd, subxact_data.subxacts, len);
+ if (nread != len)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from streaming transaction's subxact file \"%s\": %m",
- path)));
+ errmsg("could not read from streaming transaction's subxact file \"%s\": read only %zu of %zu bytes",
+ path, nread, len)));
+ }
BufFileClose(fd);
}