public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Smith <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Alvaro Herrera <[email protected]>
Cc: Nathan Bossart <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Daniel Gustafsson <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: GUC names in messages
Date: Fri, 8 Dec 2023 15:10:29 +1100
Message-ID: <CAHut+Ps3Lbo=hGevYf8AyjFo8+=SSwXUo7onB-6nS6e-Q-bQoQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAHut+PtqTao+OKRxGcCzUxt9h9d0=TQZZoRjMYe3xe0-O7_hsQ@mail.gmail.com>
<[email protected]>
<CAHut+PsXEqjxdvR6sZX6ihgWhK8jwk=L7VJdAJJT+hwAVwwj7w@mail.gmail.com>
<[email protected]>
<CAHut+PtOqRPyVuX=xL=EhDAEWkpBh2MgeSW1KoyMjru-tEWO9w@mail.gmail.com>
<CAHut+PusWzeZBcOnn07m8TLHJBRiD8HCOV8QPwOwagFv3fs4kA@mail.gmail.com>
<[email protected]>
<[email protected]>
On Fri, Dec 1, 2023 at 7:38 AM Peter Eisentraut <[email protected]> wrote:
>
> On 30.11.23 06:59, Michael Paquier wrote:
> > ereport(elevel,
> > (errcode(ERRCODE_UNDEFINED_OBJECT),
> > - errmsg("unrecognized configuration parameter \"%s\" in file \"%s\" line %d",
> > - item->name,
> > + /* translator: %s%s%s is for an optionally quoted GUC name */
> > + errmsg("unrecognized configuration parameter %s%s%s in file \"%s\" line %d",
> > + GUC_FORMAT(item->name),
> > item->filename, item->sourceline)));
>
> I think this is completely over-engineered and wrong. If we start down
> this road, then the next person is going to start engineering some rules
> by which we should quote file names and other things. Which will lead
> to more confusion, not less. The whole point of this quoting thing is
> that you do it all the time or not, not dynamically based on what's
> inside of it.
>
> The original version of this string (and similar ones) seems the most
> correct, simple, and useful one to me.
>
Yeah, trying to manipulate the quoting dynamically seems like it was
an overreach...
Removing that still leaves some other changes needed to "fix" the
messages using MixedCase GUCs.
PSA v4
======
Details:
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].
- Some others agreed, expecting the exact GUC name (in the message)
can be found in pg_settings [2].
- OTOH, Michael didn't like the diff churn [3] caused by this patch.
~~~
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:
BEFORE Patch 0002 (see the lowercase in the error message)
2023-12-08 13:21:32.897 AEDT [32609] STATEMENT: set intervalstyle = 1234;
ERROR: invalid value for parameter "intervalstyle": "1234"
HINT: Available values: postgres, postgres_verbose, sql_standard, iso_8601.
AFTER Patch 0002
2023-12-08 13:38:48.638 AEDT [29684] STATEMENT: set intervalstyle = 1234;
ERROR: invalid value for parameter "IntervalStyle": "1234"
HINT: Available values: postgres, postgres_verbose, sql_standard, iso_8601.
======
[1] GUC quoting guidelines -
https://github.com/postgres/postgres/commit/a243569bf65c5664436e8f63d870b7ee9c014dcb
[2] The case should match pg_settings -
https://www.postgresql.org/message-id/db3e4290ced77111c17e7a2adfb1d660734f5f78.camel%40cybertec.at
[3] Dislike of diff churn -
https://www.postgresql.org/message-id/ZWUd8dYYA9v83KvI%40paquier.xyz
Kind Regards,
Peter Smith.
Fujitsu Australia
Attachments:
[application/octet-stream] v4-0002-GUC-names-use-mixed-case-for-intervalstyle-error-.patch (853B, ../CAHut+Ps3Lbo=hGevYf8AyjFo8+=SSwXUo7onB-6nS6e-Q-bQoQ@mail.gmail.com/2-v4-0002-GUC-names-use-mixed-case-for-intervalstyle-error-.patch)
download | inline diff:
From f2755db57e375bc07226438faac83ea789ecf9fd Mon Sep 17 00:00:00 2001
From: Peter Smith <[email protected]>
Date: Fri, 8 Dec 2023 14:41:02 +1100
Subject: [PATCH v4] GUC names - use mixed case for intervalstyle error message
---
src/backend/utils/misc/guc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index e76c083..c134024 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)
--
1.8.3.1
[application/octet-stream] v4-0001-GUC-names-use-mixed-case-for-datestyle-in-message.patch (11.1K, ../CAHut+Ps3Lbo=hGevYf8AyjFo8+=SSwXUo7onB-6nS6e-Q-bQoQ@mail.gmail.com/3-v4-0001-GUC-names-use-mixed-case-for-datestyle-in-message.patch)
download | inline diff:
From 663701868262f892f42ccbe2c10c9c42ff25d998 Mon Sep 17 00:00:00 2001
From: Peter Smith <[email protected]>
Date: Fri, 8 Dec 2023 12:59:20 +1100
Subject: [PATCH v4] 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 c361bb2..2703d2e 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 fca9a2a..8ef5bf0 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 f5949f3..99650bf 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 cfb4b20..4aeefd5 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
--
1.8.3.1
view thread (21+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: GUC names in messages
In-Reply-To: <CAHut+Ps3Lbo=hGevYf8AyjFo8+=SSwXUo7onB-6nS6e-Q-bQoQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox