pgpool2.git / summary / log / commit / refs

commit    09ef05a3d9c4d148af214728c632bfa4d9cf72f8
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Fri Sep 05 08:12:12 2025 +0000

    Fix query cache when pgpool is built without memcached.
    
    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 <pengbo@sraoss.co.jp>
    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"), [parent: 09cd631edb0f]