pgpool2.git / summary / log / commit / refs
commit 0d7c8a3f340674921f360412289083bfaf39ff57
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Tue Mar 06 16:02:43 2012 +0000
Enhance SimpleQuery() so that it judges builtin show commands more
effectively. Rather than relying on string comparison, now we look
into the parse tree, which is more efficient and reliable. Before
"show pool_status" is not recognized(notice extra spaces after
"show"), now it can be recognized.
pool_proto_modules.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/pool_proto_modules.c b/pool_proto_modules.c
index 30a0d48c0..0ad818994 100644
--- a/pool_proto_modules.c
+++ b/pool_proto_modules.c
@@ -103,11 +103,11 @@ static POOL_STATUS close_standby_transactions(POOL_CONNECTION *frontend,
POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend, int len, char *contents)
{
- static char *sq_config = "show pool_status";
- static char *sq_pools = "show pool_pools";
- static char *sq_processes = "show pool_processes";
- static char *sq_nodes = "show pool_nodes";
- static char *sq_version = "show pool_version";
+ static char *sq_config = "pool_status";
+ static char *sq_pools = "pool_pools";
+ static char *sq_processes = "pool_processes";
+ static char *sq_nodes = "pool_nodes";
+ static char *sq_version = "pool_version";
int commit;
List *parse_tree_list;
Node *node = NULL;
@@ -271,32 +271,33 @@ POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend,
if (IsA(node, VariableShowStmt))
{
bool is_valid_show_command = false;
+ VariableShowStmt *vnode = (VariableShowStmt *)node;
- if (strncasecmp(sq_config, contents, strlen(sq_config)) == 0)
+ if (!strcmp(sq_config, vnode->name))
{
is_valid_show_command = true;
pool_debug("config reporting");
config_reporting(frontend, backend);
}
- else if (strncasecmp(sq_pools, contents, strlen(sq_pools)) == 0)
+ else if (!strcmp(sq_pools, vnode->name))
{
is_valid_show_command = true;
pool_debug("pools reporting");
pools_reporting(frontend, backend);
}
- else if (strncasecmp(sq_processes, contents, strlen(sq_processes)) == 0)
+ else if (!strcmp(sq_processes, vnode->name))
{
is_valid_show_command = true;
pool_debug("processes reporting");
processes_reporting(frontend, backend);
}
- else if (strncasecmp(sq_nodes, contents, strlen(sq_nodes)) == 0)
+ else if (!strcmp(sq_nodes, vnode->name))
{
is_valid_show_command = true;
pool_debug("nodes reporting");
nodes_reporting(frontend, backend);
}
- else if (strncasecmp(sq_version, contents, strlen(sq_version)) == 0)
+ else if (!strcmp(sq_version, vnode->name))
{
is_valid_show_command = true;
pool_debug("version reporting");
[parent: 867bee20b365]