Allow to use in memory query cache size > 4GB
authorTatsuo Ishii <ishii@postgresql.org>
Sat, 20 Jun 2015 10:03:22 +0000 (19:03 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sat, 20 Jun 2015 10:06:38 +0000 (19:06 +0900)
This should have been allowed since in memory query cache was born.

src/config/pool_config.c
src/config/pool_config.l
src/include/pool_config.h
src/query_cache/pool_memqcache.c

index 158f17d34dec26f446a1a635ddae7fc029000a80..c2a6c46327435b8b336b8fa7d1e83bcd296f37f7 100644 (file)
@@ -2018,7 +2018,7 @@ int pool_init_config(void)
     pool_config->memqcache_method = "shmem";
     pool_config->memqcache_memcached_host = "localhost";
     pool_config->memqcache_memcached_port = 11211;
-    pool_config->memqcache_total_size = 67108864;
+    pool_config->memqcache_total_size = (int64)67108864;
     pool_config->memqcache_max_num_cache = 1000000;
     pool_config->memqcache_expire = 0;
     pool_config->memqcache_auto_cache_invalidation = 1;
@@ -4845,7 +4845,7 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
         }
         else if (!strcmp(key, "memqcache_total_size") && CHECK_CONTEXT(INIT_CONFIG, context))
         {
-            int v = atoi(yytext);
+            int64 v = atoll(yytext);
 
             if (token != POOL_INTEGER || v < 0)
             {
index 64a513df3225a9d02cb3ebd78b18ee4372712a66..41782021fea28ee451b2c289db9a47a5f60c7ba7 100644 (file)
@@ -279,7 +279,7 @@ int pool_init_config(void)
     pool_config->memqcache_method = "shmem";
     pool_config->memqcache_memcached_host = "localhost";
     pool_config->memqcache_memcached_port = 11211;
-    pool_config->memqcache_total_size = 67108864;
+    pool_config->memqcache_total_size = (int64)67108864;
     pool_config->memqcache_max_num_cache = 1000000;
     pool_config->memqcache_expire = 0;
     pool_config->memqcache_auto_cache_invalidation = 1;
@@ -3106,7 +3106,7 @@ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
         }
         else if (!strcmp(key, "memqcache_total_size") && CHECK_CONTEXT(INIT_CONFIG, context))
         {
-            int v = atoi(yytext);
+            int64 v = atoll(yytext);
 
             if (token != POOL_INTEGER || v < 0)
             {
index 4cff9568b49aeed543cba5ffeffd3c6b283118cc..9590eba247d780aab8dc13973ce459a5514202e1 100644 (file)
@@ -214,7 +214,7 @@ typedef struct {
        char *memqcache_method;   /* Cache store method. Either 'shmem'(shared memory) or 'memcached'. 'shmem' by default */
        char *memqcache_memcached_host;   /* Memcached host name. Mandatory if memqcache_method=memcached. */
        int memqcache_memcached_port;   /* Memcached port number. Mandatory if memqcache_method=memcached. */
-       int memqcache_total_size;   /* Total memory size in bytes for storing memory cache. Mandatory if memqcache_method=shmem. */
+       int64 memqcache_total_size;   /* Total memory size in bytes for storing memory cache. Mandatory if memqcache_method=shmem. */
        int memqcache_max_num_cache;   /* Total number of cache entries. Mandatory if memqcache_method=shmem. */
        int memqcache_expire;   /* Memory cache entry life time specified in seconds. 60 by default. */
        int memqcache_auto_cache_invalidation; /* If true, invalidation of query cache is triggered by corresponding */
index 29552a08c44952063ab3d146534d02027f4a9c36..79bd10ac4663579049408babda3e00de45f8e259 100644 (file)
@@ -1738,7 +1738,7 @@ static int pool_get_memqcache_blocks(void)
  */
 size_t pool_shared_memory_cache_size(void)
 {
-       int num_blocks;
+       int64 num_blocks;
        size_t size;
 
        if (pool_config->memqcache_maxcache > pool_config->memqcache_cache_block_size)
@@ -1754,13 +1754,13 @@ size_t pool_shared_memory_cache_size(void)
        if (num_blocks == 0)
                ereport(FATAL,
                        (errmsg("invalid memory cache configuration"),
-                                       errdetail("memqcache_total_size %d should be greater or equal to memqcache_cache_block_size %d",
+                                       errdetail("memqcache_total_size %ld should be greater or equal to memqcache_cache_block_size %d",
                                                                pool_config->memqcache_total_size,
                                                                pool_config->memqcache_cache_block_size)));
 
                ereport(LOG,
                        (errmsg("memory cache initialized"),
-                                       errdetail("memcache blocks :%d",num_blocks)));
+                                       errdetail("memcache blocks :%ld",num_blocks)));
        /* Remember # of blocks */
        pool_set_memqcache_blocks(num_blocks);
        size = pool_config->memqcache_cache_block_size * num_blocks;