Please answer these questions before submitting your issue. Thanks!
/* init */ drop table if exists t;
/* init */ drop view if exists v;
/* init */ create table t(a int primary key, b int);
/* init */ create view v as select a, b from t;
/* init */ insert into t values(1,2),(2,3);
/* t1 */ begin;
/* t2 */ begin;
/* t1 */ update t set b = 12 where a = 1;
/* t2 */ select * from v where a < 2 for update; -- range-scan on view, not blocked
# /* t2 */ select * from v where a = 1 for update; -- point-get on view, blocked
# /* t2 */ select * from t where a < 2 for update; -- range-scan on table, blocked
# /* t2 */ select * from t where a = 1 for update; -- point-get on table, blocked
/* t1 */ commit;
/* t2 */ commit;
select * from v where a < 2 for update; should be blocked by t1.
It's not blocked.
release-4.0 (1e73c51515e123e3066fa5abeb14430551d00758)
Because views are non-writeable in TiDB, the expected behavior should be an error when trying FOR UPDATE or LOCK IN SHARE MODE.
PTAL @cfzjywxk @lysu
Most helpful comment
Because views are non-writeable in TiDB, the expected behavior should be an error when trying
FOR UPDATEorLOCK IN SHARE MODE.