!2458 issue修复:memcheck编译下gist索引构建内存泄漏修复
Merge pull request !2458 from zhangzhixian/gist_index_memory_leak_fix
This commit is contained in:
@ -882,8 +882,11 @@ static void gistProcessEmptyingQueue(GISTBuildState *buildstate)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Free all the memory allocated during index tuple processing */
|
||||
MemoryContextReset(buildstate->giststate->tempCxt);
|
||||
/*
|
||||
* MemoryContextReset will be called by caller, or caller of caller (for example, gistBuildCallback).
|
||||
* Just reset after all utilities of relative pointers in buildstate->giststate->tempCxt is finished
|
||||
* in case of memory leak.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -936,6 +939,7 @@ static void gistEmptyAllBuffers(GISTBuildState *buildstate)
|
||||
ereport(DEBUG2, (errmsg("emptied all buffers at level %d", i)));
|
||||
}
|
||||
(void)MemoryContextSwitchTo(oldCtx);
|
||||
MemoryContextReset(buildstate->giststate->tempCxt);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -501,6 +501,10 @@ SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0
|
||||
(10,10)
|
||||
(4 rows)
|
||||
|
||||
-- test for gist index building when buffering=on
|
||||
create table t(id int, c_point point);
|
||||
insert into t select id, point'(1, 2)' from (select * from generate_series(1, 200000) as id) as x;
|
||||
create index i on t using gist(c_point) with (buffering=on);
|
||||
|
||||
RESET enable_seqscan;
|
||||
RESET enable_indexscan;
|
||||
|
||||
@ -181,6 +181,11 @@ EXPLAIN (NUM_NODES OFF, NODES OFF, COSTS OFF)
|
||||
SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1';
|
||||
SELECT * FROM point_tbl WHERE f1 <@ '(-10,-10),(10,10)':: box ORDER BY f1 <-> '0,1';
|
||||
|
||||
-- test for gist index building when buffering=on
|
||||
create table t(id int, c_point point);
|
||||
insert into t select id, point'(1, 2)' from (select * from generate_series(1, 200000) as id) as x;
|
||||
create index i on t using gist(c_point) with (buffering=on);
|
||||
|
||||
RESET enable_seqscan;
|
||||
RESET enable_indexscan;
|
||||
RESET enable_bitmapscan;
|
||||
Reference in New Issue
Block a user