Commit 8c2f099a authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Fix memory overhelding while forming index' result:

memory allocation for ItemPointerData of heap' tuple is useless
because of FormRetrieveIndexResult makes neccessary palloc.
parent 5d7e44fc
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.9 1996/11/13 20:47:20 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.10 1996/11/21 06:10:55 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -535,7 +535,6 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) ...@@ -535,7 +535,6 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
RetrieveIndexResult res; RetrieveIndexResult res;
BlockNumber blkno; BlockNumber blkno;
ItemPointer current; ItemPointer current;
ItemPointer iptr;
BTItem btitem; BTItem btitem;
IndexTuple itup; IndexTuple itup;
BTScanOpaque so; BTScanOpaque so;
...@@ -569,10 +568,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) ...@@ -569,10 +568,7 @@ _bt_next(IndexScanDesc scan, ScanDirection dir)
itup = &btitem->bti_itup; itup = &btitem->bti_itup;
if (_bt_checkqual(scan, itup)) { if (_bt_checkqual(scan, itup)) {
iptr = (ItemPointer) palloc(sizeof(ItemPointerData)); res = FormRetrieveIndexResult(current, &(itup->t_tid));
memmove((char *) iptr, (char *) &(itup->t_tid),
sizeof(ItemPointerData));
res = FormRetrieveIndexResult(current, iptr);
/* remember which buffer we have pinned and locked */ /* remember which buffer we have pinned and locked */
so->btso_curbuf = buf; so->btso_curbuf = buf;
...@@ -608,7 +604,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -608,7 +604,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
BTItem btitem; BTItem btitem;
IndexTuple itup; IndexTuple itup;
ItemPointer current; ItemPointer current;
ItemPointer iptr;
BlockNumber blkno; BlockNumber blkno;
StrategyNumber strat; StrategyNumber strat;
RetrieveIndexResult res; RetrieveIndexResult res;
...@@ -764,11 +759,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) ...@@ -764,11 +759,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
itup = &btitem->bti_itup; itup = &btitem->bti_itup;
if (_bt_checkqual(scan, itup)) { if (_bt_checkqual(scan, itup)) {
iptr = (ItemPointer) palloc(sizeof(ItemPointerData)); res = FormRetrieveIndexResult(current, &(itup->t_tid));
memmove((char *) iptr, (char *) &(itup->t_tid),
sizeof(ItemPointerData));
res = FormRetrieveIndexResult(current, iptr);
pfree(iptr);
/* remember which buffer we have pinned */ /* remember which buffer we have pinned */
so->btso_curbuf = buf; so->btso_curbuf = buf;
...@@ -1035,7 +1026,6 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) ...@@ -1035,7 +1026,6 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
Page page; Page page;
BTPageOpaque opaque; BTPageOpaque opaque;
ItemPointer current; ItemPointer current;
ItemPointer iptr;
OffsetNumber offnum, maxoff; OffsetNumber offnum, maxoff;
OffsetNumber start = 0; OffsetNumber start = 0;
BlockNumber blkno; BlockNumber blkno;
...@@ -1132,10 +1122,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) ...@@ -1132,10 +1122,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
/* see if we picked a winner */ /* see if we picked a winner */
if (_bt_checkqual(scan, itup)) { if (_bt_checkqual(scan, itup)) {
iptr = (ItemPointer) palloc(sizeof(ItemPointerData)); res = FormRetrieveIndexResult(current, &(itup->t_tid));
memmove((char *) iptr, (char *) &(itup->t_tid),
sizeof(ItemPointerData));
res = FormRetrieveIndexResult(current, iptr);
/* remember which buffer we have pinned */ /* remember which buffer we have pinned */
so = (BTScanOpaque) scan->opaque; so = (BTScanOpaque) scan->opaque;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.6 1996/11/05 10:54:16 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.7 1996/11/21 06:13:43 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -66,7 +66,6 @@ rtfirst(IndexScanDesc s, ScanDirection dir) ...@@ -66,7 +66,6 @@ rtfirst(IndexScanDesc s, ScanDirection dir)
RTSTACK *stk; RTSTACK *stk;
BlockNumber blk; BlockNumber blk;
IndexTuple it; IndexTuple it;
ItemPointer ip;
b = ReadBuffer(s->relation, P_ROOT); b = ReadBuffer(s->relation, P_ROOT);
p = BufferGetPage(b); p = BufferGetPage(b);
...@@ -106,13 +105,10 @@ rtfirst(IndexScanDesc s, ScanDirection dir) ...@@ -106,13 +105,10 @@ rtfirst(IndexScanDesc s, ScanDirection dir)
ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n); ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n);
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
memmove((char *) ip, (char *) &(it->t_tid),
sizeof(ItemPointerData));
ReleaseBuffer(b);
res = FormRetrieveIndexResult(&(s->currentItemData), ip); res = FormRetrieveIndexResult(&(s->currentItemData), &(it->t_tid));
ReleaseBuffer(b);
return (res); return (res);
} else { } else {
stk = (RTSTACK *) palloc(sizeof(RTSTACK)); stk = (RTSTACK *) palloc(sizeof(RTSTACK));
...@@ -145,7 +141,6 @@ rtnext(IndexScanDesc s, ScanDirection dir) ...@@ -145,7 +141,6 @@ rtnext(IndexScanDesc s, ScanDirection dir)
RTSTACK *stk; RTSTACK *stk;
BlockNumber blk; BlockNumber blk;
IndexTuple it; IndexTuple it;
ItemPointer ip;
blk = ItemPointerGetBlockNumber(&(s->currentItemData)); blk = ItemPointerGetBlockNumber(&(s->currentItemData));
n = ItemPointerGetOffsetNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData));
...@@ -191,13 +186,10 @@ rtnext(IndexScanDesc s, ScanDirection dir) ...@@ -191,13 +186,10 @@ rtnext(IndexScanDesc s, ScanDirection dir)
ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n); ItemPointerSet(&(s->currentItemData), BufferGetBlockNumber(b), n);
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
ip = (ItemPointer) palloc(sizeof(ItemPointerData));
memmove((char *) ip, (char *) &(it->t_tid),
sizeof(ItemPointerData));
ReleaseBuffer(b);
res = FormRetrieveIndexResult(&(s->currentItemData), ip); res = FormRetrieveIndexResult(&(s->currentItemData), &(it->t_tid));
ReleaseBuffer(b);
return (res); return (res);
} else { } else {
stk = (RTSTACK *) palloc(sizeof(RTSTACK)); stk = (RTSTACK *) palloc(sizeof(RTSTACK));
...@@ -288,6 +280,8 @@ rtscancache(IndexScanDesc s, ScanDirection dir) ...@@ -288,6 +280,8 @@ rtscancache(IndexScanDesc s, ScanDirection dir)
else else
res = (RetrieveIndexResult) NULL; res = (RetrieveIndexResult) NULL;
pfree (ip);
return (res); return (res);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment