From 7428f03dac9cd1612da3c03d4297759f66ceed76 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 27 Jun 2019 15:47:40 +0800 Subject: [PATCH 1/2] session,parser: make MAX_EXECUTION_TIME sql hint and global variable work update go.mod to use the latest parser which fix the sql hint for MAX_EXECUTION_TIME put max_execution_time into the auto load system variable list so it's correctly initialized Fix issue https://github.com/pingcap/tidb/issues/10955 --- go.mod | 2 +- go.sum | 2 ++ session/session.go | 1 + session/session_test.go | 6 ++++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7d50459ecc134..493d4df6179e7 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/pingcap/goleveldb v0.0.0-20171020122428-b9ff6c35079e github.com/pingcap/kvproto v0.0.0-20190619024611-a4759dfe3753 github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596 - github.com/pingcap/parser v0.0.0-20190613082312-d2cf6071823d + github.com/pingcap/parser v0.0.0-20190627064259-e9c42442aa72 github.com/pingcap/pd v0.0.0-20190617100349-293d4b5189bf github.com/pingcap/tidb-tools v2.1.3-0.20190321065848-1e8b48f5c168+incompatible github.com/pingcap/tipb v0.0.0-20190428032612-535e1abaa330 diff --git a/go.sum b/go.sum index b810ff993a08b..b12edbfb6cb24 100644 --- a/go.sum +++ b/go.sum @@ -168,6 +168,8 @@ github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596 h1:t2OQTpPJnrPDGlvA+3F github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596/go.mod h1:WpHUKhNZ18v116SvGrmjkA9CBhYmuUTKL+p8JC9ANEw= github.com/pingcap/parser v0.0.0-20190613082312-d2cf6071823d h1:JzkfOBJLcmtPJs+U5i0FUdN84wf4m0eNVB1c7EQcA9I= github.com/pingcap/parser v0.0.0-20190613082312-d2cf6071823d/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= +github.com/pingcap/parser v0.0.0-20190627064259-e9c42442aa72 h1:yPYZB/rPuTost36QcoOLzvkDxVjqfJ9w0xTpohwlSlA= +github.com/pingcap/parser v0.0.0-20190627064259-e9c42442aa72/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= github.com/pingcap/pd v0.0.0-20190617100349-293d4b5189bf h1:vmlN6DpZI5LtHd8r9YRAsyCeTU2pxRq+WlWn5CZ+ax4= github.com/pingcap/pd v0.0.0-20190617100349-293d4b5189bf/go.mod h1:3DlDlFT7EF64A1bmb/tulZb6wbPSagm5G4p1AlhaEDs= github.com/pingcap/tidb-tools v2.1.3-0.20190321065848-1e8b48f5c168+incompatible h1:MkWCxgZpJBgY2f4HtwWMMFzSBb3+JPzeJgF3VrXE/bU= diff --git a/session/session.go b/session/session.go index 50f849fc85e3e..baa70b764a294 100644 --- a/session/session.go +++ b/session/session.go @@ -1705,6 +1705,7 @@ var builtinGlobalVariable = []string{ variable.AutoIncrementIncrement, variable.CollationServer, variable.NetWriteTimeout, + variable.MaxExecutionTime, /* TiDB specific global variables: */ variable.TiDBSkipUTF8Check, diff --git a/session/session_test.go b/session/session_test.go index b2f05bee9158b..bc1950fed99a5 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -451,6 +451,12 @@ func (s *testSessionSuite) TestGlobalVarAccessor(c *C) { c.Assert(err, IsNil) c.Assert(v, Equals, varValue2) + // For issue 10955, make sure the new session load `max_execution_time` into sessionVars. + s.dom.GetGlobalVarsCache().Disable() + tk1.MustExec("set @@global.max_execution_time = 100") + tk2 := testkit.NewTestKitWithInit(c, s.store) + c.Assert(tk2.Se.GetSessionVars().MaxExecutionTime, Equals, uint64(100)) + result := tk.MustQuery("show global variables where variable_name='sql_select_limit';") result.Check(testkit.Rows("sql_select_limit 18446744073709551615")) result = tk.MustQuery("show session variables where variable_name='sql_select_limit';") From 83cba40ef29a2c6b178cea85f2c6bd04eb712155 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Fri, 28 Jun 2019 14:47:01 +0800 Subject: [PATCH 2/2] go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index b12edbfb6cb24..0d36801dfe059 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,6 @@ github.com/pingcap/kvproto v0.0.0-20190619024611-a4759dfe3753/go.mod h1:QMdbTAXC github.com/pingcap/log v0.0.0-20190214045112-b37da76f67a7/go.mod h1:xsfkWVaFVV5B8e1K9seWfyJWFrIhbtUTAD8NV1Pq3+w= github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596 h1:t2OQTpPJnrPDGlvA+3FwJptMTt6MEPdzK1Wt99oaefQ= github.com/pingcap/log v0.0.0-20190307075452-bd41d9273596/go.mod h1:WpHUKhNZ18v116SvGrmjkA9CBhYmuUTKL+p8JC9ANEw= -github.com/pingcap/parser v0.0.0-20190613082312-d2cf6071823d h1:JzkfOBJLcmtPJs+U5i0FUdN84wf4m0eNVB1c7EQcA9I= -github.com/pingcap/parser v0.0.0-20190613082312-d2cf6071823d/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= github.com/pingcap/parser v0.0.0-20190627064259-e9c42442aa72 h1:yPYZB/rPuTost36QcoOLzvkDxVjqfJ9w0xTpohwlSlA= github.com/pingcap/parser v0.0.0-20190627064259-e9c42442aa72/go.mod h1:1FNvfp9+J0wvc4kl8eGNh7Rqrxveg15jJoWo/a0uHwA= github.com/pingcap/pd v0.0.0-20190617100349-293d4b5189bf h1:vmlN6DpZI5LtHd8r9YRAsyCeTU2pxRq+WlWn5CZ+ax4=