From b2636829133009eefecfdc9d01ca0d7285c00ca8 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Mon, 10 Nov 2025 16:35:36 +0800 Subject: [PATCH v1] 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 (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: 'max_index_keys' of type 'int' is missing required field 'max' No functional changes to generated guc_tables.c. Author: Chao Li --- src/backend/utils/misc/gen_guc_tables.pl | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl index 601c34ec30b..f46fe498603 100644 --- a/src/backend/utils/misc/gen_guc_tables.pl +++ b/src/backend/utils/misc/gen_guc_tables.pl @@ -38,6 +38,40 @@ 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)], + bool => [], # no extra required fields + string => [], # no extra required fields + ); + + # Check common required fields + for my $f (@required_common) { + unless (defined $entry->{$f}) { + die sprintf("error: guc_parameters.data: '%s' is missing required field '%s'\n", + $entry->{name} // '', $f); + } + } + + # Check type-specific fields + if (exists $required_by_type{$entry->{type}}) { + for my $f (@{ $required_by_type{$entry->{type}} }) { + unless (defined $entry->{$f}) { + die sprintf("error: guc_parameters.data: '%s' of type '%s' is missing required field '%s'\n", + $entry->{name}, $entry->{type}, $f); + } + } + } +} + # Print GUC table. sub print_table { @@ -50,6 +84,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)