mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Third round of fmgr updates: eliminate calls using fmgr() and
fmgr_faddr() in favor of new-style calls. Lots of cleanup of sloppy casts to use XXXGetDatum and DatumGetXXX ...
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.24 2000/01/26 05:55:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.25 2000/05/30 04:24:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ index_keytest(IndexTuple tuple,
|
||||
{
|
||||
bool isNull;
|
||||
Datum datum;
|
||||
int test;
|
||||
Datum test;
|
||||
|
||||
IncrIndexProcessed();
|
||||
|
||||
@@ -62,18 +62,16 @@ index_keytest(IndexTuple tuple,
|
||||
|
||||
if (key[0].sk_flags & SK_COMMUTE)
|
||||
{
|
||||
test = (*(fmgr_faddr(&key[0].sk_func)))
|
||||
(DatumGetPointer(key[0].sk_argument),
|
||||
datum) ? 1 : 0;
|
||||
test = FunctionCall2(&key[0].sk_func,
|
||||
key[0].sk_argument, datum);
|
||||
}
|
||||
else
|
||||
{
|
||||
test = (*(fmgr_faddr(&key[0].sk_func)))
|
||||
(datum,
|
||||
DatumGetPointer(key[0].sk_argument)) ? 1 : 0;
|
||||
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;
|
||||
|
||||
scanKeySize -= 1;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.52 2000/01/26 05:55:53 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.53 2000/05/30 04:24:27 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -206,8 +206,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
|
||||
continue;
|
||||
if (OidIsValid(thisState->typoutput))
|
||||
{
|
||||
outputstr = (char *) (*fmgr_faddr(&thisState->finfo))
|
||||
(attr, thisState->typelem, typeinfo->attrs[i]->atttypmod);
|
||||
outputstr = DatumGetCString(FunctionCall3(&thisState->finfo,
|
||||
attr,
|
||||
ObjectIdGetDatum(thisState->typelem),
|
||||
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
|
||||
pq_sendcountedtext(&buf, outputstr, strlen(outputstr));
|
||||
pfree(outputstr);
|
||||
}
|
||||
@@ -295,8 +297,10 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
|
||||
if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
|
||||
&typoutput, &typelem))
|
||||
{
|
||||
value = fmgr(typoutput, attr, typelem,
|
||||
typeinfo->attrs[i]->atttypmod);
|
||||
value = DatumGetCString(OidFunctionCall3(typoutput,
|
||||
attr,
|
||||
ObjectIdGetDatum(typelem),
|
||||
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
|
||||
printatt((unsigned) i + 1, typeinfo->attrs[i], value);
|
||||
pfree(value);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.54 2000/05/30 00:49:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.55 2000/05/30 04:24:28 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -551,10 +551,16 @@ gistAdjustKeys(Relation r,
|
||||
ev1p = &((GISTENTRY *) VARDATA(evec))[1];
|
||||
|
||||
/* form union of decompressed entries */
|
||||
datum = (*fmgr_faddr(&giststate->unionFn)) (evec, &datumsize);
|
||||
datum = (char *)
|
||||
DatumGetPointer(FunctionCall2(&giststate->unionFn,
|
||||
PointerGetDatum(evec),
|
||||
PointerGetDatum(&datumsize)));
|
||||
|
||||
/* did union leave decompressed version of oldud unchanged? */
|
||||
(*fmgr_faddr(&giststate->equalFn)) (ev0p->pred, datum, &result);
|
||||
FunctionCall3(&giststate->equalFn,
|
||||
PointerGetDatum(ev0p->pred),
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(&result));
|
||||
if (!result)
|
||||
{
|
||||
TupleDesc td = RelationGetDescr(r);
|
||||
@@ -727,7 +733,9 @@ gistSplit(Relation r,
|
||||
VARSIZE(entryvec) = (maxoff + 2) * sizeof(GISTENTRY) + VARHDRSZ;
|
||||
|
||||
/* now let the user-defined picksplit function set up the split vector */
|
||||
(*fmgr_faddr(&giststate->picksplitFn)) (entryvec, &v);
|
||||
FunctionCall2(&giststate->picksplitFn,
|
||||
PointerGetDatum(entryvec),
|
||||
PointerGetDatum(&v));
|
||||
|
||||
/* compress ldatum and rdatum */
|
||||
gistcentryinit(giststate, &tmpentry, v.spl_ldatum, (Relation) NULL,
|
||||
@@ -1054,7 +1062,10 @@ gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
|
||||
size = IndexTupleSize(datum) - sizeof(IndexTupleData);
|
||||
datum += sizeof(IndexTupleData);
|
||||
gistdentryinit(giststate, &entry, datum, r, p, i, size, FALSE);
|
||||
(*fmgr_faddr(&giststate->penaltyFn)) (&entry, &identry, &usize);
|
||||
FunctionCall3(&giststate->penaltyFn,
|
||||
PointerGetDatum(&entry),
|
||||
PointerGetDatum(&identry),
|
||||
PointerGetDatum(&usize));
|
||||
if (which_grow < 0 || usize < which_grow)
|
||||
{
|
||||
which = i;
|
||||
@@ -1237,7 +1248,9 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
|
||||
gistentryinit(*e, pr, r, pg, o, b, l);
|
||||
if (giststate->haskeytype)
|
||||
{
|
||||
dep = (GISTENTRY *) ((*fmgr_faddr(&giststate->decompressFn)) (e));
|
||||
dep = (GISTENTRY *)
|
||||
DatumGetPointer(FunctionCall1(&giststate->decompressFn,
|
||||
PointerGetDatum(e)));
|
||||
gistentryinit(*e, dep->pred, dep->rel, dep->page, dep->offset, dep->bytes,
|
||||
dep->leafkey);
|
||||
if (dep != e)
|
||||
@@ -1258,7 +1271,9 @@ gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
|
||||
gistentryinit(*e, pr, r, pg, o, b, l);
|
||||
if (giststate->haskeytype)
|
||||
{
|
||||
cep = (GISTENTRY *) ((*fmgr_faddr(&giststate->compressFn)) (e));
|
||||
cep = (GISTENTRY *)
|
||||
DatumGetPointer(FunctionCall1(&giststate->compressFn,
|
||||
PointerGetDatum(e)));
|
||||
gistentryinit(*e, cep->pred, cep->rel, cep->page, cep->offset, cep->bytes,
|
||||
cep->leafkey);
|
||||
if (cep != e)
|
||||
|
||||
@@ -227,7 +227,7 @@ gistindex_keytest(IndexTuple tuple,
|
||||
{
|
||||
bool isNull;
|
||||
Datum datum;
|
||||
int test;
|
||||
Datum test;
|
||||
GISTENTRY de;
|
||||
|
||||
IncrIndexProcessed();
|
||||
@@ -251,19 +251,20 @@ gistindex_keytest(IndexTuple tuple,
|
||||
|
||||
if (key[0].sk_flags & SK_COMMUTE)
|
||||
{
|
||||
test = (*fmgr_faddr(&key[0].sk_func))
|
||||
(DatumGetPointer(key[0].sk_argument),
|
||||
&de, key[0].sk_procedure) ? 1 : 0;
|
||||
test = FunctionCall3(&key[0].sk_func,
|
||||
key[0].sk_argument,
|
||||
PointerGetDatum(&de),
|
||||
ObjectIdGetDatum(key[0].sk_procedure));
|
||||
}
|
||||
else
|
||||
{
|
||||
test = (*fmgr_faddr(&key[0].sk_func))
|
||||
(&de,
|
||||
DatumGetPointer(key[0].sk_argument),
|
||||
key[0].sk_procedure) ? 1 : 0;
|
||||
test = FunctionCall3(&key[0].sk_func,
|
||||
PointerGetDatum(&de),
|
||||
key[0].sk_argument,
|
||||
ObjectIdGetDatum(key[0].sk_procedure));
|
||||
}
|
||||
|
||||
if (!test == !(key[0].sk_flags & SK_NEGATE))
|
||||
if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
|
||||
return false;
|
||||
|
||||
scanKeySize -= 1;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.23 2000/01/26 05:55:55 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.24 2000/05/30 04:24:31 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -91,10 +91,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key)
|
||||
{
|
||||
uint32 n;
|
||||
Bucket bucket;
|
||||
RegProcedure proc;
|
||||
|
||||
proc = metap->hashm_procid;
|
||||
n = (uint32) fmgr(proc, key);
|
||||
n = DatumGetUInt32(OidFunctionCall1(metap->hashm_procid, key));
|
||||
bucket = n & metap->hashm_highmask;
|
||||
if (bucket > metap->hashm_maxbucket)
|
||||
bucket = bucket & metap->hashm_lowmask;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.43 2000/05/28 17:55:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.44 2000/05/30 04:24:32 tgl Exp $
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
* index_open - open an index relation by relationId
|
||||
@@ -195,7 +195,13 @@ index_insert(Relation relation,
|
||||
* ----------------
|
||||
*/
|
||||
specificResult = (InsertIndexResult)
|
||||
fmgr(procedure, relation, datum, nulls, heap_t_ctid, heapRel, NULL);
|
||||
DatumGetPointer(OidFunctionCall6(procedure,
|
||||
PointerGetDatum(relation),
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(nulls),
|
||||
PointerGetDatum(heap_t_ctid),
|
||||
PointerGetDatum(heapRel),
|
||||
PointerGetDatum(NULL)));
|
||||
|
||||
/* must be pfree'ed */
|
||||
return specificResult;
|
||||
@@ -213,7 +219,9 @@ index_delete(Relation relation, ItemPointer indexItem)
|
||||
RELATION_CHECKS;
|
||||
GET_REL_PROCEDURE(delete, amdelete);
|
||||
|
||||
fmgr(procedure, relation, indexItem);
|
||||
OidFunctionCall2(procedure,
|
||||
PointerGetDatum(relation),
|
||||
PointerGetDatum(indexItem));
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -245,7 +253,11 @@ index_beginscan(Relation relation,
|
||||
LockRelation(relation, AccessShareLock);
|
||||
|
||||
scandesc = (IndexScanDesc)
|
||||
fmgr(procedure, relation, scanFromEnd, numberOfKeys, key);
|
||||
DatumGetPointer(OidFunctionCall4(procedure,
|
||||
PointerGetDatum(relation),
|
||||
BoolGetDatum(scanFromEnd),
|
||||
UInt16GetDatum(numberOfKeys),
|
||||
PointerGetDatum(key)));
|
||||
|
||||
return scandesc;
|
||||
}
|
||||
@@ -262,7 +274,10 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
|
||||
SCAN_CHECKS;
|
||||
GET_SCAN_PROCEDURE(rescan, amrescan);
|
||||
|
||||
fmgr(procedure, scan, scanFromEnd, key);
|
||||
OidFunctionCall3(procedure,
|
||||
PointerGetDatum(scan),
|
||||
BoolGetDatum(scanFromEnd),
|
||||
PointerGetDatum(key));
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -277,7 +292,7 @@ index_endscan(IndexScanDesc scan)
|
||||
SCAN_CHECKS;
|
||||
GET_SCAN_PROCEDURE(endscan, amendscan);
|
||||
|
||||
fmgr(procedure, scan);
|
||||
OidFunctionCall1(procedure, PointerGetDatum(scan));
|
||||
|
||||
/* Release lock and refcount acquired by index_beginscan */
|
||||
|
||||
@@ -301,7 +316,7 @@ index_markpos(IndexScanDesc scan)
|
||||
SCAN_CHECKS;
|
||||
GET_SCAN_PROCEDURE(markpos, ammarkpos);
|
||||
|
||||
fmgr(procedure, scan);
|
||||
OidFunctionCall1(procedure, PointerGetDatum(scan));
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -316,7 +331,7 @@ index_restrpos(IndexScanDesc scan)
|
||||
SCAN_CHECKS;
|
||||
GET_SCAN_PROCEDURE(restrpos, amrestrpos);
|
||||
|
||||
fmgr(procedure, scan);
|
||||
OidFunctionCall1(procedure, PointerGetDatum(scan));
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
@@ -350,7 +365,9 @@ index_getnext(IndexScanDesc scan,
|
||||
* ----------------
|
||||
*/
|
||||
result = (RetrieveIndexResult)
|
||||
(*fmgr_faddr(&scan->fn_getnext)) (scan, direction);
|
||||
DatumGetPointer(FunctionCall2(&scan->fn_getnext,
|
||||
PointerGetDatum(scan),
|
||||
Int32GetDatum(direction)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.43 2000/05/28 17:55:52 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.44 2000/05/30 04:24:32 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -217,15 +217,14 @@ StrategyTermEvaluate(StrategyTerm term,
|
||||
Datum left,
|
||||
Datum right)
|
||||
{
|
||||
bool result = false;
|
||||
Index index;
|
||||
long tmpres = 0;
|
||||
bool result = 0;
|
||||
StrategyOperator operator;
|
||||
ScanKey entry;
|
||||
|
||||
for (index = 0, operator = &term->operatorData[0];
|
||||
index < term->degree; index += 1, operator += 1)
|
||||
{
|
||||
ScanKey entry;
|
||||
|
||||
entry = &map->entry[operator->strategy - 1];
|
||||
|
||||
@@ -234,31 +233,29 @@ StrategyTermEvaluate(StrategyTerm term,
|
||||
switch (operator->flags ^ entry->sk_flags)
|
||||
{
|
||||
case 0x0:
|
||||
tmpres = (long) FMGR_PTR2(&entry->sk_func,
|
||||
left, right);
|
||||
result = DatumGetBool(FunctionCall2(&entry->sk_func,
|
||||
left, right));
|
||||
break;
|
||||
|
||||
case SK_NEGATE:
|
||||
tmpres = (long) !FMGR_PTR2(&entry->sk_func,
|
||||
left, right);
|
||||
result = ! DatumGetBool(FunctionCall2(&entry->sk_func,
|
||||
left, right));
|
||||
break;
|
||||
|
||||
case SK_COMMUTE:
|
||||
tmpres = (long) FMGR_PTR2(&entry->sk_func,
|
||||
right, left);
|
||||
result = DatumGetBool(FunctionCall2(&entry->sk_func,
|
||||
right, left));
|
||||
break;
|
||||
|
||||
case SK_NEGATE | SK_COMMUTE:
|
||||
tmpres = (long) !FMGR_PTR2(&entry->sk_func,
|
||||
right, left);
|
||||
result = ! DatumGetBool(FunctionCall2(&entry->sk_func,
|
||||
right, left));
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(FATAL, "StrategyTermEvaluate: impossible case %d",
|
||||
elog(ERROR, "StrategyTermEvaluate: impossible case %d",
|
||||
operator->flags ^ entry->sk_flags);
|
||||
}
|
||||
|
||||
result = (bool) tmpres;
|
||||
if (!result)
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.46 2000/05/30 00:49:41 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.47 2000/05/30 04:24:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -415,10 +415,18 @@ rttighten(Relation r,
|
||||
oldud = (char *) PageGetItem(p, PageGetItemId(p, stk->rts_child));
|
||||
oldud += sizeof(IndexTupleData);
|
||||
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (oldud, &old_size);
|
||||
datum = (char *) (*fmgr_faddr(&rtstate->unionFn)) (oldud, datum);
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(oldud),
|
||||
PointerGetDatum(&old_size));
|
||||
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (datum, &newd_size);
|
||||
datum = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(oldud),
|
||||
PointerGetDatum(datum)));
|
||||
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(&newd_size));
|
||||
|
||||
if (newd_size != old_size)
|
||||
{
|
||||
@@ -445,7 +453,10 @@ rttighten(Relation r,
|
||||
* union proc, which is guaranteed to return a rectangle.
|
||||
*/
|
||||
|
||||
tdatum = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum, datum);
|
||||
tdatum = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(datum)));
|
||||
rttighten(r, stk->rts_parent, tdatum, att_size, rtstate);
|
||||
pfree(tdatum);
|
||||
}
|
||||
@@ -665,7 +676,10 @@ rtintinsert(Relation r,
|
||||
WriteBuffer(b);
|
||||
ldatum = (((char *) ltup) + sizeof(IndexTupleData));
|
||||
rdatum = (((char *) rtup) + sizeof(IndexTupleData));
|
||||
newdatum = (char *) (*fmgr_faddr(&rtstate->unionFn)) (ldatum, rdatum);
|
||||
newdatum = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(ldatum),
|
||||
PointerGetDatum(rdatum)));
|
||||
|
||||
rttighten(r, stk->rts_parent, newdatum,
|
||||
(IndexTupleSize(rtup) - sizeof(IndexTupleData)), rtstate);
|
||||
@@ -744,10 +758,20 @@ picksplit(Relation r,
|
||||
datum_beta = ((char *) item_2) + sizeof(IndexTupleData);
|
||||
|
||||
/* compute the wasted space by unioning these guys */
|
||||
union_d = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum_alpha, datum_beta);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (union_d, &size_union);
|
||||
inter_d = (char *) (*fmgr_faddr(&rtstate->interFn)) (datum_alpha, datum_beta);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (inter_d, &size_inter);
|
||||
union_d = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum_alpha),
|
||||
PointerGetDatum(datum_beta)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(union_d),
|
||||
PointerGetDatum(&size_union));
|
||||
inter_d = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->interFn,
|
||||
PointerGetDatum(datum_alpha),
|
||||
PointerGetDatum(datum_beta)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(inter_d),
|
||||
PointerGetDatum(&size_inter));
|
||||
size_waste = size_union - size_inter;
|
||||
|
||||
pfree(union_d);
|
||||
@@ -777,12 +801,22 @@ picksplit(Relation r,
|
||||
|
||||
item_1 = (IndexTuple) PageGetItem(page, PageGetItemId(page, seed_1));
|
||||
datum_alpha = ((char *) item_1) + sizeof(IndexTupleData);
|
||||
datum_l = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum_alpha, datum_alpha);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (datum_l, &size_l);
|
||||
datum_l = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum_alpha),
|
||||
PointerGetDatum(datum_alpha)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(datum_l),
|
||||
PointerGetDatum(&size_l));
|
||||
item_2 = (IndexTuple) PageGetItem(page, PageGetItemId(page, seed_2));
|
||||
datum_beta = ((char *) item_2) + sizeof(IndexTupleData);
|
||||
datum_r = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum_beta, datum_beta);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (datum_r, &size_r);
|
||||
datum_r = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum_beta),
|
||||
PointerGetDatum(datum_beta)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(datum_r),
|
||||
PointerGetDatum(&size_r));
|
||||
|
||||
/*
|
||||
* Now split up the regions between the two seeds. An important
|
||||
@@ -826,10 +860,20 @@ picksplit(Relation r,
|
||||
item_1 = (IndexTuple) PageGetItem(page, PageGetItemId(page, i));
|
||||
|
||||
datum_alpha = ((char *) item_1) + sizeof(IndexTupleData);
|
||||
union_dl = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum_l, datum_alpha);
|
||||
union_dr = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum_r, datum_alpha);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (union_dl, &size_alpha);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (union_dr, &size_beta);
|
||||
union_dl = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum_l),
|
||||
PointerGetDatum(datum_alpha)));
|
||||
union_dr = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum_r),
|
||||
PointerGetDatum(datum_alpha)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(union_dl),
|
||||
PointerGetDatum(&size_alpha));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(union_dr),
|
||||
PointerGetDatum(&size_beta));
|
||||
|
||||
/* pick which page to add it to */
|
||||
if (size_alpha - size_l < size_beta - size_r)
|
||||
@@ -896,9 +940,16 @@ choose(Relation r, Page p, IndexTuple it, RTSTATE *rtstate)
|
||||
{
|
||||
datum = (char *) PageGetItem(p, PageGetItemId(p, i));
|
||||
datum += sizeof(IndexTupleData);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (datum, &dsize);
|
||||
ud = (char *) (*fmgr_faddr(&rtstate->unionFn)) (datum, id);
|
||||
(*fmgr_faddr(&rtstate->sizeFn)) (ud, &usize);
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(&dsize));
|
||||
ud = (char *)
|
||||
DatumGetPointer(FunctionCall2(&rtstate->unionFn,
|
||||
PointerGetDatum(datum),
|
||||
PointerGetDatum(id)));
|
||||
FunctionCall2(&rtstate->sizeFn,
|
||||
PointerGetDatum(ud),
|
||||
PointerGetDatum(&usize));
|
||||
pfree(ud);
|
||||
if (which_grow < 0 || usize - dsize < which_grow)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user