Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session: fix dml_batch_size doesn't load the global variable #24710

Merged
merged 9 commits into from
May 18, 2021
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)
}