diff options
author | Sergei Golubchik <serg@mariadb.org> | 2021-11-24 16:50:21 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-12-11 17:08:35 +0100 |
commit | b5ec3e30b59a75e68192be8fb4550237bd146a2f (patch) | |
tree | 360ed8a0f4010b5e5ab1a7b93418aa3e22df5355 /sql/key.cc | |
parent | 52a9d82ecb5b14b89dc47549c45b88e6f07a53bb (diff) | |
download | mariadb-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/key.cc')
-rw-r--r-- | sql/key.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/key.cc b/sql/key.cc index f2cebfe6d82..ef1af849391 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -573,6 +573,9 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) /* loop over every key part */ do { + const int GREATER= key_part->key_part_flag & HA_REVERSE_SORT ? -1 : +1; + const int LESS= -GREATER; + field= key_part->field; if (key_part->null_bit) @@ -593,12 +596,12 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) ; /* Fall through, no NULL fields */ else { - DBUG_RETURN(+1); + DBUG_RETURN(GREATER); } } else if (!sec_is_null) { - DBUG_RETURN(-1); + DBUG_RETURN(LESS); } else goto next_loop; /* Both were NULL */ @@ -612,7 +615,7 @@ int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec) */ if ((result= field->cmp_prefix(field->ptr+first_diff, field->ptr+sec_diff, key_part->length))) - DBUG_RETURN(result); + DBUG_RETURN(result * GREATER); next_loop: key_part++; key_part_num++; |