summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-11-24 16:50:21 +0100
committerSergei Golubchik <serg@mariadb.org>2021-12-11 17:08:35 +0100
commitb5ec3e30b59a75e68192be8fb4550237bd146a2f (patch)
tree360ed8a0f4010b5e5ab1a7b93418aa3e22df5355 /sql/opt_range.cc
parent52a9d82ecb5b14b89dc47549c45b88e6f07a53bb (diff)
downloadmariadb-git-bb-10.8-MDEV-26938.tar.gz
MDEV-26938 Support descending indexes internally in InnoDB (server part)bb-10.8-MDEV-26938
* 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
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 06063cb9ae1..86539046a32 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2020, MariaDB
+ Copyright (c) 2008, 2021, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2805,11 +2805,11 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
continue; // ToDo: ft-keys in non-ft ranges, if possible SerG
}
- trace_idx_details.add("usable", true);
param.key[param.keys]=key_parts;
key_part_info= key_info->key_part;
uint cur_key_len= 0;
Json_writer_array trace_keypart(thd, "key_parts");
+ bool unusable_has_desc_keyparts= false;
for (uint part= 0 ; part < n_key_parts ;
part++, key_parts++, key_part_info++)
{
@@ -2824,8 +2824,17 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
(key_info->flags & HA_SPATIAL) ? Field::itMBR : Field::itRAW;
/* Only HA_PART_KEY_SEG is used */
key_parts->flag= (uint8) key_part_info->key_part_flag;
+ if (key_part_info->key_part_flag & HA_REVERSE_SORT)
+ unusable_has_desc_keyparts= true;
trace_keypart.add(key_parts->field->field_name);
}
+ trace_keypart.end();
+ trace_idx_details.add("usable", !unusable_has_desc_keyparts);
+ if (unusable_has_desc_keyparts) // TODO MDEV-13756
+ {
+ key_parts= param.key[param.keys];
+ continue;
+ }
param.real_keynr[param.keys++]=idx;
if (cur_key_len > max_key_len)
max_key_len= cur_key_len;