pgpool2.git / summary / log / commit / refs

commit    c7aa75cd787b84ee3708d07c7057b95a32b197b5
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Wed Jul 07 04:03:59 2021 +0000

    Fix query cache to not cache SQLValueFunctions (CURRENT_TIME, CURRENT_USER etc.).
    
    Checking SQLValueFunctions was missed whether to be cached or not and
    they were regarded as non function objects. As a result they were
    cached.
    
    Also add more test cases.


src/test/regression/tests/006.memqcache/test.sh | 4 ++++ src/utils/pool_select_walker.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/regression/tests/006.memqcache/test.sh b/src/test/regression/tests/006.memqcache/test.sh index 840ede6ac..6a5a11814 100755 --- a/src/test/regression/tests/006.memqcache/test.sh +++ b/src/test/regression/tests/006.memqcache/test.sh @@ -68,6 +68,8 @@ SELECT other_schema.volatile_func(1); SELECT * FROM explain_analyze; EXPLAIN ANALYZE INSERT INTO explain_analyze VALUES(1); SELECT * FROM explain_analyze; +SELECT CURRENT_TIMESTAMP; +SELECT CURRENT_USER; EOF success=true @@ -79,6 +81,8 @@ EOF grep "fetched from cache" log/pgpool.log | grep immutable_func > /dev/null || success=false grep "fetched from cache" log/pgpool.log | grep volatile_func > /dev/null && success=false grep "fetched from cache" log/pgpool.log | grep explain_analyze > /dev/null && success=false + grep "fetched from cache" log/pgpool.log | grep CURRENT_TIMESTAMP > /dev/null && success=false + grep "fetched from cache" log/pgpool.log | grep CURRENT_USER > /dev/null && success=false if [ $success = false ];then ./shutdownall exit 1 diff --git a/src/utils/pool_select_walker.c b/src/utils/pool_select_walker.c index 1ca6a997e..14804cfa0 100644 --- a/src/utils/pool_select_walker.c +++ b/src/utils/pool_select_walker.c @@ -3,7 +3,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2020 PgPool Global Development Group + * Copyright (c) 2003-2021 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -1043,6 +1043,15 @@ non_immutable_function_call_walker(Node *node, void *context) return false; } } + else if (IsA(node, SQLValueFunction)) + { + /* + * SQLValueFunctions (CURRENT_TIME, CURRENT_USER etc.) are regarded as + * non immutable functions. + */ + ctx->has_non_immutable_function_call = true; + return false; + } return raw_expression_tree_walker(node, non_immutable_function_call_walker, context); } [parent: fd9942a32714]