git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9a740f8)
Fix some BufFileRead() error reporting
2023年1月16日 08:20:44 +0000 (09:20 +0100)
2023年1月16日 08:44:04 +0000 (09:44 +0100)
Remove "%m" from error messages where errno would be bogus. Add short
read byte counts where appropriate.

This is equivalent to what was done in
7897e3bb902c557412645b82120f4d95f7474906, but some code was apparently
developed concurrently to that and not updated accordingly.

Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/f3501945-c591-8cc3-5ef0-b72a2e0eaa9c@enterprisedb.com


diff --git a/src/backend/backup/backup_manifest.c b/src/backend/backup/backup_manifest.c
index 21ca2941dcfe48b05a5feb43121a797049f121b4..d325ef047aef0c847040ac2dbd0aff2719221545 100644 (file)
--- a/src/backend/backup/backup_manifest.c
+++ b/src/backend/backup/backup_manifest.c
@@ -371,7 +371,8 @@ SendBackupManifest(backup_manifest_info *manifest, bbsink *sink)
if (rc != bytes_to_read)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from temporary file: %m")));
+ errmsg("could not read from temporary file: read only %zu of %zu bytes",
+ rc, bytes_to_read)));
bbsink_manifest_contents(sink, bytes_to_read);
manifest_bytes_done += bytes_to_read;
}
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 79cda3944530a26b81b911def0f44bbc15823a6f..f3856c984337606440ce49979bfba614af633d66 100644 (file)
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -2063,7 +2063,7 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
nchanges = 0;
while (true)
{
- int nbytes;
+ size_t nbytes;
int len;
CHECK_FOR_INTERRUPTS();
@@ -2079,8 +2079,8 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
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\"",
@@ -2090,11 +2090,12 @@ apply_spooled_messages(FileSet *stream_fileset, TransactionId xid,
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);
@@ -3992,6 +3993,7 @@ static void
subxact_info_read(Oid subid, TransactionId xid)
{
char path[MAXPGPATH];
+ size_t nread;
Size len;
BufFile *fd;
MemoryContext oldctx;
@@ -4011,13 +4013,12 @@ subxact_info_read(Oid subid, TransactionId xid)
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;
@@ -4035,11 +4036,15 @@ subxact_info_read(Oid subid, TransactionId xid)
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);
}
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /