# test that add index keeps cardinality for older indexes

source include/have_tokudb.inc;
set default_storage_engine='tokudb';

disable_warnings;
drop table if exists tt;
enable_warnings;

# this test is explicitly testing analyze functionality so we need to disable
# the auto and background analysis (on by default in 5.7) for this test
set session tokudb_auto_analyze = 0;
set session tokudb_analyze_in_background = 0;

create table tt (a int, b int, c int, key(b), key(c), primary key(a));
insert into tt values (1,0,0),(2,0,0),(3,0,1),(4,0,1);

# compute cardinality
show indexes from tt;
analyze table tt;
show indexes from tt;

# drop key a
alter table tt drop primary key;
show indexes from tt;

# test that cardinality is persistent
flush tables;
show indexes from tt;

drop table tt;
