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));
}
}
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));
}
/*
#include "pg_rewind.h"
/*
- * Currently open destination file.
+ * Currently open target file.
*/
static int dstfd = -1;
static char dstpath[MAXPGPATH] = "";
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));
}
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;
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;
* 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);
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;
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
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));
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;
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 */
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");
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))
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);
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 */
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;
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++)
}
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));
}
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));
}
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"));
}
}
}
- /* 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);
}
*/
#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);
*/
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)));
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);
}
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);
}