From ef1811ac9a7b9c5accde1652c22fb041cb0f34b3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 29 Apr 2025 09:19:15 +0200 Subject: [PATCH] pg_verifybackup: Message style improvements --- src/bin/pg_verifybackup/astreamer_verify.c | 12 ++++++------ src/bin/pg_verifybackup/pg_verifybackup.c | 10 +++++----- src/bin/pg_verifybackup/t/003_corruption.pl | 12 ++++++------ src/bin/pg_verifybackup/t/004_options.pl | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/bin/pg_verifybackup/astreamer_verify.c b/src/bin/pg_verifybackup/astreamer_verify.c index 268c5f0e246..33cf67670a7 100644 --- a/src/bin/pg_verifybackup/astreamer_verify.c +++ b/src/bin/pg_verifybackup/astreamer_verify.c @@ -127,7 +127,7 @@ astreamer_verify_content(astreamer *streamer, astreamer_member *member, default: /* Shouldn't happen. */ - pg_fatal("unexpected state while parsing tar file"); + pg_fatal("unexpected state while parsing tar archive"); } } @@ -195,7 +195,7 @@ member_verify_header(astreamer *streamer, astreamer_member *member) if (m == NULL) { report_backup_error(mystreamer->context, - "\"%s\" is present in \"%s\" but not in the manifest", + "file \"%s\" is present in archive \"%s\" but not in the manifest", member->pathname, mystreamer->archive_name); return; } @@ -208,7 +208,7 @@ member_verify_header(astreamer *streamer, astreamer_member *member) if (m->size != member->size) { report_backup_error(mystreamer->context, - "\"%s\" has size %llu in \"%s\" but size %" PRIu64 " in the manifest", + "file \"%s\" has size %llu in archive \"%s\" but size %" PRIu64 " in the manifest", member->pathname, (unsigned long long) member->size, mystreamer->archive_name, @@ -297,7 +297,7 @@ member_verify_checksum(astreamer *streamer) if (mystreamer->checksum_bytes != m->size) { report_backup_error(mystreamer->context, - "file \"%s\" in \"%s\" should contain %" PRIu64 " bytes, but read %" PRIu64 " bytes", + "file \"%s\" in archive \"%s\" should contain %" PRIu64 " bytes, but %" PRIu64 " bytes were read", m->pathname, mystreamer->archive_name, m->size, mystreamer->checksum_bytes); @@ -317,12 +317,12 @@ member_verify_checksum(astreamer *streamer) /* And check it against the manifest. */ if (checksumlen != m->checksum_length) report_backup_error(mystreamer->context, - "file \"%s\" in \"%s\" has checksum of length %d, but expected %d", + "file \"%s\" in archive \"%s\" has checksum of length %d, but expected %d", m->pathname, mystreamer->archive_name, m->checksum_length, checksumlen); else if (memcmp(checksumbuf, m->checksum_payload, checksumlen) != 0) report_backup_error(mystreamer->context, - "checksum mismatch for file \"%s\" in \"%s\"", + "checksum mismatch for file \"%s\" in archive \"%s\"", m->pathname, mystreamer->archive_name); } diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c index a034d521123..48994ef9bc6 100644 --- a/src/bin/pg_verifybackup/pg_verifybackup.c +++ b/src/bin/pg_verifybackup/pg_verifybackup.c @@ -338,7 +338,7 @@ main(int argc, char **argv) if (!no_parse_wal && context.format == 't') { pg_log_error("pg_waldump cannot read tar files"); - pg_log_error_hint("You must use -n or --no-parse-wal when verifying a tar-format backup."); + pg_log_error_hint("You must use -n/--no-parse-wal when verifying a tar-format backup."); exit(1); } @@ -694,11 +694,11 @@ verify_plain_backup_file(verifier_context *context, char *relpath, return; } - /* If it's not a directory, it should be a plain file. */ + /* If it's not a directory, it should be a regular file. */ if (!S_ISREG(sb.st_mode)) { report_backup_error(context, - "\"%s\" is not a file or directory", + "\"%s\" is not a regular file or directory", relpath); return; } @@ -899,11 +899,11 @@ precheck_tar_backup_file(verifier_context *context, char *relpath, return; } - /* In a tar format backup, we expect only plain files. */ + /* In a tar format backup, we expect only regular files. */ if (!S_ISREG(sb.st_mode)) { report_backup_error(context, - "\"%s\" is not a plain file", + "file \"%s\" is not a regular file", relpath); return; } diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl index 84f23b8bc3d..1dd60f709cf 100644 --- a/src/bin/pg_verifybackup/t/003_corruption.pl +++ b/src/bin/pg_verifybackup/t/003_corruption.pl @@ -37,37 +37,37 @@ my @scenario = ( 'name' => 'extra_file', 'mutilate' => \&mutilate_extra_file, 'fails_like' => - qr/extra_file.*present (on disk|in "[^"]+") but not in the manifest/ + qr/extra_file.*present (on disk|in archive "[^"]+") but not in the manifest/ }, { 'name' => 'extra_tablespace_file', 'mutilate' => \&mutilate_extra_tablespace_file, 'fails_like' => - qr/extra_ts_file.*present (on disk|in "[^"]+") but not in the manifest/ + qr/extra_ts_file.*present (on disk|in archive "[^"]+") but not in the manifest/ }, { 'name' => 'missing_file', 'mutilate' => \&mutilate_missing_file, 'fails_like' => - qr/pg_xact\/0000.*present in the manifest but not (on disk|in "[^"]+")/ + qr/pg_xact\/0000.*present in the manifest but not (on disk|in archive "[^"]+")/ }, { 'name' => 'missing_tablespace', 'mutilate' => \&mutilate_missing_tablespace, 'fails_like' => - qr/pg_tblspc.*present in the manifest but not (on disk|in "[^"]+")/ + qr/pg_tblspc.*present in the manifest but not (on disk|in archive "[^"]+")/ }, { 'name' => 'append_to_file', 'mutilate' => \&mutilate_append_to_file, 'fails_like' => - qr/has size \d+ (on disk|in "[^"]+") but size \d+ in the manifest/ + qr/has size \d+ (on disk|in archive "[^"]+") but size \d+ in the manifest/ }, { 'name' => 'truncate_file', 'mutilate' => \&mutilate_truncate_file, 'fails_like' => - qr/has size 0 (on disk|in "[^"]+") but size \d+ in the manifest/ + qr/has size 0 (on disk|in archive "[^"]+") but size \d+ in the manifest/ }, { 'name' => 'replace_file', diff --git a/src/bin/pg_verifybackup/t/004_options.pl b/src/bin/pg_verifybackup/t/004_options.pl index 8c83dc7189e..3cdbe816862 100644 --- a/src/bin/pg_verifybackup/t/004_options.pl +++ b/src/bin/pg_verifybackup/t/004_options.pl @@ -53,7 +53,7 @@ $primary->command_fails_like( '--no-parse-wal', $backup_path ], - qr("pg_multixact" is not a plain file), + qr("pg_multixact" is not a regular file), "does not verify with --format=tar --no-parse-wal"); # Test invalid options -- 2.30.2