1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-26938 Support descending indexes internally in InnoDB (server part)

* preserve DESC index property in the parser
* store it in the frm (only for HA_KEY_ALG_BTREE)
* read it from the frm
* show it in SHOW CREATE
* skip DESC indexes in opt_range.cc and opt_sum.cc
* ORDER BY test

This includes a fix of MDEV-27432.
This commit is contained in:
Sergei Golubchik
2021-11-24 16:50:21 +01:00
parent 358921ce32
commit a4cac0e07a
28 changed files with 882 additions and 119 deletions

View File

@ -220,6 +220,41 @@ dd.d1, dd.d2, dd.id limit 1
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL PRIMARY 4 NULL # Using index
1 PRIMARY t2 eq_ref PRIMARY,id2 PRIMARY 4 func # Using where
2 DEPENDENT SUBQUERY dd range id2,for_latest_sort for_latest_sort 6 NULL # Using where
2 DEPENDENT SUBQUERY dd index id2,for_latest_sort for_latest_sort 14 NULL # Using where
drop table t1,t2;
# End of 10.2 tests
#
# MDEV-26938 Support descending indexes internally in InnoDB
#
create table t1 (a int, b int, c int, key r (a desc, b asc));
insert t1 select seq % 10, seq div 10, seq from seq_1_to_55;
insert t1 values (NULL, NULL, NULL), (9, NULL, NULL);
explain select * from t1 force index(r) order by a,b limit 20;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 57 Using filesort
explain select * from t1 force index(r) order by a desc,b limit 20;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL r 10 NULL 20
select * from t1 force index(r) order by a desc,b limit 20;
a b c
9 NULL NULL
9 0 9
9 1 19
9 2 29
9 3 39
9 4 49
8 0 8
8 1 18
8 2 28
8 3 38
8 4 48
7 0 7
7 1 17
7 2 27
7 3 37
7 4 47
6 0 6
6 1 16
6 2 26
6 3 36
drop table t1;