aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/gist/gist.c58
-rw-r--r--src/backend/access/gist/gistget.c10
-rw-r--r--src/backend/access/gist/gistscan.c51
-rw-r--r--src/backend/access/hash/hash.c124
-rw-r--r--src/backend/access/index/indexam.c7
-rw-r--r--src/backend/access/nbtree/nbtree.c104
-rw-r--r--src/backend/access/rtree/rtget.c12
-rw-r--r--src/backend/access/rtree/rtproc.c12
-rw-r--r--src/backend/access/rtree/rtree.c48
-rw-r--r--src/backend/access/rtree/rtscan.c51
10 files changed, 293 insertions, 184 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 7c3bb452cce..1d8c25104ce 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -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
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index c08a5cc2fea..f7b49430d07 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -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
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 2196e897e4a..729837e8008 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -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
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 1e5bc15bf2f..eec339f42df 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.37 2000/04/12 17:14:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.38 2000/06/13 07:34:28 tgl Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -36,17 +36,20 @@ bool BuildingHash = false;
* since the index won't be visible until this transaction commits
* and since building is guaranteed to be single-threaded.
*/
-void
-hashbuild(Relation heap,
- Relation index,
- int natts,
- AttrNumber *attnum,
- IndexStrategy istrat,
- uint16 pcount,
- Datum *params,
- FuncIndexInfo *finfo,
- PredInfo *predInfo)
+Datum
+hashbuild(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 hscan;
HeapTuple htup;
IndexTuple itup;
@@ -262,6 +265,8 @@ hashbuild(Relation heap,
/* all done */
BuildingHash = false;
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
@@ -271,20 +276,26 @@ hashbuild(Relation heap,
* for the new tuple, put it there, and return an InsertIndexResult
* to the caller.
*/
-InsertIndexResult
-hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
+Datum
+hashinsert(PG_FUNCTION_ARGS)
{
+ Relation rel = (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;
HashItem hitem;
IndexTuple itup;
- InsertIndexResult res;
-
/* generate an index tuple */
itup = index_formtuple(RelationGetDescr(rel), datum, nulls);
itup->t_tid = *ht_ctid;
if (itup->t_info & INDEX_NULL_MASK)
- return (InsertIndexResult) NULL;
+ PG_RETURN_POINTER((InsertIndexResult) NULL);
hitem = _hash_formitem(itup);
@@ -293,16 +304,18 @@ hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relatio
pfree(hitem);
pfree(itup);
- return res;
+ PG_RETURN_POINTER(res);
}
/*
* hashgettuple() -- Get the next tuple in the scan.
*/
-char *
-hashgettuple(IndexScanDesc scan, ScanDirection dir)
+Datum
+hashgettuple(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+ ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res;
/*
@@ -316,19 +329,20 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir)
else
res = _hash_first(scan, dir);
- return (char *) res;
+ PG_RETURN_POINTER(res);
}
/*
* hashbeginscan() -- start a scan on a hash index
*/
-char *
-hashbeginscan(Relation rel,
- bool fromEnd,
- uint16 keysz,
- ScanKey scankey)
+Datum
+hashbeginscan(PG_FUNCTION_ARGS)
{
+ Relation rel = (Relation) PG_GETARG_POINTER(0);
+ bool fromEnd = PG_GETARG_BOOL(1);
+ uint16 keysz = PG_GETARG_UINT16(2);
+ ScanKey scankey = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc scan;
HashScanOpaque so;
@@ -341,15 +355,20 @@ hashbeginscan(Relation rel,
/* register scan in case we change pages it's using */
_hash_regscan(scan);
- return (char *) scan;
+ PG_RETURN_POINTER(scan);
}
/*
* hashrescan() -- rescan an index relation
*/
-void
-hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
+Datum
+hashrescan(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
+ bool fromEnd = PG_GETARG_BOOL(1);
+#endif
+ ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr;
HashScanOpaque so;
@@ -376,15 +395,17 @@ hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
scankey,
scan->numberOfKeys * sizeof(ScanKeyData));
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
* hashendscan() -- close down a scan
*/
-void
-hashendscan(IndexScanDesc scan)
+Datum
+hashendscan(PG_FUNCTION_ARGS)
{
-
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
HashScanOpaque so;
@@ -411,26 +432,21 @@ hashendscan(IndexScanDesc scan)
/* be tidy */
pfree(scan->opaque);
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
* hashmarkpos() -- save current scan position
*
*/
-void
-hashmarkpos(IndexScanDesc scan)
+Datum
+hashmarkpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
HashScanOpaque so;
- /*
- * see if we ever call this code. if we do, then so_mrkbuf a useful
- * element in the scan->opaque structure. if this procedure is never
- * called, so_mrkbuf should be removed from the scan->opaque
- * structure.
- */
- elog(NOTICE, "Hashmarkpos() called.");
-
so = (HashScanOpaque) scan->opaque;
/* release lock on old marked data, if any */
@@ -449,25 +465,20 @@ hashmarkpos(IndexScanDesc scan)
HASH_READ);
scan->currentMarkData = scan->currentItemData;
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
* hashrestrpos() -- restore scan to last saved position
*/
-void
-hashrestrpos(IndexScanDesc scan)
+Datum
+hashrestrpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
HashScanOpaque so;
- /*
- * see if we ever call this code. if we do, then so_mrkbuf a useful
- * element in the scan->opaque structure. if this procedure is never
- * called, so_mrkbuf should be removed from the scan->opaque
- * structure.
- */
- elog(NOTICE, "Hashrestrpos() called.");
-
so = (HashScanOpaque) scan->opaque;
/* release lock on current data, if any */
@@ -487,15 +498,22 @@ hashrestrpos(IndexScanDesc scan)
scan->currentItemData = scan->currentMarkData;
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/* stubs */
-void
-hashdelete(Relation rel, ItemPointer tid)
+Datum
+hashdelete(PG_FUNCTION_ARGS)
{
+ Relation rel = (Relation) PG_GETARG_POINTER(0);
+ ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
+
/* adjust any active scans that will be affected by this deletion */
_hash_adjscans(rel, tid);
/* delete the data from the page */
_hash_pagedel(rel, tid);
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 7f402a33e37..2d1504238de 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.44 2000/05/30 04:24:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.45 2000/06/13 07:34:35 tgl Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -195,13 +195,12 @@ index_insert(Relation relation,
* ----------------
*/
specificResult = (InsertIndexResult)
- DatumGetPointer(OidFunctionCall6(procedure,
+ DatumGetPointer(OidFunctionCall5(procedure,
PointerGetDatum(relation),
PointerGetDatum(datum),
PointerGetDatum(nulls),
PointerGetDatum(heap_t_ctid),
- PointerGetDatum(heapRel),
- PointerGetDatum(NULL)));
+ PointerGetDatum(heapRel)));
/* must be pfree'ed */
return specificResult;
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 58469932e99..ccd5a265d31 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.55 2000/05/31 00:28:14 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.56 2000/06/13 07:34:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,17 +42,20 @@ static void _bt_restscan(IndexScanDesc scan);
* since the index won't be visible until this transaction commits
* and since building is guaranteed to be single-threaded.
*/
-void
-btbuild(Relation heap,
- Relation index,
- int natts,
- AttrNumber *attnum,
- IndexStrategy istrat,
- uint16 pcount,
- Datum *params,
- FuncIndexInfo *finfo,
- PredInfo *predInfo)
+Datum
+btbuild(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 hscan;
HeapTuple htup;
IndexTuple itup;
@@ -332,6 +335,8 @@ btbuild(Relation heap,
/* all done */
BuildingBtree = false;
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
@@ -341,12 +346,17 @@ btbuild(Relation heap,
* new tuple, put it there, set its unique OID as appropriate, and
* return an InsertIndexResult to the caller.
*/
-InsertIndexResult
-btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
+Datum
+btinsert(PG_FUNCTION_ARGS)
{
+ Relation rel = (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);
+ Relation heapRel = (Relation) PG_GETARG_POINTER(4);
+ InsertIndexResult res;
BTItem btitem;
IndexTuple itup;
- InsertIndexResult res;
/* generate an index tuple */
itup = index_formtuple(RelationGetDescr(rel), datum, nulls);
@@ -355,7 +365,8 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
/*
* See comments in btbuild.
*
- * if (itup->t_info & INDEX_NULL_MASK) return (InsertIndexResult) NULL;
+ * if (itup->t_info & INDEX_NULL_MASK)
+ * PG_RETURN_POINTER((InsertIndexResult) NULL);
*/
btitem = _bt_formitem(itup);
@@ -366,15 +377,17 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
pfree(btitem);
pfree(itup);
- return res;
+ PG_RETURN_POINTER(res);
}
/*
* btgettuple() -- Get the next tuple in the scan.
*/
-char *
-btgettuple(IndexScanDesc scan, ScanDirection dir)
+Datum
+btgettuple(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+ ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res;
/*
@@ -403,18 +416,23 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
if (res)
{
((BTScanOpaque) scan->opaque)->curHeapIptr = res->heap_iptr;
- LockBuffer(((BTScanOpaque) scan->opaque)->btso_curbuf, BUFFER_LOCK_UNLOCK);
+ LockBuffer(((BTScanOpaque) scan->opaque)->btso_curbuf,
+ BUFFER_LOCK_UNLOCK);
}
- return (char *) res;
+ PG_RETURN_POINTER(res);
}
/*
* btbeginscan() -- start a scan on a btree index
*/
-char *
-btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
+Datum
+btbeginscan(PG_FUNCTION_ARGS)
{
+ Relation rel = (Relation) PG_GETARG_POINTER(0);
+ bool fromEnd = PG_GETARG_BOOL(1);
+ uint16 keysz = PG_GETARG_UINT16(2);
+ ScanKey scankey = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc scan;
/* get the scan */
@@ -423,15 +441,20 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
/* register scan in case we change pages it's using */
_bt_regscan(scan);
- return (char *) scan;
+ PG_RETURN_POINTER(scan);
}
/*
* btrescan() -- rescan an index relation
*/
-void
-btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
+Datum
+btrescan(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
+#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
+ bool fromEnd = PG_GETARG_BOOL(1);
+#endif
+ ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr;
BTScanOpaque so;
@@ -479,6 +502,7 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
so->numberOfKeys * sizeof(ScanKeyData));
}
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
void
@@ -504,9 +528,10 @@ btmovescan(IndexScanDesc scan, Datum v)
/*
* btendscan() -- close down a scan
*/
-void
-btendscan(IndexScanDesc scan)
+Datum
+btendscan(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
BTScanOpaque so;
@@ -534,14 +559,17 @@ btendscan(IndexScanDesc scan)
pfree(so);
_bt_dropscan(scan);
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
* btmarkpos() -- save current scan position
*/
-void
-btmarkpos(IndexScanDesc scan)
+Datum
+btmarkpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
BTScanOpaque so;
@@ -563,14 +591,17 @@ btmarkpos(IndexScanDesc scan)
scan->currentMarkData = scan->currentItemData;
so->mrkHeapIptr = so->curHeapIptr;
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
* btrestrpos() -- restore scan to last saved position
*/
-void
-btrestrpos(IndexScanDesc scan)
+Datum
+btrestrpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr;
BTScanOpaque so;
@@ -593,17 +624,24 @@ btrestrpos(IndexScanDesc scan)
scan->currentItemData = scan->currentMarkData;
so->curHeapIptr = so->mrkHeapIptr;
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/* stubs */
-void
-btdelete(Relation rel, ItemPointer tid)
+Datum
+btdelete(PG_FUNCTION_ARGS)
{
+ Relation rel = (Relation) PG_GETARG_POINTER(0);
+ ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
+
/* adjust any active scans that will be affected by this deletion */
_bt_adjscans(rel, tid);
/* delete the data from the page */
_bt_pagedel(rel, tid);
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
static void
diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c
index 5b99e807f6f..8854163def9 100644
--- a/src/backend/access/rtree/rtget.c
+++ b/src/backend/access/rtree/rtget.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.20 2000/01/26 05:56:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.21 2000/06/13 07:34:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,21 +28,23 @@ static RetrieveIndexResult rtnext(IndexScanDesc s, ScanDirection dir);
static ItemPointer rtheapptr(Relation r, ItemPointer itemp);
-RetrieveIndexResult
-rtgettuple(IndexScanDesc s, ScanDirection dir)
+Datum
+rtgettuple(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 = rtscancache(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 = rtnext(s, dir);
else
res = rtfirst(s, dir);
- return res;
+ PG_RETURN_POINTER(res);
}
static RetrieveIndexResult
diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c
index 6b571c7d4af..df410045c2d 100644
--- a/src/backend/access/rtree/rtproc.c
+++ b/src/backend/access/rtree/rtproc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.25 2000/01/26 05:56:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.26 2000/06/13 07:34:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -102,13 +102,15 @@ rt_poly_union(POLYGON *a, POLYGON *b)
return p;
}
-void
-rt_poly_size(POLYGON *a, float *size)
+Datum
+rt_poly_size(PG_FUNCTION_ARGS)
{
+ POLYGON *a = PG_GETARG_POLYGON_P(0);
+ /* NB: size is an output argument */
+ float *size = (float *) PG_GETARG_POINTER(1);
double xdim,
ydim;
- size = (float *) palloc(sizeof(float));
if (a == (POLYGON *) NULL ||
a->boundbox.high.x <= a->boundbox.low.x ||
a->boundbox.high.y <= a->boundbox.low.y)
@@ -121,7 +123,7 @@ rt_poly_size(POLYGON *a, float *size)
*size = (float) (xdim * ydim);
}
- return;
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
POLYGON *
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 020f6bdff82..358d307d0b5 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.47 2000/05/30 04:24:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.48 2000/06/13 07:34:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,17 +59,20 @@ static int nospace(Page p, IndexTuple it);
static void initRtstate(RTSTATE *rtstate, Relation index);
-void
-rtbuild(Relation heap,
- Relation index,
- int natts,
- AttrNumber *attnum,
- IndexStrategy istrat,
- uint16 pcount,
- Datum *params,
- FuncIndexInfo *finfo,
- PredInfo *predInfo)
+Datum
+rtbuild(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;
@@ -277,6 +280,8 @@ rtbuild(Relation heap,
/* be tidy */
pfree(nulls);
pfree(d);
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
/*
@@ -285,9 +290,16 @@ rtbuild(Relation heap,
* This is the public interface routine for tuple insertion in rtrees.
* It doesn't do any work; just locks the relation and passes the buck.
*/
-InsertIndexResult
-rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel)
+Datum
+rtinsert(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;
RTSTATE rtState;
@@ -305,7 +317,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he
res = rtdoinsert(r, itup, &rtState);
- return res;
+ PG_RETURN_POINTER(res);
}
static InsertIndexResult
@@ -982,9 +994,11 @@ freestack(RTSTACK *s)
}
}
-char *
-rtdelete(Relation r, ItemPointer tid)
+Datum
+rtdelete(PG_FUNCTION_ARGS)
{
+ Relation r = (Relation) PG_GETARG_POINTER(0);
+ ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
BlockNumber blkno;
OffsetNumber offnum;
Buffer buf;
@@ -1011,7 +1025,7 @@ rtdelete(Relation r, ItemPointer tid)
WriteBuffer(buf);
- return (char *) NULL;
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
static void
diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c
index 71e2acf5f88..97a71a00588 100644
--- a/src/backend/access/rtree/rtscan.c
+++ b/src/backend/access/rtree/rtscan.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.32 2000/04/12 17:14:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.33 2000/06/13 07:34:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,12 +51,13 @@ typedef RTScanListData *RTScanList;
/* pointer to list of local scans on rtrees */
static RTScanList RTScans = (RTScanList) NULL;
-IndexScanDesc
-rtbeginscan(Relation r,
- bool fromEnd,
- uint16 nkeys,
- ScanKey key)
+Datum
+rtbeginscan(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;
/*
@@ -68,22 +69,19 @@ rtbeginscan(Relation r,
s = RelationGetIndexScan(r, fromEnd, nkeys, key);
rtregscan(s);
- return s;
+ PG_RETURN_POINTER(s);
}
-void
-rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
+Datum
+rtrescan(PG_FUNCTION_ARGS)
{
+ IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
+ bool fromEnd = PG_GETARG_BOOL(1);
+ ScanKey key = (ScanKey) PG_GETARG_POINTER(2);
RTreeScanOpaque p;
RegProcedure internal_proc;
int i;
- if (!IndexScanIsValid(s))
- {
- elog(ERROR, "rtrescan: invalid scan.");
- return;
- }
-
/*
* Clear all the pointers.
*/
@@ -157,11 +155,14 @@ rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
}
}
}
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
-void
-rtmarkpos(IndexScanDesc s)
+Datum
+rtmarkpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p;
RTSTACK *o,
*n,
@@ -190,11 +191,14 @@ rtmarkpos(IndexScanDesc s)
freestack(p->s_markstk);
p->s_markstk = o;
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
-void
-rtrestrpos(IndexScanDesc s)
+Datum
+rtrestrpos(PG_FUNCTION_ARGS)
{
+ IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p;
RTSTACK *o,
*n,
@@ -223,11 +227,14 @@ rtrestrpos(IndexScanDesc s)
freestack(p->s_stack);
p->s_stack = o;
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
-void
-rtendscan(IndexScanDesc s)
+Datum
+rtendscan(PG_FUNCTION_ARGS)
{
+ IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p;
p = (RTreeScanOpaque) s->opaque;
@@ -241,6 +248,8 @@ rtendscan(IndexScanDesc s)
rtdropscan(s);
/* XXX don't unset read lock -- two-phase locking */
+
+ PG_RETURN_POINTER(NULL); /* no real return value */
}
static void