Fix backend_flag* parameter shown twice while executing "pgpool show all".
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 8 Aug 2021 04:19:33 +0000 (13:19 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 8 Aug 2021 04:27:04 +0000 (13:27 +0900)
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

index 5df2b6ab4f468ffe77381cb4b1a0bba4c3c4c900..842cb2066faa4d54e5a587b42604f9fb651d1fb2 100644 (file)
@@ -1396,9 +1396,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,
                "ALWAYS_MASTER",
@@ -4811,6 +4827,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)
 {
@@ -4866,7 +4885,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)
 {
@@ -4916,7 +4937,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)