Skip to content

Commit

Permalink
*: close transaction for all auto-committed SQLs
Browse files Browse the repository at this point in the history
Signed-off-by: Shuaipeng Yu <jackysp@gmail.com>
  • Loading branch information
jackysp committed Nov 30, 2020
1 parent 93313cc commit c93f3bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions executor/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func (s *testSuite3) TestDo(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("do 1, @a:=1")
tk.MustQuery("select @a").Check(testkit.Rows("1"))

tk.MustExec("use test")
tk.MustExec("create table t (i int)")
tk.MustExec("insert into t values (1)")
tk2 := testkit.NewTestKit(c, s.store)
tk2.MustExec("use test")
tk.MustQuery("select * from t").Check(testkit.Rows("1"))
tk.MustExec("do @a := (select * from t where i = 1)")
tk2.MustExec("insert into t values (2)")
tk.MustQuery("select * from t").Check(testkit.Rows("1", "2"))
}

func (s *testSuite3) TestSetRoleAllCorner(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion session/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ func runStmt(ctx context.Context, sctx sessionctx.Context, s sqlexec.Statement)
} else {
logutil.BgLogger().Error("get txn failed", zap.Error(err1))
}
err = finishStmt(ctx, se, err, s)
}

if rs != nil {
Expand All @@ -336,6 +335,7 @@ func runStmt(ctx context.Context, sctx sessionctx.Context, s sqlexec.Statement)
}, err
}

err = finishStmt(ctx, se, err, s)
if se.hasQuerySpecial() {
// The special query will be handled later in handleQuerySpecial,
// then should call the ExecStmt.FinishExecuteStmt to finish this statement.
Expand Down

0 comments on commit c93f3bc

Please sign in to comment.