Commit 05b3b861 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 58802bf3
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* /usr/local/devel/pglite/cvs/src/backend/access/gisr/gistget.c,v 1.9 1995/08/01 20:16:02 jolly Exp * /usr/local/devel/pglite/cvs/src/backend/access/gisr/gistget.c,v 1.9.1 1996/11/21 01:00:00 vadim Exp
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -67,7 +67,6 @@ gistfirst(IndexScanDesc s, ScanDirection dir) ...@@ -67,7 +67,6 @@ gistfirst(IndexScanDesc s, ScanDirection dir)
GISTSTACK *stk; GISTSTACK *stk;
BlockNumber blk; BlockNumber blk;
IndexTuple it; IndexTuple it;
ItemPointer ip;
b = ReadBuffer(s->relation, GISTP_ROOT); b = ReadBuffer(s->relation, GISTP_ROOT);
p = BufferGetPage(b); p = BufferGetPage(b);
...@@ -107,13 +106,10 @@ gistfirst(IndexScanDesc s, ScanDirection dir) ...@@ -107,13 +106,10 @@ gistfirst(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 = (GISTSTACK *) palloc(sizeof(GISTSTACK)); stk = (GISTSTACK *) palloc(sizeof(GISTSTACK));
...@@ -146,7 +142,6 @@ gistnext(IndexScanDesc s, ScanDirection dir) ...@@ -146,7 +142,6 @@ gistnext(IndexScanDesc s, ScanDirection dir)
GISTSTACK *stk; GISTSTACK *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));
...@@ -192,13 +187,10 @@ gistnext(IndexScanDesc s, ScanDirection dir) ...@@ -192,13 +187,10 @@ gistnext(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 = (GISTSTACK *) palloc(sizeof(GISTSTACK)); stk = (GISTSTACK *) palloc(sizeof(GISTSTACK));
...@@ -341,6 +333,8 @@ gistscancache(IndexScanDesc s, ScanDirection dir) ...@@ -341,6 +333,8 @@ gistscancache(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