Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7169c0b

Browse files
committed
gen_guc_tables.pl: Validate required GUC fields before code generation
Previously, gen_guc_tables.pl would emit "Use of uninitialized value"warnings if required fields were missing in guc_parameters.dat (forexample, when an integer or real GUC omitted the 'max' value). Theresulting error messages were unclear and did not identify which GUCentry was problematic.Add explicit validation of required fields depending on the parametertype, and fail with a clear and specific message such as: guc_parameters.dat:1909: error: entry "max_index_keys" of type "int" is missing required field "max"No changes to generated guc_tables.c.Author: Chao Li <lic@highgo.com>Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://www.postgresql.org/message-id/flat/CAEoWx2%3DoP4LgHi771_OKhPPUS7B-CTqCs%3D%3DuQcNXWrwBoAm5Vg%40mail.gmail.com
1 parent2256af4 commit7169c0b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

‎src/backend/utils/misc/gen_guc_tables.pl‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,52 @@ sub dquote
3838
returnq{"} .$s =~s/"/\\"/gr .q{"};
3939
}
4040

41+
subvalidate_guc_entry
42+
{
43+
my ($entry) =@_;
44+
45+
my@required_common =
46+
qw(name type context group short_desc variable boot_val);
47+
48+
my%required_by_type = (
49+
int=> [qw(min max)],
50+
real=> [qw(min max)],
51+
enum=> [qw(options)],
52+
bool=> [],# no extra required fields
53+
string=> [],# no extra required fields
54+
);
55+
56+
formy$f (@required_common)
57+
{
58+
unless (defined$entry->{$f})
59+
{
60+
diesprintf(
61+
qq{%s:%d: error: entry "%s" is missing required field "%s"\n},
62+
$input_fname,$entry->{line_number},
63+
$entry->{name} //'<unknown>',$f);
64+
}
65+
}
66+
67+
unless (exists$required_by_type{$entry->{type} })
68+
{
69+
diesprintf(
70+
qq{%s:%d: error: entry "%s" has unrecognized GUC type "%s"\n},
71+
$input_fname,$entry->{line_number},
72+
$entry->{name},$entry->{type} //'<unknown>');
73+
}
74+
75+
formy$f (@{$required_by_type{$entry->{type} } })
76+
{
77+
unless (defined$entry->{$f})
78+
{
79+
diesprintf(
80+
qq{%s:%d: error: entry "%s" of type "%s" is missing required field "%s"\n},
81+
$input_fname,$entry->{line_number},$entry->{name},
82+
$entry->{type},$f);
83+
}
84+
}
85+
}
86+
4187
# Print GUC table.
4288
subprint_table
4389
{
@@ -50,6 +96,8 @@ sub print_table
5096

5197
foreachmy$entry (@{$parse})
5298
{
99+
validate_guc_entry($entry);
100+
53101
if (defined($prev_name) &&lc($prev_name)gelc($entry->{name}))
54102
{
55103
diesprintf(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp