Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac2303a

Browse files
committed
Fix memory leak in IndexScan node with reordering
Fix ExecReScanIndexScan() to free the referenced tuples while emptying thepriority queue. Backpatch to all supported versions.Discussion:https://postgr.es/m/CAHqSB9gECMENBQmpbv5rvmT3HTaORmMK3Ukg73DsX5H7EJV7jw%40mail.gmail.comAuthor: Aliaksandr KalenikReviewed-by: Tom Lane, Alexander KorotkovBackpatch-through: 10
1 parent51ee561 commitac2303a

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+
HeapTupletuple;
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
@@ -639,6 +639,33 @@ SELECT circle_center(f1), round(radius(f1)) as radius FROM gcircle_tbl ORDER BY
639639
(751.5,2655) | 20
640640
(10 rows)
641641

642+
EXPLAIN (COSTS OFF)
643+
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;
644+
QUERY PLAN
645+
--------------------------------------------------------------------------------------------
646+
Function Scan on generate_series x
647+
SubPlan 1
648+
-> Limit
649+
-> Index Scan using ggpolygonind on gpolygon_tbl
650+
Order By: (f1 <-> point((x.x)::double precision, (x.x)::double precision))
651+
(5 rows)
652+
653+
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;
654+
point | c
655+
---------+-------------------------------------------
656+
(0,0) | ((240,359),(240,455),(337,455),(337,359))
657+
(1,1) | ((240,359),(240,455),(337,455),(337,359))
658+
(2,2) | ((240,359),(240,455),(337,455),(337,359))
659+
(3,3) | ((240,359),(240,455),(337,455),(337,359))
660+
(4,4) | ((240,359),(240,455),(337,455),(337,359))
661+
(5,5) | ((240,359),(240,455),(337,455),(337,359))
662+
(6,6) | ((240,359),(240,455),(337,455),(337,359))
663+
(7,7) | ((240,359),(240,455),(337,455),(337,359))
664+
(8,8) | ((240,359),(240,455),(337,455),(337,359))
665+
(9,9) | ((240,359),(240,455),(337,455),(337,359))
666+
(10,10) | ((240,359),(240,455),(337,455),(337,359))
667+
(11 rows)
668+
642669
-- Now check the results from bitmap indexscan
643670
SET enable_seqscan = OFF;
644671
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
@@ -255,6 +255,10 @@ EXPLAIN (COSTS OFF)
255255
SELECT circle_center(f1), round(radius(f1))as radiusFROM gcircle_tblORDER BY f1<->'(200,300)'::pointLIMIT10;
256256
SELECT circle_center(f1), round(radius(f1))as radiusFROM gcircle_tblORDER BY f1<->'(200,300)'::pointLIMIT10;
257257

258+
EXPLAIN (COSTS OFF)
259+
SELECTpoint(x,x), (SELECT f1FROM gpolygon_tblORDER BY f1<->point(x,x)LIMIT1)as cFROM generate_series(0,10,1) x;
260+
SELECTpoint(x,x), (SELECT f1FROM gpolygon_tblORDER BY f1<->point(x,x)LIMIT1)as cFROM generate_series(0,10,1) x;
261+
258262
-- Now check the results from bitmap indexscan
259263
SET enable_seqscan= OFF;
260264
SET enable_indexscan= OFF;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp