diff options
author | Tom Lane | 2008-10-10 14:17:08 +0000 |
---|---|---|
committer | Tom Lane | 2008-10-10 14:17:08 +0000 |
commit | 92a40c6eb9cf861790f170c63c44cf927141374c (patch) | |
tree | 32e1fb2bb1fdb4b9427cd456245079e8cd2a1bb5 | |
parent | c13c230ad22d502b4ff6cc0d0f5dec9e3554fb85 (diff) |
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.
-rw-r--r-- | src/backend/access/index/indexam.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 0d101acbe9..0a17f96b32 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -655,6 +655,7 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap) { FmgrInfo *procedure; int64 ntids; + Datum d; SCAN_CHECKS; GET_SCAN_PROCEDURE(amgetbitmap); @@ -665,9 +666,16 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap) /* * have the am's getbitmap proc do all the work. */ - ntids = DatumGetInt64(FunctionCall2(procedure, - PointerGetDatum(scan), - PointerGetDatum(bitmap))); + d = FunctionCall2(procedure, + PointerGetDatum(scan), + 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); |