Content-Length: 376210 | pFad | http://github.com/postgrespro/postgres/commit/3f74daa8dfc634132ff7270212c57da5e316b001

B6 Fix memory leak in IndexScan node with reordering · postgrespro/postgres@3f74daa · GitHub
Skip to content

Commit 3f74daa

Browse files
committed
Fix memory leak in IndexScan node with reordering
Fix ExecReScanIndexScan() to free the referenced tuples while emptying the priority queue. Backpatch to all supported versions. Discussion: https://postgr.es/m/CAHqSB9gECMENBQmpbv5rvmT3HTaORmMK3Ukg73DsX5H7EJV7jw%40mail.gmail.com Author: Aliaksandr Kalenik Reviewed-by: Tom Lane, Alexander Korotkov Backpatch-through: 10
1 parent c963e84 commit 3f74daa

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/backend/executor/nodeIndexscan.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,12 @@ ExecReScanIndexScan(IndexScanState *node)
574574
/* flush the reorder queue */
575575
if (node->iss_ReorderQueue)
576576
{
577+
HeapTuple tuple;
577578
while (!pairingheap_is_empty(node->iss_ReorderQueue))
578-
reorderqueue_pop(node);
579+
{
580+
tuple = reorderqueue_pop(node);
581+
heap_freetuple(tuple);
582+
}
579583
}
580584

581585
/* reset index scan */

src/test/regress/expected/create_index.out

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,33 @@ SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY
588588
(751.5,2655) | 20
589589
(10 rows)
590590

591+
EXPLAIN (COSTS OFF)
592+
SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x;
593+
QUERY PLAN
594+
--------------------------------------------------------------------------------------------
595+
Function Scan on generate_series x
596+
SubPlan 1
597+
-> Limit
598+
-> Index Scan using ggpolygonind on gpolygon_tbl
599+
Order By: (f1 <-> point((x.x)::double precision, (x.x)::double precision))
600+
(5 rows)
601+
602+
SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x;
603+
point | c
604+
---------+-------------------------------------------
605+
(0,0) | ((240,359),(240,455),(337,455),(337,359))
606+
(1,1) | ((240,359),(240,455),(337,455),(337,359))
607+
(2,2) | ((240,359),(240,455),(337,455),(337,359))
608+
(3,3) | ((240,359),(240,455),(337,455),(337,359))
609+
(4,4) | ((240,359),(240,455),(337,455),(337,359))
610+
(5,5) | ((240,359),(240,455),(337,455),(337,359))
611+
(6,6) | ((240,359),(240,455),(337,455),(337,359))
612+
(7,7) | ((240,359),(240,455),(337,455),(337,359))
613+
(8,8) | ((240,359),(240,455),(337,455),(337,359))
614+
(9,9) | ((240,359),(240,455),(337,455),(337,359))
615+
(10,10) | ((240,359),(240,455),(337,455),(337,359))
616+
(11 rows)
617+
591618
-- Now check the results from bitmap indexscan
592619
SET enable_seqscan = OFF;
593620
SET enable_indexscan = OFF;

src/test/regress/sql/create_index.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ EXPLAIN (COSTS OFF)
239239
SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10;
240240
SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY f1 <-> '(200,300)'::point LIMIT 10;
241241

242+
EXPLAIN (COSTS OFF)
243+
SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x;
244+
SELECT point(x,x), (SELECT f1 FROM gpolygon_tbl ORDER BY f1 <-> point(x,x) LIMIT 1) as c FROM generate_series(0,10,1) x;
245+
242246
-- Now check the results from bitmap indexscan
243247
SET enable_seqscan = OFF;
244248
SET enable_indexscan = OFF;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/3f74daa8dfc634132ff7270212c57da5e316b001

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy