summaryrefslogtreecommitdiff
path: root/sql/unireg.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/unireg.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/unireg.cc')
-rw-r--r--sql/unireg.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 2726b9a68c2..6c342f1373f 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2020, MariaDB Corporation.
+ Copyright (c) 2009, 2021, MariaDB Corporation.
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
@@ -685,6 +685,13 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
DBUG_PRINT("loop", ("flags: %lu key_parts: %d key_part: %p",
key->flags, key->user_defined_key_parts,
key->key_part));
+
+ /* For SPATIAL, FULLTEXT and HASH indexes (anything other than B-tree),
+ ignore the ASC/DESC attribute of columns. */
+ const uchar ha_reverse_sort=
+ key->algorithm > HA_KEY_ALG_BTREE || key->flags & (HA_FULLTEXT|HA_SPATIAL)
+ ? 0 : HA_REVERSE_SORT;
+
for (key_part=key->key_part,key_part_end=key_part+key->user_defined_key_parts ;
key_part != key_part_end ;
key_part++)
@@ -697,7 +704,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
int2store(pos,key_part->fieldnr+1+FIELD_NAME_USED);
offset= (uint) (key_part->offset+data_offset+1);
int2store(pos+2, offset);
- pos[4]=0; // Sort order
+ pos[4]= key_part->key_part_flag & ha_reverse_sort;
int2store(pos+5,key_part->key_type);
int2store(pos+7,key_part->length);
pos+=9;