Enhancement
According to the description in Stale Read Product Design, SELECT ... AS OF TIMESTAMP
- Only used in the implicit transaction with autocommit = 1.
However, we can still successfully execute the SELECT ... AS OF TIMESTAMP statement even with autocommit = 0.
drop table if exists t;
create table t (id int primary key, v int);
insert into t values (1, 10);
select sleep(0.1);
set @ts1 = now(6);
select sleep(0.1);
update t set v = 20 where id = 1;
set @ts2 = now(6);
select sleep(0.1);
update t set v = 30 where id = 1;
select sleep(1);
set @@tidb_read_staleness = -1;
set @@autocommit = 0;
-- should report error but sometimes it doesn't
select * from t as of timestamp @ts1 where id = 1;
select * from t as of timestamp @ts2 where id = 1;