From 96ccca15437cf137f988f5ac99096f7ccb8c0180 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Sun, 8 Jun 2008 22:00:48 +0000 Subject: [PATCH] Move BufferGetPageSize and BufferGetPage from bufpage.h to bufmgr.h. It is more logical that way, and also it reduces the amount of unnecessary includes in bufpage.h, which is widely used. Zdenek Kotala. My previous patch to bufpage.h should also have credited him as author, but I forgot (sorry about that). --- src/backend/access/gin/ginentrypage.c | 2 ++ src/backend/access/heap/heapam.c | 1 + src/backend/access/heap/hio.c | 2 +- src/backend/access/heap/pruneheap.c | 2 +- src/backend/access/heap/rewriteheap.c | 1 + src/backend/access/transam/xlog.c | 2 +- src/backend/access/transam/xlogutils.c | 2 +- src/backend/commands/analyze.c | 1 + src/backend/storage/buffer/bufmgr.c | 2 +- src/include/storage/bufmgr.h | 24 ++++++++++++++++++++++++ src/include/storage/bufpage.h | 24 ------------------------ 11 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c index 8630a6881a..5ee5024a94 100644 --- a/src/backend/access/gin/ginentrypage.c +++ b/src/backend/access/gin/ginentrypage.c @@ -13,8 +13,10 @@ */ #include "postgres.h" + #include "access/gin.h" #include "access/tuptoaster.h" +#include "storage/bufmgr.h" /* * forms tuple for entry tree. On leaf page, Index tuple has diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index c1afff3742..6c20b48cc4 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -52,6 +52,7 @@ #include "catalog/namespace.h" #include "miscadmin.h" #include "pgstat.h" +#include "storage/bufmgr.h" #include "storage/lmgr.h" #include "storage/procarray.h" #include "storage/smgr.h" diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 4da44db398..18103dd1d9 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -16,7 +16,7 @@ #include "postgres.h" #include "access/hio.h" -#include "storage/bufpage.h" +#include "storage/bufmgr.h" #include "storage/freespace.h" #include "storage/lmgr.h" diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 1b95ab67b9..50e61b3771 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -19,7 +19,7 @@ #include "access/transam.h" #include "miscadmin.h" #include "pgstat.h" -#include "storage/bufpage.h" +#include "storage/bufmgr.h" #include "storage/off.h" #include "utils/inval.h" #include "utils/tqual.h" diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c index 775c4e23bd..22cd90d1a6 100644 --- a/src/backend/access/heap/rewriteheap.c +++ b/src/backend/access/heap/rewriteheap.c @@ -106,6 +106,7 @@ #include "access/rewriteheap.h" #include "access/transam.h" #include "access/tuptoaster.h" +#include "storage/bufmgr.h" #include "storage/smgr.h" #include "utils/memutils.h" diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 58f16be591..0ceb9f579e 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -38,7 +38,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "postmaster/bgwriter.h" -#include "storage/bufpage.h" +#include "storage/bufmgr.h" #include "storage/fd.h" #include "storage/ipc.h" #include "storage/pmsignal.h" diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index 1561d4ce2e..ef441872b5 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -18,7 +18,7 @@ #include "postgres.h" #include "access/xlogutils.h" -#include "storage/bufpage.h" +#include "storage/bufmgr.h" #include "storage/smgr.h" #include "utils/hsearch.h" diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index c4d61a6100..1b2945ebd4 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -33,6 +33,7 @@ #include "parser/parse_relation.h" #include "pgstat.h" #include "postmaster/autovacuum.h" +#include "storage/bufmgr.h" #include "storage/proc.h" #include "storage/procarray.h" #include "utils/acl.h" diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index f098d1a307..10ebdf44cd 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -36,7 +36,7 @@ #include "miscadmin.h" #include "postmaster/bgwriter.h" #include "storage/buf_internals.h" -#include "storage/bufpage.h" +#include "storage/bufmgr.h" #include "storage/ipc.h" #include "storage/proc.h" #include "storage/smgr.h" diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 8ec57f2e93..153f28def4 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -15,6 +15,7 @@ #define BUFMGR_H #include "storage/buf.h" +#include "storage/bufpage.h" #include "utils/rel.h" typedef void *Block; @@ -114,6 +115,29 @@ extern PGDLLIMPORT int32 *LocalRefCount; (Block) (BufferBlocks + ((Size) ((buffer) - 1)) * BLCKSZ) \ ) +/* + * BufferGetPageSize + * Returns the page size within a buffer. + * + * Notes: + * Assumes buffer is valid. + * + * The buffer can be a raw disk block and need not contain a valid + * (formatted) disk page. + */ +/* XXX should dig out of buffer descriptor */ +#define BufferGetPageSize(buffer) \ +( \ + AssertMacro(BufferIsValid(buffer)), \ + (Size)BLCKSZ \ +) + +/* + * BufferGetPage + * Returns the page associated with a buffer. + */ +#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) + /* * prototypes for functions in bufmgr.c */ diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index a665c7cf6c..cabc48f68b 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -15,7 +15,6 @@ #define BUFPAGE_H #include "access/xlogdefs.h" -#include "storage/bufmgr.h" #include "storage/item.h" #include "storage/off.h" @@ -290,29 +289,6 @@ typedef PageHeaderData *PageHeader; (Item)(((char *)(page)) + ItemIdGetOffset(itemId)) \ ) -/* - * BufferGetPageSize - * Returns the page size within a buffer. - * - * Notes: - * Assumes buffer is valid. - * - * The buffer can be a raw disk block and need not contain a valid - * (formatted) disk page. - */ -/* XXX should dig out of buffer descriptor */ -#define BufferGetPageSize(buffer) \ -( \ - AssertMacro(BufferIsValid(buffer)), \ - (Size)BLCKSZ \ -) - -/* - * BufferGetPage - * Returns the page associated with a buffer. - */ -#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) - /* * PageGetMaxOffsetNumber * Returns the maximum offset number used by the given page. -- 2.39.5