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 1383874 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))
3759
+
(3 rows)
3760
+
3750
3761
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);
3751
3762
create table hp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
3752
3763
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
@@ -1051,6 +1051,11 @@ create table rp_prefix_test3_p2 partition of rp_prefix_test3 for values from (2,
1051
1051
-- clauses for the partition key b (ie, b >= 1 and b >= 2)
1052
1052
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b >=2and c >=2and d >=0;
1053
1053
1054
+
-- Test that get_steps_using_prefix() handles a prefix that contains multiple
1055
+
-- clauses for the partition key b (ie, b >= 1 and b = 2) (This also tests
1056
+
-- that the caller arranges clauses in that prefix in the required order)
1057
+
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b =2and c =2and d >=0;
1058
+
1054
1059
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);
1055
1060
createtablehp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
1056
1061
createtablehp_prefix_test_p2 partition of hp_prefix_test for values with (modulus 2, remainder 1);
0 commit comments