Skip to content

Commit 9c047da

Browse files
committed
Get rid of long datatype in CATCACHE_STATS enabled builds
"long" is 32 bits on Windows 64-bit. Switch to a datatype that's 64-bit on all platforms. While we're there, use an unsigned type as these fields count things that have occurred, of which it's not possible to have negative numbers of. Author: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/CAApHDvoGFjSA3aNyVQ3ivbyc4ST=CC5L-_VjEUQ92HbE2Cxovg@mail.gmail.com
1 parent e7cde9d commit 9c047da

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/backend/utils/cache/catcache.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,22 +461,25 @@ static void
461461
CatCachePrintStats(int code, Datum arg)
462462
{
463463
slist_iter iter;
464-
long cc_searches = 0;
465-
long cc_hits = 0;
466-
long cc_neg_hits = 0;
467-
long cc_newloads = 0;
468-
long cc_invals = 0;
469-
long cc_nlists = 0;
470-
long cc_lsearches = 0;
471-
long cc_lhits = 0;
464+
uint64 cc_searches = 0;
465+
uint64 cc_hits = 0;
466+
uint64 cc_neg_hits = 0;
467+
uint64 cc_newloads = 0;
468+
uint64 cc_invals = 0;
469+
uint64 cc_nlists = 0;
470+
uint64 cc_lsearches = 0;
471+
uint64 cc_lhits = 0;
472472

473473
slist_foreach(iter, &CacheHdr->ch_caches)
474474
{
475475
CatCache *cache = slist_container(CatCache, cc_next, iter.cur);
476476

477477
if (cache->cc_ntup == 0 && cache->cc_searches == 0)
478478
continue; /* don't print unused caches */
479-
elog(DEBUG2, "catcache %s/%u: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %d lists, %ld lsrch, %ld lhits",
479+
elog(DEBUG2, "catcache %s/%u: %d tup, %" PRIu64 " srch, %" PRIu64 "+%"
480+
PRIu64 "=%" PRIu64 " hits, %" PRIu64 "+%" PRIu64 "=%"
481+
PRIu64 " loads, %" PRIu64 " invals, %d lists, %" PRIu64
482+
" lsrch, %" PRIu64 " lhits",
480483
cache->cc_relname,
481484
cache->cc_indexoid,
482485
cache->cc_ntup,
@@ -500,7 +503,10 @@ CatCachePrintStats(int code, Datum arg)
500503
cc_lsearches += cache->cc_lsearches;
501504
cc_lhits += cache->cc_lhits;
502505
}
503-
elog(DEBUG2, "catcache totals: %d tup, %ld srch, %ld+%ld=%ld hits, %ld+%ld=%ld loads, %ld invals, %ld lists, %ld lsrch, %ld lhits",
506+
elog(DEBUG2, "catcache totals: %d tup, %" PRIu64 " srch, %" PRIu64 "+%"
507+
PRIu64 "=%" PRIu64 " hits, %" PRIu64 "+%" PRIu64 "=%" PRIu64
508+
" loads, %" PRIu64 " invals, %" PRIu64 " lists, %" PRIu64
509+
" lsrch, %" PRIu64 " lhits",
504510
CacheHdr->ch_ntup,
505511
cc_searches,
506512
cc_hits,

src/include/utils/catcache.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ typedef struct catcache
6969
* doesn't break ABI for other modules
7070
*/
7171
#ifdef CATCACHE_STATS
72-
long cc_searches; /* total # searches against this cache */
73-
long cc_hits; /* # of matches against existing entry */
74-
long cc_neg_hits; /* # of matches against negative entry */
75-
long cc_newloads; /* # of successful loads of new entry */
72+
uint64 cc_searches; /* total # searches against this cache */
73+
uint64 cc_hits; /* # of matches against existing entry */
74+
uint64 cc_neg_hits; /* # of matches against negative entry */
75+
uint64 cc_newloads; /* # of successful loads of new entry */
7676

7777
/*
7878
* cc_searches - (cc_hits + cc_neg_hits + cc_newloads) is number of failed
7979
* searches, each of which will result in loading a negative entry
8080
*/
81-
long cc_invals; /* # of entries invalidated from cache */
82-
long cc_lsearches; /* total # list-searches */
83-
long cc_lhits; /* # of matches against existing lists */
81+
uint64 cc_invals; /* # of entries invalidated from cache */
82+
uint64 cc_lsearches; /* total # list-searches */
83+
uint64 cc_lhits; /* # of matches against existing lists */
8484
#endif
8585
} CatCache;
8686

0 commit comments

Comments
 (0)