Skip to content

Commit

Permalink
session: fix dml_batch_size doesn't load the global variable (#24710)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 authored May 18, 2021
1 parent b515e14 commit 44830b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,7 @@ var builtinGlobalVariable = []string{
variable.TiDBAllowFallbackToTiKV,
variable.TiDBEnableDynamicPrivileges,
variable.CTEMaxRecursionDepth,
variable.TiDBDMLBatchSize,
}

// loadCommonGlobalVariablesIfNeeded loads and applies commonly used global variables for the session.
Expand Down
10 changes: 10 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4476,3 +4476,13 @@ func (s *testTxnStateSuite) TestRollbacking(c *C) {
c.Assert(tk.Se.TxnInfo().State, Equals, txninfo.TxnRollingBack)
<-ch
}

func (s *testSessionSuite) TestReadDMLBatchSize(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("set global tidb_dml_batch_size=1000")
se, err := session.CreateSession(s.store)
c.Assert(err, IsNil)
// `select 1` to load the global variables.
_, _ = se.Execute(context.TODO(), "select 1")
c.Assert(se.GetSessionVars().DMLBatchSize, Equals, 1000)
}

0 comments on commit 44830b9

Please sign in to comment.