pgpool2.git / summary / log / commit / refs
commit 9b9d2a04f95d9a8c8ca2ed5cc0c724c54ee34601
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Thu Jan 14 04:33:14 2016 +0000
Fix white/black_memqcache_table_list not require quotaion
The tables and schemas name specified in *_memqcache_table_list
were needed to be quoted by double quotation since commit
43ff7d3de9db4c8a1143258f4ffff98682dab560. This is fixed
by stripping quote from table name before pattern matching.
Patch contributed by Dang Minh Huong.
Per [pgpool-hackers: 1323]
src/utils/pool_select_walker.c | 35 ++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/utils/pool_select_walker.c b/src/utils/pool_select_walker.c
index 4478a1949..567e14110 100644
--- a/src/utils/pool_select_walker.c
+++ b/src/utils/pool_select_walker.c
@@ -43,6 +43,7 @@ static bool insertinto_or_locking_clause_walker(Node *node, void *context);
static bool is_immutable_function(char *fname);
static bool select_table_walker(Node *node, void *context);
static bool non_immutable_function_call_walker(Node *node, void *context);
+static char *strip_quote(char *str);
/*
* Return true if this SELECT has function calls *and* supposed to
@@ -166,6 +167,7 @@ bool pool_has_insertinto_or_locking_clause(Node *node)
int pattern_compare(char *str, const int type, const char *param_name)
{
int i = 0;
+ char *s;
RegPattern *lists_patterns;
int *pattc;
@@ -188,11 +190,12 @@ int pattern_compare(char *str, const int type, const char *param_name)
return -1;
}
+ s = strip_quote(str);
for (i = 0; i < *pattc; i++) {
if (lists_patterns[i].type != type)
continue;
- if (regexec(&lists_patterns[i].regexv, str, 0, 0, 0) == 0)
+ if (regexec(&lists_patterns[i].regexv, s, 0, 0, 0) == 0)
{
switch(type) {
/* return 1 if string matches whitelist pattern */
@@ -200,31 +203,53 @@ int pattern_compare(char *str, const int type, const char *param_name)
ereport(DEBUG2,
(errmsg("comparing function name in whitelist regex array"),
errdetail("pattern_compare: %s (%s) matched: %s",
- param_name, lists_patterns[i].pattern, str)));
+ param_name, lists_patterns[i].pattern, s)));
return 1;
/* return 1 if string matches blacklist pattern */
case BLACKLIST:
ereport(DEBUG2,
(errmsg("comparing function name in blacklist regex array"),
errdetail("pattern_compare: %s (%s) matched: %s",
- param_name, lists_patterns[i].pattern, str)));
+ param_name, lists_patterns[i].pattern, s)));
return 1;
default:
ereport(WARNING,
- (errmsg("pattern_compare: \"%s\" unknown pattern match type: \"%s\"", param_name, str)));
+ (errmsg("pattern_compare: \"%s\" unknown pattern match type: \"%s\"", param_name, s)));
return -1;
}
}
ereport(DEBUG2,
(errmsg("comparing function name in blacklist/whitelist regex array"),
errdetail("pattern_compare: %s (%s) not matched: %s",
- param_name, lists_patterns[i].pattern, str)));
+ param_name, lists_patterns[i].pattern, s)));
}
+ free(s);
/* return 0 otherwise */
return 0;
}
+static char *strip_quote(char *str)
+{
+ char *after;
+ int i = 0;
+
+ after = malloc(sizeof(char) * strlen(str) + 1);
+
+ do {
+ if (*str != '"')
+ {
+ after[i] = *str;
+ i++;
+ }
+ str++;
+ } while (*str != '\0');
+
+ after[i] = '\0';
+
+ return after;
+}
+
/*
* Walker function to find a function call which is supposed to write
* database.
[parent: 6ac8844288d2]