Skip to content

Commit 681aa43

Browse files
author
Maksim Milyutin
committed
Fix problem with parallel queries when none partition is selected
1 parent 5327ca9 commit 681aa43

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/pg_pathman.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,12 +1878,15 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti,
18781878

18791879
parallel_workers = Max(parallel_workers, path->parallel_workers);
18801880
}
1881-
Assert(parallel_workers > 0);
18821881

1883-
/* Generate a partial append path. */
1884-
appendpath = create_append_path(rel, partial_subpaths, NULL,
1885-
parallel_workers);
1886-
add_partial_path(rel, (Path *) appendpath);
1882+
if (parallel_workers > 0)
1883+
{
1884+
1885+
/* Generate a partial append path. */
1886+
appendpath = create_append_path(rel, partial_subpaths, NULL,
1887+
parallel_workers);
1888+
add_partial_path(rel, (Path *) appendpath);
1889+
}
18871890
}
18881891
#endif
18891892

tests/python/partitioning_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,22 @@ def ordered(obj):
580580
res_tuples = sorted(map(lambda x: x[0], res_tuples))
581581
expected = [1, 2, 3, 4, 5]
582582
self.assertEqual(res_tuples, expected)
583+
584+
# Check the case when none partition is selected in result plan
585+
test_query = 'select * from range_partitioned where i < 1'
586+
plan = con.execute('select query_plan(\'%s\')' % test_query)[0][0]
587+
expected = json.loads("""
588+
[
589+
{
590+
"Plan": {
591+
"Node Type": "Result",
592+
"Parallel Aware": false,
593+
"One-Time Filter": "false"
594+
}
595+
}
596+
]
597+
""")
598+
self.assertEqual(ordered(plan), ordered(expected))
583599
# import ipdb; ipdb.set_trace()
584600

585601
# Remove all objects for testing

0 commit comments

Comments
 (0)