diff options
Diffstat (limited to 'src/backend/access/nbtree')
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 29 | ||||
-rw-r--r-- | src/backend/access/nbtree/nbtree.c | 33 |
2 files changed, 22 insertions, 40 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 3a1a4712897..868a91ab3a5 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.119 2004/12/31 21:59:22 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.120 2005/03/21 01:23:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ static Buffer _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf); static TransactionId _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, Buffer buf, ScanKey itup_scankey); -static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, +static void _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, @@ -71,7 +71,7 @@ static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, * This routine is called by the public interface routines, btbuild * and btinsert. By here, btitem is filled in, including the TID. */ -InsertIndexResult +void _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel) { @@ -80,7 +80,6 @@ _bt_doinsert(Relation rel, BTItem btitem, ScanKey itup_scankey; BTStack stack; Buffer buf; - InsertIndexResult res; /* we need a scan key to do our search, so build one */ itup_scankey = _bt_mkscankey(rel, itup); @@ -138,14 +137,11 @@ top: } /* do the insertion */ - res = _bt_insertonpg(rel, buf, stack, natts, itup_scankey, btitem, - 0, false); + _bt_insertonpg(rel, buf, stack, natts, itup_scankey, btitem, 0, false); /* be tidy */ _bt_freestack(stack); _bt_freeskey(itup_scankey); - - return res; } /* @@ -357,7 +353,7 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, * insertion on internal pages. *---------- */ -static InsertIndexResult +static void _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, @@ -367,7 +363,6 @@ _bt_insertonpg(Relation rel, OffsetNumber afteritem, bool split_only_page) { - InsertIndexResult res; Page page; BTPageOpaque lpageop; OffsetNumber itup_off; @@ -630,12 +625,6 @@ _bt_insertonpg(Relation rel, _bt_wrtbuf(rel, buf); } - - /* by here, the new tuple is inserted at itup_blkno/itup_off */ - res = (InsertIndexResult) palloc(sizeof(InsertIndexResultData)); - ItemPointerSet(&(res->pointerData), itup_blkno, itup_off); - - return res; } /* @@ -1190,7 +1179,6 @@ _bt_insert_parent(Relation rel, BlockNumber bknum = BufferGetBlockNumber(buf); BlockNumber rbknum = BufferGetBlockNumber(rbuf); Page page = BufferGetPage(buf); - InsertIndexResult newres; BTItem new_item; BTStackData fakestack; BTItem ritem; @@ -1244,12 +1232,11 @@ _bt_insert_parent(Relation rel, RelationGetRelationName(rel)); /* Recursively update the parent */ - newres = _bt_insertonpg(rel, pbuf, stack->bts_parent, - 0, NULL, new_item, stack->bts_offset, - is_only); + _bt_insertonpg(rel, pbuf, stack->bts_parent, + 0, NULL, new_item, stack->bts_offset, + is_only); /* be tidy */ - pfree(newres); pfree(new_item); } } diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 8f6fe7d27cc..1fc26ea8958 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 - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.125 2005/03/20 22:00:50 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.126 2005/03/21 01:23:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -52,8 +52,8 @@ bool FastBuild = true; /* use SORT instead of insertion build */ static void _bt_restscan(IndexScanDesc scan); static void btbuildCallback(Relation index, HeapTuple htup, - Datum *attdata, - char *nulls, + Datum *values, + bool *isnull, bool tupleIsAlive, void *state); @@ -178,18 +178,17 @@ btbuild(PG_FUNCTION_ARGS) static void btbuildCallback(Relation index, HeapTuple htup, - Datum *attdata, - char *nulls, + Datum *values, + bool *isnull, bool tupleIsAlive, void *state) { BTBuildState *buildstate = (BTBuildState *) state; IndexTuple itup; BTItem btitem; - InsertIndexResult res; /* form an index tuple and point it at the heap tuple */ - itup = index_formtuple(RelationGetDescr(index), attdata, nulls); + itup = index_form_tuple(RelationGetDescr(index), values, isnull); itup->t_tid = htup->t_self; btitem = _bt_formitem(itup); @@ -212,10 +211,8 @@ btbuildCallback(Relation index, } else { - res = _bt_doinsert(index, btitem, - buildstate->isUnique, buildstate->heapRel); - if (res) - pfree(res); + _bt_doinsert(index, btitem, + buildstate->isUnique, buildstate->heapRel); } buildstate->indtuples += 1; @@ -228,33 +225,31 @@ btbuildCallback(Relation index, * btinsert() -- insert an index tuple into a btree. * * Descend the tree recursively, find the appropriate location for our - * new tuple, put it there, set its unique OID as appropriate, and - * return an InsertIndexResult to the caller. + * new tuple, and put it there. */ 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); + Datum *values = (Datum *) PG_GETARG_POINTER(1); + bool *isnull = (bool *) PG_GETARG_POINTER(2); ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3); Relation heapRel = (Relation) PG_GETARG_POINTER(4); bool checkUnique = PG_GETARG_BOOL(5); - InsertIndexResult res; BTItem btitem; IndexTuple itup; /* generate an index tuple */ - itup = index_formtuple(RelationGetDescr(rel), datum, nulls); + itup = index_form_tuple(RelationGetDescr(rel), values, isnull); itup->t_tid = *ht_ctid; btitem = _bt_formitem(itup); - res = _bt_doinsert(rel, btitem, checkUnique, heapRel); + _bt_doinsert(rel, btitem, checkUnique, heapRel); pfree(btitem); pfree(itup); - PG_RETURN_POINTER(res); + PG_RETURN_BOOL(true); } /* |