aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/nbtree')
-rw-r--r--src/backend/access/nbtree/nbtinsert.c11
-rw-r--r--src/backend/access/nbtree/nbtsearch.c36
-rw-r--r--src/backend/access/nbtree/nbtutils.c38
3 files changed, 43 insertions, 42 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index 975b53d658a..0ec7af2cf96 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.57 2000/04/12 17:14:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.58 2000/05/30 04:24:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1398,8 +1398,8 @@ _bt_tuplecompare(Relation rel,
}
else
{
- compare = (int32) FMGR_PTR2(&entry->sk_func,
- attrDatum1, attrDatum2);
+ compare = DatumGetInt32(FunctionCall2(&entry->sk_func,
+ attrDatum1, attrDatum2));
}
if (compare != 0)
@@ -1520,7 +1520,7 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
IndexTuple itup;
ScanKey entry;
AttrNumber attno;
- long result;
+ int32 result;
int i;
bool null;
@@ -1538,7 +1538,8 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum,
if (entry->sk_flags & SK_ISNULL || null)
return false;
- result = (long) FMGR_PTR2(&entry->sk_func, entry->sk_argument, datum);
+ result = DatumGetInt32(FunctionCall2(&entry->sk_func,
+ entry->sk_argument, datum));
if (result != 0)
return false;
}
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index cad117e5e61..54c15b2f6a9 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.59 2000/04/12 17:14:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.60 2000/05/30 04:24:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,8 +22,8 @@
static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey,
Buffer *bufP, BTStack stack_in);
-static int _bt_compare(Relation rel, TupleDesc itupdesc, Page page,
- int keysz, ScanKey scankey, OffsetNumber offnum);
+static int32 _bt_compare(Relation rel, TupleDesc itupdesc, Page page,
+ int keysz, ScanKey scankey, OffsetNumber offnum);
static bool
_bt_twostep(IndexScanDesc scan, Buffer *bufP, ScanDirection dir);
static RetrieveIndexResult
@@ -277,14 +277,12 @@ _bt_skeycmp(Relation rel,
ScanKey entry = &scankey[i - 1];
Datum attrDatum;
bool isNull;
- Datum keyDatum;
Assert(entry->sk_attno == i);
attrDatum = index_getattr(indexTuple,
entry->sk_attno,
tupDes,
&isNull);
- keyDatum = entry->sk_argument;
/* see comments about NULLs handling in btbuild */
if (entry->sk_flags & SK_ISNULL) /* key is NULL */
@@ -299,7 +297,9 @@ _bt_skeycmp(Relation rel,
compare = -1; /* not-NULL key "<" NULL datum */
}
else
- compare = (int32) FMGR_PTR2(&entry->sk_func, keyDatum, attrDatum);
+ compare = DatumGetInt32(FunctionCall2(&entry->sk_func,
+ entry->sk_argument,
+ attrDatum));
if (compare != 0)
break; /* done when we find unequal attributes */
@@ -353,7 +353,7 @@ _bt_binsrch(Relation rel,
high;
bool haveEq;
int natts = rel->rd_rel->relnatts;
- int result;
+ int32 result;
itupdesc = RelationGetDescr(rel);
page = BufferGetPage(buf);
@@ -474,9 +474,9 @@ _bt_binsrch(Relation rel,
* _bt_compare() -- Compare scankey to a particular tuple on the page.
*
* This routine returns:
- * -1 if scankey < tuple at offnum;
+ * <0 if scankey < tuple at offnum;
* 0 if scankey == tuple at offnum;
- * +1 if scankey > tuple at offnum.
+ * >0 if scankey > tuple at offnum.
*
* -- Old comments:
* In order to avoid having to propagate changes up the tree any time
@@ -492,7 +492,7 @@ _bt_binsrch(Relation rel,
* but not "any time a new min key is inserted" (see _bt_insertonpg).
* - vadim 12/05/96
*/
-static int
+static int32
_bt_compare(Relation rel,
TupleDesc itupdesc,
Page page,
@@ -506,7 +506,7 @@ _bt_compare(Relation rel,
BTPageOpaque opaque;
ScanKey entry;
AttrNumber attno;
- int result;
+ int32 result;
int i;
bool null;
@@ -573,8 +573,6 @@ _bt_compare(Relation rel,
for (i = 1; i <= keysz; i++)
{
- long tmpres;
-
entry = &scankey[i - 1];
attno = entry->sk_attno;
datum = index_getattr(itup, attno, itupdesc, &null);
@@ -583,17 +581,17 @@ _bt_compare(Relation rel,
if (entry->sk_flags & SK_ISNULL) /* key is NULL */
{
if (null)
- tmpres = (long) 0; /* NULL "=" NULL */
+ result = 0; /* NULL "=" NULL */
else
- tmpres = (long) 1; /* NULL ">" NOT_NULL */
+ result = 1; /* NULL ">" NOT_NULL */
}
else if (null) /* key is NOT_NULL and item is NULL */
{
- tmpres = (long) -1; /* NOT_NULL "<" NULL */
+ result = -1; /* NOT_NULL "<" NULL */
}
else
- tmpres = (long) FMGR_PTR2(&entry->sk_func, entry->sk_argument, datum);
- result = tmpres;
+ result = DatumGetInt32(FunctionCall2(&entry->sk_func,
+ entry->sk_argument, datum));
/* if the keys are unequal, return the difference */
if (result != 0)
@@ -697,7 +695,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
StrategyNumber strat;
RetrieveIndexResult res;
RegProcedure proc;
- int result;
+ int32 result;
BTScanOpaque so;
Size keysok;
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 38b152e61b2..5853267670f 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.36 2000/04/12 17:14:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.37 2000/05/30 04:24:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -133,7 +133,7 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
ScanKeyData *cur;
StrategyMap map;
int nbytes;
- long test;
+ Datum test;
int i,
j;
int init[BTMaxStrategyNumber + 1];
@@ -212,8 +212,9 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
if (j == (BTEqualStrategyNumber - 1) || init[j] == 0)
continue;
chk = &xform[j];
- test = (long) fmgr(chk->sk_procedure, eq->sk_argument, chk->sk_argument);
- if (!test)
+ test = OidFunctionCall2(chk->sk_procedure,
+ eq->sk_argument, chk->sk_argument);
+ if (!DatumGetBool(test))
so->qual_ok = 0;
}
init[BTLessStrategyNumber - 1] = 0;
@@ -241,8 +242,9 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
* anyway. The transform maps are hard-coded, and can't
* be initialized in the correct way.
*/
- test = (long) fmgr(le->sk_procedure, lt->sk_argument, le->sk_argument);
- if (test)
+ test = OidFunctionCall2(le->sk_procedure,
+ lt->sk_argument, le->sk_argument);
+ if (DatumGetBool(test))
init[BTLessEqualStrategyNumber - 1] = 0;
else
init[BTLessStrategyNumber - 1] = 0;
@@ -259,8 +261,9 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
ge = &xform[BTGreaterEqualStrategyNumber - 1];
/* see note above on function cache */
- test = (long) fmgr(ge->sk_procedure, gt->sk_argument, ge->sk_argument);
- if (test)
+ test = OidFunctionCall2(ge->sk_procedure,
+ gt->sk_argument, ge->sk_argument);
+ if (DatumGetBool(test))
init[BTGreaterEqualStrategyNumber - 1] = 0;
else
init[BTGreaterStrategyNumber - 1] = 0;
@@ -298,8 +301,9 @@ _bt_orderkeys(Relation relation, BTScanOpaque so)
if (init[j])
{
/* yup, use the appropriate value */
- test = (long) FMGR_PTR2(&cur->sk_func, cur->sk_argument, xform[j].sk_argument);
- if (test)
+ test = FunctionCall2(&cur->sk_func,
+ cur->sk_argument, xform[j].sk_argument);
+ if (DatumGetBool(test))
xform[j].sk_argument = cur->sk_argument;
else if (j == (BTEqualStrategyNumber - 1))
so->qual_ok = 0;/* key == a && key == b, but a != b */
@@ -385,7 +389,7 @@ _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size *keysok)
ScanKey key;
Datum datum;
bool isNull;
- int test;
+ Datum test;
*keysok = 0;
if (keysz == 0)
@@ -415,18 +419,16 @@ _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size *keysok)
if (key[0].sk_flags & SK_COMMUTE)
{
- test = (int) (*fmgr_faddr(&key[0].sk_func))
- (DatumGetPointer(key[0].sk_argument),
- datum);
+ test = FunctionCall2(&key[0].sk_func,
+ key[0].sk_argument, datum);
}
else
{
- test = (int) (*fmgr_faddr(&key[0].sk_func))
- (datum,
- DatumGetPointer(key[0].sk_argument));
+ test = FunctionCall2(&key[0].sk_func,
+ datum, key[0].sk_argument);
}
- if (!test == !(key[0].sk_flags & SK_NEGATE))
+ if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
return false;
keysz -= 1;