pg_rewind: Improve message wording

This commit is contained in:
Peter Eisentraut 2015-06-22 20:40:01 -04:00
parent 747781f25e
commit e98d635d5d
7 changed files with 54 additions and 56 deletions

View File

@ -148,7 +148,7 @@ recurse_dir(const char *datadir, const char *parentpath,
fullparentpath, strerror(errno));
if (closedir(xldir))
pg_fatal("could not close archive location \"%s\": %s\n",
pg_fatal("could not close directory \"%s\": %s\n",
fullparentpath, strerror(errno));
}
@ -199,7 +199,7 @@ copy_file_range(const char *path, off_t begin, off_t end, bool trunc)
}
if (close(srcfd) != 0)
pg_fatal("error closing file \"%s\": %s\n", srcpath, strerror(errno));
pg_fatal("could not close file \"%s\": %s\n", srcpath, strerror(errno));
}
/*

View File

@ -25,7 +25,7 @@
#include "pg_rewind.h"
/*
* Currently open destination file.
* Currently open target file.
*/
static int dstfd = -1;
static char dstpath[MAXPGPATH] = "";
@ -61,7 +61,7 @@ open_target_file(const char *path, bool trunc)
mode |= O_TRUNC;
dstfd = open(dstpath, mode, 0600);
if (dstfd < 0)
pg_fatal("could not open destination file \"%s\": %s\n",
pg_fatal("could not open target file \"%s\": %s\n",
dstpath, strerror(errno));
}
@ -75,7 +75,7 @@ close_target_file(void)
return;
if (close(dstfd) != 0)
pg_fatal("error closing destination file \"%s\": %s\n",
pg_fatal("could not close target file \"%s\": %s\n",
dstpath, strerror(errno));
dstfd = -1;
@ -96,7 +96,7 @@ write_target_range(char *buf, off_t begin, size_t size)
return;
if (lseek(dstfd, begin, SEEK_SET) == -1)
pg_fatal("could not seek in destination file \"%s\": %s\n",
pg_fatal("could not seek in target file \"%s\": %s\n",
dstpath, strerror(errno));
writeleft = size;

View File

@ -93,7 +93,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
* regular file
*/
if (type != FILE_TYPE_REGULAR && isRelDataFile(path))
pg_fatal("data file in source \"%s\" is not a regular file\n", path);
pg_fatal("data file \"%s\" in source is not a regular file\n", path);
snprintf(localpath, sizeof(localpath), "%s/%s", datadir_target, path);
@ -256,7 +256,7 @@ process_target_file(const char *path, file_type_t type, size_t oldsize,
if (lstat(localpath, &statbuf) < 0)
{
if (errno != ENOENT)
pg_fatal("could not stat file \"%s\": %s",
pg_fatal("could not stat file \"%s\": %s\n",
localpath, strerror(errno));
exists = false;

View File

@ -52,10 +52,10 @@ libpqConnect(const char *connstr)
conn = PQconnectdb(connstr);
if (PQstatus(conn) == CONNECTION_BAD)
pg_fatal("could not connect to remote server: %s\n",
pg_fatal("could not connect to server: %s",
PQerrorMessage(conn));
pg_log(PG_PROGRESS, "connected to remote server\n");
pg_log(PG_PROGRESS, "connected to server\n");
/*
* Check that the server is not in hot standby mode. There is no
@ -91,12 +91,12 @@ run_simple_query(const char *sql)
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
pg_fatal("error running query (%s) in source server: %s\n",
pg_fatal("error running query (%s) in source server: %s",
sql, PQresultErrorMessage(res));
/* sanity check the result set */
if (PQnfields(res) != 1 || PQntuples(res) != 1 || PQgetisnull(res, 0, 0))
pg_fatal("unexpected result set while running query\n");
pg_fatal("unexpected result set from query\n");
result = pg_strdup(PQgetvalue(res, 0, 0));
@ -119,7 +119,7 @@ libpqGetCurrentXlogInsertLocation(void)
val = run_simple_query("SELECT pg_current_xlog_insert_location()");
if (sscanf(val, "%X/%X", &hi, &lo) != 2)
pg_fatal("unexpected result \"%s\" while fetching current XLOG insert location\n", val);
pg_fatal("unrecognized result \"%s\" for current XLOG insert location\n", val);
result = ((uint64) hi) << 32 | lo;
@ -167,7 +167,7 @@ libpqProcessFileList(void)
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
pg_fatal("unexpected result while fetching file list: %s\n",
pg_fatal("could not fetch file list: %s",
PQresultErrorMessage(res));
/* sanity check the result set */
@ -210,7 +210,7 @@ receiveFileChunks(const char *sql)
PGresult *res;
if (PQsendQueryParams(conn, sql, 0, NULL, NULL, NULL, NULL, 1) != 1)
pg_fatal("could not send query: %s\n", PQerrorMessage(conn));
pg_fatal("could not send query: %s", PQerrorMessage(conn));
pg_log(PG_DEBUG, "getting file chunks");
@ -262,7 +262,7 @@ receiveFileChunks(const char *sql)
PQgetisnull(res, 0, 1) ||
PQgetisnull(res, 0, 2))
{
pg_fatal("unexpected NULL result while fetching remote files\n");
pg_fatal("unexpected null values in result while fetching remote files\n");
}
if (PQgetlength(res, 0, 1) != sizeof(int32))
@ -280,7 +280,7 @@ receiveFileChunks(const char *sql)
chunk = PQgetvalue(res, 0, 2);
pg_log(PG_DEBUG, "received chunk for file \"%s\", off %d, len %d\n",
pg_log(PG_DEBUG, "received chunk for file \"%s\", offset %d, size %d\n",
filename, chunkoff, chunksize);
open_target_file(filename, false);
@ -309,7 +309,7 @@ libpqGetFile(const char *filename, size_t *filesize)
1, NULL, paramValues, NULL, NULL, 1);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
pg_fatal("unexpected result while fetching remote file \"%s\": %s\n",
pg_fatal("could not fetch remote file \"%s\": %s",
filename, PQresultErrorMessage(res));
/* sanity check the result set */
@ -355,7 +355,7 @@ fetch_file_range(const char *path, unsigned int begin, unsigned int end)
snprintf(linebuf, sizeof(linebuf), "%s\t%u\t%u\n", path, begin, len);
if (PQputCopyData(conn, linebuf, strlen(linebuf)) != 1)
pg_fatal("error sending COPY data: %s\n",
pg_fatal("could not send COPY data: %s",
PQerrorMessage(conn));
begin += len;
@ -381,14 +381,14 @@ libpq_executeFileMap(filemap_t *map)
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
pg_fatal("error creating temporary table: %s\n",
pg_fatal("could not create temporary table: %s",
PQresultErrorMessage(res));
sql = "COPY fetchchunks FROM STDIN";
res = PQexec(conn, sql);
if (PQresultStatus(res) != PGRES_COPY_IN)
pg_fatal("unexpected result while sending file list: %s\n",
pg_fatal("could not send file list: %s",
PQresultErrorMessage(res));
for (i = 0; i < map->narray; i++)
@ -429,13 +429,13 @@ libpq_executeFileMap(filemap_t *map)
}
if (PQputCopyEnd(conn, NULL) != 1)
pg_fatal("error sending end-of-COPY: %s\n",
pg_fatal("could not send end-of-COPY: %s",
PQerrorMessage(conn));
while ((res = PQgetResult(conn)) != NULL)
{
if (PQresultStatus(res) != PGRES_COMMAND_OK)
pg_fatal("unexpected result while sending file list: %s\n",
pg_fatal("unexpected result while sending file list: %s",
PQresultErrorMessage(res));
}

View File

@ -84,11 +84,11 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, TimeLineID tli,
errptr = startpoint ? startpoint : xlogreader->EndRecPtr;
if (errormsg)
pg_fatal("error reading WAL at %X/%X: %s\n",
pg_fatal("could not read WAL record at %X/%X: %s\n",
(uint32) (errptr >> 32), (uint32) (errptr),
errormsg);
else
pg_fatal("error reading WAL at %X/%X\n",
pg_fatal("could not read WAL record at %X/%X\n",
(uint32) (startpoint >> 32),
(uint32) (startpoint));
}

View File

@ -56,22 +56,18 @@ bool dry_run = false;
static void
usage(const char *progname)
{
printf(_("%s resynchronizes a cluster with another copy of the cluster.\n\n"), progname);
printf(_("%s resynchronizes a PostgreSQL cluster with another copy of the cluster.\n\n"), progname);
printf(_("Usage:\n %s [OPTION]...\n\n"), progname);
printf(_("Options:\n"));
printf(_(" -D, --target-pgdata=DIRECTORY\n"));
printf(_(" existing data directory to modify\n"));
printf(_(" --source-pgdata=DIRECTORY\n"));
printf(_(" source data directory to sync with\n"));
printf(_(" --source-server=CONNSTR\n"));
printf(_(" source server to sync with\n"));
printf(_(" -P, --progress write progress messages\n"));
printf(_(" -n, --dry-run stop before modifying anything\n"));
printf(_(" --debug write a lot of debug messages\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\n"));
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
printf(_(" -D, --target-pgdata=DIRECTORY existing data directory to modify\n"));
printf(_(" --source-pgdata=DIRECTORY source data directory to sync with\n"));
printf(_(" --source-server=CONNSTR source server to sync with\n"));
printf(_(" -n, --dry-run stop before modifying anything\n"));
printf(_(" -P, --progress write progress messages\n"));
printf(_(" --debug write a lot of debug messages\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
}
@ -154,24 +150,24 @@ main(int argc, char **argv)
}
}
/* No source given? Show usage */
if (datadir_source == NULL && connstr_source == NULL)
{
fprintf(stderr, _("no source specified (--source-pgdata or --source-server)\n"));
fprintf(stderr, _("%s: no source specified (--source-pgdata or --source-server)\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
if (datadir_target == NULL)
{
fprintf(stderr, _("no target data directory specified (--target-pgdata)\n"));
fprintf(stderr, _("%s: no target data directory specified (--target-pgdata)\n"), progname);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
if (argc != optind)
if (optind < argc)
{
fprintf(stderr, _("invalid arguments\n"));
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
@ -184,9 +180,11 @@ main(int argc, char **argv)
*/
#ifndef WIN32
if (geteuid() == 0)
pg_fatal("cannot be executed by \"root\"\n"
"You must run %s as the PostgreSQL superuser.\n",
progname);
{
fprintf(stderr, _("cannot be executed by \"root\"\n"));
fprintf(stderr, _("You must run %s as the PostgreSQL superuser.\n"),
progname);
}
#endif
get_restricted_token(progname);
@ -295,7 +293,7 @@ main(int argc, char **argv)
*/
if (showprogress)
{
pg_log(PG_PROGRESS, "Need to copy %lu MB (total source directory size is %lu MB)\n",
pg_log(PG_PROGRESS, "need to copy %lu MB (total source directory size is %lu MB)\n",
(unsigned long) (filemap->fetch_size / (1024 * 1024)),
(unsigned long) (filemap->total_size / (1024 * 1024)));

View File

@ -73,20 +73,20 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
if (nfields < 1)
{
/* expect a numeric timeline ID as first field of line */
printf(_("syntax error in history file: %s\n"), fline);
printf(_("Expected a numeric timeline ID.\n"));
fprintf(stderr, _("syntax error in history file: %s\n"), fline);
fprintf(stderr, _("Expected a numeric timeline ID.\n"));
exit(1);
}
if (nfields != 3)
{
printf(_("syntax error in history file: %s\n"), fline);
printf(_("Expected an XLOG switchpoint location.\n"));
fprintf(stderr, _("syntax error in history file: %s\n"), fline);
fprintf(stderr, _("Expected an XLOG switchpoint location.\n"));
exit(1);
}
if (entries && tli <= lasttli)
{
printf(_("invalid data in history file: %s\n"), fline);
printf(_("Timeline IDs must be in increasing sequence.\n"));
fprintf(stderr, _("invalid data in history file: %s\n"), fline);
fprintf(stderr, _("Timeline IDs must be in increasing sequence.\n"));
exit(1);
}
@ -106,8 +106,8 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
if (entries && targetTLI <= lasttli)
{
printf(_("invalid data in history file\n"));
printf(_("Timeline IDs must be less than child timeline's ID.\n"));
fprintf(stderr, _("invalid data in history file\n"));
fprintf(stderr, _("Timeline IDs must be less than child timeline's ID.\n"));
exit(1);
}