aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/valid.h45
-rw-r--r--src/include/storage/bufmgr.h24
-rw-r--r--src/include/utils/tqual.h34
3 files changed, 42 insertions, 61 deletions
diff --git a/src/include/access/valid.h b/src/include/access/valid.h
index 785ae80b243..62a547a181a 100644
--- a/src/include/access/valid.h
+++ b/src/include/access/valid.h
@@ -7,20 +7,18 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/valid.h,v 1.34 2004/08/29 04:13:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/valid.h,v 1.35 2004/10/15 22:40:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VALID_H
#define VALID_H
-/* ----------------
+/*
* HeapKeyTest
*
- * Test a heap tuple with respect to a scan key.
- * ----------------
+ * Test a heap tuple to see if it satisfies a scan key.
*/
-
#define HeapKeyTest(tuple, \
tupdesc, \
nkeys, \
@@ -28,9 +26,7 @@
result) \
do \
{ \
-/* We use underscores to protect the variable passed in as parameters */ \
-/* We use two underscore here because this macro is included in the \
- macro below */ \
+ /* Use underscores to protect the variables passed in as parameters */ \
int __cur_nkeys = (nkeys); \
ScanKey __cur_keys = (keys); \
\
@@ -41,6 +37,12 @@ do \
bool __isnull; \
Datum __test; \
\
+ if (__cur_keys->sk_flags & SK_ISNULL) \
+ { \
+ (result) = false; \
+ break; \
+ } \
+ \
__atp = heap_getattr((tuple), \
__cur_keys->sk_attno, \
(tupdesc), \
@@ -48,13 +50,6 @@ do \
\
if (__isnull) \
{ \
- /* XXX eventually should check if SK_ISNULL */ \
- (result) = false; \
- break; \
- } \
- \
- if (__cur_keys->sk_flags & SK_ISNULL) \
- { \
(result) = false; \
break; \
} \
@@ -70,7 +65,7 @@ do \
} \
} while (0)
-/* ----------------
+/*
* HeapTupleSatisfies
*
* res is set TRUE if the HeapTuple satisfies the timequal and keytest,
@@ -83,7 +78,6 @@ do \
* least likely to fail, too. we should really add the time qual test to
* the restriction and optimize it in the normal way. this has interactions
* with joey's expensive function work.
- * ----------------
*/
#define HeapTupleSatisfies(tuple, \
relation, \
@@ -95,24 +89,13 @@ do \
res) \
do \
{ \
-/* We use underscores to protect the variable passed in as parameters */ \
if ((key) != NULL) \
- HeapKeyTest(tuple, RelationGetDescr(relation), \
- (nKeys), (key), (res)); \
+ HeapKeyTest(tuple, RelationGetDescr(relation), nKeys, key, res); \
else \
(res) = true; \
\
- if (res) \
- { \
- if ((relation)->rd_rel->relkind != RELKIND_UNCATALOGED) \
- { \
- uint16 _infomask = (tuple)->t_data->t_infomask; \
- \
- (res) = HeapTupleSatisfiesVisibility((tuple), (snapshot)); \
- if ((tuple)->t_data->t_infomask != _infomask) \
- SetBufferCommitInfoNeedsSave(buffer); \
- } \
- } \
+ if ((res) && (relation)->rd_rel->relkind != RELKIND_UNCATALOGED) \
+ (res) = HeapTupleSatisfiesVisibility(tuple, snapshot, buffer); \
} while (0)
#endif /* VALID_H */
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) \
- ) \
)
/*
diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h
index 0854fa793a1..8aa6ed2c678 100644
--- a/src/include/utils/tqual.h
+++ b/src/include/utils/tqual.h
@@ -1,14 +1,14 @@
/*-------------------------------------------------------------------------
*
* tqual.h
- * POSTGRES "time" qualification definitions, ie, tuple visibility rules.
+ * POSTGRES "time qualification" definitions, ie, tuple visibility rules.
*
* Should be moved/renamed... - vadim 07/28/98
*
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.53 2004/09/16 18:35:23 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.54 2004/10/15 22:40:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include "access/htup.h"
#include "access/xact.h"
+#include "storage/buf.h"
/*
@@ -72,23 +73,23 @@ extern TransactionId RecentGlobalXmin;
* Assumes heap tuple is valid.
* Beware of multiple evaluations of snapshot argument.
*/
-#define HeapTupleSatisfiesVisibility(tuple, snapshot) \
+#define HeapTupleSatisfiesVisibility(tuple, snapshot, buffer) \
((snapshot) == SnapshotNow ? \
- HeapTupleSatisfiesNow((tuple)->t_data) \
+ HeapTupleSatisfiesNow((tuple)->t_data, buffer) \
: \
((snapshot) == SnapshotSelf ? \
- HeapTupleSatisfiesItself((tuple)->t_data) \
+ HeapTupleSatisfiesItself((tuple)->t_data, buffer) \
: \
((snapshot) == SnapshotAny ? \
true \
: \
((snapshot) == SnapshotToast ? \
- HeapTupleSatisfiesToast((tuple)->t_data) \
+ HeapTupleSatisfiesToast((tuple)->t_data, buffer) \
: \
((snapshot) == SnapshotDirty ? \
- HeapTupleSatisfiesDirty((tuple)->t_data) \
+ HeapTupleSatisfiesDirty((tuple)->t_data, buffer) \
: \
- HeapTupleSatisfiesSnapshot((tuple)->t_data, snapshot) \
+ HeapTupleSatisfiesSnapshot((tuple)->t_data, snapshot, buffer) \
) \
) \
) \
@@ -108,21 +109,20 @@ typedef enum
HEAPTUPLE_DEAD, /* tuple is dead and deletable */
HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
- HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in
- * progress */
+ HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */
} HTSV_Result;
-extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple);
-extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple);
-extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple);
-extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple);
+extern bool HeapTupleSatisfiesItself(HeapTupleHeader tuple, Buffer buffer);
+extern bool HeapTupleSatisfiesNow(HeapTupleHeader tuple, Buffer buffer);
+extern bool HeapTupleSatisfiesDirty(HeapTupleHeader tuple, Buffer buffer);
+extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple, Buffer buffer);
extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
- Snapshot snapshot);
+ Snapshot snapshot, Buffer buffer);
extern int HeapTupleSatisfiesUpdate(HeapTupleHeader tuple,
- CommandId curcid);
+ CommandId curcid, Buffer buffer);
extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
- TransactionId OldestXmin);
+ TransactionId OldestXmin, Buffer buffer);
extern Snapshot GetTransactionSnapshot(void);
extern Snapshot GetLatestSnapshot(void);