Skip to content

Commit

Permalink
session: do not add history for pessimistic transaction (#10824)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Jun 17, 2019
1 parent 23d8d2b commit 089358d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions session/pessimistic_test.go
Expand Up @@ -84,6 +84,7 @@ func (s *testPessimisticSuite) TestPessimisticTxn(c *C) {
// Update can see the change, so this statement affects 0 roews.
tk1.MustExec("update pessimistic set v = 3 where v = 1")
c.Assert(tk1.Se.AffectedRows(), Equals, uint64(0))
c.Assert(session.GetHistory(tk1.Se).Count(), Equals, 0)
// select for update can see the change of another transaction.
tk1.MustQuery("select * from pessimistic for update").Check(testkit.Rows("1 2"))
// plain select can not see the change of another transaction.
Expand Down
2 changes: 1 addition & 1 deletion session/tidb.go
Expand Up @@ -223,7 +223,7 @@ func runStmt(ctx context.Context, sctx sessionctx.Context, s sqlexec.Statement)
// All the history should be added here.
sessVars.TxnCtx.StatementCount++
if !s.IsReadOnly(sessVars) {
if err == nil {
if err == nil && !sessVars.TxnCtx.IsPessimistic {
GetHistory(sctx).Add(0, s, se.sessionVars.StmtCtx)
}
if txn, err1 := sctx.Txn(false); err1 == nil {
Expand Down

0 comments on commit 089358d

Please sign in to comment.