v1-0005-Change-config_generic.vartype-to-be-initialized-a.patch
text/plain
Filename: v1-0005-Change-config_generic.vartype-to-be-initialized-a.patch
Type: text/plain
Part: 4
Message:
Reorganize GUC structs
Patch
Format: format-patch
Series: patch v1-0005
Subject: Change config_generic.vartype to be initialized at compile time
| File | + | − |
|---|---|---|
| src/backend/utils/misc/gen_guc_tables.pl | 2 | 1 |
| src/backend/utils/misc/guc.c | 1 | 27 |
| src/include/utils/guc_tables.h | 1 | 1 |
From 8b632e14022f3a2dd15cbbba81fd83d26925466e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 3 Oct 2025 08:27:18 +0200
Subject: [PATCH v1 5/8] 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.
---
src/backend/utils/misc/gen_guc_tables.pl | 3 ++-
src/backend/utils/misc/guc.c | 28 +-----------------------
src/include/utils/guc_tables.h | 2 +-
3 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl
index b221fd8c71e..8a416ca48d1 100644
--- a/src/backend/utils/misc/gen_guc_tables.pl
+++ b/src/backend/utils/misc/gen_guc_tables.pl
@@ -64,6 +64,7 @@ sub print_one_table
printf $ofh "\t\t\t.short_desc = gettext_noop(%s),\n", dquote($entry->{short_desc});
printf $ofh "\t\t\t.long_desc = gettext_noop(%s),\n", dquote($entry->{long_desc}) 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};
@@ -79,7 +80,7 @@ sub print_one_table
}
print $ofh "\t/* End-of-list marker */\n";
- print $ofh "\t{0}\n";
+ print $ofh "\t{{0}}\n";
print $ofh "};\n";
return;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index d3c3179a053..647a0166adc 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -889,48 +889,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 */
--
2.51.0