mirror of
https://github.com/postgres/postgres.git
synced 2026-05-28 04:35:45 -04:00
gen_guc_tables.pl: Improve detection of inconsistent data
This commit adds two improvements to gen_guc_tables.pl: 1) When finding two entries with the same name, the script complained about these being not in alphabetical order, which was confusing. Duplicated entries are now reported as their own error. 2) While the presence of the required fields is checked for all the parameters, the script did not perform any checks on the non-required fields. A check is added to check that any field defined matches with what can be accepted. Previously, a typo in the name of a required field would cause the field to be reported as missing. Non-mandatory fields would be silently ignored, which was problematic as we could lose some information. Author: Zsolt Parragi <zsolt.parragi@percona.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAN4CZFP=3xUoXb9jpn5OWwicg+rbyrca8-tVmgJsQAa4+OExkw@mail.gmail.com
This commit is contained in:
parent
1a7ccd2b33
commit
233e6ae953
1 changed files with 27 additions and 2 deletions
|
|
@ -53,6 +53,25 @@ sub validate_guc_entry
|
|||
string => [], # no extra required fields
|
||||
);
|
||||
|
||||
# All fields recognized by the generator. "line_number" is injected
|
||||
# by Catalog::ParseData and is not a user-facing field.
|
||||
my %valid_fields = map { $_ => 1 } (
|
||||
@required_common,
|
||||
qw(long_desc flags ifdef min max options
|
||||
check_hook assign_hook show_hook
|
||||
line_number));
|
||||
|
||||
for my $f (sort keys %$entry)
|
||||
{
|
||||
unless ($valid_fields{$f})
|
||||
{
|
||||
die sprintf(
|
||||
qq{%s:%d: error: entry "%s" has unrecognized field "%s"\n},
|
||||
$input_fname, $entry->{line_number},
|
||||
$entry->{name} // '<unknown>', $f);
|
||||
}
|
||||
}
|
||||
|
||||
for my $f (@required_common)
|
||||
{
|
||||
unless (defined $entry->{$f})
|
||||
|
|
@ -98,10 +117,16 @@ sub print_table
|
|||
{
|
||||
validate_guc_entry($entry);
|
||||
|
||||
if (defined($prev_name) && lc($prev_name) ge lc($entry->{name}))
|
||||
if (defined($prev_name) && lc($prev_name) eq lc($entry->{name}))
|
||||
{
|
||||
die sprintf(qq{%s:%d: error: duplicate entry "%s"\n},
|
||||
$input_fname, $entry->{line_number}, $entry->{name});
|
||||
}
|
||||
if (defined($prev_name) && lc($prev_name) gt lc($entry->{name}))
|
||||
{
|
||||
die sprintf(
|
||||
"entries are not in alphabetical order: \"%s\", \"%s\"\n",
|
||||
qq{%s:%d: error: entries are not in alphabetical order: "%s", "%s"\n},
|
||||
$input_fname, $entry->{line_number},
|
||||
$prev_name, $entry->{name});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue