pgpool2.git / summary / log / commit / refs

commit    537a2c1d381fe351a5cd76906a45d68ac9f8e620
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Thu Jul 02 05:51:47 2020 +0000

    Add public API to invalidate query cache by table/database oid.
    
    This would be called by new PCP command to invalidate particular query
    cache.


src/include/query_cache/pool_memqcache.h | 2 ++ src/query_cache/pool_memqcache.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/include/query_cache/pool_memqcache.h b/src/include/query_cache/pool_memqcache.h index e93536204..4e1a8ea20 100644 --- a/src/include/query_cache/pool_memqcache.h +++ b/src/include/query_cache/pool_memqcache.h @@ -282,4 +282,6 @@ extern void pool_shmem_lock(void); extern void pool_shmem_unlock(void); extern bool pool_is_shmem_lock(void); +extern void InvalidateQueryCache(int tableoid, int dboid); + #endif /* POOL_MEMQCACHE_H */ diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index 95f2ed5ca..cf90ec2dc 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -4348,3 +4348,21 @@ inject_cached_message(POOL_CONNECTION * backend, char *qcache, int qcachelen) */ pool_pop(backend, &len); } + +/* + * Public API to invalidate query cache specified by the table/database oids. + */ +void +InvalidateQueryCache(int tableoid, int dboid) +{ + pool_sigset_t oldmask; + + POOL_SETMASK2(&BlockSig, &oldmask); + pool_shmem_lock(); + + /* Invalidate query cache */ + pool_invalidate_query_cache(1, &tableoid, true, dboid); + + pool_semaphore_unlock(QUERY_CACHE_STATS_SEM); + POOL_SETMASK(&oldmask); +} [parent: 3f9a0a3d2ece]