On 2023-Dec-08, Peter Smith wrote: > Patch 0001 -- "datestyle" becomes DateStyle in messages > Rebased this again, which was part of an earlier patch set > - I think any GUC names documented as MixedCase should keep that same > case in messages; this also obeys the guidelines recently pushed [1].
I agree. > Patch 0002 -- use mixed case for intervalstyle error message > I found that the GUC name substituted to the error message was coming > from the statement, not from the original name in the guc_tables, so > there was a case mismatch: I agree. Let's also add a test that shows this difference (my 0002 here). I'm annoyed that this saga has transiently created a few untranslated strings by removing unnecessary quotes but failing to move the variable names outside the translatable part of the string. I change a few of those in 0003 -- mostly the ones in strings already touched by commit 8d9978a7176a, but also a few others. Didn't go out of my way to grep for other possible messages to fix, though. (I feel like this is missing some "translator:" comments.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "We’ve narrowed the problem down to the customer’s pants being in a situation of vigorous combustion" (Robert Haas, Postgres expert extraordinaire)
>From 0ccf4f8342d49d42116a1b1b872b15aeeddaf568 Mon Sep 17 00:00:00 2001 From: Peter Smith <peter.b.sm...@fujitsu.com> Date: Fri, 8 Dec 2023 12:59:20 +1100 Subject: [PATCH v5 1/3] GUC names - use mixed case for datestyle in messages --- src/backend/commands/variable.c | 2 +- src/backend/utils/adt/datetime.c | 2 +- src/test/regress/expected/date.out | 58 +++++++++++++------------- src/test/regress/expected/horology.out | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index c361bb2079..2703d2edc4 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -182,7 +182,7 @@ check_datestyle(char **newval, void **extra, GucSource source) if (!ok) { - GUC_check_errdetail("Conflicting \"datestyle\" specifications."); + GUC_check_errdetail("Conflicting DateStyle specifications."); return false; } diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index fca9a2a6e9..8ef5bf0076 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -4022,7 +4022,7 @@ DateTimeParseError(int dterr, DateTimeErrorExtra *extra, (errcode(ERRCODE_DATETIME_FIELD_OVERFLOW), errmsg("date/time field value out of range: \"%s\"", str), - errhint("Perhaps you need a different \"datestyle\" setting."))); + errhint("Perhaps you need a different DateStyle setting."))); break; case DTERR_INTERVAL_OVERFLOW: errsave(escontext, diff --git a/src/test/regress/expected/date.out b/src/test/regress/expected/date.out index f5949f3d17..99650bf231 100644 --- a/src/test/regress/expected/date.out +++ b/src/test/regress/expected/date.out @@ -94,17 +94,17 @@ SELECT date '1/8/1999'; ERROR: date/time field value out of range: "1/8/1999" LINE 1: SELECT date '1/8/1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1/18/1999'; ERROR: date/time field value out of range: "1/18/1999" LINE 1: SELECT date '1/18/1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '18/1/1999'; ERROR: date/time field value out of range: "18/1/1999" LINE 1: SELECT date '18/1/1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01/02/03'; date ------------ @@ -139,7 +139,7 @@ SELECT date 'January 8, 99 BC'; ERROR: date/time field value out of range: "January 8, 99 BC" LINE 1: SELECT date 'January 8, 99 BC'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '99-Jan-08'; date ------------ @@ -156,7 +156,7 @@ SELECT date '08-Jan-99'; ERROR: date/time field value out of range: "08-Jan-99" LINE 1: SELECT date '08-Jan-99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '08-Jan-1999'; date ------------ @@ -167,7 +167,7 @@ SELECT date 'Jan-08-99'; ERROR: date/time field value out of range: "Jan-08-99" LINE 1: SELECT date 'Jan-08-99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date 'Jan-08-1999'; date ------------ @@ -198,7 +198,7 @@ SELECT date '08 Jan 99'; ERROR: date/time field value out of range: "08 Jan 99" LINE 1: SELECT date '08 Jan 99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '08 Jan 1999'; date ------------ @@ -209,7 +209,7 @@ SELECT date 'Jan 08 99'; ERROR: date/time field value out of range: "Jan 08 99" LINE 1: SELECT date 'Jan 08 99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date 'Jan 08 1999'; date ------------ @@ -244,22 +244,22 @@ SELECT date '08-01-99'; ERROR: date/time field value out of range: "08-01-99" LINE 1: SELECT date '08-01-99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '08-01-1999'; ERROR: date/time field value out of range: "08-01-1999" LINE 1: SELECT date '08-01-1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01-08-99'; ERROR: date/time field value out of range: "01-08-99" LINE 1: SELECT date '01-08-99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01-08-1999'; ERROR: date/time field value out of range: "01-08-1999" LINE 1: SELECT date '01-08-1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '99-08-01'; date ------------ @@ -288,22 +288,22 @@ SELECT date '08 01 99'; ERROR: date/time field value out of range: "08 01 99" LINE 1: SELECT date '08 01 99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '08 01 1999'; ERROR: date/time field value out of range: "08 01 1999" LINE 1: SELECT date '08 01 1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01 08 99'; ERROR: date/time field value out of range: "01 08 99" LINE 1: SELECT date '01 08 99'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01 08 1999'; ERROR: date/time field value out of range: "01 08 1999" LINE 1: SELECT date '01 08 1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '99 08 01'; date ------------ @@ -345,7 +345,7 @@ SELECT date '1/18/1999'; ERROR: date/time field value out of range: "1/18/1999" LINE 1: SELECT date '1/18/1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '18/1/1999'; date ------------ @@ -392,7 +392,7 @@ SELECT date '99-Jan-08'; ERROR: date/time field value out of range: "99-Jan-08" LINE 1: SELECT date '99-Jan-08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-Jan-08'; date ------------ @@ -435,7 +435,7 @@ SELECT date '99 Jan 08'; ERROR: date/time field value out of range: "99 Jan 08" LINE 1: SELECT date '99 Jan 08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999 Jan 08'; date ------------ @@ -480,7 +480,7 @@ SELECT date '99-01-08'; ERROR: date/time field value out of range: "99-01-08" LINE 1: SELECT date '99-01-08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-01-08'; date ------------ @@ -515,7 +515,7 @@ SELECT date '99-08-01'; ERROR: date/time field value out of range: "99-08-01" LINE 1: SELECT date '99-08-01'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-08-01'; date ------------ @@ -526,7 +526,7 @@ SELECT date '99 01 08'; ERROR: date/time field value out of range: "99 01 08" LINE 1: SELECT date '99 01 08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999 01 08'; date ------------ @@ -561,7 +561,7 @@ SELECT date '99 08 01'; ERROR: date/time field value out of range: "99 08 01" LINE 1: SELECT date '99 08 01'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999 08 01'; date ------------ @@ -603,7 +603,7 @@ SELECT date '18/1/1999'; ERROR: date/time field value out of range: "18/1/1999" LINE 1: SELECT date '18/1/1999'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '01/02/03'; date ------------ @@ -644,7 +644,7 @@ SELECT date '99-Jan-08'; ERROR: date/time field value out of range: "99-Jan-08" LINE 1: SELECT date '99-Jan-08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-Jan-08'; date ------------ @@ -731,7 +731,7 @@ SELECT date '99-01-08'; ERROR: date/time field value out of range: "99-01-08" LINE 1: SELECT date '99-01-08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-01-08'; date ------------ @@ -766,7 +766,7 @@ SELECT date '99-08-01'; ERROR: date/time field value out of range: "99-08-01" LINE 1: SELECT date '99-08-01'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999-08-01'; date ------------ @@ -777,7 +777,7 @@ SELECT date '99 01 08'; ERROR: date/time field value out of range: "99 01 08" LINE 1: SELECT date '99 01 08'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999 01 08'; date ------------ @@ -812,7 +812,7 @@ SELECT date '99 08 01'; ERROR: date/time field value out of range: "99 08 01" LINE 1: SELECT date '99 08 01'; ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. SELECT date '1999 08 01'; date ------------ diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out index cfb4b205e4..4aeefd53bd 100644 --- a/src/test/regress/expected/horology.out +++ b/src/test/regress/expected/horology.out @@ -100,7 +100,7 @@ SELECT timestamp with time zone '27/12/2001 04:05:06.789-08'; ERROR: date/time field value out of range: "27/12/2001 04:05:06.789-08" LINE 1: SELECT timestamp with time zone '27/12/2001 04:05:06.789-08'... ^ -HINT: Perhaps you need a different "datestyle" setting. +HINT: Perhaps you need a different DateStyle setting. set datestyle to dmy; SELECT timestamp with time zone '27/12/2001 04:05:06.789-08'; timestamptz -- 2.39.2
>From 8b5bd09c818590afd858b9c8159887339db8e456 Mon Sep 17 00:00:00 2001 From: Peter Smith <peter.b.sm...@fujitsu.com> Date: Fri, 8 Dec 2023 14:41:02 +1100 Subject: [PATCH v5 2/3] Ensure we use documented CamelCase in error messages Author: Peter Smith --- src/backend/utils/misc/guc.c | 2 +- src/test/regress/expected/guc.out | 4 ++++ src/test/regress/sql/guc.sql | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index e76c083003..c134024fd5 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3252,7 +3252,7 @@ parse_and_validate_value(struct config_generic *record, ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid value for parameter \"%s\": \"%s\"", - name, value), + conf->gen.name, value), hintmsg ? errhint("%s", _(hintmsg)) : 0)); if (hintmsg) diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out index 127c953297..66ddc4c938 100644 --- a/src/test/regress/expected/guc.out +++ b/src/test/regress/expected/guc.out @@ -6,6 +6,10 @@ SHOW datestyle; Postgres, MDY (1 row) +-- Check output style of CamelCase enum options +SET intervalstyle to 'asd'; +ERROR: invalid value for parameter "IntervalStyle": "asd" +HINT: Available values: postgres, postgres_verbose, sql_standard, iso_8601. -- SET to some nondefault value SET vacuum_cost_delay TO 40; SET datestyle = 'ISO, YMD'; diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql index dc79761955..e540495fc1 100644 --- a/src/test/regress/sql/guc.sql +++ b/src/test/regress/sql/guc.sql @@ -2,6 +2,9 @@ -- we can't rely on any specific default value of vacuum_cost_delay SHOW datestyle; +-- Check output style of CamelCase enum options +SET intervalstyle to 'asd'; + -- SET to some nondefault value SET vacuum_cost_delay TO 40; SET datestyle = 'ISO, YMD'; -- 2.39.2
>From 86402523bc1783d8cc508418bb4be796d3aa7dae Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Fri, 8 Dec 2023 13:46:41 +0100 Subject: [PATCH v5 3/3] move variable names out of translatable message string --- contrib/pg_prewarm/autoprewarm.c | 3 +- src/backend/access/transam/xlog.c | 75 +++++++++++++---------- src/backend/access/transam/xlogrecovery.c | 2 +- src/backend/commands/vacuum.c | 10 +-- src/backend/commands/variable.c | 11 ++-- src/backend/port/sysv_shmem.c | 3 +- src/backend/postmaster/bgworker.c | 3 +- src/backend/postmaster/checkpointer.c | 3 +- src/backend/replication/syncrep.c | 3 +- src/backend/storage/buffer/localbuf.c | 3 +- src/backend/storage/file/fd.c | 9 ++- src/backend/storage/lmgr/predicate.c | 6 +- src/backend/tcop/postgres.c | 15 +++-- src/backend/utils/fmgr/dfmgr.c | 16 ++--- 14 files changed, 97 insertions(+), 65 deletions(-) diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c index 0993bd2453..fcc8debb0b 100644 --- a/contrib/pg_prewarm/autoprewarm.c +++ b/contrib/pg_prewarm/autoprewarm.c @@ -877,7 +877,8 @@ apw_start_database_worker(void) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_RESOURCES), errmsg("registering dynamic bgworker autoprewarm failed"), - errhint("Consider increasing configuration parameter max_worker_processes."))); + errhint("Consider increasing the configuration parameter %s.", + "max_worker_processes"))); /* * Ignore return value; if it fails, postmaster has died, but we have diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index daed1a7a49..d3831ea978 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4161,16 +4161,21 @@ ReadControlFile(void) if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with CATALOG_VERSION_NO %d," - " but the server was compiled with CATALOG_VERSION_NO %d.", - ControlFile->catalog_version_no, CATALOG_VERSION_NO), + /*- translator: %s is a variable name and %d is its value */ + errdetail("The database cluster was initialized with %s %d," + " 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."))); if (ControlFile->maxAlign != MAXIMUM_ALIGNOF) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with MAXALIGN %d," - " but the server was compiled with MAXALIGN %d.", - ControlFile->maxAlign, MAXIMUM_ALIGNOF), + errdetail("The database cluster was initialized with %s %d," + " but the server was compiled with %s %d.", + "MAXALIGN", ControlFile->maxAlign, + "MAXALIGN", MAXIMUM_ALIGNOF), errhint("It looks like you need to initdb."))); if (ControlFile->floatFormat != FLOATFORMAT_VALUE) ereport(FATAL, @@ -4180,51 +4185,57 @@ ReadControlFile(void) if (ControlFile->blcksz != BLCKSZ) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with BLCKSZ %d," - " but the server was compiled with BLCKSZ %d.", - ControlFile->blcksz, BLCKSZ), + errdetail("The database cluster was initialized with %s %d," + " but the server was compiled with %s %d.", + "BLCKSZ", ControlFile->blcksz, "BLCKSZ", BLCKSZ), errhint("It looks like you need to recompile or initdb."))); if (ControlFile->relseg_size != RELSEG_SIZE) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with RELSEG_SIZE %d," - " but the server was compiled with RELSEG_SIZE %d.", - ControlFile->relseg_size, RELSEG_SIZE), + errdetail("The database cluster was initialized with %s %d," + " 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."))); if (ControlFile->xlog_blcksz != XLOG_BLCKSZ) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with XLOG_BLCKSZ %d," - " but the server was compiled with XLOG_BLCKSZ %d.", - ControlFile->xlog_blcksz, XLOG_BLCKSZ), + errdetail("The database cluster was initialized with %s %d," + " 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."))); if (ControlFile->nameDataLen != NAMEDATALEN) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with NAMEDATALEN %d," - " but the server was compiled with NAMEDATALEN %d.", - ControlFile->nameDataLen, NAMEDATALEN), + errdetail("The database cluster was initialized with %s %d," + " but the server was compiled with %s %d.", + "NAMEDATALEN", ControlFile->nameDataLen, + "NAMEDATALEN", NAMEDATALEN), errhint("It looks like you need to recompile or initdb."))); if (ControlFile->indexMaxKeys != INDEX_MAX_KEYS) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with INDEX_MAX_KEYS %d," - " but the server was compiled with INDEX_MAX_KEYS %d.", - ControlFile->indexMaxKeys, INDEX_MAX_KEYS), + errdetail("The database cluster was initialized with %s %d," + " 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."))); if (ControlFile->toast_max_chunk_size != TOAST_MAX_CHUNK_SIZE) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with TOAST_MAX_CHUNK_SIZE %d," - " but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.", - ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE), + errdetail("The database cluster was initialized with %s %d," + " 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."))); if (ControlFile->loblksize != LOBLKSIZE) ereport(FATAL, (errmsg("database files are incompatible with server"), - errdetail("The database cluster was initialized with LOBLKSIZE %d," - " but the server was compiled with LOBLKSIZE %d.", - ControlFile->loblksize, (int) LOBLKSIZE), + errdetail("The database cluster was initialized with %s %d," + " but the server was compiled with %s %d.", + "LOBLKSIZE", ControlFile->loblksize, + "LOBLKSIZE", (int) LOBLKSIZE), errhint("It looks like you need to recompile or initdb."))); #ifdef USE_FLOAT8_BYVAL @@ -4259,12 +4270,14 @@ ReadControlFile(void) /* check and update variables dependent on wal_segment_size */ if (ConvertToXSegs(min_wal_size_mb, wal_segment_size) < 2) - ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("min_wal_size must be at least twice wal_segment_size"))); + ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("%s must be at least twice %s", + "min_wal_size", "wal_segment_size")); if (ConvertToXSegs(max_wal_size_mb, wal_segment_size) < 2) - ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("max_wal_size must be at least twice wal_segment_size"))); + ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("%s must be at least twice %s", + "max_wal_size", "wal_segment_size")); UsableBytesInSegment = (wal_segment_size / XLOG_BLCKSZ * UsableBytesInPage) - diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 4bc4d3e323..524d792ae9 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -4726,7 +4726,7 @@ check_recovery_target(char **newval, void **extra, GucSource source) { if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0) { - GUC_check_errdetail("The only allowed value is \"immediate\"."); + GUC_check_errdetail("The only allowed value is \"%s\".", "immediate"); return false; } return true; diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index be43b46c04..a80438f30b 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -134,8 +134,9 @@ check_vacuum_buffer_usage_limit(int *newval, void **extra, return true; /* Value does not fall within any allowable range */ - GUC_check_errdetail("vacuum_buffer_usage_limit must be 0 or between %d kB and %d kB", - MIN_BAS_VAC_RING_SIZE_KB, MAX_BAS_VAC_RING_SIZE_KB); + GUC_check_errdetail("%s must be 0 or between %d kB and %d kB.", + "vacuum_buffer_usage_limit", MIN_BAS_VAC_RING_SIZE_KB, + MAX_BAS_VAC_RING_SIZE_KB); return false; } @@ -206,8 +207,9 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("BUFFER_USAGE_LIMIT option must be 0 or between %d kB and %d kB", - MIN_BAS_VAC_RING_SIZE_KB, MAX_BAS_VAC_RING_SIZE_KB), + errmsg("%s option must be 0 or between %d kB and %d kB", + "BUFFER_USAGE_LIMIT", MIN_BAS_VAC_RING_SIZE_KB, + MAX_BAS_VAC_RING_SIZE_KB), hintmsg ? errhint("%s", _(hintmsg)) : 0)); } diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 2703d2edc4..da5e2de310 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -182,7 +182,7 @@ check_datestyle(char **newval, void **extra, GucSource source) if (!ok) { - GUC_check_errdetail("Conflicting DateStyle specifications."); + GUC_check_errdetail("Conflicting %s specifications.", "DateStyle"); return false; } @@ -717,7 +717,8 @@ check_client_encoding(char **newval, void **extra, GucSource source) else { /* Provide a useful complaint */ - GUC_check_errdetail("Cannot change client_encoding now."); + GUC_check_errdetail("Cannot change %s now.", + "client_encoding"); } return false; } @@ -1202,7 +1203,8 @@ check_effective_io_concurrency(int *newval, void **extra, GucSource source) #ifndef USE_PREFETCH if (*newval != 0) { - GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise()."); + GUC_check_errdetail("%s must be set to 0 on platforms that lack posix_fadvise().", + "effective_io_concurrency"); return false; } #endif /* USE_PREFETCH */ @@ -1215,7 +1217,8 @@ check_maintenance_io_concurrency(int *newval, void **extra, GucSource source) #ifndef USE_PREFETCH if (*newval != 0) { - GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise()."); + GUC_check_errdetail("%s must be set to 0 on platforms that lack posix_fadvise().", + "maintenance_io_concurrency"); return false; } #endif /* USE_PREFETCH */ diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 2de280ecb6..88c39f577d 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -580,7 +580,8 @@ check_huge_page_size(int *newval, void **extra, GucSource source) /* Recent enough Linux only, for now. See GetHugePageSize(). */ if (*newval != 0) { - GUC_check_errdetail("huge_page_size must be 0 on this platform."); + GUC_check_errdetail("%s must be 0 on this platform.", + "huge_page_size"); return false; } #endif diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index c345639086..f2dc53ac85 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -919,7 +919,8 @@ RegisterBackgroundWorker(BackgroundWorker *worker) "Up to %d background workers can be registered with the current settings.", max_worker_processes, max_worker_processes), - errhint("Consider increasing the configuration parameter max_worker_processes."))); + errhint("Consider increasing the configuration parameter %s.", + "max_worker_processes"))); return; } diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index dc2da5a2cd..9060eeea67 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -423,7 +423,8 @@ CheckpointerMain(void) "checkpoints are occurring too frequently (%d seconds apart)", elapsed_secs, elapsed_secs), - errhint("Consider increasing the configuration parameter max_wal_size."))); + errhint("Consider increasing the configuration parameter %s.", + "max_wal_size"))); /* * Initialize checkpointer-private variables used during diff --git a/src/backend/replication/syncrep.c b/src/backend/replication/syncrep.c index 0ea71b5c43..7d1fecb607 100644 --- a/src/backend/replication/syncrep.c +++ b/src/backend/replication/syncrep.c @@ -1016,7 +1016,8 @@ check_synchronous_standby_names(char **newval, void **extra, GucSource source) if (syncrep_parse_error_msg) GUC_check_errdetail("%s", syncrep_parse_error_msg); else - GUC_check_errdetail("synchronous_standby_names parser failed"); + GUC_check_errdetail("%s parser failed", + "synchronous_standby_names"); return false; } diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index aebcf146b4..5b9cc850a2 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -705,7 +705,8 @@ check_temp_buffers(int *newval, void **extra, GucSource source) */ if (source != PGC_S_TEST && NLocBuffer && NLocBuffer != *newval) { - GUC_check_errdetail("temp_buffers cannot be changed after any temporary tables have been accessed in the session."); + GUC_check_errdetail("%s cannot be changed after any temporary tables have been accessed in the session.", + "temp_buffers"); return false; } return true; diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index a185fb3d08..3b5d395a0f 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -3917,7 +3917,8 @@ check_debug_io_direct(char **newval, void **extra, GucSource source) #if PG_O_DIRECT == 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; } flags = 0; @@ -3964,14 +3965,16 @@ check_debug_io_direct(char **newval, void **extra, GucSource source) #if XLOG_BLCKSZ < PG_IO_ALIGN_SIZE 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; } #endif #if BLCKSZ < PG_IO_ALIGN_SIZE 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 data because %s is too small", + "debug_io_direct", "BLCKSZ"); result = false; } #endif diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 1129b8e4f2..b8d3df1a3b 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -1644,8 +1644,10 @@ GetSerializableTransactionSnapshot(Snapshot snapshot) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot use serializable mode in a hot standby"), - errdetail("default_transaction_isolation is set to \"serializable\"."), - errhint("You can use \"SET default_transaction_isolation = 'repeatable read'\" to change the default."))); + errdetail("%s is set to \"%s\".", + "default_transaction_isolation", "serializable"), + errhint("You can use \"%s\" to change the default.", + "SET default_transaction_isolation = 'repeatable read'"))); /* * A special optimization is available for SERIALIZABLE READ ONLY diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 7298a187d1..9b55a584ed 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3571,7 +3571,8 @@ check_max_stack_depth(int *newval, void **extra, GucSource source) if (stack_rlimit > 0 && newval_bytes > stack_rlimit - STACK_DEPTH_SLOP) { - GUC_check_errdetail("max_stack_depth must not exceed %ldkB.", + GUC_check_errdetail("%s must not exceed %ldkB.", + "max_stack_depth", (stack_rlimit - STACK_DEPTH_SLOP) / 1024L); GUC_check_errhint("Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent."); return false; @@ -3596,7 +3597,8 @@ check_client_connection_check_interval(int *newval, void **extra, GucSource sour { if (!WaitEventSetCanReportClosed() && *newval != 0) { - GUC_check_errdetail("client_connection_check_interval must be set to 0 on this platform."); + GUC_check_errdetail("%s must be set to 0 on this platform.", + "client_connection_check_interval"); return false; } return true; @@ -3617,7 +3619,8 @@ check_stage_log_stats(bool *newval, void **extra, GucSource source) { if (*newval && log_statement_stats) { - GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true."); + GUC_check_errdetail("Cannot enable parameter when %s is true.", + "log_statement_stats"); return false; } return true; @@ -3632,9 +3635,9 @@ check_log_stats(bool *newval, void **extra, GucSource source) if (*newval && (log_parser_stats || log_planner_stats || log_executor_stats)) { - GUC_check_errdetail("Cannot enable log_statement_stats when " - "log_parser_stats, log_planner_stats, " - "or log_executor_stats is true."); + GUC_check_errdetail("Cannot enable %s when %s, %s, or %s is true.", + "log_statement_stats", "log_parser_stats", + "log_planner_stats", "log_executor_stats"); return false; } return true; diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 56724ff815..60469e6258 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -358,8 +358,8 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has FUNC_MAX_ARGS = %d, library has %d."), - magic_data.funcmaxargs, + _("Server has %s = %d, library has %d."), + "FUNC_MAX_ARGS", magic_data.funcmaxargs, module_magic_data->funcmaxargs); } if (module_magic_data->indexmaxkeys != magic_data.indexmaxkeys) @@ -367,8 +367,8 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has INDEX_MAX_KEYS = %d, library has %d."), - magic_data.indexmaxkeys, + _("Server has %s = %d, library has %d."), + "INDEX_MAX_KEYS", magic_data.indexmaxkeys, module_magic_data->indexmaxkeys); } if (module_magic_data->namedatalen != magic_data.namedatalen) @@ -376,8 +376,8 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has NAMEDATALEN = %d, library has %d."), - magic_data.namedatalen, + _("Server has %s = %d, library has %d."), + "NAMEDATALEN", magic_data.namedatalen, module_magic_data->namedatalen); } if (module_magic_data->float8byval != magic_data.float8byval) @@ -385,8 +385,8 @@ incompatible_module_error(const char *libname, if (details.len) appendStringInfoChar(&details, '\n'); appendStringInfo(&details, - _("Server has FLOAT8PASSBYVAL = %s, library has %s."), - magic_data.float8byval ? "true" : "false", + _("Server has %s = %s, library has %s."), + "FLOAT8PASSBYVAL", magic_data.float8byval ? "true" : "false", module_magic_data->float8byval ? "true" : "false"); } -- 2.39.2