File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -2216,7 +2216,9 @@ insertScanItem(RumScanOpaque so, bool recheck)
2216
2216
RumSortItem * item ;
2217
2217
int i , j ;
2218
2218
2219
- item = (RumSortItem * )palloc (RumSortItemSize (so -> norderbys ));
2219
+ item = (RumSortItem * )
2220
+ MemoryContextAlloc (rum_tuplesort_get_memorycontext (so -> sortstate ),
2221
+ RumSortItemSize (so -> norderbys ));
2220
2222
item -> iptr = so -> iptr ;
2221
2223
item -> recheck = recheck ;
2222
2224
@@ -2264,7 +2266,6 @@ insertScanItem(RumScanOpaque so, bool recheck)
2264
2266
j ++ ;
2265
2267
}
2266
2268
rum_tuplesort_putrum (so -> sortstate , item );
2267
- pfree (item );
2268
2269
}
2269
2270
2270
2271
bool
Original file line number Diff line number Diff line change @@ -911,6 +911,12 @@ rum_tuplesort_begin_common(int workMem, bool randomAccess)
911
911
return state ;
912
912
}
913
913
914
+ MemoryContext
915
+ rum_tuplesort_get_memorycontext (Tuplesortstate * state )
916
+ {
917
+ return state -> sortcontext ;
918
+ }
919
+
914
920
Tuplesortstate *
915
921
rum_tuplesort_begin_heap (TupleDesc tupDesc ,
916
922
int nkeys , AttrNumber * attNums ,
@@ -1536,15 +1542,12 @@ rum_tuplesort_putrum(Tuplesortstate *state, RumSortItem *item)
1536
1542
{
1537
1543
MemoryContext oldcontext = MemoryContextSwitchTo (state -> sortcontext );
1538
1544
SortTuple stup ;
1539
- RumSortItem * itemCopy = palloc (RumSortItemSize (state -> nKeys ));
1540
-
1541
- memcpy (itemCopy , item , RumSortItemSize (state -> nKeys ));
1542
1545
1543
1546
/*
1544
1547
* Copy the given tuple into memory we control, and decrease availMem.
1545
1548
* Then call the common code.
1546
1549
*/
1547
- COPYTUP (state , & stup , (void * ) itemCopy );
1550
+ COPYTUP (state , & stup , (void * ) item );
1548
1551
1549
1552
puttuple_common (state , & stup );
1550
1553
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ typedef struct
67
67
68
68
#define RumSortItemSize (nKeys ) (offsetof(RumSortItem,data)+(nKeys)*sizeof(float8))
69
69
70
+ extern MemoryContext rum_tuplesort_get_memorycontext (Tuplesortstate * state );
70
71
extern Tuplesortstate * rum_tuplesort_begin_heap (TupleDesc tupDesc ,
71
72
int nkeys , AttrNumber * attNums ,
72
73
Oid * sortOperators , Oid * sortCollations ,
You can’t perform that action at this time.
0 commit comments