Commit 58195449 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash

just like in SHOW KEYS, suppress DESC in SHOW CREATE if not HA_READ_ORDER
parent aea076dc
drop table if exists t1,t2;
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
insert into t1 values(1,1),(2,2),(3,3),(4,4); insert into t1 values(1,1),(2,2),(3,3),(4,4);
delete from t1 where a=1 or a=0; delete from t1 where a=1 or a=0;
...@@ -467,4 +466,23 @@ SELECT * FROM t1 WHERE c1='bar2'; ...@@ -467,4 +466,23 @@ SELECT * FROM t1 WHERE c1='bar2';
c1 c1
bar2 bar2
DROP TABLE t1; DROP TABLE t1;
End of 5.5 tests #
# End of 5.5 tests
#
#
# MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash
#
create table t1 (a int, key(a desc)) engine=memory;
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
t1 1 a 1 a NULL 0 NULL NULL YES HASH NO
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
KEY `a` (`a`)
) ENGINE=MEMORY DEFAULT CHARSET=latin1
drop table t1;
#
# End of 10.8 tests
#
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
# Test of heap tables. # Test of heap tables.
# #
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100; create table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
insert into t1 values(1,1),(2,2),(3,3),(4,4); insert into t1 values(1,1),(2,2),(3,3),(4,4);
delete from t1 where a=1 or a=0; delete from t1 where a=1 or a=0;
...@@ -346,4 +342,18 @@ explain SELECT * FROM t1 WHERE c1='bar2'; ...@@ -346,4 +342,18 @@ explain SELECT * FROM t1 WHERE c1='bar2';
SELECT * FROM t1 WHERE c1='bar2'; SELECT * FROM t1 WHERE c1='bar2';
DROP TABLE t1; DROP TABLE t1;
--echo End of 5.5 tests --echo #
--echo # End of 5.5 tests
--echo #
--echo #
--echo # MDEV-27406 Index on a HEAP table retains DESC attribute despite being hash
--echo #
create table t1 (a int, key(a desc)) engine=memory;
show index from t1;
show create table t1;
drop table t1;
--echo #
--echo # End of 10.8 tests
--echo #
...@@ -2369,7 +2369,8 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list, ...@@ -2369,7 +2369,8 @@ int show_create_table_ex(THD *thd, TABLE_LIST *table_list,
packet->append_parenthesized((long) key_part->length / packet->append_parenthesized((long) key_part->length /
key_part->field->charset()->mbmaxlen); key_part->field->charset()->mbmaxlen);
} }
if (key_part->key_part_flag & HA_REVERSE_SORT) if (table->file->index_flags(i, j, 0) & HA_READ_ORDER &&
key_part->key_part_flag & HA_REVERSE_SORT) /* same in SHOW KEYS */
packet->append(STRING_WITH_LEN(" DESC")); packet->append(STRING_WITH_LEN(" DESC"));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment