pgpool2.git / summary / log / commit / refs

commit    41febb3aaa4480e0c9219e4538e04ef7398669a6
Author:   Yugo Nagata <nagata@sraoss.co.jp>
Date:     Tue Dec 18 05:52:39 2012 +0000

    Fix bug that only tables in white_memqcache_table_list was cached
    when black_memqcache_table_list has any tables.


pool_memqcache.c | 39 ++++++++++++++++++++------------------- pool_memqcache.h | 3 ++- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pool_memqcache.c b/pool_memqcache.c index 4546c7f12..ae4083484 100644 --- a/pool_memqcache.c +++ b/pool_memqcache.c @@ -747,7 +747,7 @@ bool pool_is_allow_to_cache(Node *node, char *query) for (i = 0; i < num_oids; i++) { pool_debug("pool_is_allow_to_cache: check table_names[%d] = %s", i, ctx.table_names[i]); - if (pool_is_table_to_cache(ctx.table_names[i]) == false) + if (pool_is_table_in_black_list(ctx.table_names[i]) == true) { pool_debug("pool_is_allow_to_cache: false"); return false; @@ -796,7 +796,7 @@ bool pool_is_allow_to_cache(Node *node, char *query) pool_debug("pool_is_allow_to_cache: check table_names[%d] = %s", i, table); if (is_view(table) || is_unlogged_table(table)) { - if (pool_is_table_to_cache(table) == false) + if (pool_is_table_in_white_list(table) == false) { pool_debug("pool_is_allow_to_cache: false"); return false; @@ -822,32 +822,33 @@ bool pool_is_allow_to_cache(Node *node, char *query) return true; } + /* - * Return true If the SELECTed table is in white list or is not in black list, - * and table is to be cached. + * Return true If the SELECTed table is in back list. */ -bool pool_is_table_to_cache(const char *table_name) +bool pool_is_table_in_black_list(const char *table_name) { - /* Cache in case of the table in white list */ - if (pool_config->num_white_memqcache_table_list > 0) + + if (pool_config->num_black_memqcache_table_list > 0 && + pattern_compare((char *)table_name, BLACKLIST, "black_memqcache_table_list") == 1) { - if (pattern_compare((char *)table_name, WHITELIST, "white_memqcache_table_list") == 1) - return true; - else - return false; + return true; } - /* No cache in case of the table in black list */ - else if (pool_config->num_black_memqcache_table_list > 0) + return false; +} + +/* + * Return true If the SELECTed table is in white list. + */ +bool pool_is_table_in_white_list(const char *table_name) +{ + if (pool_config->num_white_memqcache_table_list > 0 && + pattern_compare((char *)table_name, WHITELIST, "white_memqcache_table_list") == 1) { - if (pattern_compare((char *)table_name, BLACKLIST, "black_memqcache_table_list") == 1) - return false; - else - return true; + return true; } - /* No cache otherwise */ - pool_error("pool_is_table_to_cache: unknown case"); return false; } diff --git a/pool_memqcache.h b/pool_memqcache.h index 281b6cb46..bcc9196c7 100644 --- a/pool_memqcache.h +++ b/pool_memqcache.h @@ -226,7 +226,8 @@ extern POOL_STATUS pool_fetch_from_memory_cache(POOL_CONNECTION *frontend, char *contents, bool *foundp); extern bool pool_is_likely_select(char *query); -extern bool pool_is_table_to_cache(const char *table_name); +extern bool pool_is_table_in_black_list(const char *table_name); +extern bool pool_is_table_in_white_list(const char *table_name); extern bool pool_is_allow_to_cache(Node *node, char *query); extern int pool_extract_table_oids(Node *node, int **oidsp); extern void pool_add_dml_table_oid(int oid); [parent: 646c1eba2b38]