summaryrefslogtreecommitdiff
path: root/sql/sql_table.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/sql_table.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/sql_table.cc')
-rw-r--r--sql/sql_table.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b07efb29bba..452c03b67fa 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2281,7 +2281,7 @@ void promote_first_timestamp_column(List<Create_field> *column_definitions)
static bool key_cmp(const Key_part_spec &a, const Key_part_spec &b)
{
- return a.length == b.length &&
+ return a.length == b.length && a.asc == b.asc &&
!lex_string_cmp(system_charset_info, &a.field_name, &b.field_name);
}
@@ -3324,6 +3324,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
key_part_info->fieldnr= field;
key_part_info->offset= (uint16) sql_field->offset;
key_part_info->key_type=sql_field->pack_flag;
+ key_part_info->key_part_flag= column->asc ? 0 : HA_REVERSE_SORT;
uint key_part_length= sql_field->type_handler()->
calc_key_length(*sql_field);
@@ -8381,9 +8382,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
key_part_length= 0; // Use whole field
}
key_part_length /= kfield->charset()->mbmaxlen;
- key_parts.push_back(new (thd->mem_root) Key_part_spec(&cfield->field_name,
- key_part_length, true),
- thd->mem_root);
+ Key_part_spec *kps= new (thd->mem_root) Key_part_spec(&cfield->field_name,
+ key_part_length, true);
+ kps->asc= !(key_part->key_part_flag & HA_REVERSE_SORT);
+ key_parts.push_back(kps, thd->mem_root);
if (!(cfield->invisible == INVISIBLE_SYSTEM && cfield->vers_sys_field()))
user_keyparts= true;
}