summaryrefslogtreecommitdiff
path: root/sql/unireg.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r--sql/unireg.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 7f89f4e78b1..e6f52cd953e 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,8 @@ 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
+ key_part->key_part_flag &= ha_reverse_sort;
+ pos[4]= (uchar)(key_part->key_part_flag);
int2store(pos+5,key_part->key_type);
int2store(pos+7,key_part->length);
pos+=9;