From 09ef05a3d9c4d148af214728c632bfa4d9cf72f8 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 5 Sep 2025 17:12:12 +0900 Subject: [PATCH] Fix query cache when pgpool is built without memcached. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When configure is not provided --with-memcached, compiler error occured. query_cache/pool_memqcache.c:542:17: 警告: 'free' called on pointer 'cih' with nonzero offset 24 -Wfree-nonheap-objec t] 542 | free(ptr); | ^~~~~~~~~ query_cache/pool_memqcache.c:2843:15: 備考: returned from 'pool_cache_item_header' 2843 | cih = pool_cache_item_header(cacheid); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is caused by the code block: if (!pool_is_shmem_cache()) { free(ptr); } The compiler thought that "ptr" could be the value returned by pool_cache_item_header(), because the compiler does not understand pool_is_shmem_cache() could return false only when memcached is enabled. To fix this, surround the code block above with #ifdef USE_MEMCACHED. Reported-by: Bo Peng Backpatch-through: v4.2 --- src/query_cache/pool_memqcache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index 40ad93e1a..ba6b36afa 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -537,10 +537,12 @@ pool_fetch_cache(POOL_CONNECTION_POOL *backend, const char *query, char **buf, s memcpy(p, ptr, *len); +#ifdef USE_MEMCACHED if (!pool_is_shmem_cache()) { free(ptr); } +#endif ereport(DEBUG1, (errmsg("fetching from cache storage"), -- 2.39.5