diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c index 9a81e22..64c6239 100644 --- a/src/backend/executor/nodeGatherMerge.c +++ b/src/backend/executor/nodeGatherMerge.c @@ -334,6 +334,7 @@ ExecReScanGatherMerge(GatherMergeState *node) ExecShutdownGatherMergeWorkers(node); node->initialized = false; + node->gm_initialized = false; if (node->pei) ExecParallelReinitialize(node->pei); diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 0efb211..fbce71c 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -300,6 +300,52 @@ select count(*) from tenk1 group by twenty; 500 (20 rows) +--test rescan behavior of gather merge +set min_parallel_index_scan_size=0; +set enable_gather=off; +set enable_material=off; +set enable_seqscan=off; +set enable_bitmapscan=off; +set cpu_tuple_cost=0.05; +explain (costs off) + select count(tenk1.hundred) from + tenk1 right join (values (1,100), (2,200)) as t (two, hundred) on + t.two > 1 and tenk1.hundred > 95 group by tenk1.hundred order by + tenk1.hundred; + QUERY PLAN +------------------------------------------------------------------------------- + GroupAggregate + Group Key: tenk1.hundred + -> Sort + Sort Key: tenk1.hundred + -> Nested Loop Left Join + Join Filter: ("*VALUES*".column1 > 1) + -> Values Scan on "*VALUES*" + -> Gather Merge + Workers Planned: 4 + -> Parallel Index Only Scan using tenk1_hundred on tenk1 + Index Cond: (hundred > 95) +(11 rows) + +select count(tenk1.hundred) from +tenk1 right join (values (1,100), (2,200)) as t (two, hundred) on +t.two > 1 and tenk1.hundred > 95 group by tenk1.hundred order by +tenk1.hundred; + count +------- + 100 + 100 + 100 + 100 + 0 +(5 rows) + +reset min_parallel_index_scan_size; +reset enable_gather; +reset enable_material; +reset enable_seqscan; +reset enable_bitmapscan; +reset cpu_tuple_cost; -- gather merge test with 0 worker set max_parallel_workers = 0; explain (costs off) diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql index e717f92..ad73d87 100644 --- a/src/test/regress/sql/select_parallel.sql +++ b/src/test/regress/sql/select_parallel.sql @@ -118,6 +118,32 @@ explain (costs off) select count(*) from tenk1 group by twenty; +--test rescan behavior of gather merge +set min_parallel_index_scan_size=0; +set enable_gather=off; +set enable_material=off; +set enable_seqscan=off; +set enable_bitmapscan=off; +set cpu_tuple_cost=0.05; + +explain (costs off) + select count(tenk1.hundred) from + tenk1 right join (values (1,100), (2,200)) as t (two, hundred) on + t.two > 1 and tenk1.hundred > 95 group by tenk1.hundred order by + tenk1.hundred; + +select count(tenk1.hundred) from +tenk1 right join (values (1,100), (2,200)) as t (two, hundred) on +t.two > 1 and tenk1.hundred > 95 group by tenk1.hundred order by +tenk1.hundred; + +reset min_parallel_index_scan_size; +reset enable_gather; +reset enable_material; +reset enable_seqscan; +reset enable_bitmapscan; +reset cpu_tuple_cost; + -- gather merge test with 0 worker set max_parallel_workers = 0; explain (costs off)