Skip to content

Commit a876464

Browse files
committed
Message style improvements
Some message style improvements in new code, and some small refactorings to make translations easier.
1 parent f83f148 commit a876464

16 files changed

+70
-63
lines changed

src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ usage(void)
247247
printf(_(" %s [OPTION]...\n"), progname);
248248
printf(_("\nOptions:\n"));
249249
printf(_(" -a, --all create subscriptions for all databases except template\n"
250-
" databases or databases that don't allow connections\n"));
250+
" databases and databases that don't allow connections\n"));
251251
printf(_(" -d, --database=DBNAME database in which to create a subscription\n"));
252252
printf(_(" -D, --pgdata=DATADIR location for the subscriber data directory\n"));
253253
printf(_(" -n, --dry-run dry run, just show what would be done\n"));
254254
printf(_(" -p, --subscriber-port=PORT subscriber port number (default %s)\n"), DEFAULT_SUB_PORT);
255255
printf(_(" -P, --publisher-server=CONNSTR publisher connection string\n"));
256256
printf(_(" -R, --remove=OBJECTTYPE remove all objects of the specified type from specified\n"
257-
" databases on the subscriber; accepts: publications\n"));
257+
" databases on the subscriber; accepts: \"%s\"\n"), "publications");
258258
printf(_(" -s, --socketdir=DIR socket directory to use (default current dir.)\n"));
259259
printf(_(" -t, --recovery-timeout=SECS seconds to wait for recovery to end\n"));
260260
printf(_(" -T, --enable-two-phase enable two-phase commit for all subscriptions\n"));
@@ -973,7 +973,7 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
973973
pg_log_warning("two_phase option will not be enabled for replication slots");
974974
pg_log_warning_detail("Subscriptions will be created with the two_phase option disabled. "
975975
"Prepared transactions will be replicated at COMMIT PREPARED.");
976-
pg_log_warning_hint("You can use --enable-two-phase switch to enable two_phase.");
976+
pg_log_warning_hint("You can use the command-line option --enable-two-phase to enable two_phase.");
977977
}
978978

979979
/*
@@ -2143,7 +2143,7 @@ main(int argc, char **argv)
21432143
if (!simple_string_list_member(&opt.objecttypes_to_remove, optarg))
21442144
simple_string_list_append(&opt.objecttypes_to_remove, optarg);
21452145
else
2146-
pg_fatal("object type \"%s\" is specified more than once for -R/--remove", optarg);
2146+
pg_fatal("object type \"%s\" specified more than once for -R/--remove", optarg);
21472147
break;
21482148
case 's':
21492149
opt.socket_dir = pg_strdup(optarg);
@@ -2214,7 +2214,7 @@ main(int argc, char **argv)
22142214

22152215
if (bad_switch)
22162216
{
2217-
pg_log_error("%s cannot be used with -a/--all", bad_switch);
2217+
pg_log_error("options %s and -a/--all cannot be used together", bad_switch);
22182218
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
22192219
exit(1);
22202220
}
@@ -2341,7 +2341,7 @@ main(int argc, char **argv)
23412341
else
23422342
{
23432343
pg_log_error("invalid object type \"%s\" specified for -R/--remove", cell->val);
2344-
pg_log_error_hint("The valid option is: \"publications\"");
2344+
pg_log_error_hint("The valid value is: \"%s\"", "publications");
23452345
exit(1);
23462346
}
23472347
}

src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ usage(void)
9191
printf(_("\nOptions:\n"));
9292
printf(_(" -E, --endpos=LSN exit after receiving the specified LSN\n"));
9393
printf(_(" --failover enable replication slot synchronization to standby servers when\n"
94-
" creating a slot\n"));
94+
" creating a replication slot\n"));
9595
printf(_(" -f, --file=FILE receive log into this file, - for stdout\n"));
9696
printf(_(" -F --fsync-interval=SECS\n"
9797
" time between fsyncs to the output file (default: %d)\n"), (fsync_interval / 1000));

src/bin/pg_basebackup/t/040_pg_createsubscriber.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ sub generate_db
399399
'--database' => $db1,
400400
'--all',
401401
],
402-
qr/--database cannot be used with -a\/--all/,
402+
qr/options --database and -a\/--all cannot be used together/,
403403
'fail if --database is used with --all');
404404

405405
# run pg_createsubscriber with '--publication' and '--all' and verify
@@ -416,7 +416,7 @@ sub generate_db
416416
'--all',
417417
'--publication' => 'pub1',
418418
],
419-
qr/--publication cannot be used with -a\/--all/,
419+
qr/options --publication and -a\/--all cannot be used together/,
420420
'fail if --publication is used with --all');
421421

422422
# run pg_createsubscriber with '--all' option

src/bin/pg_dump/pg_dump.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6936,7 +6936,7 @@ getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages,
69366936
info->section = SECTION_POST_DATA;
69376937
break;
69386938
default:
6939-
pg_fatal("cannot dump statistics for relation kind '%c'",
6939+
pg_fatal("cannot dump statistics for relation kind \"%c\"",
69406940
info->relkind);
69416941
}
69426942

@@ -9461,7 +9461,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
94619461
int i_consrc;
94629462
int i_conislocal;
94639463

9464-
pg_log_info("finding invalid not null constraints");
9464+
pg_log_info("finding invalid not-null constraints");
94659465

94669466
resetPQExpBuffer(q);
94679467
appendPQExpBuffer(q,
@@ -10855,7 +10855,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
1085510855
expected_te = expected_te->next;
1085610856

1085710857
if (te != expected_te)
10858-
pg_fatal("stats dumped out of order (current: %d %s %s) (expected: %d %s %s)",
10858+
pg_fatal("statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
1085910859
te->dumpId, te->desc, te->tag,
1086010860
expected_te->dumpId, expected_te->desc, expected_te->tag);
1086110861

@@ -10996,7 +10996,7 @@ dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
1099610996
appendStringLiteralAH(out, rsinfo->dobj.name, fout);
1099710997

1099810998
if (PQgetisnull(res, rownum, i_attname))
10999-
pg_fatal("attname cannot be NULL");
10999+
pg_fatal("unexpected null attname");
1100011000
attname = PQgetvalue(res, rownum, i_attname);
1100111001

1100211002
/*

src/bin/pg_dump/pg_dumpall.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ main(int argc, char *argv[])
525525

526526
OPF = fopen(global_path, PG_BINARY_W);
527527
if (!OPF)
528-
pg_fatal("could not open \"%s\": %m", global_path);
528+
pg_fatal("could not open file \"%s\": %m", global_path);
529529
}
530530
else if (filename)
531531
{
@@ -1659,14 +1659,14 @@ dumpDatabases(PGconn *conn, ArchiveFormat archDumpFormat)
16591659

16601660
/* Create a subdirectory with 'databases' name under main directory. */
16611661
if (mkdir(db_subdir, pg_dir_create_mode) != 0)
1662-
pg_fatal("could not create subdirectory \"%s\": %m", db_subdir);
1662+
pg_fatal("could not create directory \"%s\": %m", db_subdir);
16631663

16641664
snprintf(map_file_path, MAXPGPATH, "%s/map.dat", filename);
16651665

16661666
/* Create a map file (to store dboid and dbname) */
16671667
map_file = fopen(map_file_path, PG_BINARY_W);
16681668
if (!map_file)
1669-
pg_fatal("could not open map file: %s", strerror(errno));
1669+
pg_fatal("could not open file \"%s\": %m", map_file_path);
16701670
}
16711671

16721672
for (i = 0; i < PQntuples(res); i++)
@@ -1976,7 +1976,7 @@ parseDumpFormat(const char *format)
19761976
else if (pg_strcasecmp(format, "tar") == 0)
19771977
archDumpFormat = archTar;
19781978
else
1979-
pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", \"p\", or \"t\"",
1979+
pg_fatal("unrecognized output format \"%s\"; please specify \"c\", \"d\", \"p\", or \"t\"",
19801980
format);
19811981

19821982
return archDumpFormat;

src/bin/pg_dump/pg_restore.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ main(int argc, char **argv)
523523
*/
524524
if (!globals_only && opts->createDB != 1)
525525
{
526-
pg_log_error("-C/--create option should be specified when restoring an archive created by pg_dumpall");
526+
pg_log_error("option -C/--create must be specified when restoring an archive created by pg_dumpall");
527527
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
528528
pg_log_error_hint("Individual databases can be restored using their specific archives.");
529529
exit_nicely(1);
@@ -557,7 +557,7 @@ main(int argc, char **argv)
557557
if (conn)
558558
PQfinish(conn);
559559

560-
pg_log_info("database restoring skipped as -g/--globals-only option was specified");
560+
pg_log_info("database restoring skipped because option -g/--globals-only was specified");
561561
}
562562
else
563563
{
@@ -725,8 +725,8 @@ usage(const char *progname)
725725
printf(_(" --role=ROLENAME do SET ROLE before restore\n"));
726726

727727
printf(_("\n"
728-
"The options -I, -n, -N, -P, -t, -T, --section, and --exclude-database can be combined\n"
729-
"and specified multiple times to select multiple objects.\n"));
728+
"The options -I, -n, -N, -P, -t, -T, --section, and --exclude-database can be\n"
729+
"combined and specified multiple times to select multiple objects.\n"));
730730
printf(_("\nIf no input file name is supplied, then standard input is used.\n\n"));
731731
printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
732732
printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
@@ -946,7 +946,7 @@ get_dbnames_list_to_restore(PGconn *conn,
946946
query = createPQExpBuffer();
947947

948948
if (!conn)
949-
pg_log_info("considering PATTERN as NAME for --exclude-database option as no db connection while doing pg_restore.");
949+
pg_log_info("considering PATTERN as NAME for --exclude-database option as no database connection while doing pg_restore");
950950

951951
/*
952952
* Process one by one all dbnames and if specified to skip restoring, then
@@ -992,7 +992,7 @@ get_dbnames_list_to_restore(PGconn *conn,
992992
if ((PQresultStatus(res) == PGRES_TUPLES_OK) && PQntuples(res))
993993
{
994994
skip_db_restore = true;
995-
pg_log_info("database \"%s\" matches exclude pattern: \"%s\"", dbidname->str, pat_cell->val);
995+
pg_log_info("database name \"%s\" matches exclude pattern \"%s\"", dbidname->str, pat_cell->val);
996996
}
997997

998998
PQclear(res);
@@ -1048,7 +1048,7 @@ get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimplePtrList *dbname_oi
10481048
*/
10491049
if (!file_exists_in_directory(dumpdirpath, "map.dat"))
10501050
{
1051-
pg_log_info("database restoring is skipped as \"map.dat\" is not present in \"%s\"", dumpdirpath);
1051+
pg_log_info("database restoring is skipped because file \"%s\" does not exist in directory \"%s\"", "map.dat", dumpdirpath);
10521052
return 0;
10531053
}
10541054

@@ -1058,7 +1058,7 @@ get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimplePtrList *dbname_oi
10581058
pfile = fopen(map_file_path, PG_BINARY_R);
10591059

10601060
if (pfile == NULL)
1061-
pg_fatal("could not open \"%s\": %m", map_file_path);
1061+
pg_fatal("could not open file \"%s\": %m", map_file_path);
10621062

10631063
initStringInfo(&linebuf);
10641064

@@ -1086,10 +1086,10 @@ get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimplePtrList *dbname_oi
10861086

10871087
/* Report error and exit if the file has any corrupted data. */
10881088
if (!OidIsValid(db_oid) || namelen <= 1)
1089-
pg_fatal("invalid entry in \"%s\" at line: %d", map_file_path,
1089+
pg_fatal("invalid entry in file \"%s\" on line %d", map_file_path,
10901090
count + 1);
10911091

1092-
pg_log_info("found database \"%s\" (OID: %u) in \"%s\"",
1092+
pg_log_info("found database \"%s\" (OID: %u) in file \"%s\"",
10931093
dbname, db_oid, map_file_path);
10941094

10951095
dbidname = pg_malloc(offsetof(DbOidName, str) + namelen + 1);
@@ -1142,11 +1142,14 @@ restore_all_databases(PGconn *conn, const char *dumpdirpath,
11421142
if (dbname_oid_list.head == NULL)
11431143
return process_global_sql_commands(conn, dumpdirpath, opts->filename);
11441144

1145-
pg_log_info("found %d database names in \"map.dat\"", num_total_db);
1145+
pg_log_info(ngettext("found %d database name in \"%s\"",
1146+
"found %d database names in \"%s\"",
1147+
num_total_db),
1148+
num_total_db, "map.dat");
11461149

11471150
if (!conn)
11481151
{
1149-
pg_log_info("trying to connect database \"postgres\"");
1152+
pg_log_info("trying to connect to database \"%s\"", "postgres");
11501153

11511154
conn = ConnectDatabase("postgres", NULL, opts->cparams.pghost,
11521155
opts->cparams.pgport, opts->cparams.username, TRI_DEFAULT,
@@ -1155,7 +1158,7 @@ restore_all_databases(PGconn *conn, const char *dumpdirpath,
11551158
/* Try with template1. */
11561159
if (!conn)
11571160
{
1158-
pg_log_info("trying to connect database \"template1\"");
1161+
pg_log_info("trying to connect to database \"%s\"", "template1");
11591162

11601163
conn = ConnectDatabase("template1", NULL, opts->cparams.pghost,
11611164
opts->cparams.pgport, opts->cparams.username, TRI_DEFAULT,
@@ -1179,7 +1182,9 @@ restore_all_databases(PGconn *conn, const char *dumpdirpath,
11791182
/* Exit if no db needs to be restored. */
11801183
if (dbname_oid_list.head == NULL || num_db_restore == 0)
11811184
{
1182-
pg_log_info("no database needs to restore out of %d databases", num_total_db);
1185+
pg_log_info(ngettext("no database needs restoring out of %d database",
1186+
"no database needs restoring out of %d databases", num_total_db),
1187+
num_total_db);
11831188
return n_errors_total;
11841189
}
11851190

@@ -1314,7 +1319,7 @@ process_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o
13141319
pfile = fopen(global_file_path, PG_BINARY_R);
13151320

13161321
if (pfile == NULL)
1317-
pg_fatal("could not open \"%s\": %m", global_file_path);
1322+
pg_fatal("could not open file \"%s\": %m", global_file_path);
13181323

13191324
/*
13201325
* If outfile is given, then just copy all global.dat file data into
@@ -1354,15 +1359,17 @@ process_global_sql_commands(PGconn *conn, const char *dumpdirpath, const char *o
13541359
break;
13551360
default:
13561361
n_errors++;
1357-
pg_log_error("could not execute query: \"%s\" \nCommand was: \"%s\"", PQerrorMessage(conn), sqlstatement.data);
1362+
pg_log_error("could not execute query: %s", PQerrorMessage(conn));
1363+
pg_log_error_detail("Command was: %s", sqlstatement.data);
13581364
}
13591365
PQclear(result);
13601366
}
13611367

13621368
/* Print a summary of ignored errors during global.dat. */
13631369
if (n_errors)
1364-
pg_log_warning("ignored %d errors in \"%s\"", n_errors, global_file_path);
1365-
1370+
pg_log_warning(ngettext("ignored %d error in file \"%s\"",
1371+
"ignored %d errors in file \"%s\"", n_errors),
1372+
n_errors, global_file_path);
13661373
fclose(pfile);
13671374

13681375
return n_errors;

src/bin/pg_dump/t/001_basic.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,6 @@
261261

262262
command_fails_like(
263263
[ 'pg_dumpall', '--format', 'x' ],
264-
qr/\Qpg_dumpall: error: unrecognized archive format "x";\E/,
265-
'pg_dumpall: unrecognized archive format');
264+
qr/\Qpg_dumpall: error: unrecognized output format "x";\E/,
265+
'pg_dumpall: unrecognized output format');
266266
done_testing();

src/bin/pg_dump/t/006_pg_dumpall.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
"$tempdir/format_custom",
366366
'--format' => 'custom',
367367
'--file' => "$tempdir/error_test.sql", ],
368-
qr/\Qpg_restore: error: -C\/--create option should be specified when restoring an archive created by pg_dumpall\E/,
368+
qr/\Qpg_restore: error: option -C\/--create must be specified when restoring an archive created by pg_dumpall\E/,
369369
'When -C is not used in pg_restore with dump of pg_dumpall');
370370
371371
# test case 2: When --list option is used with dump of pg_dumpall

src/bin/pg_upgrade/check.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ check_cluster_versions(void)
885885
*/
886886
if (GET_MAJOR_VERSION(old_cluster.major_version) >= 1800 &&
887887
user_opts.char_signedness != -1)
888-
pg_fatal("%s option cannot be used to upgrade from PostgreSQL %s and later.",
888+
pg_fatal("The option %s cannot be used for upgrades from PostgreSQL %s and later.",
889889
"--set-char-signedness", "18");
890890

891891
check_ok();
@@ -1934,7 +1934,7 @@ check_for_unicode_update(ClusterInfo *cluster)
19341934
{
19351935
fclose(report.file);
19361936
report_status(PG_WARNING, "warning");
1937-
pg_log(PG_WARNING, "Your installation contains relations that may be affected by a new version of Unicode.\n"
1937+
pg_log(PG_WARNING, "Your installation contains relations that might be affected by a new version of Unicode.\n"
19381938
"A list of potentially-affected relations is in the file:\n"
19391939
" %s", report.path);
19401940
}

src/bin/pg_upgrade/relfilenumber.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,19 @@ prepare_for_swap(const char *old_tablespace, Oid db_oid,
290290

291291
/* Create directory for stuff that is moved aside. */
292292
if (pg_mkdir_p(moved_tblspc, pg_dir_create_mode) != 0 && errno != EEXIST)
293-
pg_fatal("could not create directory \"%s\"", moved_tblspc);
293+
pg_fatal("could not create directory \"%s\": %m", moved_tblspc);
294294

295295
/* Create directory for old catalog files. */
296296
if (pg_mkdir_p(old_catalog_dir, pg_dir_create_mode) != 0)
297-
pg_fatal("could not create directory \"%s\"", old_catalog_dir);
297+
pg_fatal("could not create directory \"%s\": %m", old_catalog_dir);
298298

299299
/* Move the new cluster's database directory aside. */
300300
if (rename(new_db_dir, moved_db_dir) != 0)
301-
pg_fatal("could not rename \"%s\" to \"%s\"", new_db_dir, moved_db_dir);
301+
pg_fatal("could not rename directory \"%s\" to \"%s\": %m", new_db_dir, moved_db_dir);
302302

303303
/* Move the old cluster's database directory into place. */
304304
if (rename(old_db_dir, new_db_dir) != 0)
305-
pg_fatal("could not rename \"%s\" to \"%s\"", old_db_dir, new_db_dir);
305+
pg_fatal("could not rename directory \"%s\" to \"%s\": %m", old_db_dir, new_db_dir);
306306

307307
return true;
308308
}
@@ -390,7 +390,7 @@ swap_catalog_files(FileNameMap *maps, int size, const char *old_catalog_dir,
390390

391391
snprintf(dest, sizeof(dest), "%s/%s", old_catalog_dir, de->d_name);
392392
if (rename(path, dest) != 0)
393-
pg_fatal("could not rename \"%s\" to \"%s\": %m", path, dest);
393+
pg_fatal("could not rename file \"%s\" to \"%s\": %m", path, dest);
394394
}
395395
if (errno)
396396
pg_fatal("could not read directory \"%s\": %m", new_db_dir);
@@ -417,7 +417,7 @@ swap_catalog_files(FileNameMap *maps, int size, const char *old_catalog_dir,
417417

418418
snprintf(dest, sizeof(dest), "%s/%s", new_db_dir, de->d_name);
419419
if (rename(path, dest) != 0)
420-
pg_fatal("could not rename \"%s\" to \"%s\": %m", path, dest);
420+
pg_fatal("could not rename file \"%s\" to \"%s\": %m", path, dest);
421421

422422
/*
423423
* We don't fsync() the database files in the file synchronization

0 commit comments

Comments
 (0)