mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Fix small query-lifespan memory leak introduced by 8.4 change in index AM API
for bitmap index scans. Per report and test case from Kevin Grittner.
This commit is contained in:
parent
8fc4197f7d
commit
30584cda35
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.110 2008/09/11 14:01:09 alvherre Exp $
|
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.111 2008/10/10 14:17:08 tgl Exp $
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* index_open - open an index relation by relation OID
|
* index_open - open an index relation by relation OID
|
||||||
@ -655,6 +655,7 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
|
|||||||
{
|
{
|
||||||
FmgrInfo *procedure;
|
FmgrInfo *procedure;
|
||||||
int64 ntids;
|
int64 ntids;
|
||||||
|
Datum d;
|
||||||
|
|
||||||
SCAN_CHECKS;
|
SCAN_CHECKS;
|
||||||
GET_SCAN_PROCEDURE(amgetbitmap);
|
GET_SCAN_PROCEDURE(amgetbitmap);
|
||||||
@ -665,9 +666,16 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
|
|||||||
/*
|
/*
|
||||||
* have the am's getbitmap proc do all the work.
|
* have the am's getbitmap proc do all the work.
|
||||||
*/
|
*/
|
||||||
ntids = DatumGetInt64(FunctionCall2(procedure,
|
d = FunctionCall2(procedure,
|
||||||
PointerGetDatum(scan),
|
PointerGetDatum(scan),
|
||||||
PointerGetDatum(bitmap)));
|
PointerGetDatum(bitmap));
|
||||||
|
|
||||||
|
ntids = DatumGetInt64(d);
|
||||||
|
|
||||||
|
/* If int8 is pass-by-ref, must free the result to avoid memory leak */
|
||||||
|
#ifndef USE_FLOAT8_BYVAL
|
||||||
|
pfree(DatumGetPointer(d));
|
||||||
|
#endif
|
||||||
|
|
||||||
pgstat_count_index_tuples(scan->indexRelation, ntids);
|
pgstat_count_index_tuples(scan->indexRelation, ntids);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user