I need to lock a full table in shared mode. If I execute something like "select 1 from (select * from mytable lock in share mode) t where 1=2", will the query optimizer remove the nested subquery and basically make the query no-op? In my simple experiment, it doesn't (this is what I need). I'm wondering if it's expected by design bahavour and not just an accident. Any other alternatives to lock a full table? Note: I cannot use "LOCK TABLE READ" beause it seems it cannot be promoted into WRITE lock without releasing it first.
MySQL version: 5.1.50 and 5.5.27.