Mark Kirkwood wrote:
> Mark Kirkwood wrote:
>
>>
>> I couldn't use int4 as the underlying datatype is unsigned int (not
>> available as exposed Pg type). However, using int8 sounds promising
>> (is int8 larger than unsigned int on 64-bit platforms?).
>
>
> Blocknumber is defined as uint32 in block.h - so should always be safe
> to represent as an int8 I am thinking.
>
> I will look at patching pg_buffercache, changing numeric -> int8 for the
> relblocknumber column. This seems a tidier solution than using numeric,
> and loses the numeric overhead.
This patch changes the use of numeric to int8 to represent the
relblocknumber column.
regards
Mark
diff -Ncar pgsql.orig/contrib/pg_buffercache/README.pg_buffercache pgsql/contrib/pg_buffercache/README.pg_buffercache
*** pgsql.orig/contrib/pg_buffercache/README.pg_buffercache Tue May 31 11:02:41 2005
--- pgsql/contrib/pg_buffercache/README.pg_buffercache Tue May 31 11:05:48 2005
***************
*** 66,78 ****
relfilenode | oid |
reltablespace | oid |
reldatabase | oid |
! relblocknumber | numeric |
isdirty | boolean |
View definition:
SELECT p.bufferid, p.relfilenode, p.reltablespace, p.reldatabase,
p.relblocknumber, p.isdirty
FROM pg_buffercache_pages() p(bufferid integer, relfilenode oid,
! reltablespace oid, reldatabase oid, relblocknumber numeric(10,0),
isdirty boolean);
regression=# SELECT c.relname, count(*) AS buffers
--- 66,78 ----
relfilenode | oid |
reltablespace | oid |
reldatabase | oid |
! relblocknumber | bigint |
isdirty | boolean |
View definition:
SELECT p.bufferid, p.relfilenode, p.reltablespace, p.reldatabase,
p.relblocknumber, p.isdirty
FROM pg_buffercache_pages() p(bufferid integer, relfilenode oid,
! reltablespace oid, reldatabase oid, relblocknumber bigint,
isdirty boolean);
regression=# SELECT c.relname, count(*) AS buffers
diff -Ncar pgsql.orig/contrib/pg_buffercache/pg_buffercache.sql.in pgsql/contrib/pg_buffercache/pg_buffercache.sql.in
*** pgsql.orig/contrib/pg_buffercache/pg_buffercache.sql.in Tue May 31 11:02:41 2005
--- pgsql/contrib/pg_buffercache/pg_buffercache.sql.in Tue May 31 09:15:03 2005
***************
*** 11,17 ****
CREATE VIEW pg_buffercache AS
SELECT P.* FROM pg_buffercache_pages() AS P
(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
! relblocknumber numeric(10), isdirty bool);
-- Don't want these to be available at public.
REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;
--- 11,17 ----
CREATE VIEW pg_buffercache AS
SELECT P.* FROM pg_buffercache_pages() AS P
(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
! relblocknumber int8, isdirty bool);
-- Don't want these to be available at public.
REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;
diff -Ncar pgsql.orig/contrib/pg_buffercache/pg_buffercache_pages.c pgsql/contrib/pg_buffercache/pg_buffercache_pages.c
*** pgsql.orig/contrib/pg_buffercache/pg_buffercache_pages.c Tue May 31 11:02:41 2005
--- pgsql/contrib/pg_buffercache/pg_buffercache_pages.c Tue May 31 11:23:46 2005
***************
*** 93,99 ****
TupleDescInitEntry(tupledesc, (AttrNumber) 4, "reldatabase",
OIDOID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber) 5, "relblockbumber",
! NUMERICOID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber) 6, "isdirty",
BOOLOID, -1, 0);
--- 93,99 ----
TupleDescInitEntry(tupledesc, (AttrNumber) 4, "reldatabase",
OIDOID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber) 5, "relblockbumber",
! INT8OID, -1, 0);
TupleDescInitEntry(tupledesc, (AttrNumber) 6, "isdirty",
BOOLOID, -1, 0);