Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <disxiaofei@163.com>
  • Loading branch information
Yisaer committed Jul 15, 2021
1 parent c1097eb commit 6a1e65d
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions executor/stale_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,53 +946,6 @@ func (s *testStaleTxnSuite) TestStaleReadTemporaryTable(c *C) {
for _, query := range queries {
tk.MustExec(query.sql)
}

// test prepared stale select with schema change
tk.MustExec("alter table t add column c int")
tk.MustExec("insert into t values (4, 5)")
time.Sleep(10 * time.Millisecond)
tk.MustQuery("execute s").Check(staleRows)

// test dynamic timestamp stale select
time3 := time.Now()
tk.MustExec("alter table t add column d int")
tk.MustExec("insert into t values (4, 4, 4)")
time.Sleep(tolerance)
time4 := time.Now()
staleRows = testkit.Rows("1 <nil>", "2 <nil>", "3 <nil>", "4 5")
tk.MustQuery(fmt.Sprintf("select * from t as of timestamp CURRENT_TIMESTAMP(3) - INTERVAL %d MICROSECOND", time4.Sub(time3).Microseconds())).Check(staleRows)

// test prepared dynamic timestamp stale select
time5 := time.Now()
tk.MustExec(fmt.Sprintf(`prepare v from "select * from t as of timestamp CURRENT_TIMESTAMP(3) - INTERVAL %d MICROSECOND"`, time5.Sub(time3).Microseconds()))
tk.MustQuery("execute v").Check(staleRows)

// test point get
time6 := time.Now()
tk.MustExec("insert into t values (5, 5, 5)")
time.Sleep(tolerance)
tk.MustQuery(fmt.Sprintf("select * from t as of timestamp '%s' where c=5", time6.Format("2006-1-2 15:04:05.000"))).Check(testkit.Rows("4 5 <nil>"))
}

func (s *testStaleTxnSuite) TestStaleReadFutureTime(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
defer tk.MustExec("drop table if exists t")
tk.MustExec("create table t (id int)")
// Setting tx_read_ts to a time in the future will fail. (One day before the 2038 problem)
_, err := tk.Exec("start transaction read only as of timestamp '2038-01-18 03:14:07'")
c.Assert(err, ErrorMatches, "cannot set read timestamp to a future time")
// Transaction should not be started and read ts should not be set if check fails
c.Assert(tk.Se.GetSessionVars().InTxn(), IsFalse)
c.Assert(tk.Se.GetSessionVars().TxnReadTS.PeakTxnReadTS(), Equals, uint64(0))

_, err = tk.Exec("set transaction read only as of timestamp '2038-01-18 03:14:07'")
c.Assert(err, ErrorMatches, "cannot set read timestamp to a future time")
c.Assert(tk.Se.GetSessionVars().TxnReadTS.PeakTxnReadTS(), Equals, uint64(0))

_, err = tk.Exec("select * from t as of timestamp '2038-01-18 03:14:07'")
c.Assert(err, ErrorMatches, "cannot set read timestamp to a future time")
}

func (s *testStaleTxnSerialSuite) TestStaleReadPrepare(c *C) {
Expand Down

0 comments on commit 6a1e65d

Please sign in to comment.