summaryrefslogtreecommitdiff
path: root/src/include/storage/bufmgr.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/storage/bufmgr.h')
-rw-r--r--src/include/storage/bufmgr.h24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index cb8feda8bdf..04bc09e22c6 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.86 2004/08/29 05:06:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.87 2004/10/15 22:40:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,13 +51,14 @@ extern int32 *LocalRefCount;
* These routines are beaten on quite heavily, hence the macroization.
*/
-#define BAD_BUFFER_ID(bid) ((bid) < 1 || (bid) > NBuffers)
-
/*
* BufferIsValid
* True iff the given buffer number is valid (either as a shared
* or local buffer).
*
+ * This is not quite the inverse of the BufferIsInvalid() macro, since this
+ * adds sanity rangechecks on the buffer number.
+ *
* Note: For a long time this was defined the same as BufferIsPinned,
* that is it would say False if you didn't hold a pin on the buffer.
* I believe this was bogus and served only to mask logic errors.
@@ -66,10 +67,9 @@ extern int32 *LocalRefCount;
*/
#define BufferIsValid(bufnum) \
( \
- BufferIsLocal(bufnum) ? \
- ((bufnum) >= -NLocBuffer) \
- : \
- (! BAD_BUFFER_ID(bufnum)) \
+ (bufnum) != InvalidBuffer && \
+ (bufnum) >= -NLocBuffer && \
+ (bufnum) <= NBuffers \
)
/*
@@ -81,15 +81,13 @@ extern int32 *LocalRefCount;
*/
#define BufferIsPinned(bufnum) \
( \
- BufferIsLocal(bufnum) ? \
- ((bufnum) >= -NLocBuffer && LocalRefCount[-(bufnum) - 1] > 0) \
+ !BufferIsValid(bufnum) ? \
+ false \
: \
- ( \
- BAD_BUFFER_ID(bufnum) ? \
- false \
+ BufferIsLocal(bufnum) ? \
+ (LocalRefCount[-(bufnum) - 1] > 0) \
: \
(PrivateRefCount[(bufnum) - 1] > 0) \
- ) \
)
/*