Loading myisam/mi_open.c +19 −2 Original line number Diff line number Diff line Loading @@ -1264,13 +1264,30 @@ int mi_enable_indexes(MI_INFO *info) RETURN 0 indexes are not disabled 1 all indexes are disabled [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] 2 non-unique indexes are disabled */ int mi_indexes_are_disabled(MI_INFO *info) { MYISAM_SHARE *share= info->s; return (! mi_is_any_key_active(share->state.key_map) && share->base.keys); /* No keys or all are enabled. keys is the number of keys. Left shifted gives us only one bit set. When decreased by one, gives us all all bits up to this one set and it gets unset. */ if (!share->base.keys || (mi_is_all_keys_active(share->state.key_map, share->base.keys))) return 0; /* All are disabled */ if (mi_is_any_key_active(share->state.key_map)) return 1; /* We have keys. Some enabled, some disabled. Don't check for any non-unique disabled but return directly 2 */ return 2; } myisam/myisampack.c +2 −0 Original line number Diff line number Diff line Loading @@ -2923,6 +2923,8 @@ static void flush_bits(void) bits-= 8; *file_buffer.pos++= (uchar) (bit_buffer >> bits); } if (file_buffer.pos >= file_buffer.end) VOID(flush_buffer(~ (ulong) 0)); file_buffer.bits= BITS_SAVED; file_buffer.bitbucket= 0; } Loading mysql-test/r/alter_table.result +121 −0 Original line number Diff line number Diff line Loading @@ -541,6 +541,127 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys 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 t1 1 a 1 a A NULL NULL NULL YES BTREE "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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE "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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled desc t1; Field Type Null Key Default Extra a bigint(20) YES MUL NULL b char(10) YES NULL 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE "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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled drop table t1; create database mysqltest; create table t1 (c1 int); alter table t1 rename mysqltest.t1; Loading mysql-test/r/information_schema.result +1 −1 Original line number Diff line number Diff line Loading @@ -1027,7 +1027,7 @@ CREATE PROCEDURE p1 () BEGIN SELECT 'foo' FROM DUAL; END | ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Unknown database 'information_schema' select ROUTINE_NAME from routines; ROUTINE_NAME grant all on information_schema.* to 'user1'@'localhost'; Loading mysql-test/r/rpl_sp.result +9 −12 Original line number Diff line number Diff line Loading @@ -467,6 +467,7 @@ DROP FUNCTION f1; drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; reset master; drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; Loading @@ -475,19 +476,15 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8186; show binlog events in 'master-bin.000001' from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 8186 Query 1 8317 use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 master-bin.000001 8317 Query 1 8397 use `test`; DROP PROCEDURE p1 master-bin.000001 8397 Query 1 8476 use `test`; DROP FUNCTION f1 master-bin.000001 8476 Query 1 8552 use `test`; drop table t1 master-bin.000001 8552 Query 1 8653 drop database if exists mysqltest master-bin.000001 8653 Query 1 8756 drop database if exists mysqltest2 master-bin.000001 8756 Query 1 8849 create database mysqltest master-bin.000001 8849 Query 1 8944 create database mysqltest2 master-bin.000001 8944 Query 1 9041 use `mysqltest2`; create table t ( t integer ) master-bin.000001 9041 Query 1 9180 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 9180 Query 1 9275 use `mysqltest2`; insert into t values ( 1 ) master-bin.000001 98 Query 1 199 drop database if exists mysqltest master-bin.000001 199 Query 1 302 drop database if exists mysqltest2 master-bin.000001 302 Query 1 395 create database mysqltest master-bin.000001 395 Query 1 490 create database mysqltest2 master-bin.000001 490 Query 1 587 use `mysqltest2`; create table t ( t integer ) master-bin.000001 587 Query 1 726 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 726 Query 1 821 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Incorrect database name '\\' drop database mysqltest; Loading Loading
myisam/mi_open.c +19 −2 Original line number Diff line number Diff line Loading @@ -1264,13 +1264,30 @@ int mi_enable_indexes(MI_INFO *info) RETURN 0 indexes are not disabled 1 all indexes are disabled [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] 2 non-unique indexes are disabled */ int mi_indexes_are_disabled(MI_INFO *info) { MYISAM_SHARE *share= info->s; return (! mi_is_any_key_active(share->state.key_map) && share->base.keys); /* No keys or all are enabled. keys is the number of keys. Left shifted gives us only one bit set. When decreased by one, gives us all all bits up to this one set and it gets unset. */ if (!share->base.keys || (mi_is_all_keys_active(share->state.key_map, share->base.keys))) return 0; /* All are disabled */ if (mi_is_any_key_active(share->state.key_map)) return 1; /* We have keys. Some enabled, some disabled. Don't check for any non-unique disabled but return directly 2 */ return 2; }
myisam/myisampack.c +2 −0 Original line number Diff line number Diff line Loading @@ -2923,6 +2923,8 @@ static void flush_bits(void) bits-= 8; *file_buffer.pos++= (uchar) (bit_buffer >> bits); } if (file_buffer.pos >= file_buffer.end) VOID(flush_buffer(~ (ulong) 0)); file_buffer.bits= BITS_SAVED; file_buffer.bitbucket= 0; } Loading
mysql-test/r/alter_table.result +121 −0 Original line number Diff line number Diff line Loading @@ -541,6 +541,127 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys 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 t1 1 a 1 a A NULL NULL NULL YES BTREE "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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 1 a 1 a A NULL NULL NULL YES BTREE "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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled desc t1; Field Type Null Key Default Extra a bigint(20) YES MUL NULL b char(10) YES NULL 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 t1 1 a 1 a A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE "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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled 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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled "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 t1 0 a 1 a A NULL NULL NULL YES BTREE t1 1 b 1 b A NULL NULL NULL YES BTREE disabled drop table t1; create database mysqltest; create table t1 (c1 int); alter table t1 rename mysqltest.t1; Loading
mysql-test/r/information_schema.result +1 −1 Original line number Diff line number Diff line Loading @@ -1027,7 +1027,7 @@ CREATE PROCEDURE p1 () BEGIN SELECT 'foo' FROM DUAL; END | ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' ERROR 42000: Unknown database 'information_schema' select ROUTINE_NAME from routines; ROUTINE_NAME grant all on information_schema.* to 'user1'@'localhost'; Loading
mysql-test/r/rpl_sp.result +9 −12 Original line number Diff line number Diff line Loading @@ -467,6 +467,7 @@ DROP FUNCTION f1; drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; reset master; drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; Loading @@ -475,19 +476,15 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); show binlog events in 'master-bin.000001' from 8186; show binlog events in 'master-bin.000001' from 98; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 8186 Query 1 8317 use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 master-bin.000001 8317 Query 1 8397 use `test`; DROP PROCEDURE p1 master-bin.000001 8397 Query 1 8476 use `test`; DROP FUNCTION f1 master-bin.000001 8476 Query 1 8552 use `test`; drop table t1 master-bin.000001 8552 Query 1 8653 drop database if exists mysqltest master-bin.000001 8653 Query 1 8756 drop database if exists mysqltest2 master-bin.000001 8756 Query 1 8849 create database mysqltest master-bin.000001 8849 Query 1 8944 create database mysqltest2 master-bin.000001 8944 Query 1 9041 use `mysqltest2`; create table t ( t integer ) master-bin.000001 9041 Query 1 9180 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 9180 Query 1 9275 use `mysqltest2`; insert into t values ( 1 ) master-bin.000001 98 Query 1 199 drop database if exists mysqltest master-bin.000001 199 Query 1 302 drop database if exists mysqltest2 master-bin.000001 302 Query 1 395 create database mysqltest master-bin.000001 395 Query 1 490 create database mysqltest2 master-bin.000001 490 Query 1 587 use `mysqltest2`; create table t ( t integer ) master-bin.000001 587 Query 1 726 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end master-bin.000001 726 Query 1 821 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Incorrect database name '\\' drop database mysqltest; Loading