diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/query_cache/pool_memqcache.h | 3 | ||||
-rw-r--r-- | src/query_cache/pool_memqcache.c | 8 | ||||
-rwxr-xr-x | src/test/regression/tests/006.memqcache/test.sh | 6 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/include/query_cache/pool_memqcache.h b/src/include/query_cache/pool_memqcache.h index 9607fb835..6e94d3479 100644 --- a/src/include/query_cache/pool_memqcache.h +++ b/src/include/query_cache/pool_memqcache.h @@ -29,6 +29,9 @@ #include "pool.h" #include <sys/time.h> +#define FORCE_QUERY_CACHE "/*FORCE QUERY CACHE*/" +#define FORCE_QUERY_CACHE_COMMENT_SZ (sizeof(FORCE_QUERY_CACHE)-1) + #define NO_QUERY_CACHE "/*NO QUERY CACHE*/" #define NO_QUERY_CACHE_COMMENT_SZ (sizeof(NO_QUERY_CACHE)-1) diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index ad1501c0c..7ff8a80d9 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -925,7 +925,13 @@ pool_is_allow_to_cache(Node *node, char *query) SelectContext ctx; /* - * If NO QUERY CACHE comment exists, do not cache. + * If FORCE QUERY CACHE comment exists, cache it unconditionally. + */ + if (!strncasecmp(query, FORCE_QUERY_CACHE, FORCE_QUERY_CACHE_COMMENT_SZ)) + return true; + + /* + * If NO QUERY CACHE comment exists, do not cache unconditionally. */ if (!strncasecmp(query, NO_QUERY_CACHE, NO_QUERY_CACHE_COMMENT_SZ)) return false; diff --git a/src/test/regression/tests/006.memqcache/test.sh b/src/test/regression/tests/006.memqcache/test.sh index 05f9e26a1..e7e2353b9 100755 --- a/src/test/regression/tests/006.memqcache/test.sh +++ b/src/test/regression/tests/006.memqcache/test.sh @@ -91,6 +91,10 @@ SELECT '2022-07-05 10:00:00'::TIMETZ; SELECT '2022-07-05 10:00:00'::TIMETZ; SELECT to_timestamp(0); SELECT to_timestamp(0); +/*FORCE QUERY CACHE*/SELECT now(); +/*FORCE QUERY CACHE*/SELECT now(); +/*NO QUERY CACHE*/SELECT 1; +/*NO QUERY CACHE*/SELECT 1; EOF success=true @@ -110,6 +114,8 @@ EOF grep "fetched from cache" log/pgpool.log | grep 'TIMESTAMPTZ;' > /dev/null && success=false grep "fetched from cache" log/pgpool.log | grep 'TIMETZ;' > /dev/null && success=false grep "fetched from cache" log/pgpool.log | grep 'to_timestamp' > /dev/null && success=false + grep "fetched from cache" log/pgpool.log | grep 'FORCE QUERY CACHE' > /dev/null || success=false + grep "fetched from cache" log/pgpool.log | grep 'NO QUERY CACHE' > /dev/null && success=false if [ $success = false ];then ./shutdownall |