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
memcpy(p, ptr, *len);
+#ifdef USE_MEMCACHED
if (!pool_is_shmem_cache())
{
free(ptr);
}
+#endif
ereport(DEBUG1,
(errmsg("fetching from cache storage"),