[pgpool-committers: 3203] pgpool: Adding new SHOW command for pgpool-II configuration parameters.

Muhammad Usama m.usama at gmail.com
Wed May 11 06:10:16 JST 2016


Adding new SHOW command for pgpool-II configuration parameters.

This is the next in series patch to add the SHOW and SET commands for pgpool-II
configuration parameters, similar to the PostgreSQL's SET and SHOW commands for
GUC variables. This patch adds the show variable functionality and for that it
adds a new syntax in pgpool which is similar to PostgreSQL's show variable
syntax with an addition of pgpool keyword at the start to distinguish the
pgpool's show command from PG's.  Another reason for using the changed syntax
from the PG's show command is that there are some configuration parameter names
that are same in PostgreSQL and pgpool-II like "port", "log_min_messages"...
And if we use the same syntax without any difference, we would have no way of
telling if the command is referring to the pgpool-II or PG's config parameter.

Although on most parts the PGPOOL SHOW command works similar to the
PG's SHOW command but below are some differences.

-- syntax:
PGPOOL SHOW config_var_name;
PGPOOL SHOW all;

-- config parameter with index:
Since unlike PostgreSQL pgpool-II also have config parameters that can be
assigned with multiple values using the index number at the end of a parameter
name (e.g. backend_port12). For all these type of variables if the index number
is supplied in PGPOOL SHOW command than the single value corresponding to that
index will be printed otherwise if index is not present at the end of variable
name the pgpool show command will print the values at all indexes for that
config parameter.

-- group parameters.
There are some configuration parameters in pgpool-II that can be considered as
part of a logical group. For example the parameters to configure the backend
servers and parameters to configure the watchdog nodes. Providing the logical
group name in pgpool show command will print the values of all config parameters
belonging to that particular group.

For example:
postgres=# pgpool show backend;
item           |             value             |                  description
-------------------------+-------------------------------+-----------------------------------------------
backend_hostname0       | 127.0.0.1                     | hostname or IP address of PostgreSQL backend.
backend_port0           | 5434                          | port number of PostgreSQL backend.
backend_weight0         | 0                             | load balance weight of backend.
backend_data_directory0 | /var/lib/pgsql/data           | data directory of the backend.
backend_flag0           | ALLOW_TO_FAILOVER             | Controls various backend behavior.
backend_hostname1       | 192.168.0.1                   | hostname or IP address of PostgreSQL backend.
backend_port1           | 5432                          | port number of PostgreSQL backend.
backend_weight1         | 1                             | load balance weight of backend.
backend_data_directory1 | /home/usama/work/installed/pg | data directory of the backend.
backend_flag1           | ALLOW_TO_FAILOVER             | Controls various backend behavior.
(10 rows)

Here in the above example the "backend" is the group name and 'pgpool show backend'
command lists the values of all parameters belonging to the backend group.

This patch creates three logical config parameter groups.
1- "backend": This group combines all the parameters related to the backend
server configurations
2-  "other_pgpool": This group contains the parameters for remote watchdog
node configurations.
3- "heartbeat": Config parameters related to watchdog lifecheck node
configurations are part of this logical group.

Apart from adding the new show variable command there are few other under the
hood changes and design decision made by this patch that requires a mentioning.

-- The patch adds the new log level (FRONTEND_ONLY_ERROR) to elog API, that acts
as a non error type, message internally for pgpool-II (the code is returned to
the caller unlike the ERROR message where elog API performs a long jump) but is
forwarded to the front-end client as an ERROR message followed by the
ReadyForQuery message.
This new ereport(FRONTEND_ONLY_ERROR,...) can be used to terminate the current
query from a client with an error while keeping the client session intact.

-- for the new syntax the patch uses the same parse node structure VariableShowStmt
used by PG's SHOW command but with the different node tag.
i.e. T_PgpoolVariableShowStmt instead of T_VariableShowStmt. This is specifically
done to make sure we make a minimum amount of changes in parser imported from the
PostgreSQL. Otherwise, keeping the parser of pgpool in-sync with PostgreSQL would
require more merging efforts.

Branch
------
master

Details
-------
http://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=25dc79e478c24aa884a7be3eb5bc2af51dc6f396

Modified Files
--------------
src/config/pool_config_variables.c         |  1119 +-
src/include/parser/kwlist.h                |     1 +
src/include/parser/nodes.h                 |     6 +-
src/include/pool_config_variables.h        |    74 +-
src/include/utils/elog.h                   |    15 +-
src/include/utils/pool_process_reporting.h |     2 +
src/parser/gram.c                          | 49612 +++++++++++++--------------
src/parser/gram.h                          |   716 +-
src/parser/gram.y                          |    17 +-
src/protocol/pool_proto_modules.c          |    13 +
src/utils/error/elog.c                     |    44 +-
src/utils/pool_process_reporting.c         |   103 +
12 files changed, 25514 insertions(+), 26208 deletions(-)



More information about the pgpool-committers mailing list