Re: Generate GUC tables from .dat file

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Generate GUC tables from .dat file
Date: 2025-08-28 06:53:56
Message-ID: 1745fc45-41a2-4166-ad19-8df16a678171@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27.08.25 01:38, John Naylor wrote:
> Looks good overall. Some style suggestions:
>
> + print $ofh qq[\t\t]
> + . ($entry->{check_hook} || 'NULL') . qq[, ]
> + . ($entry->{assign_hook} || 'NULL') . qq[, ]
> + . ($entry->{show_hook} || 'NULL') . qq[\n];
>
> The string construction in this script is rather verbose. I'd do something like:
>
> printf $ofh "\t\t%s, %s, %s\n",
> $entry->{check_hook} || 'NULL',
> $entry->{assign_hook} || 'NULL',
> $entry->{show_hook} || 'NULL';
>
> + print $ofh "#ifdef " . $entry->{ifdef} . "\n" if $entry->{ifdef};
>
> Likewise:
>
> print $ofh "#ifdef $entry->{ifdef}\n" if $entry->{ifdef};
>
> + print $ofh qq[\t\t\tgettext_noop("]
> + . escape($entry->{long_desc}) . qq[")];
>
> If the "escape" function was a "quote" function that also did its own
> escaping, there'd be less need for these literal quotes, and so maybe
> no need for the "qq[]"'s here.

Ok, good suggestions. I addressed all those, and did another cleanup
pass over the script. (The formatting is from pgperltidy.)

> + boot_val => '""',
>
> + boot_val => '"ISO, MDY"',
>
> A "quote" function could also insert these for config_string GUCs.

The default values might not be string literals, so writing them out
unquoted and having the script quoting them would not work in general.
So I left this. Maybe this is something to fine-tune in the future.

Attachment Content-Type Size
v3-0001-Generate-GUC-tables-from-.dat-file.patch text/plain 156.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2025-08-28 07:22:04 Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM
Previous Message Hayato Kuroda (Fujitsu) 2025-08-28 06:49:13 doc patch: missing tags in protocol.sgml