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:33:40 +0000 (13:33 +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 05d65693f7c8daf9a82d02a726867b93c1eaf7b7..d5c27215d63d094efc142d4ac1f403aa0f6a6e9d 100644 (file)
@@ -1334,9 +1334,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",
@@ -4514,6 +4530,9 @@ bool reset_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backen
        return true;
 }
 
+/*
+ * Handle "pgpool show all" command.
+*/
 bool report_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
 {
        int i;
@@ -4565,7 +4584,9 @@ bool report_all_variables(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backe
        return true;
 }
 
-
+/*
+ * Handle "pgpool show" command.
+*/
 bool report_config_variable(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const char* var_name)
 {
        int index = 0;
@@ -4611,7 +4632,7 @@ bool report_config_variable(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
                        /* Index is not included in parameter name.
                         * this is the multi 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)