From: Peter Eisentraut Date: Fri, 17 Oct 2025 08:33:54 +0000 (+0200) Subject: Change config_generic.vartype to be initialized at compile time X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=e1a912c86d5205371b043772aa89908f2452cbf0;p=postgresql.git Change config_generic.vartype to be initialized at compile time Previously, this was initialized at run time so that it did not have to be maintained by hand in guc_tables.c. But since that table is now generated anyway, we might as well generate this bit as well. Reviewed-by: Chao Li Discussion: https://www.postgresql.org/message-id/flat/8fdfb91e-60fb-44fa-8df6-f5dea47353c9@eisentraut.org --- diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl index a48a9ebd0eb..b187259bf1e 100644 --- a/src/backend/utils/misc/gen_guc_tables.pl +++ b/src/backend/utils/misc/gen_guc_tables.pl @@ -68,6 +68,7 @@ sub print_one_table if $entry->{long_desc}; printf $ofh "\t\t\t.flags = %s,\n", $entry->{flags} if $entry->{flags}; + printf $ofh "\t\t\t.vartype = %s,\n", ('PGC_' . uc($type)); print $ofh "\t\t},\n"; printf $ofh "\t\t.variable = &%s,\n", $entry->{variable}; printf $ofh "\t\t.boot_val = %s,\n", $entry->{boot_val}; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a64427ac979..a82286cc98a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -890,48 +890,22 @@ build_guc_variables(void) ALLOCSET_DEFAULT_SIZES); /* - * Count all the built-in variables, and set their vartypes correctly. + * Count all the built-in variables. */ for (int i = 0; ConfigureNamesBool[i].gen.name; i++) - { - struct config_bool *conf = &ConfigureNamesBool[i]; - - /* Rather than requiring vartype to be filled in by hand, do this: */ - conf->gen.vartype = PGC_BOOL; num_vars++; - } for (int i = 0; ConfigureNamesInt[i].gen.name; i++) - { - struct config_int *conf = &ConfigureNamesInt[i]; - - conf->gen.vartype = PGC_INT; num_vars++; - } for (int i = 0; ConfigureNamesReal[i].gen.name; i++) - { - struct config_real *conf = &ConfigureNamesReal[i]; - - conf->gen.vartype = PGC_REAL; num_vars++; - } for (int i = 0; ConfigureNamesString[i].gen.name; i++) - { - struct config_string *conf = &ConfigureNamesString[i]; - - conf->gen.vartype = PGC_STRING; num_vars++; - } for (int i = 0; ConfigureNamesEnum[i].gen.name; i++) - { - struct config_enum *conf = &ConfigureNamesEnum[i]; - - conf->gen.vartype = PGC_ENUM; num_vars++; - } /* * Create hash table with 20% slack diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index c5776be029b..3de3d809545 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -177,8 +177,8 @@ struct config_generic const char *short_desc; /* short desc. of this variable's purpose */ const char *long_desc; /* long desc. of this variable's purpose */ int flags; /* flag bits, see guc.h */ + enum config_type vartype; /* type of variable */ /* variable fields, initialized at runtime: */ - enum config_type vartype; /* type of variable (set only at startup) */ int status; /* status bits, see below */ GucSource source; /* source of the current actual value */ GucSource reset_source; /* source of the reset_value */