3
3
* pg_buffercache_pages.c
4
4
* display some contents of the buffer cache
5
5
*
6
- * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.11 2006/10/22 17:49:21 tgl Exp $
6
+ * $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.12 2007/04/07 16:09:14 momjian Exp $
7
7
*-------------------------------------------------------------------------
8
8
*/
9
9
#include "postgres.h"
16
16
#include "utils/relcache.h"
17
17
18
18
19
- #define NUM_BUFFERCACHE_PAGES_ELEM 6
19
+ #define NUM_BUFFERCACHE_PAGES_ELEM 7
20
20
21
21
PG_MODULE_MAGIC ;
22
22
@@ -35,6 +35,7 @@ typedef struct
35
35
BlockNumber blocknum ;
36
36
bool isvalid ;
37
37
bool isdirty ;
38
+ uint16 usagecount ;
38
39
} BufferCachePagesRec ;
39
40
40
41
@@ -91,6 +92,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
91
92
INT8OID , -1 , 0 );
92
93
TupleDescInitEntry (tupledesc , (AttrNumber ) 6 , "isdirty" ,
93
94
BOOLOID , -1 , 0 );
95
+ TupleDescInitEntry (tupledesc , (AttrNumber ) 7 , "usage_count" ,
96
+ INT2OID , -1 , 0 );
94
97
95
98
fctx -> tupdesc = BlessTupleDesc (tupledesc );
96
99
@@ -126,6 +129,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
126
129
fctx -> record [i ].reltablespace = bufHdr -> tag .rnode .spcNode ;
127
130
fctx -> record [i ].reldatabase = bufHdr -> tag .rnode .dbNode ;
128
131
fctx -> record [i ].blocknum = bufHdr -> tag .blockNum ;
132
+ fctx -> record [i ].usagecount = bufHdr -> usage_count ;
129
133
130
134
if (bufHdr -> flags & BM_DIRTY )
131
135
fctx -> record [i ].isdirty = true;
@@ -172,6 +176,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
172
176
nulls [3 ] = true;
173
177
nulls [4 ] = true;
174
178
nulls [5 ] = true;
179
+ nulls [6 ] = true;
175
180
}
176
181
else
177
182
{
@@ -185,6 +190,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
185
190
nulls [4 ] = false;
186
191
values [5 ] = BoolGetDatum (fctx -> record [i ].isdirty );
187
192
nulls [5 ] = false;
193
+ values [6 ] = Int16GetDatum (fctx -> record [i ].usagecount );
194
+ nulls [6 ] = false;
188
195
}
189
196
190
197
/* Build and return the tuple. */
0 commit comments