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,parser: make MAX_EXECUTION_TIME sql hint and global variable work #10963

Merged
merged 3 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to change parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To include this fix pingcap/parser#366
The SQL hint is not successful parsed in select /*+ MAX_EXECUTION_TIME(1000) */ SLEEP(5);
@crazycs520

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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ 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=
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=
Expand Down
1 change: 1 addition & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ var builtinGlobalVariable = []string{
variable.AutoIncrementIncrement,
variable.CollationServer,
variable.NetWriteTimeout,
variable.MaxExecutionTime,

/* TiDB specific global variables: */
variable.TiDBSkipUTF8Check,
Expand Down
7 changes: 7 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ 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))
tk1.MustExec("set @@global.max_execution_time = 0")

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';")
Expand Down