summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2021-12-22 17:19:48 +0300
committerSergei Golubchik <serg@mariadb.org>2022-01-26 18:43:06 +0100
commit96bdda6c96bd0cf63077a72c594e08ce4507c006 (patch)
tree2eafcb9d8a922db894cf637e7c13878ad60b7a51
parentd6c6f79f5d0a4f2b747fc1bec08dd202c433f1d6 (diff)
downloadmariadb-git-96bdda6c96bd0cf63077a72c594e08ce4507c006.tar.gz
MDEV-26996 Reverse-ordered indexes: improve print-out
When printing a range into optimizer trace, print DESC for columns that are reverse-ordered, for example: "(4) <= (key1 DESC) <= (2)"
-rw-r--r--mysql-test/main/desc_index_range.result14
-rw-r--r--sql/opt_range.cc2
2 files changed, 9 insertions, 7 deletions
diff --git a/mysql-test/main/desc_index_range.result b/mysql-test/main/desc_index_range.result
index feec5dc1720..244659e3f48 100644
--- a/mysql-test/main/desc_index_range.result
+++ b/mysql-test/main/desc_index_range.result
@@ -13,9 +13,9 @@ json_detailed(json_extract(trace, '$**.range_access_plan.ranges'))
[
[
- "(6) <= (a) <= (6)",
- "(4) <= (a) <= (4)",
- "(2) <= (a) <= (2)"
+ "(6) <= (a DESC) <= (6)",
+ "(4) <= (a DESC) <= (4)",
+ "(2) <= (a DESC) <= (2)"
]
]
set optimizer_trace=default;
@@ -57,7 +57,7 @@ json_detailed(json_extract(trace, '$**.range_access_plan.ranges'))
[
[
- "(8,50) <= (a,b)"
+ "(8,50) <= (a,b DESC)"
]
]
select * from t1 force index(ab) where a>=8 and b<=50;
@@ -104,7 +104,7 @@ json_detailed(json_extract(trace, '$**.range_access_plan.ranges'))
[
[
- "(2,80) <= (a,b) <= (4,50)"
+ "(2,80) <= (a,b DESC) <= (4,50)"
]
]
select * from t1 where a between 2 and 4 and b between 50 and 80;
@@ -138,7 +138,7 @@ json_detailed(json_extract(trace, '$**.range_access_plan.ranges'))
[
[
- "(4) <= (a) <= (2)"
+ "(4) <= (a DESC) <= (2)"
]
]
explain
@@ -151,7 +151,7 @@ json_detailed(json_extract(trace, '$**.range_access_plan.ranges'))
[
[
- "(4,80) <= (a,b) <= (2,50)"
+ "(4,80) <= (a DESC,b DESC) <= (2,50)"
]
]
drop table t2;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index ba2032dd93c..b0d3ff5a0ef 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -16637,6 +16637,8 @@ void print_keyparts_name(String *out, const KEY_PART_INFO *key_part,
else
out->append(STRING_WITH_LEN(","));
out->append(key_part->field->field_name);
+ if (key_part->key_part_flag & HA_REVERSE_SORT)
+ out->append(STRING_WITH_LEN(" DESC"));
}
else
break;