关于msql中myisam和innodb锁的疑问

myisam引擎执行的sql:

lock table test_myisam read;

select * from test_myisam where id = 1;

update test_myisam set name ='11' where id =1;

执行update 报错

innodb引擎执行的sql:

set autocommit = false;

select * from student where id = 1 lock in share mode;

select * from student where id = 1 for update;

update student set name ='11' where id =1 ;

上面所有语句都可以正常执行

我的疑问是,同一个session中myisam加上共享锁后执行update,因为有共享锁了所以无法加排它锁报错,那为什么在innodb中我加了共享锁,再加排它锁却不报错呢

首先,锁是根据索引树来的,如果ID是主键,加了共享锁后,排它锁肯定是阻塞不能更改的!确认下版本以及student表的引擎