mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Fix buffile.c error handling.
Convert buffile.c error handling to use ereport. This fixes cases where I/O errors were indistinguishable from EOF or not reported. Also remove "%m" from error messages where errno would be bogus. While we're modifying those strings, add block numbers and short read byte counts where appropriate. Back-patch to all supported releases. Reported-by: Amit Khandekar <amitdkhan.pg@gmail.com> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Ibrar Ahmed <ibrar.ahmad@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CA%2BhUKGJE04G%3D8TLK0DLypT_27D9dR8F1RQgNp0jK6qR0tZGWOw%40mail.gmail.com
This commit is contained in:
@@ -319,7 +319,7 @@ SendBackupManifest(backup_manifest_info *manifest)
|
||||
if (BufFileSeek(manifest->buffile, 0, 0L, SEEK_SET))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not rewind temporary file: %m")));
|
||||
errmsg("could not rewind temporary file")));
|
||||
|
||||
/* Send CopyOutResponse message */
|
||||
pq_beginmessage(&protobuf, 'H');
|
||||
@@ -365,15 +365,10 @@ static void
|
||||
AppendStringToManifest(backup_manifest_info *manifest, char *s)
|
||||
{
|
||||
int len = strlen(s);
|
||||
size_t written;
|
||||
|
||||
Assert(manifest != NULL);
|
||||
if (manifest->still_checksumming)
|
||||
pg_sha256_update(&manifest->manifest_ctx, (uint8 *) s, len);
|
||||
written = BufFileWrite(manifest->buffile, s, len);
|
||||
if (written != len)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write to temporary file: %m")));
|
||||
BufFileWrite(manifest->buffile, s, len);
|
||||
manifest->manifest_size += len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user