Re: GUC names in messages

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Peter Smith <smithpb2250@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-11-01T09:59:21Z
Lists: pgsql-hackers
> On 1 Nov 2023, at 10:22, Peter Smith <smithpb2250@gmail.com> wrote:
> 
> On Wed, Nov 1, 2023 at 8:02 PM Peter Smith <smithpb2250@gmail.com> wrote:
> ...
>> 
>> I had intended to make a patch to address the inconsistency, but
>> couldn't decide which of those styles was the preferred one.
>> 
>> Then I worried this could be the tip of the iceberg -- GUC names occur
>> in many other error messages where they are sometimes quoted and
>> sometimes not quoted:
>> e.g. Not quoted -- errhint("You might need to run fewer transactions
>> at a time or increase max_connections.")));
>> e.g. Quoted -- errmsg("\"max_wal_size\" must be at least twice
>> \"wal_segment_size\"")));
>> 
>> Ideally, they should all look the same everywhere, shouldn't they?
>> 
> 
> One idea to achieve consistency might be to always substitute GUC
> names using a macro.
> 
> #define GUC_NAME(s) ("\"" s "\"")
> 
> ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>    errmsg("%s must be at least twice %s",
>        GUC_NAME("max_wal_size"),
>        GUC_NAME("wal_segment_size"))));

Something like this might make translations harder since the remaining string
leaves little context about the message.  We already have that today to some
extent (so it might not be an issue), and it might be doable to automatically
add translator comments, but it's something to consider.

--
Daniel Gustafsson




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