Skip to content

Commit

Permalink
executor: add testcase to cover stale read and prepare stmt (#33270)
Browse files Browse the repository at this point in the history
ref #31550
  • Loading branch information
Yisaer authored Mar 21, 2022
1 parent 49f291d commit 0d160fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions executor/stale_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,16 @@ func TestStaleReadPrepare(t *testing.T) {
tk.MustExec(fmt.Sprintf(`set transaction read only as of timestamp '%s'`, time1.Format("2006-1-2 15:04:05.000")))
_, err = tk.Exec("execute p1")
require.Error(t, err)
tk.MustExec("execute p2")

tk.MustExec("create table t1 (id int, v int)")
tk.MustExec("insert into t1 values (1,10)")
tk.MustExec("set @a=now(6)")
time.Sleep(5 * time.Millisecond)
tk.MustExec("update t1 set v=100 where id=1")
tk.MustQuery("select * from t1").Check(testkit.Rows("1 100"))
tk.MustExec("prepare s1 from 'select * from t1 as of timestamp @a where id=1'")
tk.MustQuery("execute s1").Check(testkit.Rows("1 10"))
}

func TestStmtCtxStaleFlag(t *testing.T) {
Expand Down

0 comments on commit 0d160fb

Please sign in to comment.