Re: GUC names in messages

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Peter Smith <smithpb2250@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Nathan Bossart <nathandbossart@gmail.com>, Laurenz Albe <laurenz.albe@cybertec.at>, Tom Lane <tgl@sss.pgh.pa.us>, Daniel Gustafsson <daniel@yesql.se>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-12-16T09:33:45Z
Lists: pgsql-hackers
On Thu, Dec 14, 2023 at 09:38:40AM +0100, Peter Eisentraut wrote:
> After these discussions, I think this rule change was not a good idea. It
> effectively enforces these kinds of inconsistencies.  For example, if you
> ever refactored
> 
>     "DateStyle is wrong"
> 
> to
> 
>     "%s is wrong"
> 
> you'd need to adjust the quotes, and thus user-visible behavior, for
> entirely internal reasons.  This is not good.

So, what are you suggesting?  Should the encouraged rule be removed
from the docs?  Or do you object to some of the changes done in the
latest patch series v5?

FWIW, I am a bit meh with v5-0001, because I don't see the benefits.
On the contrary v5-0003 is useful, because it reduces a bit the number
of strings to translate.  That's always good to take.  I don't have a
problem with v5-0002, either, where we'd begin using the name of the 
GUC as stored in the static tables rather than the name provided in
the SET query, particularly for the reason that it makes the GUC name
a bit more consistent even when using double-quotes around the
parameter name in the query, where the error messages would not force
a lower-case conversion.  The patch would, AFAIU, change HEAD from
that:
=# SET "intervalstylE" to popo;
ERROR:  22023: invalid value for parameter "intervalstylE": "popo"
To that:
=# SET "intervalstylE" to popo;
ERROR:  22023: invalid value for parameter "IntervalStyle": "popo"

> And then came the idea to
> determine the quoting dynamically, which I think everyone agreed was too
> much.  So I don't see a way to make this work well.

Yeah, with the quotes being language-dependent, any idea I can think
of is as good as unreliable and dead.
--
Michael

Commits

  1. Apply GUC name from central table in more places of guc.c

  2. Use camel case for "DateStyle" in some error messages

  3. Unify some error messages to ease work of translators

  4. Apply more quoting to GUC names in messages

  5. Revise GUC names quoting in messages again

  6. doc: Mention how to use quotes with GUC names in error messages

  7. Apply quotes more consistently to GUC names in logs