Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb209e9c

Browse files
committed
Merge branch 'CORE-241-rum' of gitlab.postgrespro.ru:pgpro-dev/postgrespro into CORE-241-rum
2 parents2c94e21 +88a4c4c commitb209e9c

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

‎rum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ typedef struct
640640
typedefstructRumScanOpaqueData
641641
{
642642
MemoryContexttempCtx;
643+
MemoryContextkeyCtx;/* used to hold key and entry data */
643644
RumStaterumstate;
644645

645646
RumScanKeykeys;/* one per scan qualifier expr */

‎rumget.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,15 +606,18 @@ scan_entry_cmp(const void *p1, const void *p2)
606606
staticvoid
607607
startScan(IndexScanDescscan)
608608
{
609+
MemoryContextoldCtx=CurrentMemoryContext;
609610
RumScanOpaqueso= (RumScanOpaque)scan->opaque;
610611
RumState*rumstate=&so->rumstate;
611612
uint32i;
612613
booluseFastScan= false;
613614

615+
MemoryContextSwitchTo(so->keyCtx);
614616
for (i=0;i<so->totalentries;i++)
615617
{
616618
startScanEntry(rumstate,so->entries[i]);
617619
}
620+
MemoryContextSwitchTo(oldCtx);
618621

619622
if (RumFuzzySearchLimit>0)
620623
{

‎rumscan.c

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,19 @@ rumbeginscan(Relation rel, int nkeys, int norderbys)
3333
so->keys=NULL;
3434
so->nkeys=0;
3535
so->firstCall= true;
36+
so->totalentries=0;
37+
so->sortedEntries=NULL;
3638
so->tempCtx=AllocSetContextCreate(CurrentMemoryContext,
3739
"Rum scan temporary context",
3840
ALLOCSET_DEFAULT_MINSIZE,
3941
ALLOCSET_DEFAULT_INITSIZE,
4042
ALLOCSET_DEFAULT_MAXSIZE);
43+
so->keyCtx=AllocSetContextCreate(CurrentMemoryContext,
44+
"Gin scan key context",
45+
ALLOCSET_DEFAULT_MINSIZE,
46+
ALLOCSET_DEFAULT_INITSIZE,
47+
ALLOCSET_DEFAULT_MAXSIZE);
48+
4149
initRumState(&so->rumstate,scan->indexRelation);
4250

4351
scan->opaque=so;
@@ -249,32 +257,6 @@ freeScanKeys(RumScanOpaque so)
249257
{
250258
uint32i;
251259

252-
if (so->keys==NULL)
253-
return;
254-
255-
for (i=0;i<so->nkeys;i++)
256-
{
257-
RumScanKeykey=so->keys+i;
258-
259-
if (key->nentries>0)
260-
{
261-
if (key->scanEntry)
262-
pfree(key->scanEntry);
263-
if (key->entryRes)
264-
pfree(key->entryRes);
265-
if (key->addInfo)
266-
pfree(key->addInfo);
267-
if (key->addInfoIsNull)
268-
pfree(key->addInfoIsNull);
269-
if (key->queryCategories)
270-
pfree(key->queryCategories);
271-
}
272-
}
273-
274-
pfree(so->keys);
275-
so->keys=NULL;
276-
so->nkeys=0;
277-
278260
for (i=0;i<so->totalentries;i++)
279261
{
280262
RumScanEntryentry=so->entries[i];
@@ -302,7 +284,10 @@ freeScanKeys(RumScanOpaque so)
302284
pfree(entry);
303285
}
304286

305-
pfree(so->entries);
287+
MemoryContextReset(so->keyCtx);
288+
so->keys=NULL;
289+
so->nkeys=0;
290+
306291
if (so->sortedEntries)
307292
pfree(so->sortedEntries);
308293
so->entries=NULL;
@@ -406,6 +391,14 @@ rumNewScanKey(IndexScanDesc scan)
406391
RumScanOpaqueso= (RumScanOpaque)scan->opaque;
407392
inti;
408393
boolhasNullQuery= false;
394+
MemoryContextoldCtx;
395+
396+
/*
397+
* Allocate all the scan key information in the key context. (If
398+
* extractQuery leaks anything there, it won't be reset until the end of
399+
* scan or rescan, but that's OK.)
400+
*/
401+
oldCtx=MemoryContextSwitchTo(so->keyCtx);
409402

410403
/* if no scan keys provided, allocate extra EVERYTHING RumScanKey */
411404
so->keys= (RumScanKey)
@@ -457,6 +450,8 @@ rumNewScanKey(IndexScanDesc scan)
457450
NULL,NULL,NULL,NULL, false);
458451
}
459452

453+
MemoryContextSwitchTo(oldCtx);
454+
460455
pgstat_count_index_scan(scan->indexRelation);
461456
}
462457

@@ -497,6 +492,7 @@ rumendscan(IndexScanDesc scan)
497492
rum_tuplesort_end(so->sortstate);
498493

499494
MemoryContextDelete(so->tempCtx);
495+
MemoryContextDelete(so->keyCtx);
500496

501497
pfree(so);
502498
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp