Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite98d635

Browse files
committed
pg_rewind: Improve message wording
1 parent747781f commite98d635

File tree

7 files changed

+54
-56
lines changed

7 files changed

+54
-56
lines changed

‎src/bin/pg_rewind/copy_fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ recurse_dir(const char *datadir, const char *parentpath,
148148
fullparentpath,strerror(errno));
149149

150150
if (closedir(xldir))
151-
pg_fatal("could not closearchive location \"%s\": %s\n",
151+
pg_fatal("could not closedirectory \"%s\": %s\n",
152152
fullparentpath,strerror(errno));
153153
}
154154

@@ -199,7 +199,7 @@ copy_file_range(const char *path, off_t begin, off_t end, bool trunc)
199199
}
200200

201201
if (close(srcfd)!=0)
202-
pg_fatal("error closing file \"%s\": %s\n",srcpath,strerror(errno));
202+
pg_fatal("could not close file \"%s\": %s\n",srcpath,strerror(errno));
203203
}
204204

205205
/*

‎src/bin/pg_rewind/file_ops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include"pg_rewind.h"
2626

2727
/*
28-
* Currently opendestination file.
28+
* Currently opentarget file.
2929
*/
3030
staticintdstfd=-1;
3131
staticchardstpath[MAXPGPATH]="";
@@ -61,7 +61,7 @@ open_target_file(const char *path, bool trunc)
6161
mode |=O_TRUNC;
6262
dstfd=open(dstpath,mode,0600);
6363
if (dstfd<0)
64-
pg_fatal("could not opendestination file \"%s\": %s\n",
64+
pg_fatal("could not opentarget file \"%s\": %s\n",
6565
dstpath,strerror(errno));
6666
}
6767

@@ -75,7 +75,7 @@ close_target_file(void)
7575
return;
7676

7777
if (close(dstfd)!=0)
78-
pg_fatal("error closing destination file \"%s\": %s\n",
78+
pg_fatal("could not close target file \"%s\": %s\n",
7979
dstpath,strerror(errno));
8080

8181
dstfd=-1;
@@ -96,7 +96,7 @@ write_target_range(char *buf, off_t begin, size_t size)
9696
return;
9797

9898
if (lseek(dstfd,begin,SEEK_SET)==-1)
99-
pg_fatal("could not seek indestination file \"%s\": %s\n",
99+
pg_fatal("could not seek intarget file \"%s\": %s\n",
100100
dstpath,strerror(errno));
101101

102102
writeleft=size;

‎src/bin/pg_rewind/filemap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
9393
* regular file
9494
*/
9595
if (type!=FILE_TYPE_REGULAR&&isRelDataFile(path))
96-
pg_fatal("data filein source\"%s\" is not a regular file\n",path);
96+
pg_fatal("data file \"%s\" in source is not a regular file\n",path);
9797

9898
snprintf(localpath,sizeof(localpath),"%s/%s",datadir_target,path);
9999

@@ -256,7 +256,7 @@ process_target_file(const char *path, file_type_t type, size_t oldsize,
256256
if (lstat(localpath,&statbuf)<0)
257257
{
258258
if (errno!=ENOENT)
259-
pg_fatal("could not stat file \"%s\": %s",
259+
pg_fatal("could not stat file \"%s\": %s\n",
260260
localpath,strerror(errno));
261261

262262
exists= false;

‎src/bin/pg_rewind/libpq_fetch.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ libpqConnect(const char *connstr)
5252

5353
conn=PQconnectdb(connstr);
5454
if (PQstatus(conn)==CONNECTION_BAD)
55-
pg_fatal("could not connect toremoteserver: %s\n",
55+
pg_fatal("could not connect to server: %s",
5656
PQerrorMessage(conn));
5757

58-
pg_log(PG_PROGRESS,"connected toremoteserver\n");
58+
pg_log(PG_PROGRESS,"connected to server\n");
5959

6060
/*
6161
* Check that the server is not in hot standby mode. There is no
@@ -91,12 +91,12 @@ run_simple_query(const char *sql)
9191
res=PQexec(conn,sql);
9292

9393
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
94-
pg_fatal("error running query (%s) in source server: %s\n",
94+
pg_fatal("error running query (%s) in source server: %s",
9595
sql,PQresultErrorMessage(res));
9696

9797
/* sanity check the result set */
9898
if (PQnfields(res)!=1||PQntuples(res)!=1||PQgetisnull(res,0,0))
99-
pg_fatal("unexpected result setwhile running query\n");
99+
pg_fatal("unexpected result setfrom query\n");
100100

101101
result=pg_strdup(PQgetvalue(res,0,0));
102102

@@ -119,7 +119,7 @@ libpqGetCurrentXlogInsertLocation(void)
119119
val=run_simple_query("SELECT pg_current_xlog_insert_location()");
120120

121121
if (sscanf(val,"%X/%X",&hi,&lo)!=2)
122-
pg_fatal("unexpected result \"%s\"while fetching current XLOG insert location\n",val);
122+
pg_fatal("unrecognized result \"%s\"for current XLOG insert location\n",val);
123123

124124
result= ((uint64)hi) <<32 |lo;
125125

@@ -167,7 +167,7 @@ libpqProcessFileList(void)
167167
res=PQexec(conn,sql);
168168

169169
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
170-
pg_fatal("unexpected result while fetchingfile list: %s\n",
170+
pg_fatal("could not fetchfile list: %s",
171171
PQresultErrorMessage(res));
172172

173173
/* sanity check the result set */
@@ -210,7 +210,7 @@ receiveFileChunks(const char *sql)
210210
PGresult*res;
211211

212212
if (PQsendQueryParams(conn,sql,0,NULL,NULL,NULL,NULL,1)!=1)
213-
pg_fatal("could not send query: %s\n",PQerrorMessage(conn));
213+
pg_fatal("could not send query: %s",PQerrorMessage(conn));
214214

215215
pg_log(PG_DEBUG,"getting file chunks");
216216

@@ -262,7 +262,7 @@ receiveFileChunks(const char *sql)
262262
PQgetisnull(res,0,1)||
263263
PQgetisnull(res,0,2))
264264
{
265-
pg_fatal("unexpectedNULL result while fetching remote files\n");
265+
pg_fatal("unexpectednull values in result while fetching remote files\n");
266266
}
267267

268268
if (PQgetlength(res,0,1)!=sizeof(int32))
@@ -280,7 +280,7 @@ receiveFileChunks(const char *sql)
280280

281281
chunk=PQgetvalue(res,0,2);
282282

283-
pg_log(PG_DEBUG,"received chunk for file \"%s\",off %d,len %d\n",
283+
pg_log(PG_DEBUG,"received chunk for file \"%s\",offset %d,size %d\n",
284284
filename,chunkoff,chunksize);
285285

286286
open_target_file(filename, false);
@@ -309,7 +309,7 @@ libpqGetFile(const char *filename, size_t *filesize)
309309
1,NULL,paramValues,NULL,NULL,1);
310310

311311
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
312-
pg_fatal("unexpected result while fetchingremote file \"%s\": %s\n",
312+
pg_fatal("could not fetchremote file \"%s\": %s",
313313
filename,PQresultErrorMessage(res));
314314

315315
/* sanity check the result set */
@@ -355,7 +355,7 @@ fetch_file_range(const char *path, unsigned int begin, unsigned int end)
355355
snprintf(linebuf,sizeof(linebuf),"%s\t%u\t%u\n",path,begin,len);
356356

357357
if (PQputCopyData(conn,linebuf,strlen(linebuf))!=1)
358-
pg_fatal("error sendingCOPY data: %s\n",
358+
pg_fatal("could not sendCOPY data: %s",
359359
PQerrorMessage(conn));
360360

361361
begin+=len;
@@ -381,14 +381,14 @@ libpq_executeFileMap(filemap_t *map)
381381
res=PQexec(conn,sql);
382382

383383
if (PQresultStatus(res)!=PGRES_COMMAND_OK)
384-
pg_fatal("error creatingtemporary table: %s\n",
384+
pg_fatal("could not createtemporary table: %s",
385385
PQresultErrorMessage(res));
386386

387387
sql="COPY fetchchunks FROM STDIN";
388388
res=PQexec(conn,sql);
389389

390390
if (PQresultStatus(res)!=PGRES_COPY_IN)
391-
pg_fatal("unexpected result while sendingfile list: %s\n",
391+
pg_fatal("could not sendfile list: %s",
392392
PQresultErrorMessage(res));
393393

394394
for (i=0;i<map->narray;i++)
@@ -429,13 +429,13 @@ libpq_executeFileMap(filemap_t *map)
429429
}
430430

431431
if (PQputCopyEnd(conn,NULL)!=1)
432-
pg_fatal("error sendingend-of-COPY: %s\n",
432+
pg_fatal("could not sendend-of-COPY: %s",
433433
PQerrorMessage(conn));
434434

435435
while ((res=PQgetResult(conn))!=NULL)
436436
{
437437
if (PQresultStatus(res)!=PGRES_COMMAND_OK)
438-
pg_fatal("unexpected result while sending file list: %s\n",
438+
pg_fatal("unexpected result while sending file list: %s",
439439
PQresultErrorMessage(res));
440440
}
441441

‎src/bin/pg_rewind/parsexlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ extractPageMap(const char *datadir, XLogRecPtr startpoint, TimeLineID tli,
8484
errptr=startpoint ?startpoint :xlogreader->EndRecPtr;
8585

8686
if (errormsg)
87-
pg_fatal("error readingWAL at %X/%X: %s\n",
87+
pg_fatal("could not readWAL record at %X/%X: %s\n",
8888
(uint32) (errptr >>32), (uint32) (errptr),
8989
errormsg);
9090
else
91-
pg_fatal("error readingWAL at %X/%X\n",
91+
pg_fatal("could not readWAL record at %X/%X\n",
9292
(uint32) (startpoint >>32),
9393
(uint32) (startpoint));
9494
}

‎src/bin/pg_rewind/pg_rewind.c

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,18 @@ booldry_run = false;
5656
staticvoid
5757
usage(constchar*progname)
5858
{
59-
printf(_("%s resynchronizes a cluster with another copy of the cluster.\n\n"),progname);
59+
printf(_("%s resynchronizes aPostgreSQLcluster with another copy of the cluster.\n\n"),progname);
6060
printf(_("Usage:\n %s [OPTION]...\n\n"),progname);
6161
printf(_("Options:\n"));
62-
printf(_(" -D, --target-pgdata=DIRECTORY\n"));
63-
printf(_(" existing data directory to modify\n"));
64-
printf(_(" --source-pgdata=DIRECTORY\n"));
65-
printf(_(" source data directory to sync with\n"));
66-
printf(_(" --source-server=CONNSTR\n"));
67-
printf(_(" source server to sync with\n"));
68-
printf(_(" -P, --progress write progress messages\n"));
69-
printf(_(" -n, --dry-run stop before modifying anything\n"));
70-
printf(_(" --debug write a lot of debug messages\n"));
71-
printf(_(" -V, --version output version information, then exit\n"));
72-
printf(_(" -?, --help show this help, then exit\n"));
73-
printf(_("\n"));
74-
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
62+
printf(_(" -D, --target-pgdata=DIRECTORY existing data directory to modify\n"));
63+
printf(_(" --source-pgdata=DIRECTORY source data directory to sync with\n"));
64+
printf(_(" --source-server=CONNSTR source server to sync with\n"));
65+
printf(_(" -n, --dry-run stop before modifying anything\n"));
66+
printf(_(" -P, --progress write progress messages\n"));
67+
printf(_(" --debug write a lot of debug messages\n"));
68+
printf(_(" -V, --version output version information, then exit\n"));
69+
printf(_(" -?, --help show this help, then exit\n"));
70+
printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
7571
}
7672

7773

@@ -154,24 +150,24 @@ main(int argc, char **argv)
154150
}
155151
}
156152

157-
/* No source given? Show usage */
158153
if (datadir_source==NULL&&connstr_source==NULL)
159154
{
160-
fprintf(stderr,_("no source specified (--source-pgdata or --source-server)\n"));
155+
fprintf(stderr,_("%s:no source specified (--source-pgdata or --source-server)\n"),progname);
161156
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
162157
exit(1);
163158
}
164159

165160
if (datadir_target==NULL)
166161
{
167-
fprintf(stderr,_("no target data directory specified (--target-pgdata)\n"));
162+
fprintf(stderr,_("%s:no target data directory specified (--target-pgdata)\n"),progname);
168163
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
169164
exit(1);
170165
}
171166

172-
if (argc!=optind)
167+
if (optind<argc)
173168
{
174-
fprintf(stderr,_("invalid arguments\n"));
169+
fprintf(stderr,_("%s: too many command-line arguments (first is \"%s\")\n"),
170+
progname,argv[optind]);
175171
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
176172
exit(1);
177173
}
@@ -184,9 +180,11 @@ main(int argc, char **argv)
184180
*/
185181
#ifndefWIN32
186182
if (geteuid()==0)
187-
pg_fatal("cannot be executed by \"root\"\n"
188-
"You must run %s as the PostgreSQL superuser.\n",
189-
progname);
183+
{
184+
fprintf(stderr,_("cannot be executed by \"root\"\n"));
185+
fprintf(stderr,_("You must run %s as the PostgreSQL superuser.\n"),
186+
progname);
187+
}
190188
#endif
191189

192190
get_restricted_token(progname);
@@ -295,7 +293,7 @@ main(int argc, char **argv)
295293
*/
296294
if (showprogress)
297295
{
298-
pg_log(PG_PROGRESS,"Need to copy %lu MB (total source directory size is %lu MB)\n",
296+
pg_log(PG_PROGRESS,"need to copy %lu MB (total source directory size is %lu MB)\n",
299297
(unsigned long) (filemap->fetch_size / (1024*1024)),
300298
(unsigned long) (filemap->total_size / (1024*1024)));
301299

‎src/bin/pg_rewind/timeline.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
7373
if (nfields<1)
7474
{
7575
/* expect a numeric timeline ID as first field of line */
76-
printf(_("syntax error in history file: %s\n"),fline);
77-
printf(_("Expected a numeric timeline ID.\n"));
76+
fprintf(stderr,_("syntax error in history file: %s\n"),fline);
77+
fprintf(stderr,_("Expected a numeric timeline ID.\n"));
7878
exit(1);
7979
}
8080
if (nfields!=3)
8181
{
82-
printf(_("syntax error in history file: %s\n"),fline);
83-
printf(_("Expected an XLOG switchpoint location.\n"));
82+
fprintf(stderr,_("syntax error in history file: %s\n"),fline);
83+
fprintf(stderr,_("Expected an XLOG switchpoint location.\n"));
8484
exit(1);
8585
}
8686
if (entries&&tli <=lasttli)
8787
{
88-
printf(_("invalid data in history file: %s\n"),fline);
89-
printf(_("Timeline IDs must be in increasing sequence.\n"));
88+
fprintf(stderr,_("invalid data in history file: %s\n"),fline);
89+
fprintf(stderr,_("Timeline IDs must be in increasing sequence.\n"));
9090
exit(1);
9191
}
9292

@@ -106,8 +106,8 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
106106

107107
if (entries&&targetTLI <=lasttli)
108108
{
109-
printf(_("invalid data in history file\n"));
110-
printf(_("Timeline IDs must be less than child timeline's ID.\n"));
109+
fprintf(stderr,_("invalid data in history file\n"));
110+
fprintf(stderr,_("Timeline IDs must be less than child timeline's ID.\n"));
111111
exit(1);
112112
}
113113

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp