You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix yet another issue with step generation in partition pruning.
Commit 13838740f fixed some issues with step generation in partition
pruning, but there was yet another one: get_steps_using_prefix() assumes
that clauses in the passed-in prefix list are sorted in ascending order
of their partition key numbers, but the caller failed to ensure this for
range partitioning, which led to an assertion failure in debug builds.
Adjust the caller function to arrange the clauses in the prefix list in
the required order for range partitioning.
Back-patch to v11, like the previous commit.
Patch by me, reviewed by Amit Langote.
Discussion: https://postgr.es/m/CAPmGK16jkXiFG0YqMbU66wte-oJTfW6D1HaNvQf%3D%2B5o9%3Dm55wQ%40mail.gmail.com
Filter: ((a >= 1) AND (b >= 1) AND (d >= 0) AND (b = 2) AND (c = 2))
3722
+
(2 rows)
3723
+
3714
3724
create table hp_prefix_test (a int, b int, c int, d int) partition by hash (a part_test_int4_ops, b part_test_int4_ops, c part_test_int4_ops, d part_test_int4_ops);
3715
3725
create table hp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
3716
3726
create table hp_prefix_test_p2 partition of hp_prefix_test for values with (modulus 2, remainder 1);
Copy file name to clipboardExpand all lines: src/test/regress/sql/partition_prune.sql
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1080,6 +1080,11 @@ create table rp_prefix_test3_p2 partition of rp_prefix_test3 for values from (2,
1080
1080
-- clauses for the partition key b (ie, b >= 1 and b >= 2)
1081
1081
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b >=2and c >=2and d >=0;
1082
1082
1083
+
-- Test that get_steps_using_prefix() handles a prefix that contains multiple
1084
+
-- clauses for the partition key b (ie, b >= 1 and b = 2) (This also tests
1085
+
-- that the caller arranges clauses in that prefix in the required order)
1086
+
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b =2and c =2and d >=0;
1087
+
1083
1088
createtablehp_prefix_test (a int, b int, c int, d int) partition by hash (a part_test_int4_ops, b part_test_int4_ops, c part_test_int4_ops, d part_test_int4_ops);
1084
1089
createtablehp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
1085
1090
createtablehp_prefix_test_p2 partition of hp_prefix_test for values with (modulus 2, remainder 1);
0 commit comments