1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

Another batch of fmgr updates. I think I have gotten all old-style

functions that take pass-by-value datatypes.  Should be ready for
port testing ...
This commit is contained in:
Tom Lane
2000-06-13 07:35:40 +00:00
parent 8f057d971d
commit f2d1205322
51 changed files with 1640 additions and 1592 deletions

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.55 2000/05/30 04:24:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.56 2000/06/13 07:34:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -47,7 +47,6 @@ static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, int level,
static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it,
GISTSTATE *giststate);
static int gistnospace(Page p, IndexTuple it);
void gistdelete(Relation r, ItemPointer tid);
static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
static void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
Relation r, Page pg, OffsetNumber o, int b, bool l);
@ -60,17 +59,20 @@ static char *int_range_out(INTRANGE *r);
/*
** routine to build an index. Basically calls insert over and over
*/
void
gistbuild(Relation heap,
Relation index,
int natts,
AttrNumber *attnum,
IndexStrategy istrat,
uint16 pint,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo)
Datum
gistbuild(PG_FUNCTION_ARGS)
{
Relation heap = (Relation) PG_GETARG_POINTER(0);
Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
#ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc scan;
AttrNumber i;
HeapTuple htup;
@ -83,12 +85,10 @@ gistbuild(Relation heap,
int nb,
nh,
ni;
#ifndef OMIT_PARTIAL_INDEX
ExprContext *econtext;
TupleTable tupleTable;
TupleTableSlot *slot;
#endif
Node *pred,
*oldPred;
@ -302,6 +302,8 @@ gistbuild(Relation heap,
/* be tidy */
pfree(nulls);
pfree(d);
PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
@ -310,9 +312,16 @@ gistbuild(Relation heap,
* This is the public interface routine for tuple insertion in GiSTs.
* It doesn't do any work; just locks the relation and passes the buck.
*/
InsertIndexResult
gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
Datum
gistinsert(PG_FUNCTION_ARGS)
{
Relation r = (Relation) PG_GETARG_POINTER(0);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
InsertIndexResult res;
IndexTuple itup;
GISTSTATE giststate;
@ -351,7 +360,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
pfree(itup);
pfree(compvec);
return res;
PG_RETURN_POINTER(res);
}
/*
@ -596,7 +605,9 @@ gistAdjustKeys(Relation r,
/* delete old tuple */
ItemPointerSet(&oldtid, stk->gs_blk, stk->gs_child);
gistdelete(r, (ItemPointer) &oldtid);
DirectFunctionCall2(gistdelete,
PointerGetDatum(r),
PointerGetDatum(&oldtid));
/* generate and insert new tuple */
tupDesc = r->rd_att;
@ -890,7 +901,9 @@ gistintinsert(Relation r,
/* remove old left pointer, insert the 2 new entries */
ItemPointerSet(&ltid, stk->gs_blk, stk->gs_child);
gistdelete(r, (ItemPointer) &ltid);
DirectFunctionCall2(gistdelete,
PointerGetDatum(r),
PointerGetDatum(&ltid));
gistentryinserttwo(r, stk, ltup, rtup, giststate);
}
@ -1105,9 +1118,11 @@ gistfreestack(GISTSTACK *s)
/*
** remove an entry from a page
*/
void
gistdelete(Relation r, ItemPointer tid)
Datum
gistdelete(PG_FUNCTION_ARGS)
{
Relation r = (Relation) PG_GETARG_POINTER(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
BlockNumber blkno;
OffsetNumber offnum;
Buffer buf;
@ -1134,6 +1149,7 @@ gistdelete(Relation r, ItemPointer tid)
WriteBuffer(buf);
PG_RETURN_POINTER(NULL); /* no real return value */
}
void

View File

@ -29,21 +29,23 @@ static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc,
Relation r, Page p, OffsetNumber offset);
RetrieveIndexResult
gistgettuple(IndexScanDesc s, ScanDirection dir)
Datum
gistgettuple(PG_FUNCTION_ARGS)
{
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res;
/* if we have it cached in the scan desc, just return the value */
if ((res = gistscancache(s, dir)) != (RetrieveIndexResult) NULL)
return res;
PG_RETURN_POINTER(res);
/* not cached, so we'll have to do some work */
if (ItemPointerIsValid(&(s->currentItemData)))
res = gistnext(s, dir);
else
res = gistfirst(s, dir);
return res;
PG_RETURN_POINTER(res);
}
static RetrieveIndexResult

View File

@ -48,12 +48,13 @@ typedef GISTScanListData *GISTScanList;
/* pointer to list of local scans on GiSTs */
static GISTScanList GISTScans = (GISTScanList) NULL;
IndexScanDesc
gistbeginscan(Relation r,
bool fromEnd,
uint16 nkeys,
ScanKey key)
Datum
gistbeginscan(PG_FUNCTION_ARGS)
{
Relation r = (Relation) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
uint16 nkeys = PG_GETARG_UINT16(2);
ScanKey key = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc s;
/*
@ -65,21 +66,18 @@ gistbeginscan(Relation r,
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
gistregscan(s);
return s;
PG_RETURN_POINTER(s);
}
void
gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
Datum
gistrescan(PG_FUNCTION_ARGS)
{
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
ScanKey key = (ScanKey) PG_GETARG_POINTER(2);
GISTScanOpaque p;
int i;
if (!IndexScanIsValid(s))
{
elog(ERROR, "gistrescan: invalid scan.");
return;
}
/*
* Clear all the pointers.
*/
@ -155,11 +153,14 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
s->keyData[i].sk_func = p->giststate->consistentFn;
}
}
PG_RETURN_POINTER(NULL); /* no real return value */
}
void
gistmarkpos(IndexScanDesc s)
Datum
gistmarkpos(PG_FUNCTION_ARGS)
{
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p;
GISTSTACK *o,
*n,
@ -188,11 +189,14 @@ gistmarkpos(IndexScanDesc s)
gistfreestack(p->s_markstk);
p->s_markstk = o;
PG_RETURN_POINTER(NULL); /* no real return value */
}
void
gistrestrpos(IndexScanDesc s)
Datum
gistrestrpos(PG_FUNCTION_ARGS)
{
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p;
GISTSTACK *o,
*n,
@ -221,12 +225,15 @@ gistrestrpos(IndexScanDesc s)
gistfreestack(p->s_stack);
p->s_stack = o;
PG_RETURN_POINTER(NULL); /* no real return value */
}
void
gistendscan(IndexScanDesc s)
Datum
gistendscan(PG_FUNCTION_ARGS)
{
GISTScanOpaque p;
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p;
p = (GISTScanOpaque) s->opaque;
@ -239,6 +246,8 @@ gistendscan(IndexScanDesc s)
gistdropscan(s);
/* XXX don't unset read lock -- two-phase locking */
PG_RETURN_POINTER(NULL); /* no real return value */
}
static void