Skip to content

Commit 30584cd

Browse files
committed
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.
1 parent 8fc4197 commit 30584cd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/backend/access/index/indexam.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.110 2008/09/11 14:01:09 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.111 2008/10/10 14:17:08 tgl Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
* index_open - open an index relation by relation OID
@@ -655,6 +655,7 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
655655
{
656656
FmgrInfo *procedure;
657657
int64 ntids;
658+
Datum d;
658659

659660
SCAN_CHECKS;
660661
GET_SCAN_PROCEDURE(amgetbitmap);
@@ -665,9 +666,16 @@ index_getbitmap(IndexScanDesc scan, TIDBitmap *bitmap)
665666
/*
666667
* have the am's getbitmap proc do all the work.
667668
*/
668-
ntids = DatumGetInt64(FunctionCall2(procedure,
669-
PointerGetDatum(scan),
670-
PointerGetDatum(bitmap)));
669+
d = FunctionCall2(procedure,
670+
PointerGetDatum(scan),
671+
PointerGetDatum(bitmap));
672+
673+
ntids = DatumGetInt64(d);
674+
675+
/* If int8 is pass-by-ref, must free the result to avoid memory leak */
676+
#ifndef USE_FLOAT8_BYVAL
677+
pfree(DatumGetPointer(d));
678+
#endif
671679

672680
pgstat_count_index_tuples(scan->indexRelation, ntids);
673681

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy