Commit 96bdda6c authored by Sergei Petrunia's avatar Sergei Petrunia Committed by Sergei Golubchik

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)"
parent d6c6f79f
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment