mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Reorganize GUC structs
Instead of having five separate GUC structs, one for each type, with the generic part contained in each of them, flip it around and have one common struct, with the type-specific part has a subfield. The very original GUC design had type-specific structs and type-specific lists, and the membership in one of the lists defined the type. But now the structs themselves know the type (from the .vartype field), and they are all loaded into a common hash table at run time, and so this original separation no longer makes sense. It creates a bunch of inconsistencies in the code about whether the type-specific or the generic struct is the primary struct, and a lot of casting in between, which makes certain assumptions about the struct layouts. After the change, all these casts are gone and all the data is accessed via normal field references. Also, various code is simplified because only one kind of struct needs to be processed. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://www.postgresql.org/message-id/flat/8fdfb91e-60fb-44fa-8df6-f5dea47353c9@eisentraut.org
This commit is contained in:
@@ -629,7 +629,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
{
|
||||
case PGC_BOOL:
|
||||
{
|
||||
const struct config_bool *lconf = (const struct config_bool *) conf;
|
||||
const struct config_bool *lconf = &conf->_bool;
|
||||
|
||||
/* min_val */
|
||||
values[9] = NULL;
|
||||
@@ -650,7 +650,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
|
||||
case PGC_INT:
|
||||
{
|
||||
const struct config_int *lconf = (const struct config_int *) conf;
|
||||
const struct config_int *lconf = &conf->_int;
|
||||
|
||||
/* min_val */
|
||||
snprintf(buffer, sizeof(buffer), "%d", lconf->min);
|
||||
@@ -675,7 +675,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
|
||||
case PGC_REAL:
|
||||
{
|
||||
const struct config_real *lconf = (const struct config_real *) conf;
|
||||
const struct config_real *lconf = &conf->_real;
|
||||
|
||||
/* min_val */
|
||||
snprintf(buffer, sizeof(buffer), "%g", lconf->min);
|
||||
@@ -700,7 +700,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
|
||||
case PGC_STRING:
|
||||
{
|
||||
const struct config_string *lconf = (const struct config_string *) conf;
|
||||
const struct config_string *lconf = &conf->_string;
|
||||
|
||||
/* min_val */
|
||||
values[9] = NULL;
|
||||
@@ -727,7 +727,7 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
|
||||
case PGC_ENUM:
|
||||
{
|
||||
const struct config_enum *lconf = (const struct config_enum *) conf;
|
||||
const struct config_enum *lconf = &conf->_enum;
|
||||
|
||||
/* min_val */
|
||||
values[9] = NULL;
|
||||
@@ -745,11 +745,11 @@ GetConfigOptionValues(const struct config_generic *conf, const char **values)
|
||||
"{\"", "\"}", "\",\"");
|
||||
|
||||
/* boot_val */
|
||||
values[12] = pstrdup(config_enum_lookup_by_value(lconf,
|
||||
values[12] = pstrdup(config_enum_lookup_by_value(conf,
|
||||
lconf->boot_val));
|
||||
|
||||
/* reset_val */
|
||||
values[13] = pstrdup(config_enum_lookup_by_value(lconf,
|
||||
values[13] = pstrdup(config_enum_lookup_by_value(conf,
|
||||
lconf->reset_val));
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user