Index: src/backend/storage/buffer/bufmgr.c =================================================================== RCS file: /var/lib/cvs/pgsql/src/backend/storage/buffer/bufmgr.c,v retrieving revision 1.122 diff -c -r1.122 bufmgr.c *** src/backend/storage/buffer/bufmgr.c 6 Mar 2002 06:10:02 -0000 1.122 --- src/backend/storage/buffer/bufmgr.c 2 Apr 2002 00:46:50 -0000 *************** *** 1016,1040 **** } /* - * BufferGetBlockNumber - * Returns the block number associated with a buffer. - * - * Note: - * Assumes that the buffer is valid and pinned, else the - * value may be obsolete immediately... - */ - BlockNumber - BufferGetBlockNumber(Buffer buffer) - { - Assert(BufferIsValid(buffer)); - - if (BufferIsLocal(buffer)) - return LocalBufferDescriptors[-buffer - 1].tag.blockNum; - else - return BufferDescriptors[buffer - 1].tag.blockNum; - } - - /* * BufferReplace * * Write out the buffer corresponding to 'bufHdr' --- 1016,1021 ---- Index: src/include/storage/buf.h =================================================================== RCS file: /var/lib/cvs/pgsql/src/include/storage/buf.h,v retrieving revision 1.12 diff -c -r1.12 buf.h *** src/include/storage/buf.h 5 Nov 2001 17:46:35 -0000 1.12 --- src/include/storage/buf.h 2 Apr 2002 00:46:50 -0000 *************** *** 36,47 **** */ #define BufferIsLocal(buffer) ((buffer) < 0) - /* - * If NO_BUFFERISVALID is defined, all error checking using BufferIsValid() - * are suppressed. Decision-making using BufferIsValid is not affected. - * This should be set only if one is sure there will be no errors. - * - plai 9/10/90 - */ - #undef NO_BUFFERISVALID - #endif /* BUF_H */ --- 36,39 ---- Index: src/include/storage/bufmgr.h =================================================================== RCS file: /var/lib/cvs/pgsql/src/include/storage/bufmgr.h,v retrieving revision 1.57 diff -c -r1.57 bufmgr.h *** src/include/storage/bufmgr.h 10 Nov 2001 23:51:14 -0000 1.57 --- src/include/storage/bufmgr.h 2 Apr 2002 00:46:50 -0000 *************** *** 16,21 **** --- 16,22 ---- #include "access/xlogdefs.h" #include "storage/buf.h" + #include "storage/buf_internals.h" #include "storage/lock.h" #include "storage/relfilenode.h" #include "utils/rel.h" *************** *** 33,38 **** --- 34,41 ---- extern int NLocBuffer; extern Block *LocalBufferBlockPointers; extern long *LocalRefCount; + extern BufferDesc *LocalBufferDescriptors; + extern BufferDesc *BufferDescriptors; /* special pageno for bget */ #define P_NEW InvalidBlockNumber /* grow the file to get a new page */ *************** *** 44,56 **** #define BUFFER_LOCK_SHARE 1 #define BUFFER_LOCK_EXCLUSIVE 2 - - /********************************************************************** - - the rest is function defns in the bufmgr that are externally callable - - **********************************************************************/ - /* * These routines are beaten on quite heavily, hence the macroization. */ --- 47,52 ---- *************** *** 150,155 **** --- 146,167 ---- BufferBlockPointers[(buffer) - 1] \ ) + /* + * BufferGetBlockNumber + * Returns the block number associated with a buffer. + * + * Note: + * Assumes that the buffer is valid and pinned, else the + * value may be obsolete immediately... + */ + #define BufferGetBlockNumber(buffer) \ + ( \ + AssertMacro(BufferIsPinned(buffer)), \ + BufferIsLocal(buffer) ? \ + LocalBufferDescriptors[-(buffer) -1].tag.blockNum \ + : \ + BufferDescriptors[(buffer) - 1].tag.blockNum \ + ) /* * prototypes for functions in bufmgr.c *************** *** 169,175 **** extern void ResetBufferPool(bool isCommit); extern bool BufferPoolCheckLeak(void); extern void FlushBufferPool(void); - extern BlockNumber BufferGetBlockNumber(Buffer buffer); extern BlockNumber RelationGetNumberOfBlocks(Relation relation); extern int FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock); extern void DropRelationBuffers(Relation rel); --- 181,186 ----