From 491bb25dcd3123acfb8d88a9e732d7c36cc57df1 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Sun, 8 Aug 2021 13:19:33 +0900 Subject: [PATCH] Fix backend_flag* parameter shown twice while executing "pgpool show all". There are two entries of "backend_flag" for "ALLOW_TO_FAILOVER" and "ALWAYS_PRIMARY" in the config variable struct. This is mostly ok but "pgpool show all" command displayed both backend_flag entries, which looks redundant. The reason for this is, report_all_variables() shows grouped variables first then other variables except already shown as grouped variables. Unfortunately build_variable groups() is not smart enough to build grouped variable data: it only registers the first backend_flag entry and leaves the second entry. Since the second entry is not a grouped variable, backend_flag is shown firstly as a grouped variable and then is show as a non grouped variable in report_all_variables(). To fix this, mark that the second variable is also a grouped variable (the flag is set by build_config_variables()). See bug 728 for the report of the problem. Also add/fix comments. --- src/config/pool_config_variables.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c index a1de93608..0e21d37de 100644 --- a/src/config/pool_config_variables.c +++ b/src/config/pool_config_variables.c @@ -1660,9 +1660,25 @@ static struct config_string_array ConfigureNamesStringArray[] = }, { + /* + * There are two entries of "backend_flag" for "ALLOW_TO_FAILOVER" and + * "ALWAYS_PRIMARY". This is mostly ok but "pgpool show all" command + * displayed both backend_flag entries, which looks redundant. The + * reason for this is, report_all_variables() shows grouped variables + * first then other variables except already shown as grouped + * variables. Unfortunately build_variable groups() is not smart + * enough to build grouped variable data: it only registers the first + * backend_flag entry and leaves the second entry. since the second + * entry is not a grouped variable, backend_flag is shown firstly as a + * grouped variable and then is show as a non grouped variable in + * report_all_variables(). To fix this, mark that the second variable + * is also a grouped variable (the flag is set by + * build_config_variables()). See bug 728 for the report of the + * problem. + */ {"backend_flag", CFGCXT_RELOAD, CONNECTION_CONFIG, "Controls various backend behavior.", - CONFIG_VAR_TYPE_STRING_ARRAY, true, 0, MAX_NUM_BACKENDS + CONFIG_VAR_TYPE_STRING_ARRAY, true, VAR_PART_OF_GROUP, MAX_NUM_BACKENDS }, NULL, "", /* for ALWAYS_PRIMARY */ @@ -5653,6 +5669,9 @@ reset_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) return true; } +/* + * Handle "pgpool show all" command. +*/ bool report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) { @@ -5708,7 +5727,9 @@ report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) return true; } - +/* + * Handle "pgpool show" command. +*/ bool report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *var_name) { @@ -5758,7 +5779,7 @@ report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen * value config variable */ ereport(DEBUG3, - (errmsg("show parameter \"%s\" with out index", var_name))); + (errmsg("show parameter \"%s\" without index", var_name))); send_row_description_for_detail_view(frontend, backend); num_rows = send_array_type_variable_to_frontend(record, frontend, backend); if (num_rows < 0) -- 2.39.5