aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/common/heapvalid.c130
-rw-r--r--src/backend/access/heap/heapam.c35
2 files changed, 21 insertions, 144 deletions
diff --git a/src/backend/access/common/heapvalid.c b/src/backend/access/common/heapvalid.c
index da2e93a30bc..22d62afcd3d 100644
--- a/src/backend/access/common/heapvalid.c
+++ b/src/backend/access/common/heapvalid.c
@@ -7,143 +7,15 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.19 1997/09/12 04:07:09 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.20 1997/09/18 14:19:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <postgres.h>
-#include <fmgr.h>
#include <access/heapam.h>
-#include <access/valid.h>
#include <access/xact.h>
-#include <storage/bufpage.h>
-#include <utils/rel.h>
-#include <utils/tqual.h>
-#include <storage/bufmgr.h>
-#include <utils/builtins.h>
-
-/* ----------------
- * heap_keytest
- *
- * Test a heap tuple with respect to a scan key.
- * ----------------
- */
-bool
-heap_keytest(HeapTuple t,
- TupleDesc tupdesc,
- int nkeys,
- ScanKey keys)
-{
- bool isnull;
- Datum atp;
- int test;
-
- for (; nkeys--; keys++)
- {
- atp = heap_getattr(t, InvalidBuffer,
- keys->sk_attno,
- tupdesc,
- &isnull);
-
- if (isnull)
- /* XXX eventually should check if SK_ISNULL */
- return false;
-
- if (keys->sk_flags & SK_ISNULL)
- {
- return (false);
- }
-
- if (keys->sk_func == (func_ptr) oideq) /* optimization */
- test = (keys->sk_argument == atp);
- else if (keys->sk_flags & SK_COMMUTE)
- test = (long) FMGR_PTR2(keys->sk_func, keys->sk_procedure,
- keys->sk_argument, atp);
- else
- test = (long) FMGR_PTR2(keys->sk_func, keys->sk_procedure,
- atp, keys->sk_argument);
-
- if (!test == !(keys->sk_flags & SK_NEGATE))
- return false;
- }
-
- return true;
-}
-
-/* ----------------
- * heap_tuple_satisfies
- *
- * Returns a valid HeapTuple if it satisfies the timequal and keytest.
- * Returns NULL otherwise. Used to be heap_satisifies (sic) which
- * returned a boolean. It now returns a tuple so that we can avoid doing two
- * PageGetItem's per tuple.
- *
- * Complete check of validity including LP_CTUP and keytest.
- * This should perhaps be combined with valid somehow in the
- * future. (Also, additional rule tests/time range tests.)
- *
- * on 8/21/92 mao says: i rearranged the tests here to do keytest before
- * SatisfiesTimeQual. profiling indicated that even for vacuumed relations,
- * time qual checking was more expensive than key testing. time qual is
- * 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.
- * ----------------
- */
-HeapTuple
-heap_tuple_satisfies(ItemId itemId,
- Relation relation,
- Buffer buffer,
- PageHeader disk_page,
- TimeQual qual,
- int nKeys,
- ScanKey key)
-{
- HeapTuple tuple,
- result;
- bool res;
- TransactionId old_tmin,
- old_tmax;
-
- if (!ItemIdIsUsed(itemId))
- return NULL;
-
- tuple = (HeapTuple) PageGetItem((Page) disk_page, itemId);
-
- if (key != NULL)
- res = heap_keytest(tuple, RelationGetTupleDescriptor(relation),
- nKeys, key);
- else
- res = TRUE;
-
- result = (HeapTuple) NULL;
- if (res)
- {
- if (relation->rd_rel->relkind == RELKIND_UNCATALOGED)
- {
- result = tuple;
- }
- else
- {
- old_tmin = tuple->t_tmin;
- old_tmax = tuple->t_tmax;
- res = HeapTupleSatisfiesTimeQual(tuple, qual);
- if (tuple->t_tmin != old_tmin ||
- tuple->t_tmax != old_tmax)
- {
- SetBufferCommitInfoNeedsSave(buffer);
- }
- if (res)
- {
- result = tuple;
- }
- }
- }
-
- return result;
-}
/*
* TupleUpdatedByCurXactAndCmd() -- Returns true if this tuple has
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 19bdf5b34ce..2537e7e777c 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.19 1997/09/08 21:40:57 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.20 1997/09/18 14:19:30 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -429,8 +429,9 @@ heapgettup(Relation relation,
* if current tuple qualifies, return it.
* ----------------
*/
- if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp,
- timeQual, nkeys, key)) != NULL)
+ HeapTupleSatisfies(lpp, relation, *b, (PageHeader) dp,
+ timeQual, nkeys, key, rtup);
+ if (rtup != NULL)
{
ItemPointer iptr = &(rtup->t_ctid);
@@ -1092,8 +1093,8 @@ heap_fetch(Relation relation,
* ----------------
*/
- tuple = heap_tuple_satisfies(lp, relation, buffer, dp,
- timeQual, 0, (ScanKey) NULL);
+ HeapTupleSatisfies(lp, relation, buffer, dp,
+ timeQual, 0, (ScanKey) NULL, tuple);
if (tuple == NULL)
{
@@ -1257,8 +1258,9 @@ heap_delete(Relation relation, ItemPointer tid)
* check that we're deleteing a valid item
* ----------------
*/
- if (!(tp = heap_tuple_satisfies(lp, relation, b, dp,
- NowTimeQual, 0, (ScanKey) NULL)))
+ HeapTupleSatisfies(lp, relation, b, dp,
+ NowTimeQual, 0, (ScanKey) NULL, tp);
+ if (!tp)
{
/* XXX call something else */
@@ -1317,7 +1319,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
HeapTuple tp;
Page dp;
Buffer buffer;
-
+ HeapTuple tuple;
+
/* ----------------
* increment access statistics
* ----------------
@@ -1388,13 +1391,15 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
* xact, we only want to flag the 'non-functional' NOTICE. -mer
* ----------------
*/
- if (!heap_tuple_satisfies(lp,
- relation,
- buffer,
- (PageHeader) dp,
- NowTimeQual,
- 0,
- (ScanKey) NULL))
+ HeapTupleSatisfies(lp,
+ relation,
+ buffer,
+ (PageHeader) dp,
+ NowTimeQual,
+ 0,
+ (ScanKey) NULL,
+ tuple);
+ if (!tuple)
{
ReleaseBuffer(buffer);
elog(WARN, "heap_replace: (am)invalid otid");