pgpool2.git / summary / log / commit / refs

commit    757e920d030404383ff3f44b3da50f3b0f12c3e4
Author:   Toshihiro Kitagawa <kitagawa at sraoss.co.jp>
Date:     Mon Aug 30 03:55:58 2010 +0000

    Fix the bug that pgpool using query_cache sent both cache contents and
    backend response to frontend.
    Fix possible crash when query_cache is true and error response is returned.


pool_proto_modules.c | 9 +++++++-- pool_query_cache.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pool_proto_modules.c b/pool_proto_modules.c index 02f732ac5..2b39e8ad5 100644 --- a/pool_proto_modules.c +++ b/pool_proto_modules.c @@ -183,10 +183,15 @@ POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend, IsA(node, SelectStmt) && !(is_select_pgcatalog = IsSelectpgcatalog(node, backend))) { - if (pool_execute_query_cache_lookup(frontend, backend, node) != POOL_CONTINUE) + /* + * POOL_CONTINUE of here represent cache found, and messages were + * sent to frontend already. + */ + if (pool_execute_query_cache_lookup(frontend, backend, node) == POOL_CONTINUE) { pool_query_context_destroy(query_context); - return POOL_ERROR; + pool_set_skip_reading_from_backends(); + return POOL_CONTINUE; } } diff --git a/pool_query_cache.c b/pool_query_cache.c index 955076bbb..346831b91 100644 --- a/pool_query_cache.c +++ b/pool_query_cache.c @@ -801,6 +801,9 @@ init_query_cache_info(POOL_CONNECTION *pc, char *database, char *query) return -1; strcpy(query_cache_info->db_name, database); + /* initialize create_timestamp */ + query_cache_info->create_time = NULL; + return 0; } @@ -818,7 +821,8 @@ free_query_cache_info(void) free(query_cache_info->query); free(query_cache_info->cache); free(query_cache_info->db_name); - free(query_cache_info->create_time); + if (query_cache_info->create_time) + free(query_cache_info->create_time); free(query_cache_info); query_cache_info = NULL; } @@ -993,6 +997,7 @@ define_prepared_statements(void) POOL_STATUS pool_execute_query_cache_lookup(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, Node *node) { SelectStmt *select = (SelectStmt *)node; + POOL_STATUS status = POOL_END; /* cache not found */ if (! (select->intoClause || select->lockingClause)) { @@ -1003,14 +1008,14 @@ POOL_STATUS pool_execute_query_cache_lookup(POOL_CONNECTION *frontend, POOL_CONN return POOL_ERROR; } - - if (pool_query_cache_lookup(frontend, parsed_query, backend->info->database, TSTATE(backend, MASTER_NODE_ID)) == POOL_CONTINUE) + status = pool_query_cache_lookup(frontend, parsed_query, backend->info->database, TSTATE(backend, MASTER_NODE_ID)); + if (status == POOL_CONTINUE) { free(parsed_query); parsed_query = NULL; free_parser(); - return POOL_CONTINUE; } } - return POOL_CONTINUE; + + return status; } [parent: 63518fccf53b]