Content-Length: 476424 | pFad | http://github.com/tonybelloni/postgres/commit/ef1c807c25b47960aa86cd185fb74371e88d0cbf

D1 pg_buffercache needs to be taught about relation forks, as Greg Stark · tonybelloni/postgres@ef1c807 · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ef1c807

Browse files
committedAug 14, 2008
pg_buffercache needs to be taught about relation forks, as Greg Stark
pointed out.
1 parent 4ed300b commit ef1c807

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed
 

‎contrib/pg_buffercache/pg_buffercache.sql.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache.sql.in,v 1.7 2007/11/13 04:24:28 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache.sql.in,v 1.8 2008/08/14 12:56:41 heikki Exp $ */
22

33
-- Adjust this setting to control where the objects get created.
44
SET search_path = public;
@@ -13,7 +13,7 @@ LANGUAGE C;
1313
CREATE VIEW pg_buffercache AS
1414
SELECT P.* FROM pg_buffercache_pages() AS P
1515
(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
16-
relblocknumber int8, isdirty bool, usagecount int2);
16+
relforknumber int2, relblocknumber int8, isdirty bool, usagecount int2);
1717

1818
-- Don't want these to be available at public.
1919
REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;

‎contrib/pg_buffercache/pg_buffercache_pages.c

+15-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* pg_buffercache_pages.c
44
* display some contents of the buffer cache
55
*
6-
* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.14 2007/11/15 21:14:30 momjian Exp $
6+
* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.15 2008/08/14 12:56:41 heikki Exp $
77
*-------------------------------------------------------------------------
88
*/
99
#include "postgres.h"
@@ -16,7 +16,7 @@
1616
#include "utils/relcache.h"
1717

1818

19-
#define NUM_BUFFERCACHE_PAGES_ELEM 7
19+
#define NUM_BUFFERCACHE_PAGES_ELEM 8
2020

2121
PG_MODULE_MAGIC;
2222

@@ -32,6 +32,7 @@ typedef struct
3232
Oid relfilenode;
3333
Oid reltablespace;
3434
Oid reldatabase;
35+
ForkNumber forknum;
3536
BlockNumber blocknum;
3637
bool isvalid;
3738
bool isdirty;
@@ -88,11 +89,13 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
8889
OIDOID, -1, 0);
8990
TupleDescInitEntry(tupledesc, (AttrNumber) 4, "reldatabase",
9091
OIDOID, -1, 0);
91-
TupleDescInitEntry(tupledesc, (AttrNumber) 5, "relblocknumber",
92+
TupleDescInitEntry(tupledesc, (AttrNumber) 5, "relforknumber",
93+
INT2OID, -1, 0);
94+
TupleDescInitEntry(tupledesc, (AttrNumber) 6, "relblocknumber",
9295
INT8OID, -1, 0);
93-
TupleDescInitEntry(tupledesc, (AttrNumber) 6, "isdirty",
96+
TupleDescInitEntry(tupledesc, (AttrNumber) 7, "isdirty",
9497
BOOLOID, -1, 0);
95-
TupleDescInitEntry(tupledesc, (AttrNumber) 7, "usage_count",
98+
TupleDescInitEntry(tupledesc, (AttrNumber) 8, "usage_count",
9699
INT2OID, -1, 0);
97100

98101
fctx->tupdesc = BlessTupleDesc(tupledesc);
@@ -129,6 +132,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
129132
fctx->record[i].relfilenode = bufHdr->tag.rnode.relNode;
130133
fctx->record[i].reltablespace = bufHdr->tag.rnode.spcNode;
131134
fctx->record[i].reldatabase = bufHdr->tag.rnode.dbNode;
135+
fctx->record[i].forknum = bufHdr->tag.forkNum;
132136
fctx->record[i].blocknum = bufHdr->tag.blockNum;
133137
fctx->record[i].usagecount = bufHdr->usage_count;
134138

@@ -184,6 +188,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
184188
nulls[4] = true;
185189
nulls[5] = true;
186190
nulls[6] = true;
191+
nulls[7] = true;
187192
}
188193
else
189194
{
@@ -193,12 +198,14 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
193198
nulls[2] = false;
194199
values[3] = ObjectIdGetDatum(fctx->record[i].reldatabase);
195200
nulls[3] = false;
196-
values[4] = Int64GetDatum((int64) fctx->record[i].blocknum);
201+
values[4] = ObjectIdGetDatum(fctx->record[i].forknum);
197202
nulls[4] = false;
198-
values[5] = BoolGetDatum(fctx->record[i].isdirty);
203+
values[5] = Int64GetDatum((int64) fctx->record[i].blocknum);
199204
nulls[5] = false;
200-
values[6] = Int16GetDatum(fctx->record[i].usagecount);
205+
values[6] = BoolGetDatum(fctx->record[i].isdirty);
201206
nulls[6] = false;
207+
values[7] = Int16GetDatum(fctx->record[i].usagecount);
208+
nulls[7] = false;
202209
}
203210

204211
/* Build and return the tuple. */

‎doc/src/sgml/pgbuffercache.sgml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgbuffercache.sgml,v 2.2 2007/12/10 05:32:51 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgbuffercache.sgml,v 2.3 2008/08/14 12:56:41 heikki Exp $ -->
22

33
<sect1 id="pgbuffercache">
44
<title>pg_buffercache</title>
@@ -80,6 +80,13 @@
8080
<entry>Page number within the relation</entry>
8181
</row>
8282

83+
<row>
84+
<entry><structfield>relforknumber</structfield></entry>
85+
<entry><type>smallint</type></entry>
86+
<entry></entry>
87+
<entry>Fork number within the relation</entry>
88+
</row>
89+
8390
<row>
8491
<entry><structfield>isdirty</structfield></entry>
8592
<entry><type>boolean</type></entry>

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/ef1c807c25b47960aa86cd185fb74371e88d0cbf

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy