From edcda2c6c52c15607fcffd8bf3c8779d2b901b30 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Mon, 10 Nov 2025 16:35:36 +0800 Subject: [PATCH v2] gen_guc_tables.pl: Validate required GUC fields before code generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, gen_guc_tables.pl would emit "Use of uninitialized value" warnings if required fields were missing in guc_parameters.dat (for example, when an integer or real GUC omitted the 'max' value). The resulting error messages were unclear and did not identify which GUC entry was problematic. Add explicit validation of required fields depending on the parameter type, and fail with a clear and specific message such as: error: guc_parameters.data line 1909: 'max_index_keys' of type 'int' is missing required field 'max' No functional changes to generated guc_tables.c. Author: Chao Li Reviewed-by: Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/305B1E2D-3E35-410B-A840-53F62EDF5045@gmail.com --- src/backend/utils/misc/gen_guc_tables.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl index 601c34ec30b..cdcb4966a1f 100644 --- a/src/backend/utils/misc/gen_guc_tables.pl +++ b/src/backend/utils/misc/gen_guc_tables.pl @@ -38,6 +38,28 @@ sub dquote return q{"} . $s =~ s/"/\\"/gr . q{"}; } +sub validate_guc_entry +{ + my ($entry) = @_; + + my @required_common = qw(name type context group short_desc variable boot_val); + + # Type-specific required fields + my %required_by_type = ( + int => [qw(min max)], + real => [qw(min max)], + enum => [qw(options)], + ); + + # Check common required fields + for my $f (@required_common, @{ $required_by_type{$entry->{type} // ''} // [] }) { + unless (defined $entry->{$f}) { + die sprintf("error: guc_parameters.data line %d: '%s' of type '%s' is missing required field '%s'\n", + $entry->{line_number}, $entry->{name} // '', $entry->{type} // '', $f); + } + } +} + # Print GUC table. sub print_table { @@ -50,6 +72,8 @@ sub print_table foreach my $entry (@{$parse}) { + validate_guc_entry($entry); + if (defined($prev_name) && lc($prev_name) ge lc($entry->{name})) { die sprintf( -- 2.39.5 (Apple Git-154)