Loading libmysql/libmysql.c +7 −6 Original line number Diff line number Diff line Loading @@ -3168,22 +3168,23 @@ void my_net_local_init(NET *net) null byte. When mysql_hex_string() returns, the contents of "to" will be a null-terminated string. The return value is the length of the encoded string, not including the terminating null character. The return value does not contain any leading 0x or a leading X' and trailing '. The caller must supply whichever of those is desired. */ unsigned long mysql_hex_string(char *to, const char *from, unsigned long length) ulong mysql_hex_string(char *to, const char *from, ulong length) { char *to0= to; const char *end; static char hex[]= "0123456789ABCDEF"; for (end= from + length; from < end; from++) { *to++= hex[((unsigned char) *from) >> 4]; *to++= hex[((unsigned char) *from) & 0x0F]; *to++= _dig_vec[((unsigned char) *from) >> 4]; *to++= _dig_vec[((unsigned char) *from) & 0x0F]; } *to= '\0'; return to-to0; return (ulong) (to-to0); } /* Loading myisam/myisampack.c +5 −7 Original line number Diff line number Diff line Loading @@ -418,14 +418,12 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) { if ((mrg->file[i]=open_isam_file(names[i],O_RDONLY))) { mrg->src_file_has_indexes_disabled |= (mrg->file[i]->s->state.key_map != (1ULL << mrg->file[i]->s->base.keys) - 1); } else if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY))) goto error; mrg->src_file_has_indexes_disabled|= ((mrg->file[i]->s->state.key_map != (((ulonglong) 1) << mrg->file[i]->s->base. keys) - 1)); } /* Check that files are identical */ for (j=0 ; j < count-1 ; j++) Loading mysql-test/r/innodb-lock.result +34 −0 Original line number Diff line number Diff line select @@innodb_table_locks; @@innodb_table_locks 1 drop table if exists t1; set @@innodb_table_locks=1; create table t1 (id integer, x integer) engine=INNODB; insert into t1 values(0, 0); set autocommit=0; Loading @@ -20,3 +24,33 @@ id x 0 2 commit; drop table t1; set @@innodb_table_locks=0; create table t1 (id integer primary key, x integer) engine=INNODB; insert into t1 values(0, 0),(1,1),(2,2); commit; SELECT * from t1 where id = 0 FOR UPDATE; id x 0 0 set autocommit=0; set @@innodb_table_locks=0; lock table t1 write; update t1 set x=10 where id = 2; SELECT * from t1 where id = 2; id x 2 2 UPDATE t1 set x=3 where id = 2; commit; SELECT * from t1; id x 0 0 1 1 2 3 commit; unlock tables; commit; select * from t1; id x 0 0 1 1 2 10 drop table t1; mysql-test/t/innodb-lock-master.opt 0 → 100644 +1 −0 Original line number Diff line number Diff line --innodb-table-lock=1 mysql-test/t/innodb-lock.test +56 −1 Original line number Diff line number Diff line -- source include/have_innodb.inc # # Check and select innodb lock type # select @@innodb_table_locks; # # Testing of explicit table locks with enforced table locks # connect (con1,localhost,root,,); connect (con2,localhost,root,,); drop table if exists t1; # # Testing of explicit table locks # Testing of explicit table locks with enforced table locks # set @@innodb_table_locks=1; connection con1; create table t1 (id integer, x integer) engine=INNODB; insert into t1 values(0, 0); Loading Loading @@ -38,3 +50,46 @@ select * from t1; commit; drop table t1; # # Try with old lock method (where LOCK TABLE is ignored by InnoDB) # set @@innodb_table_locks=0; create table t1 (id integer primary key, x integer) engine=INNODB; insert into t1 values(0, 0),(1,1),(2,2); commit; SELECT * from t1 where id = 0 FOR UPDATE; connection con2; set autocommit=0; set @@innodb_table_locks=0; # The following statement should work becase innodb doesn't check table locks lock table t1 write; connection con1; # This will be locked by MySQL --send update t1 set x=10 where id = 2; --sleep 2 connection con2; # Note that we will get a deadlock if we try to select any rows marked # for update by con1 ! SELECT * from t1 where id = 2; UPDATE t1 set x=3 where id = 2; commit; SELECT * from t1; commit; unlock tables; connection con1; reap; commit; select * from t1; drop table t1; Loading
libmysql/libmysql.c +7 −6 Original line number Diff line number Diff line Loading @@ -3168,22 +3168,23 @@ void my_net_local_init(NET *net) null byte. When mysql_hex_string() returns, the contents of "to" will be a null-terminated string. The return value is the length of the encoded string, not including the terminating null character. The return value does not contain any leading 0x or a leading X' and trailing '. The caller must supply whichever of those is desired. */ unsigned long mysql_hex_string(char *to, const char *from, unsigned long length) ulong mysql_hex_string(char *to, const char *from, ulong length) { char *to0= to; const char *end; static char hex[]= "0123456789ABCDEF"; for (end= from + length; from < end; from++) { *to++= hex[((unsigned char) *from) >> 4]; *to++= hex[((unsigned char) *from) & 0x0F]; *to++= _dig_vec[((unsigned char) *from) >> 4]; *to++= _dig_vec[((unsigned char) *from) & 0x0F]; } *to= '\0'; return to-to0; return (ulong) (to-to0); } /* Loading
myisam/myisampack.c +5 −7 Original line number Diff line number Diff line Loading @@ -418,14 +418,12 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) { if ((mrg->file[i]=open_isam_file(names[i],O_RDONLY))) { mrg->src_file_has_indexes_disabled |= (mrg->file[i]->s->state.key_map != (1ULL << mrg->file[i]->s->base.keys) - 1); } else if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY))) goto error; mrg->src_file_has_indexes_disabled|= ((mrg->file[i]->s->state.key_map != (((ulonglong) 1) << mrg->file[i]->s->base. keys) - 1)); } /* Check that files are identical */ for (j=0 ; j < count-1 ; j++) Loading
mysql-test/r/innodb-lock.result +34 −0 Original line number Diff line number Diff line select @@innodb_table_locks; @@innodb_table_locks 1 drop table if exists t1; set @@innodb_table_locks=1; create table t1 (id integer, x integer) engine=INNODB; insert into t1 values(0, 0); set autocommit=0; Loading @@ -20,3 +24,33 @@ id x 0 2 commit; drop table t1; set @@innodb_table_locks=0; create table t1 (id integer primary key, x integer) engine=INNODB; insert into t1 values(0, 0),(1,1),(2,2); commit; SELECT * from t1 where id = 0 FOR UPDATE; id x 0 0 set autocommit=0; set @@innodb_table_locks=0; lock table t1 write; update t1 set x=10 where id = 2; SELECT * from t1 where id = 2; id x 2 2 UPDATE t1 set x=3 where id = 2; commit; SELECT * from t1; id x 0 0 1 1 2 3 commit; unlock tables; commit; select * from t1; id x 0 0 1 1 2 10 drop table t1;
mysql-test/t/innodb-lock-master.opt 0 → 100644 +1 −0 Original line number Diff line number Diff line --innodb-table-lock=1
mysql-test/t/innodb-lock.test +56 −1 Original line number Diff line number Diff line -- source include/have_innodb.inc # # Check and select innodb lock type # select @@innodb_table_locks; # # Testing of explicit table locks with enforced table locks # connect (con1,localhost,root,,); connect (con2,localhost,root,,); drop table if exists t1; # # Testing of explicit table locks # Testing of explicit table locks with enforced table locks # set @@innodb_table_locks=1; connection con1; create table t1 (id integer, x integer) engine=INNODB; insert into t1 values(0, 0); Loading Loading @@ -38,3 +50,46 @@ select * from t1; commit; drop table t1; # # Try with old lock method (where LOCK TABLE is ignored by InnoDB) # set @@innodb_table_locks=0; create table t1 (id integer primary key, x integer) engine=INNODB; insert into t1 values(0, 0),(1,1),(2,2); commit; SELECT * from t1 where id = 0 FOR UPDATE; connection con2; set autocommit=0; set @@innodb_table_locks=0; # The following statement should work becase innodb doesn't check table locks lock table t1 write; connection con1; # This will be locked by MySQL --send update t1 set x=10 where id = 2; --sleep 2 connection con2; # Note that we will get a deadlock if we try to select any rows marked # for update by con1 ! SELECT * from t1 where id = 2; UPDATE t1 set x=3 where id = 2; commit; SELECT * from t1; commit; unlock tables; connection con1; reap; commit; select * from t1; drop table t1;