pg_combinebackup: Error message improvements

Make the wordings of some file-related error messages more like those
used in other files.
This commit is contained in:
Peter Eisentraut 2024-06-21 09:40:44 +02:00
parent aea79883c5
commit c5c82123d3
6 changed files with 32 additions and 34 deletions

View file

@ -159,7 +159,7 @@ write_backup_label(char *output_directory, StringInfo buf,
if (wb < 0)
pg_fatal("could not write file \"%s\": %m", output_filename);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes",
pg_fatal("could not write file \"%s\": wrote %d of %d",
output_filename, (int) wb, (int) (e - s));
}
if (pg_checksum_update(&checksum_ctx, (uint8 *) s, e - s) < 0)
@ -171,7 +171,7 @@ write_backup_label(char *output_directory, StringInfo buf,
}
if (close(output_fd) != 0)
pg_fatal("could not close \"%s\": %m", output_filename);
pg_fatal("could not close file \"%s\": %m", output_filename);
checksum_length = pg_checksum_final(&checksum_ctx, checksum_payload);

View file

@ -59,9 +59,9 @@ copy_file(const char *src, const char *dst,
int fd;
if ((fd = open(src, O_RDONLY | PG_BINARY, 0)) < 0)
pg_fatal("could not open \"%s\": %m", src);
pg_fatal("could not open file \"%s\": %m", src);
if (close(fd) < 0)
pg_fatal("could not close \"%s\": %m", src);
pg_fatal("could not close file \"%s\": %m", src);
}
#ifdef WIN32
@ -179,10 +179,10 @@ copy_file_blocks(const char *src, const char *dst,
if ((wb = write(dest_fd, buffer, rb)) != rb)
{
if (wb < 0)
pg_fatal("could not write file \"%s\": %m", dst);
pg_fatal("could not write to file \"%s\": %m", dst);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes at offset %u",
dst, (int) wb, (int) rb, offset);
pg_fatal("could not write to file \"%s\", offset %u: wrote %d of %d",
dst, offset, (int) wb, (int) rb);
}
if (pg_checksum_update(checksum_ctx, buffer, rb) < 0)
@ -192,7 +192,7 @@ copy_file_blocks(const char *src, const char *dst,
}
if (rb < 0)
pg_fatal("could not read file \"%s\": %m", dst);
pg_fatal("could not read from file \"%s\": %m", dst);
pg_free(buffer);
close(src_fd);
@ -287,7 +287,7 @@ copy_file_copyfile(const char *src, const char *dst,
if (CopyFile(src, dst, true) == 0)
{
_dosmaperr(GetLastError());
pg_fatal("could not copy \"%s\" to \"%s\": %m", src, dst);
pg_fatal("could not copy file \"%s\" to \"%s\": %m", src, dst);
}
/* if needed, calculate checksum of the file */

View file

@ -122,7 +122,7 @@ load_backup_manifest(char *backup_directory)
{
if (errno == ENOENT)
{
pg_log_warning("\"%s\" does not exist", pathname);
pg_log_warning("file \"%s\" does not exist", pathname);
return NULL;
}
pg_fatal("could not open file \"%s\": %m", pathname);

View file

@ -523,7 +523,7 @@ check_backup_label_files(int n_backups, char **backup_dirs)
/* Close the file. */
if (close(fd) != 0)
pg_fatal("could not close \"%s\": %m", pathbuf);
pg_fatal("could not close file \"%s\": %m", pathbuf);
/* Parse the file contents. */
parse_backup_label(pathbuf, buf, &start_tli, &start_lsn,
@ -661,7 +661,7 @@ check_input_dir_permissions(char *dir)
struct stat st;
if (stat(dir, &st) != 0)
pg_fatal("could not stat \"%s\": %m", dir);
pg_fatal("could not stat file \"%s\": %m", dir);
SetDataDirectoryCreatePerm(st.st_mode);
}
@ -1159,7 +1159,7 @@ read_pg_version_file(char *directory)
/* Close the file. */
if (close(fd) != 0)
pg_fatal("could not close \"%s\": %m", filename);
pg_fatal("could not close file \"%s\": %m", filename);
/* Convert to integer. */
errno = 0;
@ -1178,7 +1178,7 @@ read_pg_version_file(char *directory)
}
/* Debugging output. */
pg_log_debug("read server version %d from \"%s\"", version, filename);
pg_log_debug("read server version %d from file \"%s\"", version, filename);
/* Release memory and return result. */
pfree(buf.data);
@ -1296,10 +1296,10 @@ scan_for_existing_tablespaces(char *pathname, cb_options *opt)
pg_fatal("could not read symbolic link \"%s\": %m",
tblspcdir);
if (link_length >= sizeof(link_target))
pg_fatal("symbolic link \"%s\" is too long", tblspcdir);
pg_fatal("target of symbolic link \"%s\" is too long", tblspcdir);
link_target[link_length] = '\0';
if (!is_absolute_path(link_target))
pg_fatal("symbolic link \"%s\" is relative", tblspcdir);
pg_fatal("target of symbolic link \"%s\" is relative", tblspcdir);
/* Canonicalize the link target. */
canonicalize_path(link_target);
@ -1339,7 +1339,7 @@ scan_for_existing_tablespaces(char *pathname, cb_options *opt)
/* Tablespaces should not share a directory. */
for (otherts = tslist; otherts != NULL; otherts = otherts->next)
if (strcmp(ts->new_dir, otherts->new_dir) == 0)
pg_fatal("tablespaces with OIDs %u and %u both point at \"%s\"",
pg_fatal("tablespaces with OIDs %u and %u both point at directory \"%s\"",
otherts->oid, oid, ts->new_dir);
/* Add this tablespace to the list. */
@ -1367,7 +1367,7 @@ slurp_file(int fd, char *filename, StringInfo buf, int maxlen)
/* Check file size, and complain if it's too large. */
if (fstat(fd, &st) != 0)
pg_fatal("could not stat \"%s\": %m", filename);
pg_fatal("could not stat file \"%s\": %m", filename);
if (st.st_size > maxlen)
pg_fatal("file \"%s\" is too large", filename);
@ -1386,7 +1386,7 @@ slurp_file(int fd, char *filename, StringInfo buf, int maxlen)
if (rb < 0)
pg_fatal("could not read file \"%s\": %m", filename);
else
pg_fatal("could not read file \"%s\": read only %zd of %lld bytes",
pg_fatal("could not read file \"%s\": read %zd of %lld",
filename, rb, (long long int) st.st_size);
}

View file

@ -196,7 +196,7 @@ reconstruct_from_incremental_file(char *input_filename,
/* We need to know the length of the file. */
if (fstat(s->fd, &sb) < 0)
pg_fatal("could not stat \"%s\": %m", s->filename);
pg_fatal("could not stat file \"%s\": %m", s->filename);
/*
* Since we found a full file, source all blocks from it that
@ -297,8 +297,7 @@ reconstruct_from_incremental_file(char *input_filename,
* The directory is out of sync with the backup_manifest, so emit
* a warning.
*/
/*- translator: the first %s is a backup manifest file, the second is a file absent therein */
pg_log_warning("\"%s\" contains no entry for \"%s\"",
pg_log_warning("manifest file \"%s\" contains no entry for file \"%s\"",
path,
manifest_path);
pfree(path);
@ -354,7 +353,7 @@ reconstruct_from_incremental_file(char *input_filename,
if (s == NULL)
continue;
if (close(s->fd) != 0)
pg_fatal("could not close \"%s\": %m", s->filename);
pg_fatal("could not close file \"%s\": %m", s->filename);
if (s->relative_block_numbers != NULL)
pfree(s->relative_block_numbers);
pg_free(s->filename);
@ -406,7 +405,7 @@ debug_reconstruction(int n_source, rfile **sources, bool dry_run)
struct stat sb;
if (fstat(s->fd, &sb) < 0)
pg_fatal("could not stat \"%s\": %m", s->filename);
pg_fatal("could not stat file \"%s\": %m", s->filename);
if (sb.st_size < s->highest_offset_read)
pg_fatal("file \"%s\" is too short: expected %llu, found %llu",
s->filename,
@ -527,7 +526,7 @@ read_bytes(rfile *rf, void *buffer, unsigned length)
if (rb < 0)
pg_fatal("could not read file \"%s\": %m", rf->filename);
else
pg_fatal("could not read file \"%s\": read only %d of %u bytes",
pg_fatal("could not read file \"%s\": read %d of %u",
rf->filename, rb, length);
}
}
@ -725,7 +724,7 @@ write_reconstructed_file(char *input_filename,
/* Close the output file. */
if (wfd >= 0 && close(wfd) != 0)
pg_fatal("could not close \"%s\": %m", output_filename);
pg_fatal("could not close file \"%s\": %m", output_filename);
}
/*
@ -746,7 +745,7 @@ write_block(int fd, char *output_filename,
if (wb < 0)
pg_fatal("could not write file \"%s\": %m", output_filename);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes",
pg_fatal("could not write file \"%s\": wrote %d of %d",
output_filename, wb, BLCKSZ);
}
@ -769,10 +768,9 @@ read_block(rfile *s, off_t off, uint8 *buffer)
if (rb != BLCKSZ)
{
if (rb < 0)
pg_fatal("could not read file \"%s\": %m", s->filename);
pg_fatal("could not read from file \"%s\": %m", s->filename);
else
pg_fatal("could not read file \"%s\": read only %d of %d bytes at offset %llu",
s->filename, rb, BLCKSZ,
(unsigned long long) off);
pg_fatal("could not read from file \"%s\", offset %llu: read %d of %d",
s->filename, (unsigned long long) off, rb, BLCKSZ);
}
}

View file

@ -184,7 +184,7 @@ finalize_manifest(manifest_writer *mwriter,
/* Close the file. */
if (close(mwriter->fd) != 0)
pg_fatal("could not close \"%s\": %m", mwriter->pathname);
pg_fatal("could not close file \"%s\": %m", mwriter->pathname);
mwriter->fd = -1;
}
@ -257,9 +257,9 @@ flush_manifest(manifest_writer *mwriter)
if (wb != mwriter->buf.len)
{
if (wb < 0)
pg_fatal("could not write \"%s\": %m", mwriter->pathname);
pg_fatal("could not write file \"%s\": %m", mwriter->pathname);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes",
pg_fatal("could not write file \"%s\": wrote %d of %d",
mwriter->pathname, (int) wb, mwriter->buf.len);
}