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))
3974
+
(2 rows)
3975
+
3966
3976
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);
3967
3977
create table hp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
3968
3978
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
@@ -1141,6 +1141,11 @@ create table rp_prefix_test3_p2 partition of rp_prefix_test3 for values from (2,
1141
1141
-- clauses for the partition key b (ie, b >= 1 and b >= 2)
1142
1142
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b >=2and c >=2and d >=0;
1143
1143
1144
+
-- Test that get_steps_using_prefix() handles a prefix that contains multiple
1145
+
-- clauses for the partition key b (ie, b >= 1 and b = 2) (This also tests
1146
+
-- that the caller arranges clauses in that prefix in the required order)
1147
+
explain (costs off) select*from rp_prefix_test3 where a >=1and b >=1and b =2and c =2and d >=0;
1148
+
1144
1149
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);
1145
1150
createtablehp_prefix_test_p1 partition of hp_prefix_test for values with (modulus 2, remainder 0);
1146
1151
createtablehp_prefix_test_p2 partition of hp_prefix_test for values with (modulus 2, remainder 1);
0 commit comments