Commit e6cfe170 authored by Rich Prohaska's avatar Rich Prohaska

test cardinality with a single alter table drop add command

parent 882ee12c
drop table if exists tt;
create table tt (a int, b int, c int, d int, key(a), key(b), key(c));
insert into tt values (0,0,0,0),(1,0,0,0),(2,0,1,0),(3,0,1,0);
show indexes from tt;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
tt 1 a 1 a A NULL NULL NULL YES BTREE
tt 1 b 1 b A NULL NULL NULL YES BTREE
tt 1 c 1 c A NULL NULL NULL YES BTREE
analyze table tt;
Table Op Msg_type Msg_text
test.tt analyze status OK
show indexes from tt;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
tt 1 a 1 a A 4 NULL NULL YES BTREE
tt 1 b 1 b A 1 NULL NULL YES BTREE
tt 1 c 1 c A 2 NULL NULL YES BTREE
alter table tt drop key b, add key (d);
show indexes from tt;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
tt 1 a 1 a A 4 NULL NULL YES BTREE
tt 1 c 1 c A 2 NULL NULL YES BTREE
tt 1 d 1 d A NULL NULL NULL YES BTREE
analyze table tt;
Table Op Msg_type Msg_text
test.tt analyze status OK
show indexes from tt;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
tt 1 a 1 a A 4 NULL NULL YES BTREE
tt 1 c 1 c A 2 NULL NULL YES BTREE
tt 1 d 1 d A 1 NULL NULL YES BTREE
flush tables;
show indexes from tt;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
tt 1 a 1 a A 4 NULL NULL YES BTREE
tt 1 c 1 c A 2 NULL NULL YES BTREE
tt 1 d 1 d A 1 NULL NULL YES BTREE
drop table tt;
# test that add and drop works
source include/have_tokudb.inc;
disable_warnings;
drop table if exists tt;
enable_warnings;
create table tt (a int, b int, c int, d int, key(a), key(b), key(c));
insert into tt values (0,0,0,0),(1,0,0,0),(2,0,1,0),(3,0,1,0);
# test that analyze computes the correcK
show indexes from tt;
analyze table tt;
show indexes from tt;
# drop b, add d
alter table tt drop key b, add key (d);
show indexes from tt;
analyze table tt;
show indexes from tt;
# test that cardinality is persistent
flush tables;
show indexes from tt;
drop table tt;
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