Unify some error messages to ease work of translators

This commit updates a couple of error messages around control file data,
GUCs and server settings, unifying to the same message where possible.
This reduces the translation burden a bit.

Author: Peter Smith
Discussion: https://postgr.es/m/CAHut+Pv-kSN8SkxSdoHano_wPubqcg5789ejhCDZAcLFceBR-w@mail.gmail.com
This commit is contained in:
Michael Paquier 2024-09-04 14:53:18 +09:00
parent b4db64270e
commit a68159ff2b
4 changed files with 73 additions and 42 deletions

View File

@ -4395,17 +4395,21 @@ ReadControlFile(void)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with CATALOG_VERSION_NO %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with CATALOG_VERSION_NO %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->catalog_version_no, CATALOG_VERSION_NO), " but the server was compiled with %s %d.",
"CATALOG_VERSION_NO", ControlFile->catalog_version_no,
"CATALOG_VERSION_NO", CATALOG_VERSION_NO),
errhint("It looks like you need to initdb."))); errhint("It looks like you need to initdb.")));
if (ControlFile->maxAlign != MAXIMUM_ALIGNOF) if (ControlFile->maxAlign != MAXIMUM_ALIGNOF)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with MAXALIGN %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with MAXALIGN %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->maxAlign, MAXIMUM_ALIGNOF), " but the server was compiled with %s %d.",
"MAXALIGN", ControlFile->maxAlign,
"MAXALIGN", MAXIMUM_ALIGNOF),
errhint("It looks like you need to initdb."))); errhint("It looks like you need to initdb.")));
if (ControlFile->floatFormat != FLOATFORMAT_VALUE) if (ControlFile->floatFormat != FLOATFORMAT_VALUE)
ereport(FATAL, ereport(FATAL,
@ -4417,57 +4421,71 @@ ReadControlFile(void)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with BLCKSZ %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with BLCKSZ %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->blcksz, BLCKSZ), " but the server was compiled with %s %d.",
"BLCKSZ", ControlFile->blcksz,
"BLCKSZ", BLCKSZ),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->relseg_size != RELSEG_SIZE) if (ControlFile->relseg_size != RELSEG_SIZE)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with RELSEG_SIZE %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with RELSEG_SIZE %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->relseg_size, RELSEG_SIZE), " but the server was compiled with %s %d.",
"RELSEG_SIZE", ControlFile->relseg_size,
"RELSEG_SIZE", RELSEG_SIZE),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->xlog_blcksz != XLOG_BLCKSZ) if (ControlFile->xlog_blcksz != XLOG_BLCKSZ)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with XLOG_BLCKSZ %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with XLOG_BLCKSZ %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->xlog_blcksz, XLOG_BLCKSZ), " but the server was compiled with %s %d.",
"XLOG_BLCKSZ", ControlFile->xlog_blcksz,
"XLOG_BLCKSZ", XLOG_BLCKSZ),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->nameDataLen != NAMEDATALEN) if (ControlFile->nameDataLen != NAMEDATALEN)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with NAMEDATALEN %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with NAMEDATALEN %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->nameDataLen, NAMEDATALEN), " but the server was compiled with %s %d.",
"NAMEDATALEN", ControlFile->nameDataLen,
"NAMEDATALEN", NAMEDATALEN),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->indexMaxKeys != INDEX_MAX_KEYS) if (ControlFile->indexMaxKeys != INDEX_MAX_KEYS)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with INDEX_MAX_KEYS %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with INDEX_MAX_KEYS %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->indexMaxKeys, INDEX_MAX_KEYS), " but the server was compiled with %s %d.",
"INDEX_MAX_KEYS", ControlFile->indexMaxKeys,
"INDEX_MAX_KEYS", INDEX_MAX_KEYS),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->toast_max_chunk_size != TOAST_MAX_CHUNK_SIZE) if (ControlFile->toast_max_chunk_size != TOAST_MAX_CHUNK_SIZE)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with TOAST_MAX_CHUNK_SIZE %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE), " but the server was compiled with %s %d.",
"TOAST_MAX_CHUNK_SIZE", ControlFile->toast_max_chunk_size,
"TOAST_MAX_CHUNK_SIZE", (int) TOAST_MAX_CHUNK_SIZE),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
if (ControlFile->loblksize != LOBLKSIZE) if (ControlFile->loblksize != LOBLKSIZE)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("database files are incompatible with server"), errmsg("database files are incompatible with server"),
errdetail("The database cluster was initialized with LOBLKSIZE %d," /* translator: %s is a variable name and %d is its value */
" but the server was compiled with LOBLKSIZE %d.", errdetail("The database cluster was initialized with %s %d,"
ControlFile->loblksize, (int) LOBLKSIZE), " but the server was compiled with %s %d.",
"LOBLKSIZE", ControlFile->loblksize,
"LOBLKSIZE", (int) LOBLKSIZE),
errhint("It looks like you need to recompile or initdb."))); errhint("It looks like you need to recompile or initdb.")));
#ifdef USE_FLOAT8_BYVAL #ifdef USE_FLOAT8_BYVAL
@ -4505,11 +4523,15 @@ ReadControlFile(void)
/* check and update variables dependent on wal_segment_size */ /* check and update variables dependent on wal_segment_size */
if (ConvertToXSegs(min_wal_size_mb, wal_segment_size) < 2) if (ConvertToXSegs(min_wal_size_mb, wal_segment_size) < 2)
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"min_wal_size\" must be at least twice \"wal_segment_size\""))); /* translator: both %s are GUC names */
errmsg("\"%s\" must be at least twice \"%s\"",
"min_wal_size", "wal_segment_size")));
if (ConvertToXSegs(max_wal_size_mb, wal_segment_size) < 2) if (ConvertToXSegs(max_wal_size_mb, wal_segment_size) < 2)
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("\"max_wal_size\" must be at least twice \"wal_segment_size\""))); /* translator: both %s are GUC names */
errmsg("\"%s\" must be at least twice \"%s\"",
"max_wal_size", "wal_segment_size")));
UsableBytesInSegment = UsableBytesInSegment =
(wal_segment_size / XLOG_BLCKSZ * UsableBytesInPage) - (wal_segment_size / XLOG_BLCKSZ * UsableBytesInPage) -

View File

@ -1212,7 +1212,8 @@ check_effective_io_concurrency(int *newval, void **extra, GucSource source)
#ifndef USE_PREFETCH #ifndef USE_PREFETCH
if (*newval != 0) if (*newval != 0)
{ {
GUC_check_errdetail("\"effective_io_concurrency\" must be set to 0 on platforms that lack support for issuing read-ahead advice."); GUC_check_errdetail("\"%s\" must be set to 0 on platforms that lack support for issuing read-ahead advice.",
"effective_io_concurrency");
return false; return false;
} }
#endif /* USE_PREFETCH */ #endif /* USE_PREFETCH */
@ -1225,7 +1226,8 @@ check_maintenance_io_concurrency(int *newval, void **extra, GucSource source)
#ifndef USE_PREFETCH #ifndef USE_PREFETCH
if (*newval != 0) if (*newval != 0)
{ {
GUC_check_errdetail("\"maintenance_io_concurrency\" must be set to 0 on platforms that lack support for issuing read-ahead advice."); GUC_check_errdetail("\"%s\" must be set to 0 on platforms that lack support for issuing read-ahead advice.",
"maintenance_io_concurrency");
return false; return false;
} }
#endif /* USE_PREFETCH */ #endif /* USE_PREFETCH */

View File

@ -3971,7 +3971,8 @@ check_debug_io_direct(char **newval, void **extra, GucSource source)
#if PG_O_DIRECT == 0 #if PG_O_DIRECT == 0
if (strcmp(*newval, "") != 0) if (strcmp(*newval, "") != 0)
{ {
GUC_check_errdetail("\"debug_io_direct\" is not supported on this platform."); GUC_check_errdetail("\"%s\" is not supported on this platform.",
"debug_io_direct");
result = false; result = false;
} }
flags = 0; flags = 0;
@ -4018,14 +4019,16 @@ check_debug_io_direct(char **newval, void **extra, GucSource source)
#if XLOG_BLCKSZ < PG_IO_ALIGN_SIZE #if XLOG_BLCKSZ < PG_IO_ALIGN_SIZE
if (result && (flags & (IO_DIRECT_WAL | IO_DIRECT_WAL_INIT))) if (result && (flags & (IO_DIRECT_WAL | IO_DIRECT_WAL_INIT)))
{ {
GUC_check_errdetail("\"debug_io_direct\" is not supported for WAL because XLOG_BLCKSZ is too small"); GUC_check_errdetail("\"%s\" is not supported for WAL because %s is too small",
"debug_io_direct", "XLOG_BLCKSZ");
result = false; result = false;
} }
#endif #endif
#if BLCKSZ < PG_IO_ALIGN_SIZE #if BLCKSZ < PG_IO_ALIGN_SIZE
if (result && (flags & IO_DIRECT_DATA)) if (result && (flags & IO_DIRECT_DATA))
{ {
GUC_check_errdetail("\"debug_io_direct\" is not supported for data because BLCKSZ is too small"); GUC_check_errdetail("\"%s\" is not supported for WAL because %s is too small",
"debug_io_direct", "BLCKSZ");
result = false; result = false;
} }
#endif #endif

View File

@ -358,8 +358,9 @@ incompatible_module_error(const char *libname,
if (details.len) if (details.len)
appendStringInfoChar(&details, '\n'); appendStringInfoChar(&details, '\n');
appendStringInfo(&details, appendStringInfo(&details,
_("Server has FUNC_MAX_ARGS = %d, library has %d."), /* translator: %s is a variable name and %d its values */
magic_data.funcmaxargs, _("Server has %s = %d, library has %d."),
"FUNC_MAX_ARGS", magic_data.funcmaxargs,
module_magic_data->funcmaxargs); module_magic_data->funcmaxargs);
} }
if (module_magic_data->indexmaxkeys != magic_data.indexmaxkeys) if (module_magic_data->indexmaxkeys != magic_data.indexmaxkeys)
@ -367,8 +368,9 @@ incompatible_module_error(const char *libname,
if (details.len) if (details.len)
appendStringInfoChar(&details, '\n'); appendStringInfoChar(&details, '\n');
appendStringInfo(&details, appendStringInfo(&details,
_("Server has INDEX_MAX_KEYS = %d, library has %d."), /* translator: %s is a variable name and %d its values */
magic_data.indexmaxkeys, _("Server has %s = %d, library has %d."),
"INDEX_MAX_KEYS", magic_data.indexmaxkeys,
module_magic_data->indexmaxkeys); module_magic_data->indexmaxkeys);
} }
if (module_magic_data->namedatalen != magic_data.namedatalen) if (module_magic_data->namedatalen != magic_data.namedatalen)
@ -376,8 +378,9 @@ incompatible_module_error(const char *libname,
if (details.len) if (details.len)
appendStringInfoChar(&details, '\n'); appendStringInfoChar(&details, '\n');
appendStringInfo(&details, appendStringInfo(&details,
_("Server has NAMEDATALEN = %d, library has %d."), /* translator: %s is a variable name and %d its values */
magic_data.namedatalen, _("Server has %s = %d, library has %d."),
"NAMEDATALEN", magic_data.namedatalen,
module_magic_data->namedatalen); module_magic_data->namedatalen);
} }
if (module_magic_data->float8byval != magic_data.float8byval) if (module_magic_data->float8byval != magic_data.float8byval)
@ -385,8 +388,9 @@ incompatible_module_error(const char *libname,
if (details.len) if (details.len)
appendStringInfoChar(&details, '\n'); appendStringInfoChar(&details, '\n');
appendStringInfo(&details, appendStringInfo(&details,
_("Server has FLOAT8PASSBYVAL = %s, library has %s."), /* translator: %s is a variable name and %d its values */
magic_data.float8byval ? "true" : "false", _("Server has %s = %s, library has %s."),
"FLOAT8PASSBYVAL", magic_data.float8byval ? "true" : "false",
module_magic_data->float8byval ? "true" : "false"); module_magic_data->float8byval ? "true" : "false");
} }