diff --git a/include/my_base.h b/include/my_base.h index 2ebad08a620..079c5068c17 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -260,6 +260,7 @@ enum ha_base_keytype { #define HA_SPATIAL 1024 /* For spatial search */ #define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */ #define HA_GENERATED_KEY 8192 /* Automaticly generated key */ +#define HA_INVISIBLE_KEY (1<<30) /* This key is visible */ #define HA_CLUSTERING (1<<31) /* TokuDB CLUSTERING key */ /* The combination of the above can be used for key type comparison. */ diff --git a/mysql-test/include/invisible_indexes.inc b/mysql-test/include/invisible_indexes.inc new file mode 100644 index 00000000000..552534b82e6 --- /dev/null +++ b/mysql-test/include/invisible_indexes.inc @@ -0,0 +1,397 @@ +--echo # +--echo # WL#8697: Invisible Indexes +--echo # + +--echo # Test of ALTER INDEX syntax. + +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +DROP TABLE t1; + +--echo # Test of CREATE INDEX syntax with invisible indexes. + +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +DROP TABLE t1; + +--echo # Test that invisible indexes are not used. + +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); + +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; + +ANALYZE TABLE t1, t2; + +EXPLAIN SELECT a FROM t1; +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; + +EXPLAIN SELECT a FROM t2; +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; + +DROP TABLE t1, t2; + +--echo # Test that renaming an index does not change visibility and vice versa. + +CREATE TABLE t1 ( + a INT, INDEX (a), + b INT, INDEX (b) INVISIBLE +); + +SHOW INDEXES FROM t1; + +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD INDEX a1(a); +ALTER TABLE t1 DROP INDEX b; +ALTER TABLE t1 ADD INDEX b1(b) INVISIBLE; + +SHOW INDEXES FROM t1; + +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; + +SHOW INDEXES FROM t1; + +DROP TABLE t1; + +--echo # Test of SHOW CREATE TABLE. + +CREATE TABLE t1 ( + a INT, + b INT, + c INT, + INDEX (a) VISIBLE, + INDEX (b) INVISIBLE, + INDEX (c) +); + +SHOW CREATE TABLE t1; + +DROP TABLE t1; + +--echo # Test that primary key indexes can't be made invisible. + +--error ER_PK_INDEX_CANT_BE_INVISIBLE +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +--error ER_PARSE_ERROR +CREATE TABLE t1 ( a INT PRIMARY KEY INVISIBLE ); +--error ER_PARSE_ERROR +CREATE TABLE t1 ( a INT KEY INVISIBLE ); +--error ER_PARSE_ERROR +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +CREATE TABLE t1 ( + a INT, + b INT, + c INT, + INDEX (b) INVISIBLE, + INDEX (c) +); +--error ER_PK_INDEX_CANT_BE_INVISIBLE +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # Currently we allow to name the primary key index, but the name is +--echo # silently changed to PRIMARY. If this behavior changes in the future, +--echo # we need to take some additional measures to rule out invisible primary +--echo # key indexes. The below two tests serve as triggers for such a change. +--echo # +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +DROP TABLE t1; + +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 ( + a INT, KEY (a), + b INT, KEY (b) INVISIBLE +); + +--error ER_KEY_DOES_NOT_EXITS +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; + +--echo # +--echo # Repeated alter actions. Should work. +--echo # +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; + +--echo # +--echo # Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +--echo # +# --error ER_KEY_DOES_NOT_EXITS +# ALTER TABLE t1 RENAME INDEX a TO x, RENAME INDEX x TO a; +# --error ER_KEY_DOES_NOT_EXITS +# ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX x INVISIBLE; +# --error ER_KEY_DOES_NOT_EXITS +# ALTER TABLE t1 RENAME INDEX a TO x, ALTER INDEX a VISIBLE; +# --error ER_KEY_DOES_NOT_EXITS +# ALTER TABLE t1 ALTER INDEX a VISIBLE, RENAME INDEX a TO x; + + +--echo # +--echo # Various algorithms and their effects. +--echo # +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; + +--enable_info +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +--disable_info +ANALYZE TABLE t1; +SHOW INDEXES FROM t1; + +--enable_info +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +--disable_info +ANALYZE TABLE t1; +SHOW INDEXES FROM t1; + +--enable_info +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +--disable_info +ANALYZE TABLE t1; +SHOW INDEXES FROM t1; + +--enable_info +ALTER TABLE t1 ALTER INDEX a VISIBLE; +--disable_info +ANALYZE TABLE t1; +SHOW INDEXES FROM t1; + +--error ER_KEY_DOES_NOT_EXITS +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; + +DROP TABLE t1; + +--echo # +--echo # Test that constraints implemented by the indexes are still enforced +--echo # while the index is invisible. +--echo # +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, + b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); + +INSERT INTO t1 VALUES (1); +--error ER_DUP_ENTRY +INSERT INTO t1 VALUES (1); + +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +--error ER_DUP_ENTRY +INSERT INTO t2 VALUES (1); + +--error ER_BAD_NULL_ERROR +INSERT INTO t3(a) VALUES (NULL); + +--error ER_BAD_NULL_ERROR +INSERT INTO t4(a) VALUES (NULL); +INSERT INTO t4(a) VALUES (1); +--error ER_DUP_ENTRY +INSERT INTO t4(a) VALUES (1); + +INSERT INTO t5 VALUES (1, 2, 3); +--error ER_DUP_ENTRY +INSERT INTO t5 VALUES (1, 2, 3); + +DROP TABLE t1, t2, t3, t4, t5; + +--echo # +--echo # Bug#23256900: WL#8697: ASSERTION +--echo # `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +--echo # + +--echo # Test for when an index is implicitly promoted to primary key index. +--echo # The first NOT NULL UNIQUE index is candidate for promotion. +--echo # These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +--error ER_PK_INDEX_CANT_BE_INVISIBLE +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN +SELECT * FROM t1; +SELECT * FROM t1; +DROP TABLE t1; + +--echo # The first NOT NULL UNIQUE index may of course be invisible if it is +--echo # not promoted. +CREATE TABLE t1 ( + a INT NOT NULL, + b INT NOT NULL PRIMARY KEY, + UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +DROP TABLE t1; + +--echo # The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( + a INT NOT NULL, + b INT NOT NULL, + UNIQUE KEY (a), + UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +DROP TABLE t1; + +--error ER_PK_INDEX_CANT_BE_INVISIBLE +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); + +--echo # +--echo # Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +--echo # +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); + +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; + +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +EXPLAIN SELECT a FROM t1; +DROP TABLE t1; + + +--echo # +--echo # Invisible spatial indexes. +--echo # +CREATE TABLE t1 ( + fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + g GEOMETRY NOT NULL, + SPATIAL KEY(g) +) ENGINE=MyISAM; + +ANALYZE TABLE t1; + +--disable_query_log +let $1=150; +let $2=150; +while ($1) +{ + eval INSERT INTO t1 (g) VALUES (ST_GeomFromText('LineString($1 $1, $2 $2)')); + dec $1; + inc $2; +} +--enable_query_log + +let $query= +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, + ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); + +--echo # There appears to be a bug causing the cardinality number to fluctuate +--echo # for spatial indexes. +--replace_column 10 X +--eval $query +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +--replace_column 7 X +SHOW INDEXES FROM t1; +--replace_column 10 X +--eval $query + +DROP TABLE t1; + + +--echo # +--echo # Test of invisible fulltext indexes. +--echo # +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; + +let $query1= SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +let $query2= +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); + +--eval EXPLAIN $query1 +--eval EXPLAIN $query2 +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +--disable_abort_on_error +--eval EXPLAIN $query1 +--eval EXPLAIN $query2 +--eval $query1 +--eval $query2 +--enable_abort_on_error + +DROP TABLE t1; + + +--echo # +--echo # Invisible indexes on AUTO_INCREMENT columns. +--echo # +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; + +EXPLAIN SELECT a FROM t1; +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +EXPLAIN SELECT a FROM t1; + +DROP TABLE t1; + +--echo # +--echo # Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +--echo # +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 FORCE INDEX(a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); + + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 USE INDEX(a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 USE INDEX FOR JOIN (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); + + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 IGNORE INDEX(a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); + +--error ER_KEY_DOES_NOT_EXITS +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); + + +DROP TABLE t1; diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index c16757684d1..f749a001dce 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -125,24 +125,24 @@ key (n3, n4, n1, n2), key (n4, n1, n2, n3) ); alter table t1 disable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 n1 1 n1 A 0 NULL NULL BTREE -t1 1 n1_2 1 n1 A NULL NULL NULL BTREE disabled -t1 1 n1_2 2 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n1_2 3 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n1_2 4 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n2 1 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n2 2 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n2 3 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n2 4 n1 A NULL NULL NULL BTREE disabled -t1 1 n3 1 n3 A NULL NULL NULL YES BTREE disabled -t1 1 n3 2 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n3 3 n1 A NULL NULL NULL BTREE disabled -t1 1 n3 4 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n4 1 n4 A NULL NULL NULL YES BTREE disabled -t1 1 n4 2 n1 A NULL NULL NULL BTREE disabled -t1 1 n4 3 n2 A NULL NULL NULL YES BTREE disabled -t1 1 n4 4 n3 A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 n1 1 n1 A 0 NULL NULL BTREE YES +t1 1 n1_2 1 n1 A NULL NULL NULL BTREE disabled YES +t1 1 n1_2 2 n2 A NULL NULL NULL YES BTREE disabled YES +t1 1 n1_2 3 n3 A NULL NULL NULL YES BTREE disabled YES +t1 1 n1_2 4 n4 A NULL NULL NULL YES BTREE disabled YES +t1 1 n2 1 n2 A NULL NULL NULL YES BTREE disabled YES +t1 1 n2 2 n3 A NULL NULL NULL YES BTREE disabled YES +t1 1 n2 3 n4 A NULL NULL NULL YES BTREE disabled YES +t1 1 n2 4 n1 A NULL NULL NULL BTREE disabled YES +t1 1 n3 1 n3 A NULL NULL NULL YES BTREE disabled YES +t1 1 n3 2 n4 A NULL NULL NULL YES BTREE disabled YES +t1 1 n3 3 n1 A NULL NULL NULL BTREE disabled YES +t1 1 n3 4 n2 A NULL NULL NULL YES BTREE disabled YES +t1 1 n4 1 n4 A NULL NULL NULL YES BTREE disabled YES +t1 1 n4 2 n1 A NULL NULL NULL BTREE disabled YES +t1 1 n4 3 n2 A NULL NULL NULL YES BTREE disabled YES +t1 1 n4 4 n3 A NULL NULL NULL YES BTREE disabled YES insert into t1 values(10,RAND()*1000,RAND()*1000,RAND()); insert into t1 values(9,RAND()*1000,RAND()*1000,RAND()); insert into t1 values(8,RAND()*1000,RAND()*1000,RAND()); @@ -155,24 +155,24 @@ insert into t1 values(2,RAND()*1000,RAND()*1000,RAND()); insert into t1 values(1,RAND()*1000,RAND()*1000,RAND()); alter table t1 enable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 n1 1 n1 A 10 NULL NULL BTREE -t1 1 n1_2 1 n1 A 10 NULL NULL BTREE -t1 1 n1_2 2 n2 A 10 NULL NULL YES BTREE -t1 1 n1_2 3 n3 A 10 NULL NULL YES BTREE -t1 1 n1_2 4 n4 A 10 NULL NULL YES BTREE -t1 1 n2 1 n2 A 10 NULL NULL YES BTREE -t1 1 n2 2 n3 A 10 NULL NULL YES BTREE -t1 1 n2 3 n4 A 10 NULL NULL YES BTREE -t1 1 n2 4 n1 A 10 NULL NULL BTREE -t1 1 n3 1 n3 A 10 NULL NULL YES BTREE -t1 1 n3 2 n4 A 10 NULL NULL YES BTREE -t1 1 n3 3 n1 A 10 NULL NULL BTREE -t1 1 n3 4 n2 A 10 NULL NULL YES BTREE -t1 1 n4 1 n4 A 10 NULL NULL YES BTREE -t1 1 n4 2 n1 A 10 NULL NULL BTREE -t1 1 n4 3 n2 A 10 NULL NULL YES BTREE -t1 1 n4 4 n3 A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 n1 1 n1 A 10 NULL NULL BTREE YES +t1 1 n1_2 1 n1 A 10 NULL NULL BTREE YES +t1 1 n1_2 2 n2 A 10 NULL NULL YES BTREE YES +t1 1 n1_2 3 n3 A 10 NULL NULL YES BTREE YES +t1 1 n1_2 4 n4 A 10 NULL NULL YES BTREE YES +t1 1 n2 1 n2 A 10 NULL NULL YES BTREE YES +t1 1 n2 2 n3 A 10 NULL NULL YES BTREE YES +t1 1 n2 3 n4 A 10 NULL NULL YES BTREE YES +t1 1 n2 4 n1 A 10 NULL NULL BTREE YES +t1 1 n3 1 n3 A 10 NULL NULL YES BTREE YES +t1 1 n3 2 n4 A 10 NULL NULL YES BTREE YES +t1 1 n3 3 n1 A 10 NULL NULL BTREE YES +t1 1 n3 4 n2 A 10 NULL NULL YES BTREE YES +t1 1 n4 1 n4 A 10 NULL NULL YES BTREE YES +t1 1 n4 2 n1 A 10 NULL NULL BTREE YES +t1 1 n4 3 n2 A 10 NULL NULL YES BTREE YES +t1 1 n4 4 n3 A 10 NULL NULL YES BTREE YES drop table t1; create table t1 (i int unsigned not null auto_increment primary key); alter table t1 rename t2; @@ -285,18 +285,18 @@ insert into t1 values(1,2), (2,2), (3, 2); insert into t1 values(1,1), (2,1), (3, 1); alter table t1 add unique (a,b), add key (b); show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 0 a 2 b A NULL NULL NULL YES BTREE -t1 1 b 1 b A 100 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 0 a 2 b A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A 100 NULL NULL YES BTREE YES analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A 3 NULL NULL YES BTREE -t1 0 a 2 b A 300 NULL NULL YES BTREE -t1 1 b 1 b A 100 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A 3 NULL NULL YES BTREE YES +t1 0 a 2 b A 300 NULL NULL YES BTREE YES +t1 1 b 1 b A 100 NULL NULL YES BTREE YES drop table t1; CREATE TABLE t1 (i int(10), index(i) ); ALTER TABLE t1 DISABLE KEYS; @@ -314,9 +314,9 @@ ALTER TABLE t1 DISABLE KEYS; LOCK TABLES t1 WRITE; INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty'); 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 -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE YES +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE YES ALTER TABLE t1 ENABLE KEYS; UNLOCK TABLES; CHECK TABLES t1; @@ -331,23 +331,23 @@ KEY (Host) ) ENGINE=MyISAM; ALTER TABLE t1 DISABLE KEYS; 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 -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE YES +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE YES +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled YES LOCK TABLES t1 WRITE; INSERT INTO t1 VALUES ('localhost','root'),('localhost',''); 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 -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE YES +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE YES +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled YES ALTER TABLE t1 ENABLE KEYS; 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 -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 2 NULL NULL BTREE -t1 1 Host 1 Host A 1 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE YES +t1 0 PRIMARY 2 User A 2 NULL NULL BTREE YES +t1 1 Host 1 Host A 1 NULL NULL BTREE YES UNLOCK TABLES; CHECK TABLES t1; Table Op Msg_type Msg_text @@ -369,10 +369,10 @@ KEY (Host) LOCK TABLES t1 WRITE; ALTER TABLE t1 DISABLE KEYS; 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 -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE YES +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE YES +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled YES DROP TABLE t1; create table t1 (a int); alter table t1 rename to ``; @@ -546,38 +546,38 @@ drop table t1; drop table if exists t1; create table t1 (a int, key(a)); show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES "this used not to disable the index" alter table t1 modify a int, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES alter table t1 enable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 modify a bigint, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES alter table t1 enable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 add b char(10), disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES alter table t1 add c decimal(10,2), enable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES "this however did" alter table t1 disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES desc t1; Field Type Null Key Default Extra a bigint(20) YES MUL NULL @@ -586,83 +586,83 @@ c decimal(10,2) YES NULL alter table t1 add d decimal(15,5); "The key should still be disabled" show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES drop table t1; "Now will test with one unique index" create table t1(a int, b char(10), unique(a)); show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 enable keys; "If no copy on noop change, this won't touch the data file" "Unique index, no change" alter table t1 modify a int, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES "Change the type implying data copy" "Unique index, no change" alter table t1 modify a bigint, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 modify a bigint; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 modify a int; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES drop table t1; "Now will test with one unique and one non-unique index" create table t1(a int, b char(10), unique(a), key(b)); show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE YES alter table t1 disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled YES alter table t1 enable keys; "If no copy on noop change, this won't touch the data file" "The non-unique index will be disabled" alter table t1 modify a int, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled YES alter table t1 enable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE YES "Change the type implying data copy" "The non-unique index will be disabled" alter table t1 modify a bigint, disable keys; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled YES "Change again the type, but leave the indexes as_is" alter table t1 modify a int; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled YES "Try the same. When data is no copied on similar tables, this is noop" alter table t1 modify a int; show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 a 1 a A NULL NULL NULL YES BTREE -t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled YES drop table t1; create database mysqltest; create table t1 (c1 int); @@ -698,12 +698,12 @@ DROP TABLE IF EXISTS bug24219; DROP TABLE IF EXISTS bug24219_2; CREATE TABLE bug24219 (a INT, INDEX(a)); SHOW INDEX FROM bug24219; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -bug24219 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +bug24219 1 a 1 a A NULL NULL NULL YES BTREE YES ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS; SHOW INDEX FROM bug24219_2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE disabled YES DROP TABLE bug24219_2; drop table if exists table_24562; create table table_24562( @@ -1148,8 +1148,8 @@ Field Type Null Key Default Extra int_field int(10) unsigned NO MUL NULL char_field char(10) YES NULL SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 int_field 1 int_field A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 int_field 1 int_field A NULL NULL NULL BTREE YES INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet"); "Non-copy data change - new frm, but old data and index files" ALTER TABLE t1 diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result index df8a6c42924..98d85d57055 100644 --- a/mysql-test/r/analyze.result +++ b/mysql-test/r/analyze.result @@ -53,8 +53,8 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES drop table t1; End of 4.1 tests create table t1(a int); diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result index bc903d09ea2..a9dfe98b899 100644 --- a/mysql-test/r/compress.result +++ b/mysql-test/r/compress.result @@ -2090,10 +2090,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index daa0d01f26a..8022bf9b269 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1710,13 +1710,13 @@ CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE); DROP TABLE t1; CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) 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 -t1 1 c1 1 c1 NULL 0 NULL NULL YES HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 c1 1 c1 NULL 0 NULL NULL YES HASH YES DROP TABLE t1; CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) 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 -t1 1 c1 1 c1 A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 c1 1 c1 A NULL NULL NULL YES BTREE YES DROP TABLE t1; create user mysqltest_1@'test@test'; ERROR HY000: Malformed hostname (illegal symbol: '@') diff --git a/mysql-test/r/ctype_mb.result b/mysql-test/r/ctype_mb.result index 5c578e3356c..0715c5aa807 100644 --- a/mysql-test/r/ctype_mb.result +++ b/mysql-test/r/ctype_mb.result @@ -32,8 +32,8 @@ t1 CREATE TABLE `t1` ( KEY `key_a` (`a`(3)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 key_a 1 a A NULL 3 NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 key_a 1 a A NULL 3 NULL YES BTREE YES ALTER TABLE t1 CHANGE a a CHAR(4); SHOW CREATE TABLE t1; Table Create Table @@ -42,8 +42,8 @@ t1 CREATE TABLE `t1` ( KEY `key_a` (`a`(3)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 key_a 1 a A NULL 3 NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 key_a 1 a A NULL 3 NULL YES BTREE YES ALTER TABLE t1 CHANGE a a CHAR(4) CHARACTER SET utf8; SHOW CREATE TABLE t1; Table Create Table @@ -52,6 +52,6 @@ t1 CREATE TABLE `t1` ( KEY `key_a` (`a`(3)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 key_a 1 a A NULL 3 NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 key_a 1 a A NULL 3 NULL YES BTREE YES DROP TABLE t1; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 175c1807639..9db85d419c6 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -6,9 +6,9 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); 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 -t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT -t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT YES +t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT YES select * from t1 where MATCH(a,b) AGAINST ("collections"); a b Only MyISAM tables support collections @@ -242,9 +242,9 @@ match(ttxt.inhalt) against ('foobar'); id 3 show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 1 tig 1 ticket A NULL NULL NULL YES BTREE -t2 1 tix 1 inhalt NULL NULL NULL NULL YES FULLTEXT +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 1 tig 1 ticket A NULL NULL NULL YES BTREE YES +t2 1 tix 1 inhalt NULL NULL NULL NULL YES FULLTEXT YES show create table t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index d9b7a28b434..9d2c53c566a 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -622,8 +622,8 @@ a SHOW COLUMNS FROM t1; Field Type Null Key Default Extra SHOW KEYS FROM t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t3 0 PRIMARY 1 a A 0 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t3 0 PRIMARY 1 a A 0 NULL NULL BTREE YES # # SHOW CREATE TABLE. # diff --git a/mysql-test/r/grant4.result b/mysql-test/r/grant4.result index 97525ed5cbb..0c1a0e2aa29 100644 --- a/mysql-test/r/grant4.result +++ b/mysql-test/r/grant4.result @@ -87,15 +87,15 @@ use mysqltest_db1; ** Connect as restricted user mysqltest_u1. ** SELECT FROM INFORMATION_SCHEMA.STATISTICS will succeed because any privileges will do (authentication is enough). SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name='t5'; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def mysqltest_db1 t5 1 mysqltest_db1 i 1 s1 A NULL NULL NULL YES BTREE +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def mysqltest_db1 t5 1 mysqltest_db1 i 1 s1 A NULL NULL NULL YES BTREE YES ** SHOW INDEX FROM t5 will fail because we don't have any privileges on any column combination. SHOW INDEX FROM t5; ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't5' ** SHOW INDEX FROM t6 will succeed because there exist a privilege on a column combination on t6. SHOW INDEX FROM t6; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t6 1 i 1 s1 A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t6 1 i 1 s1 A NULL NULL NULL YES BTREE YES ** CHECK TABLE requires any privilege on any column combination and should succeed for t6: CHECK TABLE t6; Table Op Msg_type Msg_text diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index 546fb6d885d..edfaf7754d8 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -3,8 +3,8 @@ create table t1 (a int not null,b int not null, primary key (a)) engine=heap com insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH YES select * from t1; a b 2 2 diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result index a0d28bd0526..458f034b029 100644 --- a/mysql-test/r/heap_btree.result +++ b/mysql-test/r/heap_btree.result @@ -3,8 +3,8 @@ create table t1 (a int not null,b int not null, primary key using BTREE (a)) eng insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A NULL NULL NULL BTREE YES select * from t1; a b 2 2 diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result index 773cd373349..aa21eb518ea 100644 --- a/mysql-test/r/heap_hash.result +++ b/mysql-test/r/heap_hash.result @@ -3,8 +3,8 @@ create table t1 (a int not null,b int not null, primary key using HASH (a)) engi insert into t1 values(1,1),(2,2),(3,3),(4,4); delete from t1 where a=1 or a=0; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH YES select * from t1; a b 2 2 @@ -327,15 +327,15 @@ explain select * from t1 ignore index (btree_idx) where name='matt'; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where 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 -t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH -t1 1 heap_idx 1 name NULL 13 NULL NULL HASH -t1 1 btree_idx 1 name A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH YES +t1 1 heap_idx 1 name NULL 13 NULL NULL HASH YES +t1 1 btree_idx 1 name A NULL NULL NULL BTREE YES 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 -t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH -t1 1 heap_idx 1 name NULL 13 NULL NULL HASH -t1 1 btree_idx 1 name A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH YES +t1 1 heap_idx 1 name NULL 13 NULL NULL HASH YES +t1 1 btree_idx 1 name A NULL NULL NULL BTREE YES create table t3 ( a varchar(20) not null, @@ -344,13 +344,13 @@ key (a,b) ) engine=heap; insert into t3 select name, name from t1; show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t3 1 a 1 a NULL NULL NULL NULL HASH -t3 1 a 2 b NULL 13 NULL NULL HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t3 1 a 1 a NULL NULL NULL NULL HASH YES +t3 1 a 2 b NULL 13 NULL NULL HASH YES show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t3 1 a 1 a NULL NULL NULL NULL HASH -t3 1 a 2 b NULL 13 NULL NULL HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t3 1 a 1 a NULL NULL NULL NULL HASH YES +t3 1 a 2 b NULL 13 NULL NULL HASH YES explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 591854c62b0..15f9cf8d0af 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -215,11 +215,11 @@ table_name t1 t4 select * from information_schema.STATISTICS where TABLE_SCHEMA = "mysqltest"; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def mysqltest t1 1 mysqltest string_data 1 b A NULL NULL NULL YES BTREE YES show keys from t3 where Key_name = "a_data"; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t3 1 a_data 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t3 1 a_data 1 a A NULL NULL NULL YES BTREE YES show tables like 't%'; Tables_in_test (t%) t2 @@ -446,7 +446,7 @@ latin1_general_ci latin1_general_cs latin1_spanish_ci show keys from v4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible select * from information_schema.views where TABLE_NAME like "v%"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION def test v0 select `information_schema`.`schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci @@ -670,7 +670,7 @@ user drop view v1; create view vo as select 'a' union select 'a'; show index from vo; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME= "vo"; CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE @@ -1219,8 +1219,8 @@ describe t1; Field Type Null Key Default Extra f1 int(11) YES MUL NULL show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 f1 1 f1 A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 f1 1 f1 A NULL NULL NULL YES BTREE YES drop table t1; create table t1(f1 binary(32), f2 varbinary(64)); select character_maximum_length, character_octet_length @@ -1634,9 +1634,9 @@ CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG U select * from information_schema.schemata where schema_name = NULL; CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE select * from information_schema.tables where table_schema = NULL; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT select * from information_schema.tables where table_catalog = NULL; diff --git a/mysql-test/r/invisible_indexes.result b/mysql-test/r/invisible_indexes.result new file mode 100644 index 00000000000..9094a164236 --- /dev/null +++ b/mysql-test/r/invisible_indexes.result @@ -0,0 +1,487 @@ +# +# WL#8697: Invisible Indexes +# +# Test of ALTER INDEX syntax. +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of CREATE INDEX syntax with invisible indexes. +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +Warnings: +Note 1831 Duplicate index 'b_visible' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a_invisible 1 a A 0 NULL NULL YES BTREE NO +t1 1 b_visible 1 a A 0 NULL NULL YES BTREE YES +t1 1 a_b_invisible 1 a A 0 NULL NULL YES BTREE NO +t1 1 a_b_invisible 2 b A 0 NULL NULL YES BTREE NO +DROP TABLE t1; +# Test that invisible indexes are not used. +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL a 5 NULL 5 Using index +DROP TABLE t1, t2; +# Test that renaming an index does not change visibility and vice versa. +CREATE TABLE t1 ( +a INT, INDEX (a), +b INT, INDEX (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE YES +t1 1 b 1 b A 0 NULL NULL YES BTREE NO +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD INDEX a1(a); +ALTER TABLE t1 DROP INDEX b; +ALTER TABLE t1 ADD INDEX b1(b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A 0 NULL NULL YES BTREE YES +t1 1 b1 1 b A 0 NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A 0 NULL NULL YES BTREE NO +t1 1 b1 1 b A 0 NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of SHOW CREATE TABLE. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# Test that primary key indexes can't be made invisible. +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +CREATE TABLE t1 ( a INT PRIMARY KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +CREATE TABLE t1 ( a INT KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY INVISIBLE' at line 1 +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (b) INVISIBLE, +INDEX (c) +); +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# Currently we allow to name the primary key index, but the name is +# silently changed to PRIMARY. If this behavior changes in the future, +# we need to take some additional measures to rule out invisible primary +# key indexes. The below two tests serve as triggers for such a change. +# +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, KEY (a), +b INT, KEY (b) INVISIBLE +); +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +# +# Repeated alter actions. Should work. +# +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE NO +t1 1 b 1 b A 0 NULL NULL YES BTREE YES +# +# Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +# +# +# Various algorithms and their effects. +# +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; +ERROR 42000: Key 'ab' doesn't exist in table 't1' +DROP TABLE t1; +# +# Test that constraints implemented by the indexes are still enforced +# while the index is invisible. +# +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, +b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t3(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (1); +INSERT INTO t4(a) VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t5 VALUES (1, 2, 3); +INSERT INTO t5 VALUES (1, 2, 3); +ERROR 23000: Duplicate entry '1-2-3' for key 'a' +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#23256900: WL#8697: ASSERTION +# `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +# +# Test for when an index is implicitly promoted to primary key index. +# The first NOT NULL UNIQUE index is candidate for promotion. +# These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +EXPLAIN +SELECT * FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 4 NULL 1 Using index +SELECT * FROM t1; +a +DROP TABLE t1; +# The first NOT NULL UNIQUE index may of course be invisible if it is +# not promoted. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL PRIMARY KEY, +UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 b A 0 NULL NULL BTREE YES +t1 0 a 1 a A 0 NULL NULL BTREE NO +DROP TABLE t1; +# The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL, +UNIQUE KEY (a), +UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A 0 NULL NULL BTREE YES +t1 0 b 1 b A 0 NULL NULL BTREE NO +DROP TABLE t1; +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +# +# Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +# +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found +DROP TABLE t1; +# +# Invisible spatial indexes. +# +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL, +SPATIAL KEY(g) +) ENGINE=MyISAM; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +# There appears to be a bug causing the cardinality number to fluctuate +# for spatial indexes. +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range g g 34 NULL 8 X +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 fid A X NULL NULL BTREE YES +t1 1 g 1 g A X 32 NULL SPATIAL NO +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 150 X +DROP TABLE t1; +# +# Test of invisible fulltext indexes. +# +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL 1 NULL NULL YES FULLTEXT NO +t1 1 a 2 b NULL 1 NULL NULL YES FULLTEXT NO +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +a b +DROP TABLE t1; +# +# Invisible indexes on AUTO_INCREMENT columns. +# +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 4 NULL 3 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL +DROP TABLE t1; +# +# Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +# +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); +SELECT * FROM t1 FORCE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; +# +# Tests that don't work on MyISAM ( native partitioning, indexes on +# generated columns, etc.) +# +# +# Partitioning on keys with an invisible index, invisible indexes over +# partitioned tables. +# +CREATE TABLE t1 ( +a CHAR(2) NOT NULL, +b CHAR(2) NOT NULL, +c INT(10) UNSIGNED NOT NULL, +d VARCHAR(255) DEFAULT NULL, +e VARCHAR(1000) DEFAULT NULL, +KEY (a) INVISIBLE, +KEY (b) +) PARTITION BY KEY (a) PARTITIONS 20; +INSERT INTO t1 (a, b, c, d, e) VALUES +('07', '03', 343, '1', '07_03_343'), +('01', '04', 343, '2', '01_04_343'), +('01', '06', 343, '3', '01_06_343'), +('01', '07', 343, '4', '01_07_343'), +('01', '08', 343, '5', '01_08_343'), +('01', '09', 343, '6', '01_09_343'), +('03', '03', 343, '7', '03_03_343'), +('03', '06', 343, '8', '03_06_343'), +('03', '07', 343, '9', '03_07_343'), +('04', '03', 343, '10', '04_03_343'), +('04', '06', 343, '11', '04_06_343'), +('05', '03', 343, '12', '05_03_343'), +('11', '03', 343, '13', '11_03_343'), +('11', '04', 343, '14', '11_04_343'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 30 NULL +EXPLAIN SELECT b FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 2 NULL 30 Using index +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 2 NULL 30 Using index +EXPLAIN SELECT * FROM t1 WHERE a = '04'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 2 const 2 Using where +ALTER TABLE t1 ALTER INDEX b INVISIBLE; +EXPLAIN SELECT b FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 30 NULL +DROP TABLE t1; +CREATE TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 NULL +DROP TABLE t1; +# +# Test that referential constraints implemented by the indexes are still +# enforced while the index is invisible. +# +CREATE TABLE t1p ( a INT KEY ); +CREATE TABLE t1c ( t1p_a INT ); +ALTER TABLE t1c ADD CONSTRAINT FOREIGN KEY ( t1p_a ) REFERENCES t1p( a ); +ALTER TABLE t1c ALTER INDEX t1p_a INVISIBLE; +INSERT INTO t1c VALUES ( 1 ); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1c`, CONSTRAINT `t1c_ibfk_1` FOREIGN KEY (`t1p_a`) REFERENCES `t1p` (`a`)) +SELECT * FROM t1c; +t1p_a +DROP TABLE t1c, t1p; diff --git a/mysql-test/r/invisible_indexes_myisam.result b/mysql-test/r/invisible_indexes_myisam.result new file mode 100644 index 00000000000..9e717d90480 --- /dev/null +++ b/mysql-test/r/invisible_indexes_myisam.result @@ -0,0 +1,410 @@ +# +# WL#8697: Invisible Indexes +# +# Test of ALTER INDEX syntax. +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of CREATE INDEX syntax with invisible indexes. +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +Warnings: +Note 1831 Duplicate index 'b_visible' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a_invisible 1 a A NULL NULL NULL YES BTREE NO +t1 1 b_visible 1 a A NULL NULL NULL YES BTREE YES +t1 1 a_b_invisible 1 a A NULL NULL NULL YES BTREE NO +t1 1 a_b_invisible 2 b A NULL NULL NULL YES BTREE NO +DROP TABLE t1; +# Test that invisible indexes are not used. +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status Table is already up to date +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL a 5 NULL 5 Using index +DROP TABLE t1, t2; +# Test that renaming an index does not change visibility and vice versa. +CREATE TABLE t1 ( +a INT, INDEX (a), +b INT, INDEX (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD INDEX a1(a); +ALTER TABLE t1 DROP INDEX b; +ALTER TABLE t1 ADD INDEX b1(b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A NULL NULL NULL YES BTREE YES +t1 1 b1 1 b A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A NULL NULL NULL YES BTREE NO +t1 1 b1 1 b A NULL NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of SHOW CREATE TABLE. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# Test that primary key indexes can't be made invisible. +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +CREATE TABLE t1 ( a INT PRIMARY KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +CREATE TABLE t1 ( a INT KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY INVISIBLE' at line 1 +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (b) INVISIBLE, +INDEX (c) +); +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# Currently we allow to name the primary key index, but the name is +# silently changed to PRIMARY. If this behavior changes in the future, +# we need to take some additional measures to rule out invisible primary +# key indexes. The below two tests serve as triggers for such a change. +# +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 0 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, KEY (a), +b INT, KEY (b) INVISIBLE +); +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +# +# Repeated alter actions. Should work. +# +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +t1 1 b 1 b A NULL NULL NULL YES BTREE YES +# +# Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +# +# +# Various algorithms and their effects. +# +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; +ERROR 42000: Key 'ab' doesn't exist in table 't1' +DROP TABLE t1; +# +# Test that constraints implemented by the indexes are still enforced +# while the index is invisible. +# +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, +b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t3(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (1); +INSERT INTO t4(a) VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t5 VALUES (1, 2, 3); +INSERT INTO t5 VALUES (1, 2, 3); +ERROR 23000: Duplicate entry '1-2-3' for key 'a' +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#23256900: WL#8697: ASSERTION +# `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +# +# Test for when an index is implicitly promoted to primary key index. +# The first NOT NULL UNIQUE index is candidate for promotion. +# These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +EXPLAIN +SELECT * FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found +SELECT * FROM t1; +a +DROP TABLE t1; +# The first NOT NULL UNIQUE index may of course be invisible if it is +# not promoted. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL PRIMARY KEY, +UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 b A 0 NULL NULL BTREE YES +t1 0 a 1 a A 0 NULL NULL BTREE NO +DROP TABLE t1; +# The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL, +UNIQUE KEY (a), +UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A 0 NULL NULL BTREE YES +t1 0 b 1 b A 0 NULL NULL BTREE NO +DROP TABLE t1; +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +# +# Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +# +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found +DROP TABLE t1; +# +# Invisible spatial indexes. +# +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL, +SPATIAL KEY(g) +) ENGINE=MyISAM; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +# There appears to be a bug causing the cardinality number to fluctuate +# for spatial indexes. +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range g g 34 NULL 8 X +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 fid A X NULL NULL BTREE YES +t1 1 g 1 g A X 32 NULL SPATIAL NO +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 150 X +DROP TABLE t1; +# +# Test of invisible fulltext indexes. +# +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL 1 NULL NULL YES FULLTEXT NO +t1 1 a 2 b NULL 1 NULL NULL YES FULLTEXT NO +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +a b +DROP TABLE t1; +# +# Invisible indexes on AUTO_INCREMENT columns. +# +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 4 NULL 3 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL +DROP TABLE t1; +# +# Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +# +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); +SELECT * FROM t1 FORCE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; diff --git a/mysql-test/r/invisible_indexes_tokudb.result b/mysql-test/r/invisible_indexes_tokudb.result new file mode 100644 index 00000000000..63800d02e69 --- /dev/null +++ b/mysql-test/r/invisible_indexes_tokudb.result @@ -0,0 +1,410 @@ +# +# WL#8697: Invisible Indexes +# +# Test of ALTER INDEX syntax. +CREATE TABLE t1 ( a INT, KEY (a) ); +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a VISIBLE; +SHOW KEYS FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of CREATE INDEX syntax with invisible indexes. +CREATE TABLE t1 ( a INT, b INT ); +CREATE INDEX a_invisible ON t1(a) INVISIBLE; +CREATE INDEX b_visible ON t1(a) VISIBLE; +Warnings: +Note 1831 Duplicate index 'b_visible' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. +CREATE INDEX a_b_invisible ON t1(a, b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a_invisible 1 a A NULL NULL NULL YES BTREE NO +t1 1 b_visible 1 a A NULL NULL NULL YES BTREE YES +t1 1 a_b_invisible 1 a A NULL NULL NULL YES BTREE NO +t1 1 a_b_invisible 2 b A NULL NULL NULL YES BTREE NO +DROP TABLE t1; +# Test that invisible indexes are not used. +CREATE TABLE t1 ( a INT, KEY (a) ); +CREATE TABLE t2 ( a INT, KEY (a) INVISIBLE ); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 SELECT * FROM t1; +ANALYZE TABLE t1, t2; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 5 NULL 5 Using index +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 5 NULL +ALTER TABLE t2 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 index NULL a 5 NULL 5 Using index +DROP TABLE t1, t2; +# Test that renaming an index does not change visibility and vice versa. +CREATE TABLE t1 ( +a INT, INDEX (a), +b INT, INDEX (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 b 1 b A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 DROP INDEX a; +ALTER TABLE t1 ADD INDEX a1(a); +ALTER TABLE t1 DROP INDEX b; +ALTER TABLE t1 ADD INDEX b1(b) INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A NULL NULL NULL YES BTREE YES +t1 1 b1 1 b A NULL NULL NULL YES BTREE NO +ALTER TABLE t1 ALTER INDEX a1 INVISIBLE; +ALTER TABLE t1 ALTER INDEX b1 VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a1 1 a A NULL NULL NULL YES BTREE NO +t1 1 b1 1 b A NULL NULL NULL YES BTREE YES +DROP TABLE t1; +# Test of SHOW CREATE TABLE. +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=TokuDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# Test that primary key indexes can't be made invisible. +CREATE TABLE t1 ( a INT, PRIMARY KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +CREATE TABLE t1 ( a INT PRIMARY KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +CREATE TABLE t1 ( a INT KEY INVISIBLE ); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVISIBLE )' at line 1 +ALTER TABLE t1 ALTER INDEX PRIMARY INVISIBLE; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRIMARY INVISIBLE' at line 1 +CREATE TABLE t1 ( +a INT, +b INT, +c INT, +INDEX (b) INVISIBLE, +INDEX (c) +); +ALTER TABLE t1 ADD PRIMARY KEY (a) INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=TokuDB DEFAULT CHARSET=latin1 +DROP TABLE t1; +# +# Currently we allow to name the primary key index, but the name is +# silently changed to PRIMARY. If this behavior changes in the future, +# we need to take some additional measures to rule out invisible primary +# key indexes. The below two tests serve as triggers for such a change. +# +CREATE TABLE t1( a INT ); +ALTER TABLE t1 ADD CONSTRAINT pk PRIMARY KEY (a); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 1 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1( a INT, PRIMARY KEY pk (a) ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 1 NULL NULL BTREE YES +DROP TABLE t1; +CREATE TABLE t1 ( +a INT, KEY (a), +b INT, KEY (b) INVISIBLE +); +ALTER TABLE t1 ALTER INDEX no_such_index INVISIBLE; +ERROR 42000: Key 'no_such_index' doesn't exist in table 't1' +# +# Repeated alter actions. Should work. +# +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX a VISIBLE; +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALTER INDEX b VISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +t1 1 b 1 b A NULL NULL NULL YES BTREE YES +# +# Various combinations of RENAME INDEX and ALTER INDEX ... INVISIBLE. +# +# +# Various algorithms and their effects. +# +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = COPY; +affected rows: 3 +info: Records: 3 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE, ALGORITHM = INPLACE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a INVISIBLE, ALGORITHM = DEFAULT; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE NO +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ALTER INDEX a VISIBLE; +affected rows: 0 +info: Records: 0 Duplicates: 0 Warnings: 0 +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL YES BTREE YES +t1 1 b 1 b A 3 NULL NULL YES BTREE YES +ALTER TABLE t1 ADD INDEX ab(a, b), ALTER INDEX ab INVISIBLE; +ERROR 42000: Key 'ab' doesn't exist in table 't1' +DROP TABLE t1; +# +# Test that constraints implemented by the indexes are still enforced +# while the index is invisible. +# +CREATE TABLE t1 ( a INT, UNIQUE KEY (a) INVISIBLE ); +CREATE TABLE t2 ( a INT UNIQUE ); +CREATE TABLE t3 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT PRIMARY KEY ); +CREATE TABLE t4 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE, +b INT PRIMARY KEY AUTO_INCREMENT ); +CREATE TABLE t5 ( a INT, b INT, c INT, UNIQUE KEY (a, b, c) INVISIBLE ); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +ALTER TABLE t2 ALTER INDEX a INVISIBLE; +INSERT INTO t2 VALUES (1); +INSERT INTO t2 VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t3(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (NULL); +ERROR 23000: Column 'a' cannot be null +INSERT INTO t4(a) VALUES (1); +INSERT INTO t4(a) VALUES (1); +ERROR 23000: Duplicate entry '1' for key 'a' +INSERT INTO t5 VALUES (1, 2, 3); +INSERT INTO t5 VALUES (1, 2, 3); +ERROR 23000: Duplicate entry '1-2-3' for key 'a' +DROP TABLE t1, t2, t3, t4, t5; +# +# Bug#23256900: WL#8697: ASSERTION +# `TABLE_SHARE->IS_MISSING_PRIMARY_KEY() ...` FAILED. +# +# Test for when an index is implicitly promoted to primary key index. +# The first NOT NULL UNIQUE index is candidate for promotion. +# These indexes can't be invisible, either. +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) ); +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +ERROR HY000: A primary key index cannot be invisible +EXPLAIN +SELECT * FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 4 NULL 1 Using index +SELECT * FROM t1; +a +DROP TABLE t1; +# The first NOT NULL UNIQUE index may of course be invisible if it is +# not promoted. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL PRIMARY KEY, +UNIQUE KEY (a) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 b A 1 NULL NULL BTREE YES +t1 0 a 1 a A 1 NULL NULL BTREE NO +DROP TABLE t1; +# The check above applies only to the first NOT NULL UNIQUE index. +CREATE TABLE t1 ( +a INT NOT NULL, +b INT NOT NULL, +UNIQUE KEY (a), +UNIQUE KEY (b) INVISIBLE +); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 a 1 a A 1 NULL NULL BTREE YES +t1 0 b 1 b A 1 NULL NULL BTREE NO +DROP TABLE t1; +CREATE TABLE t1 ( a INT NOT NULL, UNIQUE KEY (a) INVISIBLE ); +ERROR HY000: A primary key index cannot be invisible +# +# Bug#23264435: WL#8697: FULLTEXT INDEXES CANNOT BE MADE INVISIBLE +# +CREATE TABLE t1 ( a INT NOT NULL, KEY (a) INVISIBLE, b INT NOT NULL UNIQUE ); +CREATE TABLE t2 ( a INT PRIMARY KEY, b INT, INDEX(b) INVISIBLE); +ALTER TABLE t2 ALTER INDEX b VISIBLE; +DROP TABLE t1, t2; +CREATE TEMPORARY TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found +DROP TABLE t1; +# +# Invisible spatial indexes. +# +CREATE TABLE t1 ( +fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +g GEOMETRY NOT NULL, +SPATIAL KEY(g) +) ENGINE=MyISAM; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Table is already up to date +# There appears to be a bug causing the cardinality number to fluctuate +# for spatial indexes. +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range g g 34 NULL 8 X +ALTER TABLE t1 ALTER INDEX g INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 fid A X NULL NULL BTREE YES +t1 1 g 1 g A X 32 NULL SPATIAL NO +EXPLAIN SELECT * +FROM t1 +WHERE ST_Within(g, +ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))')); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 150 X +DROP TABLE t1; +# +# Test of invisible fulltext indexes. +# +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES('Some data', 'for full-text search'); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 NULL 1 Using where +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL 1 NULL NULL YES FULLTEXT NO +t1 1 a 2 b NULL 1 NULL NULL YES FULLTEXT NO +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections"); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ("collections" IN BOOLEAN MODE); +a b +DROP TABLE t1; +# +# Invisible indexes on AUTO_INCREMENT columns. +# +CREATE TABLE t1 ( a INT AUTO_INCREMENT, KEY ( a ) ); +INSERT INTO t1 VALUES (), (), (); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 4 NULL 3 Using index +ALTER TABLE t1 ALTER INDEX a INVISIBLE; +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 3 NULL NULL BTREE NO +EXPLAIN SELECT a FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 NULL +DROP TABLE t1; +# +# Bug#24660093: REMOVING AN INVISIBLE INDEX BREAKS EXPLAIN +# +CREATE TABLE t1 ( a INT, KEY(a) INVISIBLE ); +SELECT * FROM t1 FORCE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 FORCE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 USE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX(a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR JOIN (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR ORDER BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +SELECT * FROM t1 IGNORE INDEX FOR GROUP BY (a); +ERROR 42000: Key 'a' doesn't exist in table 't1' +DROP TABLE t1; diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 24d81eb21a7..5cb0e21ccb6 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -148,12 +148,12 @@ a 2 drop table t1; create table t1 (a int not null unique, b int unique, c int, d int not null primary key, key(c), e int not null unique); show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 d A 0 NULL NULL BTREE -t1 0 a 1 a A 0 NULL NULL BTREE -t1 0 e 1 e A 0 NULL NULL BTREE -t1 0 b 1 b A NULL NULL NULL YES BTREE -t1 1 c 1 c A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 d A 0 NULL NULL BTREE YES +t1 0 a 1 a A 0 NULL NULL BTREE YES +t1 0 e 1 e A 0 NULL NULL BTREE YES +t1 0 b 1 b A NULL NULL NULL YES BTREE YES +t1 1 c 1 c A NULL NULL NULL YES BTREE YES drop table t1; CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT, UNIQUE (c,i)); diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index dafc2d1a8df..ada6f7f8fbd 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -759,10 +759,10 @@ a b c 1 1 1 1 1 0 show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t3 1 a 1 a A NULL NULL NULL YES BTREE -t3 1 a 2 b A NULL NULL NULL YES BTREE -t3 1 a 3 c A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t3 1 a 1 a A NULL NULL NULL YES BTREE YES +t3 1 a 2 b A NULL NULL NULL YES BTREE YES +t3 1 a 3 c A NULL NULL NULL YES BTREE YES drop table t1, t2, t3; CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) ) ENGINE=MyISAM; diff --git a/mysql-test/r/mix2_myisam.result b/mysql-test/r/mix2_myisam.result index cda0045e09e..dd82aae056f 100644 --- a/mysql-test/r/mix2_myisam.result +++ b/mysql-test/r/mix2_myisam.result @@ -169,10 +169,10 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 id A # NULL NULL BTREE -t1 1 parent_id 1 parent_id A # NULL NULL BTREE -t1 1 level 1 level A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id A # NULL NULL BTREE YES +t1 1 parent_id 1 parent_id A # NULL NULL BTREE YES +t1 1 level 1 level A # NULL NULL BTREE YES drop table t1; CREATE TABLE t1 ( gesuchnr int(11) DEFAULT '0' NOT NULL, @@ -212,8 +212,8 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 skr 1 a A # NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 skr 1 a A # NULL NULL YES BTREE YES drop table t1; create table t1 (a int,b varchar(20),key(a)) engine=MyISAM; insert into t1 values (1,""), (2,"testing"); @@ -259,13 +259,13 @@ key(a),primary key(a,b), unique(c),key(a),unique(b)) ENGINE = MyISAM; Warnings: Note 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. 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 -t1 0 PRIMARY 1 a A # NULL NULL BTREE -t1 0 PRIMARY 2 b A # NULL NULL BTREE -t1 0 c 1 c A # NULL NULL BTREE -t1 0 b 1 b A # NULL NULL BTREE -t1 1 a 1 a A # NULL NULL BTREE -t1 1 a_2 1 a A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES +t1 0 PRIMARY 2 b A # NULL NULL BTREE YES +t1 0 c 1 c A # NULL NULL BTREE YES +t1 0 b 1 b A # NULL NULL BTREE YES +t1 1 a 1 a A # NULL NULL BTREE YES +t1 1 a_2 1 a A # NULL NULL BTREE YES drop table t1; create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)) ENGINE = MEMORY; alter table t1 engine=MyISAM; @@ -637,8 +637,8 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES drop table t1; create table t1 (i int, j int ) ENGINE=MyISAM; insert into t1 values (1,2); diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 56814e2b71e..01b721f6639 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -38,16 +38,16 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK 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 -t1 0 PRIMARY 1 a A 5 NULL NULL BTREE -t1 1 b 1 b A 1 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 5 NULL NULL BTREE YES +t1 1 b 1 b A 1 NULL NULL BTREE YES optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status Table is already up to date 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 -t1 0 PRIMARY 1 a A 5 NULL NULL BTREE -t1 1 b 1 b A 1 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 5 NULL NULL BTREE YES +t1 1 b 1 b A 1 NULL NULL BTREE YES drop table t1; create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=myisam; insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4); @@ -336,13 +336,13 @@ optimize table t1; Table Op Msg_type Msg_text test.t1 optimize status OK 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 -t1 1 b 1 b A 5 NULL NULL YES BTREE -t1 1 c 1 c A 5 NULL NULL YES BTREE -t1 1 a 1 a A 1 NULL NULL BTREE -t1 1 a 2 b A 5 NULL NULL YES BTREE -t1 1 c_2 1 c A 5 NULL NULL YES BTREE -t1 1 c_2 2 a A 5 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 b 1 b A 5 NULL NULL YES BTREE YES +t1 1 c 1 c A 5 NULL NULL YES BTREE YES +t1 1 a 1 a A 1 NULL NULL BTREE YES +t1 1 a 2 b A 5 NULL NULL YES BTREE YES +t1 1 c_2 1 c A 5 NULL NULL YES BTREE YES +t1 1 c_2 2 a A 5 NULL NULL BTREE YES explain select * from t1,t2 where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL a NULL NULL NULL 2 NULL @@ -579,29 +579,29 @@ Error 1146 Table 'test.t3' doesn't exist drop table t1,t2; create table t1 (a int, key (a)); show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES alter table t1 disable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES create table t2 (a int); set @@rand_seed1=31415926,@@rand_seed2=2718281828; insert t1 select * from t2; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled YES alter table t1 enable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A 1000 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 1000 NULL NULL YES BTREE YES alter table t1 engine=heap; alter table t1 disable keys; Warnings: Note 1031 Table storage engine for 't1' doesn't have this option show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a NULL 500 NULL NULL YES HASH +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL 500 NULL NULL YES HASH YES drop table t1,t2; create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); insert into t1 values (null,''), (null,''); @@ -644,16 +644,16 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES insert into t1 values (11); delete from t1 where a=11; check table t1; Table Op Msg_type Msg_text test.t1 check status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES set myisam_stats_method=nulls_equal; show variables like 'myisam_stats_method'; Variable_name Value @@ -664,16 +664,16 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES insert into t1 values (11); delete from t1 where a=11; check table t1; Table Op Msg_type Msg_text test.t1 check status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES set myisam_stats_method=DEFAULT; show variables like 'myisam_stats_method'; Variable_name Value @@ -684,16 +684,16 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES insert into t1 values (11); delete from t1 where a=11; check table t1; Table Op Msg_type Msg_text test.t1 check status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES drop table t1; set myisam_stats_method=nulls_ignored; show variables like 'myisam_stats_method'; @@ -711,21 +711,21 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 2 NULL NULL YES BTREE -t1 1 a 2 b A 4 NULL NULL YES BTREE -t1 1 a 3 c A 4 NULL NULL YES BTREE -t1 1 a 4 d A 4 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 2 NULL NULL YES BTREE YES +t1 1 a 2 b A 4 NULL NULL YES BTREE YES +t1 1 a 3 c A 4 NULL NULL YES BTREE YES +t1 1 a 4 d A 4 NULL NULL YES BTREE YES delete from t1; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 0 NULL NULL YES BTREE -t1 1 a 2 b A 0 NULL NULL YES BTREE -t1 1 a 3 c A 0 NULL NULL YES BTREE -t1 1 a 4 d A 0 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE YES +t1 1 a 2 b A 0 NULL NULL YES BTREE YES +t1 1 a 3 c A 0 NULL NULL YES BTREE YES +t1 1 a 4 d A 0 NULL NULL YES BTREE YES set myisam_stats_method=DEFAULT; drop table t1; create table t1( @@ -1748,13 +1748,13 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A 8 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 8 NULL NULL YES BTREE YES alter table t1 disable keys; alter table t1 enable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A 8 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 8 NULL NULL YES BTREE YES drop table t1; create table t1 (c1 int) engine=myisam pack_keys=0; create table t2 (c1 int) engine=myisam pack_keys=1; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 612e0a8c6e8..499ea695246 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -15,7 +15,7 @@ INSERT INTO t1 VALUES (1), (2); - + @@ -5432,3 +5432,27 @@ a DROP TABLE t1; DROP TABLE t2; DROP DATABASE db_20772273; +# +# WL#8697: Invisible Indexes +# Test of mysqldump. +# +CREATE TABLE test.t1 ( +a INT, +b INT, +c INT, +INDEX (a) VISIBLE, +INDEX (b) INVISIBLE, +INDEX (c) +); +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + `c` int(11) DEFAULT NULL, + KEY `a` (`a`), + KEY `b` (`b`) /*!50616 INVISIBLE */, + KEY `c` (`c`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE test.t1; diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 46ffb0da17f..56949f7dc40 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -282,14 +282,14 @@ partition by list (a) partition p1 values in (2)); insert into t1 values (1,1),(2,1),(2,2),(2,3); show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK show indexes from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 a 1 a A 1 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 1 NULL NULL YES BTREE YES drop table t1; create table t1 (a int) partition by hash (a); diff --git a/mysql-test/r/pool_of_threads.result b/mysql-test/r/pool_of_threads.result index 0cb84105cdf..7f8f7ba48e8 100644 --- a/mysql-test/r/pool_of_threads.result +++ b/mysql-test/r/pool_of_threads.result @@ -2084,10 +2084,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/pool_of_threads_high_prio_tickets.result b/mysql-test/r/pool_of_threads_high_prio_tickets.result index f34bf8274b3..160f5167e14 100644 --- a/mysql-test/r/pool_of_threads_high_prio_tickets.result +++ b/mysql-test/r/pool_of_threads_high_prio_tickets.result @@ -2087,10 +2087,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index c6aa97a1f94..e110b5cd20a 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -291,9 +291,9 @@ a int(11) NO PRI NULL create index t2_idx on t2(b); prepare stmt4 from ' show index from t2 from test '; execute stmt4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 a A 0 NULL NULL BTREE -t2 1 t2_idx 1 b A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 a A 0 NULL NULL BTREE YES +t2 1 t2_idx 1 b A NULL NULL NULL YES BTREE YES prepare stmt4 from ' show table status from test like ''t2%'' '; execute stmt4; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment diff --git a/mysql-test/r/ps_ddl.result b/mysql-test/r/ps_ddl.result index d7da50f137f..007b54423c8 100644 --- a/mysql-test/r/ps_ddl.result +++ b/mysql-test/r/ps_ddl.result @@ -2237,11 +2237,11 @@ drop table if exists t1; create table t1 (a int); prepare stmt from "show keys from t1 where (1) in (select * from t1)"; execute stmt; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible drop table t1; create table t1 (x int); execute stmt; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible drop table t1; deallocate prepare stmt; # diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index 1a98f2f0f36..a648b1b4f7f 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -13,16 +13,16 @@ create table t1(id int PRIMARY KEY, st varchar(10), KEY st_key(st)); insert into t1 values(1, "One"); alter table t1 disable keys; show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 id A 1 NULL NULL BTREE -t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id A 1 NULL NULL BTREE YES +t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled YES repair table t1 extended; Table Op Msg_type Msg_text test.t1 repair status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 id A 1 NULL NULL BTREE -t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id A 1 NULL NULL BTREE YES +t1 1 st_key 1 st A NULL NULL NULL YES BTREE disabled YES drop table t1; repair table t1 use_frm; Table Op Msg_type Msg_text @@ -46,8 +46,8 @@ REPAIR TABLE t1; Table Op Msg_type Msg_text test.t1 repair status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES SET myisam_repair_threads=@@global.myisam_repair_threads; DROP TABLE t1; CREATE TABLE t1(a INT); diff --git a/mysql-test/r/select_all.result b/mysql-test/r/select_all.result index 4f76c62f66c..ddcefad6d4d 100644 --- a/mysql-test/r/select_all.result +++ b/mysql-test/r/select_all.result @@ -2087,10 +2087,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_all_bka.result b/mysql-test/r/select_all_bka.result index 0f411eb35ac..507500cb808 100644 --- a/mysql-test/r/select_all_bka.result +++ b/mysql-test/r/select_all_bka.result @@ -2088,10 +2088,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_all_bka_nixbnl.result b/mysql-test/r/select_all_bka_nixbnl.result index c67da491f07..d7012ca7d03 100644 --- a/mysql-test/r/select_all_bka_nixbnl.result +++ b/mysql-test/r/select_all_bka_nixbnl.result @@ -2088,10 +2088,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_icp_mrr.result b/mysql-test/r/select_icp_mrr.result index f78aefbed7b..d4f75423f03 100644 --- a/mysql-test/r/select_icp_mrr.result +++ b/mysql-test/r/select_icp_mrr.result @@ -2087,10 +2087,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_icp_mrr_bka.result b/mysql-test/r/select_icp_mrr_bka.result index eb652487533..aefbed08dec 100644 --- a/mysql-test/r/select_icp_mrr_bka.result +++ b/mysql-test/r/select_icp_mrr_bka.result @@ -2088,10 +2088,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_icp_mrr_bka_nixbnl.result b/mysql-test/r/select_icp_mrr_bka_nixbnl.result index cd592e0fc56..53f26687a9e 100644 --- a/mysql-test/r/select_icp_mrr_bka_nixbnl.result +++ b/mysql-test/r/select_icp_mrr_bka_nixbnl.result @@ -2088,10 +2088,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_none.result b/mysql-test/r/select_none.result index 3facd2db1de..fdcc00d8645 100644 --- a/mysql-test/r/select_none.result +++ b/mysql-test/r/select_none.result @@ -2086,10 +2086,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_none_bka.result b/mysql-test/r/select_none_bka.result index 61fa2d2b3f2..cd9b6f998fc 100644 --- a/mysql-test/r/select_none_bka.result +++ b/mysql-test/r/select_none_bka.result @@ -2087,10 +2087,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/select_none_bka_nixbnl.result b/mysql-test/r/select_none_bka_nixbnl.result index d763153914c..09438a9b232 100644 --- a/mysql-test/r/select_none_bka_nixbnl.result +++ b/mysql-test/r/select_none_bka_nixbnl.result @@ -2087,10 +2087,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; DO 1; DO benchmark(100,1+1),1,1; diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index b25efee6340..e5ff8f2cf8e 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -74,10 +74,11 @@ def information_schema STATISTICS STATISTICS NULLABLE Null 253 3 0 N 1 0 8 def information_schema STATISTICS STATISTICS INDEX_TYPE Index_type 253 16 5 N 1 0 8 def information_schema STATISTICS STATISTICS COMMENT Comment 253 16 0 Y 0 0 8 def information_schema STATISTICS STATISTICS INDEX_COMMENT Index_comment 253 1024 0 N 1 0 8 -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a A 5 NULL NULL BTREE -t1 1 b 1 b A 1 NULL NULL BTREE -t1 1 b 2 c A 5 NULL NULL BTREE +def information_schema STATISTICS STATISTICS IS_VISIBLE Visible 253 4 3 Y 0 0 8 +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A 5 NULL NULL BTREE YES +t1 1 b 1 b A 1 NULL NULL BTREE YES +t1 1 b 2 c A 5 NULL NULL BTREE YES insert into t1 values (5,5,5); ERROR 23000: Duplicate entry '5' for key 'PRIMARY' -- Here we enable metadata just to check that the collation of the @@ -164,11 +165,11 @@ def Msg_text 250 393216 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 0 PRIMARY 1 f1 A 1 NULL NULL BTREE -t1 0 PRIMARY 2 f2 A 3 NULL NULL BTREE -t1 0 PRIMARY 3 f3 A 9 NULL NULL BTREE -t1 0 PRIMARY 4 f4 A 18 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 f1 A 1 NULL NULL BTREE YES +t1 0 PRIMARY 2 f2 A 3 NULL NULL BTREE YES +t1 0 PRIMARY 3 f3 A 9 NULL NULL BTREE YES +t1 0 PRIMARY 4 f4 A 18 NULL NULL BTREE YES -- Here we enable metadata just to check that the collation of the -- resultset is non-binary for string type. This should be changed -- after Bug#29394 is implemented. @@ -181,11 +182,11 @@ def Msg_text 250 393216 2 Y 0 31 8 Table Op Msg_type Msg_text test.t1 repair status OK 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 -t1 0 PRIMARY 1 f1 A 1 NULL NULL BTREE -t1 0 PRIMARY 2 f2 A 3 NULL NULL BTREE -t1 0 PRIMARY 3 f3 A 9 NULL NULL BTREE -t1 0 PRIMARY 4 f4 A 18 NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 f1 A 1 NULL NULL BTREE YES +t1 0 PRIMARY 2 f2 A 3 NULL NULL BTREE YES +t1 0 PRIMARY 3 f3 A 9 NULL NULL BTREE YES +t1 0 PRIMARY 4 f4 A 18 NULL NULL BTREE YES drop table t1; create temporary table t1 (a int not null); show create table t1; @@ -641,8 +642,9 @@ def information_schema STATISTICS STATISTICS NULLABLE Null 253 3 0 N 1 0 63 def information_schema STATISTICS STATISTICS INDEX_TYPE Index_type 253 16 5 N 1 0 63 def information_schema STATISTICS STATISTICS COMMENT Comment 253 16 0 Y 0 0 63 def information_schema STATISTICS STATISTICS INDEX_COMMENT Index_comment 253 1024 0 N 1 0 63 -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 field1 A 0 1000 NULL BTREE +def information_schema STATISTICS STATISTICS IS_VISIBLE Visible 253 4 3 Y 0 0 63 +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 field1 A 0 1000 NULL BTREE YES drop table t1; create table t1 ( c1 int NOT NULL, @@ -907,8 +909,9 @@ def information_schema STATISTICS STATISTICS NULLABLE Null 253 9 0 N 1 0 33 def information_schema STATISTICS STATISTICS INDEX_TYPE Index_type 253 48 5 N 1 0 33 def information_schema STATISTICS STATISTICS COMMENT Comment 253 48 0 Y 0 0 33 def information_schema STATISTICS STATISTICS INDEX_COMMENT Index_comment 253 3072 0 N 1 0 33 -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 c A 0 NULL NULL BTREE +def information_schema STATISTICS STATISTICS IS_VISIBLE Visible 253 12 3 Y 0 0 33 +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 c A 0 NULL NULL BTREE YES ---------------------------------------------------------------- SELECT TABLE_CATALOG, @@ -1297,7 +1300,7 @@ show columns from `a\b` from `mysqlttest\1`; Field Type Null Key Default Extra a int(11) YES NULL show keys from `mysqlttest\1`.`a\b`; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible drop table `mysqlttest\1`.`a\b`; drop database `mysqlttest\1`; show engine foobar status; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 800d7b3191e..2ef1a289891 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2379,7 +2379,7 @@ Level Code Message Field Type Null Key Default Extra id char(16) NO data int(11) NO NULL -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Database Table In_use Name_locked Variable_name Value Tables_in_test (foo) @@ -2400,7 +2400,7 @@ Level Code Message Field Type Null Key Default Extra id char(16) NO data int(11) NO NULL -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Database Table In_use Name_locked Variable_name Value Tables_in_test (foo) diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result index f3bb31b7809..d36fbd25b9a 100644 --- a/mysql-test/r/ssl.result +++ b/mysql-test/r/ssl.result @@ -2093,10 +2093,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result index 40e6578d1ad..876e5b3679b 100644 --- a/mysql-test/r/ssl_compress.result +++ b/mysql-test/r/ssl_compress.result @@ -2090,10 +2090,10 @@ fld6 char(4) latin1_swedish_ci NO # show full columns from t2 from test like 's%'; Field Type Collation Null Key Default Extra Privileges Comment show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE -t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE -t2 1 fld3 1 fld3 A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE YES +t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE YES +t2 1 fld3 1 fld3 A NULL NULL NULL BTREE YES drop table t4, t3, t2, t1; CREATE TABLE t1 ( cont_nr int(11) NOT NULL auto_increment, diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index c342ca7cb7a..789e9609c09 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -68,21 +68,21 @@ longblob_col longblob NULL NO NULL # options enum('one','two','tree') latin1_swedish_ci NO MUL NULL # flags set('one','two','tree') latin1_swedish_ci NO # show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE -t1 1 utiny 1 utiny A NULL NULL NULL BTREE -t1 1 tiny 1 tiny A NULL NULL NULL BTREE -t1 1 short 1 short A NULL NULL NULL BTREE -t1 1 any_name 1 medium A NULL NULL NULL BTREE -t1 1 longlong 1 longlong A NULL NULL NULL BTREE -t1 1 real_float 1 real_float A NULL NULL NULL BTREE -t1 1 ushort 1 ushort A NULL NULL NULL BTREE -t1 1 umedium 1 umedium A NULL NULL NULL BTREE -t1 1 ulong 1 ulong A NULL NULL NULL BTREE -t1 1 ulonglong 1 ulonglong A NULL NULL NULL BTREE -t1 1 ulonglong 2 ulong A NULL NULL NULL BTREE -t1 1 options 1 options A NULL NULL NULL BTREE -t1 1 options 2 flags A NULL NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE YES +t1 1 utiny 1 utiny A NULL NULL NULL BTREE YES +t1 1 tiny 1 tiny A NULL NULL NULL BTREE YES +t1 1 short 1 short A NULL NULL NULL BTREE YES +t1 1 any_name 1 medium A NULL NULL NULL BTREE YES +t1 1 longlong 1 longlong A NULL NULL NULL BTREE YES +t1 1 real_float 1 real_float A NULL NULL NULL BTREE YES +t1 1 ushort 1 ushort A NULL NULL NULL BTREE YES +t1 1 umedium 1 umedium A NULL NULL NULL BTREE YES +t1 1 ulong 1 ulong A NULL NULL NULL BTREE YES +t1 1 ulonglong 1 ulonglong A NULL NULL NULL BTREE YES +t1 1 ulonglong 2 ulong A NULL NULL NULL BTREE YES +t1 1 options 1 options A NULL NULL NULL BTREE YES +t1 1 options 2 flags A NULL NULL NULL BTREE YES CREATE UNIQUE INDEX test on t1 ( auto ) ; CREATE INDEX test2 on t1 ( ulonglong,ulong) ; Warnings: diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index f63c80ae37b..ba3dcdea1b8 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3687,7 +3687,7 @@ c1 c2 2 2 CREATE VIEW v1 AS SELECT c1, c2 FROM t1; SHOW INDEX FROM v1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible SELECT * FROM v1 USE INDEX (PRIMARY) WHERE c1=2; ERROR 42000: Key 'PRIMARY' doesn't exist in table 'v1' SELECT * FROM v1 FORCE INDEX (PRIMARY) WHERE c1=2; diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index ce22107ef1c..449f6332cb4 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -63,9 +63,9 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); 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 -t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT -t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT YES +t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT YES select * from t1 where MATCH(a,b) AGAINST ("collections"); a b Only MyISAM tables support collections diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 30edb2eecc7..b3b8b79f768 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -264,6 +264,7 @@ def information_schema STATISTICS INDEX_COMMENT 16 NO varchar 1024 3072 NULL NU def information_schema STATISTICS INDEX_NAME 6 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select def information_schema STATISTICS INDEX_SCHEMA 5 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select def information_schema STATISTICS INDEX_TYPE 14 NO varchar 16 48 NULL NULL NULL utf8 utf8_general_ci varchar(16) select +def information_schema STATISTICS IS_VISIBLE 17 NULL YES varchar 4 12 NULL NULL NULL utf8 utf8_general_ci varchar(4) select def information_schema STATISTICS NON_UNIQUE 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(1) select def information_schema STATISTICS NULLABLE 13 NO varchar 3 9 NULL NULL NULL utf8 utf8_general_ci varchar(3) select def information_schema STATISTICS PACKED 12 NULL YES varchar 10 30 NULL NULL NULL utf8 utf8_general_ci varchar(10) select @@ -736,6 +737,7 @@ NULL information_schema STATISTICS SUB_PART bigint NULL NULL NULL NULL bigint(3) 3.0000 information_schema STATISTICS INDEX_TYPE varchar 16 48 utf8 utf8_general_ci varchar(16) 3.0000 information_schema STATISTICS COMMENT varchar 16 48 utf8 utf8_general_ci varchar(16) 3.0000 information_schema STATISTICS INDEX_COMMENT varchar 1024 3072 utf8 utf8_general_ci varchar(1024) +3.0000 information_schema STATISTICS IS_VISIBLE varchar 4 12 utf8 utf8_general_ci varchar(4) 3.0000 information_schema TABLES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema TABLES TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema TABLES TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result index 1ca69c16639..fda8a26d6fb 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics.result +++ b/mysql-test/suite/funcs_1/r/is_statistics.result @@ -44,6 +44,7 @@ NULLABLE varchar(3) NO INDEX_TYPE varchar(16) NO COMMENT varchar(16) YES NULL INDEX_COMMENT varchar(1024) NO +IS_VISIBLE varchar(4) YES NULL SHOW CREATE TABLE information_schema.STATISTICS; Table Create Table STATISTICS CREATE TEMPORARY TABLE `STATISTICS` ( @@ -62,7 +63,8 @@ STATISTICS CREATE TEMPORARY TABLE `STATISTICS` ( `NULLABLE` varchar(3) NOT NULL DEFAULT '', `INDEX_TYPE` varchar(16) NOT NULL DEFAULT '', `COMMENT` varchar(16) DEFAULT NULL, - `INDEX_COMMENT` varchar(1024) NOT NULL DEFAULT '' + `INDEX_COMMENT` varchar(1024) NOT NULL DEFAULT '', + `IS_VISIBLE` varchar(4) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=utf8 SHOW COLUMNS FROM information_schema.STATISTICS; Field Type Null Key Default Extra @@ -82,6 +84,7 @@ NULLABLE varchar(3) NO INDEX_TYPE varchar(16) NO COMMENT varchar(16) YES NULL INDEX_COMMENT varchar(1024) NO +IS_VISIBLE varchar(4) YES NULL SELECT table_catalog, table_schema, table_name, index_schema, index_name FROM information_schema.statistics WHERE table_catalog IS NOT NULL; table_catalog table_schema table_name index_schema index_name @@ -175,17 +178,17 @@ ENGINE = MEMORY; SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict t2 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict t2 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH -def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t4 1 db_datadict_2 f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict t2 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict t2 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t4 1 db_datadict_2 f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -196,7 +199,7 @@ GRANT USAGE ON *.* TO 'testuser2'@'localhost' SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -206,7 +209,7 @@ ERROR 42000: Access denied for user 'testuser1'@'localhost' to database 'mysql' SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE SHOW GRANTS FOR 'testuser1'@'localhost'; ERROR 42000: Access denied for user 'testuser2'@'localhost' to database 'mysql' SHOW GRANTS FOR 'testuser2'@'localhost'; @@ -218,17 +221,17 @@ GRANT SELECT(f1,f5) ON db_datadict_2.t3 TO 'testuser1'@'localhost'; SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict t2 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict t2 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH -def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t4 1 db_datadict_2 f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict t2 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict t2 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t4 1 db_datadict_2 f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t4 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -241,13 +244,13 @@ GRANT USAGE ON *.* TO 'testuser2'@'localhost' SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH -def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH -def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def db_datadict t1 1 db_datadict f2_ind 1 f2 NULL 0 NULL NULL YES HASH YES +def db_datadict t1 0 db_datadict PRIMARY 1 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -259,7 +262,7 @@ ERROR 42000: Access denied for user 'testuser1'@'localhost' to database 'mysql' SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE SHOW GRANTS FOR 'testuser1'@'localhost'; ERROR 42000: Access denied for user 'testuser2'@'localhost' to database 'mysql' SHOW GRANTS FOR 'testuser2'@'localhost'; @@ -275,11 +278,11 @@ GRANT SELECT (f5, f1) ON `db_datadict_2`.`t3` TO 'testuser1'@'localhost' SELECT * FROM information_schema.statistics WHERE table_schema LIKE 'db_datadict%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH -def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH -def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH -def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 1 f2 NULL NULL NULL NULL YES HASH YES +def db_datadict_2 t3 1 db_datadict_2 f2f1_ind 2 f1 NULL 0 NULL NULL HASH YES +def db_datadict_2 t3 0 db_datadict_2 f5 1 f5 NULL 0 NULL NULL YES HASH YES +def db_datadict_2 t3 0 db_datadict_2 PRIMARY 1 f1 NULL 0 NULL NULL HASH YES SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost GRANT USAGE ON *.* TO 'testuser1'@'localhost' @@ -309,9 +312,9 @@ ALTER TABLE test.t1_1 ADD PRIMARY KEY (f1,f3); SELECT * FROM information_schema.statistics WHERE table_name LIKE 't1_%' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def test t1_1 0 test PRIMARY 1 f1 A NULL NULL NULL BTREE -def test t1_1 0 test PRIMARY 2 f3 A 0 NULL NULL BTREE +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def test t1_1 0 test PRIMARY 1 f1 A NULL NULL NULL BTREE YES +def test t1_1 0 test PRIMARY 2 f3 A 0 NULL NULL BTREE YES ALTER TABLE test.t1_1 DROP PRIMARY KEY; SELECT table_name FROM information_schema.statistics WHERE table_name LIKE 't1_%'; @@ -319,8 +322,8 @@ table_name ALTER TABLE test.t1_1 ADD PRIMARY KEY (f1); SELECT * FROM information_schema.statistics WHERE table_name LIKE 't1_%'; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def test t1_1 0 test PRIMARY 1 f1 A 0 NULL NULL BTREE +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def test t1_1 0 test PRIMARY 1 f1 A 0 NULL NULL BTREE YES ALTER TABLE test.t1_1 ADD INDEX (f4); CREATE INDEX f3_f1 ON test.t1_1 (f3,f1); CREATE UNIQUE INDEX f4x_uni ON test.t1_1 (f4x); @@ -332,14 +335,14 @@ CREATE INDEX f2_prefix ON test.t1_1 (f2(20)); SELECT * FROM information_schema.statistics WHERE table_name LIKE 't1_%' AND index_name <> 'PRIMARY' ORDER BY table_schema,table_name,index_name,seq_in_index,column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def test t1_1 1 test f2_prefix 1 f2 A NULL 20 NULL YES BTREE -def test t1_1 1 test f3_f1 1 f3 A NULL NULL NULL BTREE -def test t1_1 1 test f3_f1 2 f1 A NULL NULL NULL BTREE -def test t1_1 1 test f4 1 f4 A NULL NULL NULL YES BTREE -def test t1_1 0 test f4x_uni 1 f4x A NULL NULL NULL YES BTREE -def test t1_1 1 test not_null 1 f3x A NULL NULL NULL YES BTREE -def test t1_2 1 test f2_hash 1 f2 NULL 0 NULL NULL YES HASH +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def test t1_1 1 test f2_prefix 1 f2 A NULL 20 NULL YES BTREE YES +def test t1_1 1 test f3_f1 1 f3 A NULL NULL NULL BTREE YES +def test t1_1 1 test f3_f1 2 f1 A NULL NULL NULL BTREE YES +def test t1_1 1 test f4 1 f4 A NULL NULL NULL YES BTREE YES +def test t1_1 0 test f4x_uni 1 f4x A NULL NULL NULL YES BTREE YES +def test t1_1 1 test not_null 1 f3x A NULL NULL NULL YES BTREE YES +def test t1_2 1 test f2_hash 1 f2 NULL 0 NULL NULL YES HASH YES DROP TABLE test.t1_2; SELECT DISTINCT table_name FROM information_schema.statistics WHERE table_name = 't1_1'; diff --git a/mysql-test/suite/funcs_1/r/is_statistics_is.result b/mysql-test/suite/funcs_1/r/is_statistics_is.result index f04a5e4c515..7d4f84e2037 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics_is.result +++ b/mysql-test/suite/funcs_1/r/is_statistics_is.result @@ -6,12 +6,12 @@ GRANT SELECT ON db_datadict.* TO testuser1@localhost; SELECT * FROM information_schema.statistics WHERE table_schema = 'information_schema' ORDER BY table_schema, table_name, index_name, seq_in_index, column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE # Establish connection testuser1 (user=testuser1) SELECT * FROM information_schema.statistics WHERE table_schema = 'information_schema' ORDER BY table_schema, table_name, index_name, seq_in_index, column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE # Switch to connection default and close connection testuser1 DROP USER testuser1@localhost; DROP DATABASE db_datadict; diff --git a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result index e6668cb50fc..8ec433a5c68 100644 --- a/mysql-test/suite/funcs_1/r/is_statistics_mysql.result +++ b/mysql-test/suite/funcs_1/r/is_statistics_mysql.result @@ -6,75 +6,75 @@ GRANT SELECT ON db_datadict.* TO testuser1@localhost; SELECT * FROM information_schema.statistics WHERE table_schema = 'mysql' ORDER BY table_schema, table_name, index_name, seq_in_index, column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT -def mysql columns_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql columns_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE -def mysql columns_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE -def mysql columns_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE -def mysql columns_priv 0 mysql PRIMARY 5 Column_name A #CARD# NULL NULL BTREE -def mysql db 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql db 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE -def mysql db 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE -def mysql db 1 mysql User 1 User A #CARD# NULL NULL BTREE -def mysql event 0 mysql PRIMARY 1 db A #CARD# NULL NULL BTREE -def mysql event 0 mysql PRIMARY 2 name A #CARD# NULL NULL BTREE -def mysql func 0 mysql PRIMARY 1 name A #CARD# NULL NULL BTREE -def mysql help_category 0 mysql name 1 name A #CARD# NULL NULL BTREE -def mysql help_category 0 mysql PRIMARY 1 help_category_id A #CARD# NULL NULL BTREE -def mysql help_keyword 0 mysql name 1 name A #CARD# NULL NULL BTREE -def mysql help_keyword 0 mysql PRIMARY 1 help_keyword_id A #CARD# NULL NULL BTREE -def mysql help_relation 0 mysql PRIMARY 1 help_keyword_id A #CARD# NULL NULL BTREE -def mysql help_relation 0 mysql PRIMARY 2 help_topic_id A #CARD# NULL NULL BTREE -def mysql help_topic 0 mysql name 1 name A #CARD# NULL NULL BTREE -def mysql help_topic 0 mysql PRIMARY 1 help_topic_id A #CARD# NULL NULL BTREE -def mysql innodb_index_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE -def mysql innodb_index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE -def mysql innodb_index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE -def mysql innodb_index_stats 0 mysql PRIMARY 4 stat_name A #CARD# NULL NULL BTREE -def mysql innodb_table_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE -def mysql innodb_table_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE -def mysql ndb_binlog_index 0 mysql PRIMARY 1 epoch A #CARD# NULL NULL BTREE -def mysql ndb_binlog_index 0 mysql PRIMARY 2 orig_server_id A #CARD# NULL NULL BTREE -def mysql ndb_binlog_index 0 mysql PRIMARY 3 orig_epoch A #CARD# NULL NULL BTREE -def mysql plugin 0 mysql PRIMARY 1 name A #CARD# NULL NULL BTREE -def mysql proc 0 mysql PRIMARY 1 db A #CARD# NULL NULL BTREE -def mysql proc 0 mysql PRIMARY 2 name A #CARD# NULL NULL BTREE -def mysql proc 0 mysql PRIMARY 3 type A #CARD# NULL NULL BTREE -def mysql procs_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE -def mysql procs_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql procs_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE -def mysql procs_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE -def mysql procs_priv 0 mysql PRIMARY 4 Routine_name A #CARD# NULL NULL BTREE -def mysql procs_priv 0 mysql PRIMARY 5 Routine_type A #CARD# NULL NULL BTREE -def mysql proxies_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE -def mysql proxies_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql proxies_priv 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE -def mysql proxies_priv 0 mysql PRIMARY 3 Proxied_host A #CARD# NULL NULL BTREE -def mysql proxies_priv 0 mysql PRIMARY 4 Proxied_user A #CARD# NULL NULL BTREE -def mysql servers 0 mysql PRIMARY 1 Server_name A #CARD# NULL NULL BTREE -def mysql slave_master_info 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql slave_master_info 0 mysql PRIMARY 2 Port A #CARD# NULL NULL BTREE -def mysql slave_relay_log_info 0 mysql PRIMARY 1 Id A #CARD# NULL NULL BTREE -def mysql slave_worker_info 0 mysql PRIMARY 1 Id A #CARD# NULL NULL BTREE -def mysql tables_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE -def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql tables_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE -def mysql tables_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE -def mysql tables_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE -def mysql time_zone 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE -def mysql time_zone_leap_second 0 mysql PRIMARY 1 Transition_time A #CARD# NULL NULL BTREE -def mysql time_zone_name 0 mysql PRIMARY 1 Name A #CARD# NULL NULL BTREE -def mysql time_zone_transition 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE -def mysql time_zone_transition 0 mysql PRIMARY 2 Transition_time A #CARD# NULL NULL BTREE -def mysql time_zone_transition_type 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE -def mysql time_zone_transition_type 0 mysql PRIMARY 2 Transition_type_id A #CARD# NULL NULL BTREE -def mysql user 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE -def mysql user 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE +def mysql columns_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql columns_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE YES +def mysql columns_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE YES +def mysql columns_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE YES +def mysql columns_priv 0 mysql PRIMARY 5 Column_name A #CARD# NULL NULL BTREE YES +def mysql db 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql db 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE YES +def mysql db 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE YES +def mysql db 1 mysql User 1 User A #CARD# NULL NULL BTREE YES +def mysql event 0 mysql PRIMARY 1 db A #CARD# NULL NULL BTREE YES +def mysql event 0 mysql PRIMARY 2 name A #CARD# NULL NULL BTREE YES +def mysql func 0 mysql PRIMARY 1 name A #CARD# NULL NULL BTREE YES +def mysql help_category 0 mysql name 1 name A #CARD# NULL NULL BTREE YES +def mysql help_category 0 mysql PRIMARY 1 help_category_id A #CARD# NULL NULL BTREE YES +def mysql help_keyword 0 mysql name 1 name A #CARD# NULL NULL BTREE YES +def mysql help_keyword 0 mysql PRIMARY 1 help_keyword_id A #CARD# NULL NULL BTREE YES +def mysql help_relation 0 mysql PRIMARY 1 help_keyword_id A #CARD# NULL NULL BTREE YES +def mysql help_relation 0 mysql PRIMARY 2 help_topic_id A #CARD# NULL NULL BTREE YES +def mysql help_topic 0 mysql name 1 name A #CARD# NULL NULL BTREE YES +def mysql help_topic 0 mysql PRIMARY 1 help_topic_id A #CARD# NULL NULL BTREE YES +def mysql innodb_index_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE YES +def mysql innodb_index_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE YES +def mysql innodb_index_stats 0 mysql PRIMARY 3 index_name A #CARD# NULL NULL BTREE YES +def mysql innodb_index_stats 0 mysql PRIMARY 4 stat_name A #CARD# NULL NULL BTREE YES +def mysql innodb_table_stats 0 mysql PRIMARY 1 database_name A #CARD# NULL NULL BTREE YES +def mysql innodb_table_stats 0 mysql PRIMARY 2 table_name A #CARD# NULL NULL BTREE YES +def mysql ndb_binlog_index 0 mysql PRIMARY 1 epoch A #CARD# NULL NULL BTREE YES +def mysql ndb_binlog_index 0 mysql PRIMARY 2 orig_server_id A #CARD# NULL NULL BTREE YES +def mysql ndb_binlog_index 0 mysql PRIMARY 3 orig_epoch A #CARD# NULL NULL BTREE YES +def mysql plugin 0 mysql PRIMARY 1 name A #CARD# NULL NULL BTREE YES +def mysql proc 0 mysql PRIMARY 1 db A #CARD# NULL NULL BTREE YES +def mysql proc 0 mysql PRIMARY 2 name A #CARD# NULL NULL BTREE YES +def mysql proc 0 mysql PRIMARY 3 type A #CARD# NULL NULL BTREE YES +def mysql procs_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE YES +def mysql procs_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql procs_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE YES +def mysql procs_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE YES +def mysql procs_priv 0 mysql PRIMARY 4 Routine_name A #CARD# NULL NULL BTREE YES +def mysql procs_priv 0 mysql PRIMARY 5 Routine_type A #CARD# NULL NULL BTREE YES +def mysql proxies_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE YES +def mysql proxies_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql proxies_priv 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE YES +def mysql proxies_priv 0 mysql PRIMARY 3 Proxied_host A #CARD# NULL NULL BTREE YES +def mysql proxies_priv 0 mysql PRIMARY 4 Proxied_user A #CARD# NULL NULL BTREE YES +def mysql servers 0 mysql PRIMARY 1 Server_name A #CARD# NULL NULL BTREE YES +def mysql slave_master_info 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql slave_master_info 0 mysql PRIMARY 2 Port A #CARD# NULL NULL BTREE YES +def mysql slave_relay_log_info 0 mysql PRIMARY 1 Id A #CARD# NULL NULL BTREE YES +def mysql slave_worker_info 0 mysql PRIMARY 1 Id A #CARD# NULL NULL BTREE YES +def mysql tables_priv 1 mysql Grantor 1 Grantor A #CARD# NULL NULL BTREE YES +def mysql tables_priv 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql tables_priv 0 mysql PRIMARY 2 Db A #CARD# NULL NULL BTREE YES +def mysql tables_priv 0 mysql PRIMARY 3 User A #CARD# NULL NULL BTREE YES +def mysql tables_priv 0 mysql PRIMARY 4 Table_name A #CARD# NULL NULL BTREE YES +def mysql time_zone 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE YES +def mysql time_zone_leap_second 0 mysql PRIMARY 1 Transition_time A #CARD# NULL NULL BTREE YES +def mysql time_zone_name 0 mysql PRIMARY 1 Name A #CARD# NULL NULL BTREE YES +def mysql time_zone_transition 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE YES +def mysql time_zone_transition 0 mysql PRIMARY 2 Transition_time A #CARD# NULL NULL BTREE YES +def mysql time_zone_transition_type 0 mysql PRIMARY 1 Time_zone_id A #CARD# NULL NULL BTREE YES +def mysql time_zone_transition_type 0 mysql PRIMARY 2 Transition_type_id A #CARD# NULL NULL BTREE YES +def mysql user 0 mysql PRIMARY 1 Host A #CARD# NULL NULL BTREE YES +def mysql user 0 mysql PRIMARY 2 User A #CARD# NULL NULL BTREE YES # Establish connection testuser1 (user=testuser1) SELECT * FROM information_schema.statistics WHERE table_schema = 'mysql' ORDER BY table_schema, table_name, index_name, seq_in_index, column_name; -TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT INDEX_COMMENT IS_VISIBLE # Switch to connection default and close connection testuser1 DROP USER testuser1@localhost; DROP DATABASE db_datadict; diff --git a/mysql-test/suite/funcs_1/r/is_table_constraints.result b/mysql-test/suite/funcs_1/r/is_table_constraints.result index 62d079e8201..727dd671e52 100644 --- a/mysql-test/suite/funcs_1/r/is_table_constraints.result +++ b/mysql-test/suite/funcs_1/r/is_table_constraints.result @@ -115,16 +115,16 @@ def db_datadict my_idx2 db_datadict t1 UNIQUE def db_datadict PRIMARY db_datadict t1 PRIMARY KEY def db_datadict PRIMARY db_datadict t2 PRIMARY KEY SHOW INDEXES FROM db_datadict.t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### -t1 0 PRIMARY 2 f2 ### ### ### ### ### ### ### -t1 0 my_idx1 1 f6 ### ### ### ### ### ### ### -t1 0 my_idx1 2 f1 ### ### ### ### ### ### ### -t1 0 my_idx2 1 f3 ### ### ### ### ### ### ### +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES +t1 0 PRIMARY 2 f2 ### ### ### ### ### ### ### YES +t1 0 my_idx1 1 f6 ### ### ### ### ### ### ### YES +t1 0 my_idx1 2 f1 ### ### ### ### ### ### ### YES +t1 0 my_idx2 1 f3 ### ### ### ### ### ### ### YES SHOW INDEXES FROM db_datadict.t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 0 PRIMARY 1 f1 ### ### ### ### ### ### ### -t2 0 PRIMARY 2 f2 ### ### ### ### ### ### ### +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES +t2 0 PRIMARY 2 f2 ### ### ### ### ### ### ### YES # Establish connection testuser1 (user=testuser1) SHOW GRANTS FOR 'testuser1'@'localhost'; Grants for testuser1@localhost @@ -138,12 +138,12 @@ def db_datadict my_idx1 db_datadict t1 UNIQUE def db_datadict my_idx2 db_datadict t1 UNIQUE def db_datadict PRIMARY db_datadict t1 PRIMARY KEY SHOW INDEXES FROM db_datadict.t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### -t1 0 PRIMARY 2 f2 ### ### ### ### ### ### ### -t1 0 my_idx1 1 f6 ### ### ### ### ### ### ### -t1 0 my_idx1 2 f1 ### ### ### ### ### ### ### -t1 0 my_idx2 1 f3 ### ### ### ### ### ### ### +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 f1 ### ### ### ### ### ### ### YES +t1 0 PRIMARY 2 f2 ### ### ### ### ### ### ### YES +t1 0 my_idx1 1 f6 ### ### ### ### ### ### ### YES +t1 0 my_idx1 2 f1 ### ### ### ### ### ### ### YES +t1 0 my_idx2 1 f3 ### ### ### ### ### ### ### YES SHOW INDEXES FROM db_datadict.t2; ERROR 42000: SELECT command denied to user 'testuser1'@'localhost' for table 't2' # Switch to connection default and close connection testuser1 diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 3442def00a7..0526cbf8635 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -22332,8 +22332,8 @@ END// CALL sp6 (10, 20, 30, 40, 50); f1 f2 f3 10 30 50 -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -res_t9 1 index_1 1 f1 A NULL 5 NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +res_t9 1 index_1 1 f1 A NULL 5 NULL YES BTREE YES DROP PROCEDURE sp6; drop table res_t9; diff --git a/mysql-test/suite/innodb/r/import_update_stats.result b/mysql-test/suite/innodb/r/import_update_stats.result index a221721eaa0..317e1bc703b 100644 --- a/mysql-test/suite/innodb/r/import_update_stats.result +++ b/mysql-test/suite/innodb/r/import_update_stats.result @@ -10,21 +10,21 @@ col_2 VARCHAR (255) CREATE INDEX idx1 ON t1(col_1); CREATE INDEX idx2 ON t1(col_2); SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE YES INSERT INTO t1 VALUES ("col1_00001", "col2_00001"), ("col1_00002", "col2_00002"); SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE YES ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE YES FLUSH TABLES t1 FOR EXPORT; backup: t1 UNLOCK TABLES; @@ -36,34 +36,34 @@ col_2 VARCHAR (255) CREATE INDEX idx1 ON t1(col_1); CREATE INDEX idx2 ON t1(col_2); SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 0 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 0 NULL NULL YES BTREE YES INSERT INTO t1 VALUES ("col1_00001", "col2_00001"); SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE YES ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 1 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 1 NULL NULL YES BTREE YES ALTER TABLE t1 DISCARD TABLESPACE; restore: t1 .ibd and .cfg files ALTER TABLE t1 IMPORT TABLESPACE; SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE YES ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK SHOW INDEXES FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE -t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 idx1 1 col_1 A 2 NULL NULL YES BTREE YES +t1 1 idx2 1 col_2 A 2 NULL NULL YES BTREE YES DROP TABLE t1; SET GLOBAL innodb_file_per_table = @old_innodb_file_per_table; diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index 8437959e0ad..aecfcb6cb74 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -167,9 +167,9 @@ INSERT INTO mysql.innodb_index_stats SELECT * FROM t1_c2_stats; DROP TABLE t1_c2_stats; CREATE INDEX c2d ON t1(c2); 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 -t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE -t1 1 c2d 1 c2 A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 c1 A 80 NULL NULL BTREE YES +t1 1 c2d 1 c2 A 10 NULL NULL YES BTREE YES EXPLAIN SELECT COUNT(*) FROM t1 WHERE c2 > 3; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range c2d c2d 5 NULL 32 Using where; Using index diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 0b891be0eae..a41feb6e7ad 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -172,10 +172,10 @@ Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 id A # NULL NULL BTREE -t1 1 parent_id 1 parent_id A # NULL NULL BTREE -t1 1 level 1 level A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 id A # NULL NULL BTREE YES +t1 1 parent_id 1 parent_id A # NULL NULL BTREE YES +t1 1 level 1 level A # NULL NULL BTREE YES drop table t1; CREATE TABLE t1 ( gesuchnr int(11) DEFAULT '0' NOT NULL, @@ -216,8 +216,8 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 1 skr 1 a A # NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 skr 1 a A # NULL NULL YES BTREE YES drop table t1; create table t1 (a int,b varchar(20),key(a)) engine=innodb; insert into t1 values (1,""), (2,"testing"); @@ -406,13 +406,13 @@ key(a),primary key(a,b), unique(c),key(a),unique(b)); Warnings: Note 1831 Duplicate index 'a_2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release. 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 -t1 0 PRIMARY 1 a A # NULL NULL BTREE -t1 0 PRIMARY 2 b A # NULL NULL BTREE -t1 0 c 1 c A # NULL NULL BTREE -t1 0 b 1 b A # NULL NULL BTREE -t1 1 a 1 a A # NULL NULL BTREE -t1 1 a_2 1 a A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES +t1 0 PRIMARY 2 b A # NULL NULL BTREE YES +t1 0 c 1 c A # NULL NULL BTREE YES +t1 0 b 1 b A # NULL NULL BTREE YES +t1 1 a 1 a A # NULL NULL BTREE YES +t1 1 a_2 1 a A # NULL NULL BTREE YES drop table t1; create table t1 (col1 int not null, col2 char(4) not null, primary key(col1)); alter table t1 engine=innodb; @@ -749,8 +749,8 @@ Table Op Msg_type Msg_text test.t1 optimize note Table does not support optimize, doing recreate + analyze instead test.t1 optimize status OK show keys from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t1 0 PRIMARY 1 a A # NULL NULL BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 PRIMARY 1 a A # NULL NULL BTREE YES drop table t1; create table t1 (i int, j int ) ENGINE=innodb; insert into t1 values (1,2); diff --git a/mysql-test/suite/innodb/r/innodb_stats.result b/mysql-test/suite/innodb/r/innodb_stats.result index d2c3bd0127e..b629ba4eee1 100644 --- a/mysql-test/suite/innodb/r/innodb_stats.result +++ b/mysql-test/suite/innodb/r/innodb_stats.result @@ -52,6 +52,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1); ANALYZE TABLE test_innodb_stats; @@ -104,6 +105,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (1); ANALYZE TABLE test_innodb_stats; @@ -156,6 +158,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1); ANALYZE TABLE test_innodb_stats; @@ -208,6 +211,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1); ANALYZE TABLE test_innodb_stats; @@ -260,6 +264,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (2); ANALYZE TABLE test_innodb_stats; @@ -312,6 +317,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2); ANALYZE TABLE test_innodb_stats; @@ -364,6 +370,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3); ANALYZE TABLE test_innodb_stats; @@ -416,6 +423,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (1), (2), (3), (3); ANALYZE TABLE test_innodb_stats; @@ -468,6 +476,7 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES TRUNCATE TABLE test_innodb_stats; INSERT INTO test_innodb_stats (a) VALUES (1), (2), (3), (4), (5), (1), (2), (3), (4), (5); ANALYZE TABLE test_innodb_stats; @@ -520,3 +529,4 @@ NULLABLE YES INDEX_TYPE BTREE COMMENT INDEX_COMMENT +IS_VISIBLE YES diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result index b75b0e52006..76a8eee65f7 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext.result +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -7,9 +7,9 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Full-text search in MySQL', 'implements vector space model'); ANALYZE TABLE t1; 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 -t1 1 a 1 a NULL 5 NULL NULL YES FULLTEXT -t1 1 a 2 b NULL 5 NULL NULL YES FULLTEXT +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a NULL 5 NULL NULL YES FULLTEXT YES +t1 1 a 2 b NULL 5 NULL NULL YES FULLTEXT YES select * from t1 where MATCH(a,b) AGAINST ("collections"); a b Full-text indexes are called collections @@ -233,9 +233,9 @@ match(ttxt.inhalt) against ('foobar'); id 3 show keys from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment -t2 1 tig 1 ticket A 3 NULL NULL YES BTREE -t2 1 tix 1 inhalt NULL 3 NULL NULL YES FULLTEXT +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 1 tig 1 ticket A 3 NULL NULL YES BTREE YES +t2 1 tix 1 inhalt NULL 3 NULL NULL YES FULLTEXT YES show create table t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/suite/opt_trace/r/eq_range_statistics.result b/mysql-test/suite/opt_trace/r/eq_range_statistics.result index ddc9ea1568a..9f9a2d42afb 100644 --- a/mysql-test/suite/opt_trace/r/eq_range_statistics.result +++ b/mysql-test/suite/opt_trace/r/eq_range_statistics.result @@ -14,16 +14,16 @@ INSERT INTO t1 VALUES (1,1), (2,2), (3,3); INSERT INTO t1 VALUES (4,1), (4,2), (4,3); INSERT INTO t1 VALUES (5,1), (5,2), (5,3); 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 -t1 1 a 1 a A NULL NULL NULL YES BTREE -t1 1 a 2 b A NULL NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A NULL NULL NULL YES BTREE YES +t1 1 a 2 b A NULL NULL NULL YES BTREE YES ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 4 NULL NULL YES BTREE -t1 1 a 2 b A 9 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 4 NULL NULL YES BTREE YES +t1 1 a 2 b A 9 NULL NULL YES BTREE YES ##### # Apply knowledge about the statistics (each index value for # the first key part has an estimate of 2 rows) to ensure that diff --git a/mysql-test/suite/rpl/r/rpl_invisible_indexes.result b/mysql-test/suite/rpl/r/rpl_invisible_indexes.result new file mode 100644 index 00000000000..058b9c3417c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_invisible_indexes.result @@ -0,0 +1,105 @@ +include/master-slave.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection master] +# Create a table with an index +CREATE TABLE t1 ( i INT , KEY (i)); +INSERT INTO t1 VALUES (2),(3),(5),(7),(11),(13); +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Check that the index is on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 i 1 i A 6 NULL NULL YES BTREE YES +[Connection Master] +# Make the index invisible +ALTER TABLE t1 ALTER INDEX i INVISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is invisible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 i 1 i A 6 NULL NULL YES BTREE NO +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using where +[Connection Master] +ALTER TABLE t1 ALTER INDEX i VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the index is visible on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 i 1 i A 6 NULL NULL YES BTREE YES +EXPLAIN SELECT * FROM t1 WHERE i=3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i i 5 const 1 Using index +[Connection Master] +# Create an invisible index on the table +CREATE UNIQUE INDEX idx ON t1(i) INVISIBLE; +include/sync_slave_sql_with_master.inc +[Connection Slave] +# Verify that the invisible is created on the slave +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 idx 1 i A 6 NULL NULL YES BTREE NO +t1 1 i 1 i A 6 NULL NULL YES BTREE YES +[Connection Master] +ALTER TABLE t1 DROP INDEX i, ALTER INDEX idx VISIBLE, ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES +[Connection Master] +# Creation of invisible indexes on MyISAM tables +CREATE TABLE t2 (i INT, KEY(i) INVISIBLE) ENGINE=MYISAM; +INSERT INTO t2 VALUES (2),(3),(5),(7),(11); +include/sync_slave_sql_with_master.inc +[Connection Slave] +[Connection Master] +# Alter the engine and then alter the index +ALTER TABLE t1 ENGINE = MYISAM; +ALTER TABLE t1 ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 0 idx 1 i A 6 NULL NULL YES BTREE YES +[Connection Master] +# Alter the engine and then alter the index +ALTER TABLE t2 ENGINE = INNODB; +ALTER TABLE t2 ALTER INDEX i INVISIBLE, ALTER INDEX i VISIBLE, ALTER INDEX i INVISIBLE; +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +include/sync_slave_sql_with_master.inc +[Connection Slave] +SHOW INDEXES FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t2 1 i 1 i A 5 NULL NULL YES BTREE NO +[Connection Master] +# Clean up +DROP TABLE t1; +DROP TABLE t2; +include/sync_slave_sql_with_master.inc +[Connection Slave] +SELECT * FROM t1; +ERROR 42S02: Table 'test.t1' doesn't exist +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_invisible_indexes-master.opt b/mysql-test/suite/rpl/t/rpl_invisible_indexes-master.opt new file mode 100644 index 00000000000..4c39ec0991e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_invisible_indexes-master.opt @@ -0,0 +1 @@ +--default-storage-engine=InnoDB diff --git a/mysql-test/suite/rpl/t/rpl_invisible_indexes-slave.opt b/mysql-test/suite/rpl/t/rpl_invisible_indexes-slave.opt new file mode 100644 index 00000000000..4c39ec0991e --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_invisible_indexes-slave.opt @@ -0,0 +1 @@ +--default-storage-engine=InnoDB diff --git a/mysql-test/suite/rpl/t/rpl_invisible_indexes.test b/mysql-test/suite/rpl/t/rpl_invisible_indexes.test new file mode 100644 index 00000000000..543781dc3e8 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_invisible_indexes.test @@ -0,0 +1,137 @@ +####################################################################### +# # +# The aim of this test is to set up replication between a master and # +# slave and test the basic functionality of invisible indexes which # +# were introduced in WL#8697: Support for INVISIBLE indexes. # +# # +# Creation Date: 2016-05-12 # +# Author: Deepa Dixit # +# # +####################################################################### + + +--source include/master-slave.inc +--connection master + +--echo # Create a table with an index + +CREATE TABLE t1 ( i INT , KEY (i)); +INSERT INTO t1 VALUES (2),(3),(5),(7),(11),(13); +ANALYZE TABLE t1; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--echo # Check that the index is on the slave + +SHOW INDEXES FROM t1; + +--echo [Connection Master] +--connection master + +--echo # Make the index invisible + +ALTER TABLE t1 ALTER INDEX i INVISIBLE; +ANALYZE TABLE t1; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--echo # Verify that the index is invisible on the slave + +SHOW INDEXES FROM t1; +EXPLAIN SELECT * FROM t1 WHERE i=3; + +--echo [Connection Master] +--connection master + +ALTER TABLE t1 ALTER INDEX i VISIBLE; +ANALYZE TABLE t1; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--echo # Verify that the index is visible on the slave + +SHOW INDEXES FROM t1; +EXPLAIN SELECT * FROM t1 WHERE i=3; + +--echo [Connection Master] +--connection master + +--echo # Create an invisible index on the table + +CREATE UNIQUE INDEX idx ON t1(i) INVISIBLE; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--echo # Verify that the invisible is created on the slave + +SHOW INDEXES FROM t1; + +--echo [Connection Master] +--connection master + +ALTER TABLE t1 DROP INDEX i, ALTER INDEX idx VISIBLE, ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +SHOW INDEXES FROM t1; + +--echo [Connection Master] +--connection master + +--echo # Creation of invisible indexes on MyISAM tables + +CREATE TABLE t2 (i INT, KEY(i) INVISIBLE) ENGINE=MYISAM; +INSERT INTO t2 VALUES (2),(3),(5),(7),(11); + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--echo [Connection Master] +--connection master + +--echo # Alter the engine and then alter the index + +ALTER TABLE t1 ENGINE = MYISAM; +ALTER TABLE t1 ALTER INDEX idx INVISIBLE, ALTER INDEX idx VISIBLE; +ANALYZE TABLE t1; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +SHOW INDEXES FROM t1; + +--echo [Connection Master] +--connection master + +--echo # Alter the engine and then alter the index + +ALTER TABLE t2 ENGINE = INNODB; +ALTER TABLE t2 ALTER INDEX i INVISIBLE, ALTER INDEX i VISIBLE, ALTER INDEX i INVISIBLE; +ANALYZE TABLE t2; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +SHOW INDEXES FROM t2; + +--echo [Connection Master] +--connection master + +--echo # Clean up + +DROP TABLE t1; +DROP TABLE t2; + +--source include/sync_slave_sql_with_master.inc +--echo [Connection Slave] + +--error ER_NO_SUCH_TABLE +SELECT * FROM t1; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result b/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result index 5efdeeedc4b..e95eac66418 100644 --- a/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result +++ b/mysql-test/suite/sys_vars/r/myisam_stats_method_func.result @@ -21,16 +21,16 @@ ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES INSERT INTO t1 VALUES (11); DELETE FROM t1 WHERE a = 11; CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK 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 -t1 1 a 1 a A 10 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 10 NULL NULL YES BTREE YES 'Set nulls to be equal' SET myisam_stats_method = nulls_equal; INSERT INTO t1 VALUES (11); @@ -39,16 +39,16 @@ ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES INSERT INTO t1 VALUES (11); DELETE FROM t1 WHERE a = 11; CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK 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 -t1 1 a 1 a A 5 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 5 NULL NULL YES BTREE YES 'Set nulls to be ignored' SET myisam_stats_method = nulls_ignored; SHOW VARIABLES LIKE 'myisam_stats_method'; @@ -67,21 +67,21 @@ ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 2 NULL NULL YES BTREE -t1 1 a 2 b A 4 NULL NULL YES BTREE -t1 1 a 3 c A 4 NULL NULL YES BTREE -t1 1 a 4 d A 4 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 2 NULL NULL YES BTREE YES +t1 1 a 2 b A 4 NULL NULL YES BTREE YES +t1 1 a 3 c A 4 NULL NULL YES BTREE YES +t1 1 a 4 d A 4 NULL NULL YES BTREE YES DELETE FROM t1; ANALYZE TABLE t1; Table Op Msg_type Msg_text test.t1 analyze status OK 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 -t1 1 a 1 a A 0 NULL NULL YES BTREE -t1 1 a 2 b A 0 NULL NULL YES BTREE -t1 1 a 3 c A 0 NULL NULL YES BTREE -t1 1 a 4 d A 0 NULL NULL YES BTREE +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible +t1 1 a 1 a A 0 NULL NULL YES BTREE YES +t1 1 a 2 b A 0 NULL NULL YES BTREE YES +t1 1 a 3 c A 0 NULL NULL YES BTREE YES +t1 1 a 4 d A 0 NULL NULL YES BTREE YES SET myisam_stats_method = DEFAULT; DROP TABLE t1; SET @@global.myisam_stats_method= @start_value; diff --git a/mysql-test/t/invisible_indexes-master.opt b/mysql-test/t/invisible_indexes-master.opt new file mode 100644 index 00000000000..4c39ec0991e --- /dev/null +++ b/mysql-test/t/invisible_indexes-master.opt @@ -0,0 +1 @@ +--default-storage-engine=InnoDB diff --git a/mysql-test/t/invisible_indexes.test b/mysql-test/t/invisible_indexes.test new file mode 100644 index 00000000000..0cd0ec885d8 --- /dev/null +++ b/mysql-test/t/invisible_indexes.test @@ -0,0 +1,73 @@ +--source include/invisible_indexes.inc + +--echo # +--echo # Tests that don't work on MyISAM ( native partitioning, indexes on +--echo # generated columns, etc.) +--echo # + +--echo # +--echo # Partitioning on keys with an invisible index, invisible indexes over +--echo # partitioned tables. +--echo # +CREATE TABLE t1 ( + a CHAR(2) NOT NULL, + b CHAR(2) NOT NULL, + c INT(10) UNSIGNED NOT NULL, + d VARCHAR(255) DEFAULT NULL, + e VARCHAR(1000) DEFAULT NULL, + KEY (a) INVISIBLE, + KEY (b) +) PARTITION BY KEY (a) PARTITIONS 20; + +INSERT INTO t1 (a, b, c, d, e) VALUES +('07', '03', 343, '1', '07_03_343'), +('01', '04', 343, '2', '01_04_343'), +('01', '06', 343, '3', '01_06_343'), +('01', '07', 343, '4', '01_07_343'), +('01', '08', 343, '5', '01_08_343'), +('01', '09', 343, '6', '01_09_343'), +('03', '03', 343, '7', '03_03_343'), +('03', '06', 343, '8', '03_06_343'), +('03', '07', 343, '9', '03_07_343'), +('04', '03', 343, '10', '04_03_343'), +('04', '06', 343, '11', '04_06_343'), +('05', '03', 343, '12', '05_03_343'), +('11', '03', 343, '13', '11_03_343'), +('11', '04', 343, '14', '11_04_343'); + +ANALYZE TABLE t1; + +EXPLAIN SELECT a FROM t1; +EXPLAIN SELECT b FROM t1; +EXPLAIN SELECT * FROM t1 WHERE a = '04'; + +ALTER TABLE t1 ALTER INDEX a VISIBLE; +EXPLAIN SELECT a FROM t1; +EXPLAIN SELECT * FROM t1 WHERE a = '04'; + +ALTER TABLE t1 ALTER INDEX b INVISIBLE; +EXPLAIN SELECT b FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1 ( a INT, KEY (a) INVISIBLE ); +SHOW INDEXES FROM t1; +EXPLAIN SELECT a FROM t1; +DROP TABLE t1; + + +--echo # +--echo # Test that referential constraints implemented by the indexes are still +--echo # enforced while the index is invisible. +--echo # + +CREATE TABLE t1p ( a INT KEY ); +CREATE TABLE t1c ( t1p_a INT ); +ALTER TABLE t1c ADD CONSTRAINT FOREIGN KEY ( t1p_a ) REFERENCES t1p( a ); +ALTER TABLE t1c ALTER INDEX t1p_a INVISIBLE; + +--error ER_NO_REFERENCED_ROW_2 +INSERT INTO t1c VALUES ( 1 ); +SELECT * FROM t1c; + +DROP TABLE t1c, t1p; diff --git a/mysql-test/t/invisible_indexes_myisam-master.opt b/mysql-test/t/invisible_indexes_myisam-master.opt new file mode 100644 index 00000000000..96f0ce3f36c --- /dev/null +++ b/mysql-test/t/invisible_indexes_myisam-master.opt @@ -0,0 +1 @@ +--default-storage-engine=MyISAM diff --git a/mysql-test/t/invisible_indexes_myisam.test b/mysql-test/t/invisible_indexes_myisam.test new file mode 100644 index 00000000000..9e311c0ba91 --- /dev/null +++ b/mysql-test/t/invisible_indexes_myisam.test @@ -0,0 +1 @@ +--source include/invisible_indexes.inc diff --git a/mysql-test/t/invisible_indexes_tokudb-master.opt b/mysql-test/t/invisible_indexes_tokudb-master.opt new file mode 100644 index 00000000000..751940ced29 --- /dev/null +++ b/mysql-test/t/invisible_indexes_tokudb-master.opt @@ -0,0 +1 @@ +--default_storage_engine=TokuDB diff --git a/mysql-test/t/invisible_indexes_tokudb.test b/mysql-test/t/invisible_indexes_tokudb.test new file mode 100644 index 00000000000..5361c323c64 --- /dev/null +++ b/mysql-test/t/invisible_indexes_tokudb.test @@ -0,0 +1,2 @@ +--source include/have_tokudb.inc +--source include/invisible_indexes.inc diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 1da8c2029c2..ecec24b0881 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2523,3 +2523,21 @@ SELECT * FROM t2; DROP TABLE t1; DROP TABLE t2; DROP DATABASE db_20772273; + +--echo # +--echo # WL#8697: Invisible Indexes +--echo # Test of mysqldump. +--echo # + +CREATE TABLE test.t1 ( + a INT, + b INT, + c INT, + INDEX (a) VISIBLE, + INDEX (b) INVISIBLE, + INDEX (c) +); + +--exec $MYSQL_DUMP --compact test t1 + +DROP TABLE test.t1; diff --git a/sql/handler.cc b/sql/handler.cc index 63588048d00..405963acfe0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -76,7 +76,7 @@ static handlerton *installed_htons[128]; #define BITMAP_STACKBUF_SIZE (128/8) KEY_CREATE_INFO default_key_create_info= - { HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0}, true }; + { HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0}, true, true }; /* number of entries in handlertons[] */ ulong total_ha= 0; @@ -4680,7 +4680,8 @@ handler::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info::ALTER_COLUMN_NAME | Alter_inplace_info::ALTER_COLUMN_DEFAULT | Alter_inplace_info::CHANGE_CREATE_OPTION | - Alter_inplace_info::ALTER_RENAME; + Alter_inplace_info::ALTER_RENAME | + Alter_inplace_info::ALTER_INDEX_VISIBILITY; /* Is there at least one operation that requires copy algorithm? */ if (ha_alter_info->handler_flags & ~inplace_offline_operations) diff --git a/sql/handler.h b/sql/handler.h index 147153900b5..4ffb23b636f 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1087,6 +1087,25 @@ typedef struct st_ha_create_information enum ha_storage_media storage_media; /* DEFAULT, DISK or MEMORY */ } HA_CREATE_INFO; +/** + Structure describing changes to an index to be caused by ALTER TABLE. +*/ + +struct KEY_PAIR +{ + /** + Pointer to KEY object describing old version of index in + TABLE::key_info array for TABLE instance representing old + version of table. + */ + KEY *old_key; + /** + Pointer to KEY object describing new version of index in + Alter_inplace_info::key_info_buffer array. + */ + KEY *new_key; +}; + /** In-place alter handler context. @@ -1241,6 +1260,9 @@ class Alter_inplace_info */ static const HA_ALTER_FLAGS ADD_COLUMN_FOR_COMFORT = 1L << 30; + // Change index visibility. + static const HA_ALTER_FLAGS ALTER_INDEX_VISIBILITY = 1L << 31; + /** Create options (like MAX_ROWS) for the new version of table. @@ -1303,6 +1325,19 @@ class Alter_inplace_info */ uint *index_add_buffer; + /** Size of index_altered_visibility_buffer array. */ + uint index_altered_visibility_count; + + /** + Array of KEY_PAIR objects describing indexes of which visibility + being changed. For each index changed it contains object with + KEY_PAIR::old_key pointing to KEY object belonging to the TABLE + instance for old version of table representing old version of + index and with KEY_PAIR::new_key pointing to KEY object for new + version of index in key_info_buffer member. + */ + KEY_PAIR *index_altered_visibility_buffer; + /** Context information to allow handlers to keep context between in-place alter API calls. @@ -1369,6 +1404,8 @@ class Alter_inplace_info index_drop_buffer(NULL), index_add_count(0), index_add_buffer(NULL), + index_altered_visibility_count(0), + index_altered_visibility_buffer(NULL), handler_ctx(NULL), group_commit_ctx(NULL), handler_flags(0), @@ -1394,6 +1431,21 @@ class Alter_inplace_info */ void report_unsupported_error(const char *not_supported, const char *try_instead); + + /** + Add old and new version of key to array of indexes whose visibility + being changed. + */ + void add_altered_index_visibility(KEY *old_key, KEY *new_key) + { + KEY_PAIR *key_pair= index_altered_visibility_buffer + + index_altered_visibility_count++; + key_pair->old_key= old_key; + key_pair->new_key= new_key; + DBUG_PRINT("info", ("index had visibility altered: %i to %i", + old_key->is_visible, + new_key->is_visible)); + } }; @@ -1410,6 +1462,7 @@ typedef struct st_key_create_information associated with it was dropped. */ bool check_for_duplicate_indexes; + bool is_visible; } KEY_CREATE_INFO; diff --git a/sql/item_func.cc b/sql/item_func.cc index f28e4426f77..346cee05044 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -6350,7 +6350,7 @@ bool Item_func_match::fix_index() { if ((table->key_info[keynr].flags & HA_FULLTEXT) && (flags & FT_BOOL ? table->keys_in_use_for_query.is_set(keynr) : - table->s->keys_in_use.is_set(keynr))) + table->s->usable_indexes().is_set(keynr))) { ft_to_key[fts]=keynr; diff --git a/sql/lex.h b/sql/lex.h index 8a077e02283..608d481bcf5 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -297,6 +297,7 @@ static SYMBOL symbols[] = { { "ISOLATION", SYM(ISOLATION)}, { "ISSUER", SYM(ISSUER_SYM)}, { "ITERATE", SYM(ITERATE_SYM)}, + { "INVISIBLE", SYM(INVISIBLE_SYM)}, { "INVOKER", SYM(INVOKER_SYM)}, { "JOIN", SYM(JOIN_SYM)}, { "KEY", SYM(KEY_SYM)}, @@ -655,6 +656,7 @@ static SYMBOL symbols[] = { { "WHERE", SYM(WHERE)}, { "WHILE", SYM(WHILE_SYM)}, { "VIEW", SYM(VIEW_SYM)}, + { "VISIBLE", SYM(VISIBLE_SYM)}, { "WITH", SYM(WITH)}, { "WORK", SYM(WORK_SYM)}, { "WRAPPER", SYM(WRAPPER_SYM)}, diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index eca705ec009..8d8aab05489 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7136,3 +7136,5 @@ ER_SEQUENCE_ACCESS_ERROR eng "Sequence '%-.192s.%-.192s' access error." ER_SEQUENCE_BINLOG_FORMAT eng "Sequence requires binlog_format= row" +ER_PK_INDEX_CANT_BE_INVISIBLE + eng "A primary key index cannot be invisible" diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index fa8d5e790c3..18417ab1bc8 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -25,6 +25,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) alter_list(rhs.alter_list, mem_root), key_list(rhs.key_list, mem_root), create_list(rhs.create_list, mem_root), + alter_index_visibility_list(rhs.alter_index_visibility_list, mem_root), flags(rhs.flags), keys_onoff(rhs.keys_onoff), partition_names(rhs.partition_names, mem_root), @@ -45,6 +46,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) list_copy_and_replace_each_value(alter_list, mem_root); list_copy_and_replace_each_value(key_list, mem_root); list_copy_and_replace_each_value(create_list, mem_root); + list_copy_and_replace_each_value(alter_index_visibility_list, mem_root); /* partition_names are not deeply copied currently */ } diff --git a/sql/sql_alter.h b/sql/sql_alter.h index c3fe8a24212..701a011f010 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -20,6 +20,7 @@ class Alter_drop; class Alter_column; class Key; +class Alter_index_visibility; /** @@ -122,6 +123,9 @@ class Alter_info // Set for ADD [COLUMN] FIRST | AFTER static const uint ALTER_COLUMN_ORDER = 1L << 25; + // Means that the visibility of and index is changed. + static const uint ALTER_INDEX_VISIBILITY = 1L << 26; + enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE }; @@ -170,6 +174,8 @@ class Alter_info List key_list; // List of columns, used by both CREATE and ALTER TABLE. List create_list; + // Indexes whose visibilities are to be changed. + List alter_index_visibility_list; // Type of ALTER TABLE operation. uint flags; // Enable or disable keys. @@ -198,6 +204,7 @@ class Alter_info alter_list.empty(); key_list.empty(); create_list.empty(); + alter_index_visibility_list.empty(); flags= 0; keys_onoff= LEAVE_AS_IS; num_parts= 0; diff --git a/sql/sql_class.h b/sql/sql_class.h index ffb5eca3c41..45d3a1771a5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -269,6 +269,34 @@ class Alter_column :public Sql_alloc { { return new (mem_root) Alter_column(*this); } }; +/** + An ALTER INDEX operation that changes the visibility of an index. +*/ +class Alter_index_visibility :public Sql_alloc { +public: + Alter_index_visibility(const char* name, bool is_visible) + :m_name(name), m_is_visible(is_visible) + { + DBUG_ASSERT(name != NULL); + } + + const char *name() const { return m_name; } + + /* The visibility after the operation is performed. */ + bool is_visible() const { return m_is_visible; } + + /** + Used to make a clone of this object for ALTER/CREATE TABLE + @sa comment for Key_part_spec::clone + */ + Alter_index_visibility *clone(MEM_ROOT *mem_root) const + { return new (mem_root) Alter_index_visibility(*this); } + +private: + const char *m_name; + bool m_is_visible; +}; + class Key :public Sql_alloc { public: diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 3d3c0c5e1bf..f7de814abd6 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1903,6 +1903,9 @@ static void store_key_options(THD *thd, String *packet, TABLE *table, append_unescaped(packet, key_info->comment.str, key_info->comment.length); } + + if (!key_info->is_visible) + packet->append(STRING_WITH_LEN(" /*!50616 INVISIBLE */")); } } @@ -5925,8 +5928,13 @@ static int get_schema_stat_record(THD *thd, TABLE_LIST *tables, DBUG_ASSERT(MY_TEST(key_info->flags & HA_USES_COMMENT) == (key_info->comment.length > 0)); if (key_info->flags & HA_USES_COMMENT) - table->field[15]->store(key_info->comment.str, + table->field[15]->store(key_info->comment.str, key_info->comment.length, cs); + /* is_visible column */ + const char *is_visible= key_info->is_visible ? "YES" : "NO"; + table->field[16]->store(is_visible, strlen(is_visible), cs); + table->field[16]->set_notnull(); + if (schema_table_store_record(thd, table)) DBUG_RETURN(1); } @@ -8155,6 +8163,7 @@ ST_FIELD_INFO stat_fields_info[]= {"COMMENT", 16, MYSQL_TYPE_STRING, 0, 1, "Comment", OPEN_FRM_ONLY}, {"INDEX_COMMENT", INDEX_COMMENT_MAXLEN, MYSQL_TYPE_STRING, 0, 0, "Index_comment", OPEN_FRM_ONLY}, + {"IS_VISIBLE", 4, MYSQL_TYPE_STRING, 0, 1, "Visible", OPEN_FULL_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dbdc3488967..81315bab7fd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3411,6 +3411,50 @@ static void check_duplicate_key(THD *thd, } +/** + Primary/unique key check. Checks that: + + - If the storage engine requires it, that there is an index that is + candidate for promotion. + + - If such a promotion occurs, checks that the candidate index is not + declared invisible. + + @param file The storage engine handler. + @param key_info_buffer All indexes in the table. + @param key_count Number of indexes. + + @retval false OK. + @retval true An error occured and my_error() was called. +*/ + +static bool check_promoted_index(const handler *file, + const KEY *key_info_buffer, + uint key_count) +{ + bool has_unique_key= false; + const KEY *end= key_info_buffer + key_count; + for (const KEY *k= key_info_buffer; k < end && !has_unique_key; ++k) + { + if (!(k->flags & HA_NULL_PART_KEY) && (k->flags & HA_NOSAME)) + { + has_unique_key= true; + if (!k->is_visible) + { + my_error(ER_PK_INDEX_CANT_BE_INVISIBLE, MYF(0)); + return true; + } + } + } + + if (!has_unique_key && (file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY)) + { + my_error(ER_REQUIRES_PRIMARY_KEY, MYF(0)); + return true; + } + return false; +} + /* Preparation for table creation @@ -3985,6 +4029,17 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_info->key_part=key_part_info; key_info->usable_key_parts= key_number; key_info->algorithm= key->key_create_info.algorithm; + key_info->is_visible= key->key_create_info.is_visible; + if (!key_info->is_visible) + { + /* Primary key can not be invisible */ + if (key->type == Key::PRIMARY) + { + my_error(ER_PK_INDEX_CANT_BE_INVISIBLE, MYF(0)); + DBUG_RETURN(TRUE); + } + key_info->flags|= HA_INVISIBLE_KEY; + } if (key->type == Key::FULLTEXT) { @@ -4375,12 +4430,10 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_info++; } - if (!unique_key && !primary_key && - (file->ha_table_flags() & HA_REQUIRE_PRIMARY_KEY)) - { - my_message(ER_REQUIRES_PRIMARY_KEY, ER(ER_REQUIRES_PRIMARY_KEY), MYF(0)); + if (!primary_key && unique_key && + check_promoted_index(file, *key_info_buffer, *key_count)) DBUG_RETURN(TRUE); - } + if (auto_increment > 0) { my_message(ER_WRONG_AUTO_KEY, ER(ER_WRONG_AUTO_KEY), MYF(0)); @@ -5774,6 +5827,32 @@ static Create_field *get_field_by_index(Alter_info *alter_info, uint idx) } +/** + Look-up KEY object by index name using case-insensitive comparison. + + @param key_name Index name. + @param key_start Start of array of KEYs for table. + @param key_end End of array of KEYs for table. + + @note Case-insensitive comparison is necessary to correctly + handle renaming of keys. + + @retval non-NULL - pointer to KEY object for index found. + @retval NULL - no index with such name found (or it is marked + as renamed). +*/ + +static KEY* find_key_ci(const char *key_name, KEY *key_start, KEY *key_end) +{ + for (KEY *key= key_start; key < key_end; key++) + { + if (! my_strcasecmp(system_charset_info, key_name, key->name)) + return key; + } + return NULL; +} + + static int compare_uint(const uint *s, const uint *t) { return (*s < *t) ? -1 : ((*s > *t) ? 1 : 0); @@ -5842,7 +5921,10 @@ static bool fill_alter_inplace_info(THD *thd, (KEY**) thd->alloc(sizeof(KEY*) * table->s->keys)) || ! (ha_alter_info->index_add_buffer= (uint*) thd->alloc(sizeof(uint) * - alter_info->key_list.elements))) + alter_info->key_list.elements)) || + ! (ha_alter_info->index_altered_visibility_buffer= + (KEY_PAIR*) thd->alloc(sizeof(KEY_PAIR) * + alter_info->alter_index_visibility_list.elements))) DBUG_RETURN(true); /* First we setup ha_alter_flags based on what was detected by parser. */ @@ -6054,6 +6136,27 @@ static bool fill_alter_inplace_info(THD *thd, DBUG_PRINT("info", ("index count old: %d new: %d", table->s->keys, ha_alter_info->key_count)); + const Alter_index_visibility *alter_index_visibility; + List_iterator + alter_index_visibility_it(alter_info->alter_index_visibility_list); + + while ((alter_index_visibility= alter_index_visibility_it++)) + { + const char *name= alter_index_visibility->name(); + table_key= find_key_ci(name, table->key_info, table_key_end); + new_key= find_key_ci(name, ha_alter_info->key_info_buffer, new_key_end); + + if (new_key == NULL) + { + my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), name, table->s->table_name.str); + DBUG_RETURN(true); + } + + new_key->is_visible= alter_index_visibility->is_visible(); + ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_INDEX_VISIBILITY; + ha_alter_info->add_altered_index_visibility(table_key, new_key); + } + /* Step through all keys of the old table and search matching new keys. */ @@ -7143,6 +7246,19 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, List_iterator find_it(new_create_list); List_iterator field_it(new_create_list); List key_parts; + + /* + This is how we check that all indexes to be altered are name-resolved: We + make a copy of the list from the alter_info, and remove all the indexes + that are found in the table. Later we check that there is nothing left in + the list. + */ + List + index_visibility_list(alter_info->alter_index_visibility_list, thd->mem_root); + List_iterator visibility_it(index_visibility_list); + List_iterator + visibility_it2(alter_info->alter_index_visibility_list); + uint db_create_options= (table->s->db_create_options & ~(HA_OPTION_PACK_RECORD)); uint used_fields= create_info->used_fields; @@ -7462,10 +7578,22 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, } if (key_parts.elements) { - KEY_CREATE_INFO key_create_info; + KEY_CREATE_INFO key_create_info= + { HA_KEY_ALG_UNDEF, 0, {NullS, 0}, {NullS, 0}, false, + key_info->is_visible }; + Key *key; enum Key::Keytype key_type; - memset(&key_create_info, 0, sizeof(key_create_info)); + + // Erase all alter operations that operate on this index. + const Alter_index_visibility *alter_index_visibility; + visibility_it.rewind(); + while ((alter_index_visibility= visibility_it++)) + { + if (my_strcasecmp(system_charset_info, key_name, + alter_index_visibility->name()) == 0) + visibility_it.remove(); + } key_create_info.algorithm= key_info->algorithm; if (key_info->flags & HA_USES_BLOCK_SIZE) @@ -7475,6 +7603,22 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, if (key_info->flags & HA_USES_COMMENT) key_create_info.comment= key_info->comment; + visibility_it2.rewind(); + while ((alter_index_visibility= visibility_it2++)) + { + const char *name= alter_index_visibility->name(); + if (my_strcasecmp(system_charset_info, key_name, name) == 0) + { + if (table->s->primary_key <= MAX_KEY && + table->key_info + table->s->primary_key == key_info) + { + my_error(ER_PK_INDEX_CANT_BE_INVISIBLE, MYF(0)); + goto err; + } + key_create_info.is_visible= alter_index_visibility->is_visible(); + } + } + if (key_info->flags & HA_SPATIAL) key_type= Key::SPATIAL; else if (key_info->flags & HA_NOSAME) @@ -7545,6 +7689,14 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, goto err; } + if (index_visibility_list.elements) + { + my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), + index_visibility_list.head()->name(), + table->s->table_name.str); + goto err; + } + if (!create_info->comment.str) { create_info->comment.str= table->s->comment.str; diff --git a/sql/sql_tmp_table.cc b/sql/sql_tmp_table.cc index f664e8f87ec..64b0e92e67b 100644 --- a/sql/sql_tmp_table.cc +++ b/sql/sql_tmp_table.cc @@ -1008,6 +1008,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, keyinfo= param->keyinfo; keyinfo->table= table; + keyinfo->is_visible= true; if (group) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1f8c7920ae5..3b70f0e5e01 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1692,6 +1692,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token YEAR_MONTH_SYM %token YEAR_SYM /* SQL-2003-R */ %token ZEROFILL +%token INVISIBLE_SYM +%token VISIBLE_SYM %left JOIN_SYM INNER_SYM STRAIGHT_JOIN CROSS LEFT RIGHT /* A dummy token to force the priority of table_ref production in a join. */ @@ -1744,7 +1746,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); opt_natural_language_mode opt_query_expansion opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt - trg_action_time trg_event force_drop + trg_action_time trg_event force_drop visibility /* Bit field of MYSQL_START_TRANS_OPT_* flags. @@ -7400,10 +7402,16 @@ key_using_alg: | TYPE_SYM btree_or_rtree { Lex->key_create_info.algorithm= $2; } ; +visibility: + VISIBLE_SYM { $$= true; } + | INVISIBLE_SYM { $$= false; } + ; + all_key_opt: KEY_BLOCK_SIZE opt_equal ulong_num { Lex->key_create_info.block_size= $3; } | COMMENT_SYM TEXT_STRING_sys { Lex->key_create_info.comment= $2; } + | visibility { Lex->key_create_info.is_visible = $1; } ; normal_key_opt: @@ -8087,6 +8095,15 @@ alter_list_item: lex->alter_info.alter_list.push_back(ac); lex->alter_info.flags|= Alter_info::ALTER_CHANGE_COLUMN_DEFAULT; } + | ALTER INDEX_SYM ident visibility + { + LEX *lex= Lex; + Alter_index_visibility *ac= new Alter_index_visibility($3.str, $4); + if (ac == NULL) + MYSQL_YYABORT; + lex->alter_info.alter_index_visibility_list.push_back(ac); + lex->alter_info.flags|= Alter_info::ALTER_INDEX_VISIBILITY; + } | ALTER opt_column field_ident DROP DEFAULT { LEX *lex=Lex; @@ -14450,6 +14467,7 @@ keyword: | HELP_SYM {} | HOST_SYM {} | INSTALL_SYM {} + | INVISIBLE_SYM {} | LANGUAGE_SYM {} | NO_SYM {} | OPEN_SYM {} @@ -14473,6 +14491,7 @@ keyword: | START_SYM {} | STOP_SYM {} | TRUNCATE_SYM {} + | VISIBLE_SYM {} | UNICODE_SYM {} | UNINSTALL_SYM {} | WRAPPER_SYM {} diff --git a/sql/structs.h b/sql/structs.h index 18d990baf0c..c037664e9f5 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -126,6 +126,11 @@ typedef struct st_key { For temporary heap tables this member is NULL. */ ulong *rec_per_key; + /** + True if this index is visible to the query optimizer. The optimizer may + only use visible indexes. + */ + bool is_visible; union { int bdb_return_if_eq; } handler; diff --git a/sql/table.cc b/sql/table.cc index 72f6225e01a..77842b7e00b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1222,6 +1222,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } share->keys_for_keyread.init(0); share->keys_in_use.init(keys); + share->visible_indexes.init(0); strpos=disk_buff+6; @@ -1271,6 +1272,22 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, keyinfo->flags&= ~HA_FULLTEXT; } + /* + Replace HA_SORT_ALLOWS_SAME with HA_INVISIBLE_KEY. This way we can support + invisible index without changing the FRM format. + */ + if (keyinfo->flags & HA_SORT_ALLOWS_SAME) + { + keyinfo->flags|= HA_INVISIBLE_KEY; + keyinfo->flags&= ~HA_SORT_ALLOWS_SAME; + keyinfo->is_visible= FALSE; + } + else + { + share->visible_indexes.set_bit(i); + keyinfo->is_visible= TRUE; + } + keyinfo->key_length= (uint) uint2korr(strpos+2); keyinfo->user_defined_key_parts= (uint) strpos[4]; keyinfo->algorithm= (enum ha_key_alg) strpos[5]; @@ -6011,7 +6028,7 @@ bool TABLE_LIST::process_index_hints(TABLE *tbl) { /* initialize the result variables */ tbl->keys_in_use_for_query= tbl->keys_in_use_for_group_by= - tbl->keys_in_use_for_order_by= tbl->s->keys_in_use; + tbl->keys_in_use_for_order_by= tbl->s->usable_indexes(); /* index hint list processing */ if (index_hints) @@ -6057,7 +6074,8 @@ bool TABLE_LIST::process_index_hints(TABLE *tbl) */ if (tbl->s->keynames.type_names == 0 || (pos= find_type(&tbl->s->keynames, hint->key_name.str, - hint->key_name.length, 1)) <= 0) + hint->key_name.length, 1)) <= 0 || + !tbl->s->key_info[pos - 1].is_visible) { my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), hint->key_name.str, alias); return 1; diff --git a/sql/table.h b/sql/table.h index 858d2dc0e2c..8ffb2d5dd9e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -631,11 +631,15 @@ struct TABLE_SHARE LEX_STRING normalized_path; /* unpack_filename(path) */ LEX_STRING connect_string; - /* - Set of keys in use, implemented as a Bitmap. - Excludes keys disabled by ALTER TABLE ... DISABLE KEYS. + /* + The set of indexes that are not disabled for this table. I.e. it excludes + indexes disabled by `ALTER TABLE ... DISABLE KEYS`, however it does + include invisible indexes. */ key_map keys_in_use; + + /* The set of visible and enabled indexes for this table. */ + key_map visible_indexes; key_map keys_for_keyread; ha_rows min_rows, max_rows; /* create information */ ulong avg_row_length; /* create information */ @@ -909,6 +913,18 @@ struct TABLE_SHARE bool wait_for_old_version(THD *thd, struct timespec *abstime, uint deadlock_weight); + /** + The set of indexes that the opitmizer may use when creating an execution + plan. + */ + + key_map usable_indexes() const + { + key_map usable_indexes(keys_in_use); + usable_indexes.intersect(visible_indexes); + return usable_indexes; + } + /** Release resources and free memory occupied by the table share. */ void destroy(); diff --git a/sql/unireg.cc b/sql/unireg.cc index 8effc0bb2e7..5573a76b5bf 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -644,6 +644,16 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, key_flags|= HA_SPATIAL; key_flags|= HA_FULLTEXT; } + + /* + Replace HA_INVISIBLE_KEY with HA_SORT_ALLOWS_SAME which is not used in FRM. + This way allow us to store invisible index without changing the FRM format. + */ + if (key->flags & HA_INVISIBLE_KEY) + { + key_flags|= HA_SORT_ALLOWS_SAME; + } + int2store(pos, (key_flags ^ HA_NOSAME)); int2store(pos+2,key->key_length); pos[4]= (uchar) key->user_defined_key_parts; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8d68bd10dc9..fb52674a449 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -82,7 +82,8 @@ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_INPLACE_IGNORE = Alter_inplace_info::ALTER_COLUMN_DEFAULT | Alter_inplace_info::ALTER_COLUMN_COLUMN_FORMAT | Alter_inplace_info::ALTER_COLUMN_STORAGE_TYPE - | Alter_inplace_info::ALTER_RENAME; + | Alter_inplace_info::ALTER_RENAME + | Alter_inplace_info::ALTER_INDEX_VISIBILITY; /** Operations on foreign key definitions (changing the schema only) */ static const Alter_inplace_info::HA_ALTER_FLAGS INNOBASE_FOREIGN_OPERATIONS diff --git a/storage/tokudb/ha_tokudb_alter_56.cc b/storage/tokudb/ha_tokudb_alter_56.cc index 286bedc9db7..b88b27544b0 100644 --- a/storage/tokudb/ha_tokudb_alter_56.cc +++ b/storage/tokudb/ha_tokudb_alter_56.cc @@ -448,6 +448,9 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *alt result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE; } #endif + else if (only_flags(ctx->handler_flags, Alter_inplace_info::ALTER_INDEX_VISIBILITY)) { + result = HA_ALTER_INPLACE_NO_LOCK; + } if (result != HA_ALTER_INPLACE_NOT_SUPPORTED && table->s->null_bytes != altered_table->s->null_bytes && (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE)) {