Skip to content

Commit

Permalink
session: support system variable interactive_timeout (#8487) (#8573)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhu-cc authored and lysu committed Dec 14, 2018
1 parent 39c0306 commit 808eab1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const defaultCapability = mysql.ClientLongPassword | mysql.ClientLongFlag |
mysql.ClientConnectWithDB | mysql.ClientProtocol41 |
mysql.ClientTransactions | mysql.ClientSecureConnection | mysql.ClientFoundRows |
mysql.ClientMultiStatements | mysql.ClientMultiResults | mysql.ClientLocalFiles |
mysql.ClientConnectAtts | mysql.ClientPluginAuth
mysql.ClientConnectAtts | mysql.ClientPluginAuth | mysql.ClientInteractive

// Server is the MySQL protocol server
type Server struct {
Expand Down
9 changes: 9 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ const loadCommonGlobalVarsSQL = "select HIGH_PRIORITY * from mysql.global_variab
variable.TimeZone + quoteCommaQuote +
variable.BlockEncryptionMode + quoteCommaQuote +
variable.WaitTimeout + quoteCommaQuote +
variable.InteractiveTimeout + quoteCommaQuote +
variable.MaxPreparedStmtCount + quoteCommaQuote +
/* TiDB specific global variables: */
variable.TiDBSkipUTF8Check + quoteCommaQuote +
Expand Down Expand Up @@ -1451,6 +1452,14 @@ func (s *session) loadCommonGlobalVariablesIfNeeded() error {
}
}
}

// when client set Capability Flags CLIENT_INTERACTIVE, init wait_timeout with interactive_timeout
if vars.ClientCapability&mysql.ClientInteractive > 0 {
if varVal, ok := vars.GetSystemVar(variable.InteractiveTimeout); ok {
vars.SetSystemVar(variable.WaitTimeout, varVal)
}
}

vars.CommonGlobalLoaded = true
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal | ScopeSession, BlockEncryptionMode, "aes-128-ecb"},
{ScopeGlobal | ScopeSession, "max_length_for_sort_data", "1024"},
{ScopeNone, "character_set_system", "utf8"},
{ScopeGlobal | ScopeSession, "interactive_timeout", "28800"},
{ScopeGlobal | ScopeSession, InteractiveTimeout, "28800"},
{ScopeGlobal, "innodb_optimize_fulltext_only", "OFF"},
{ScopeNone, "character_sets_dir", "/usr/local/mysql-5.6.25-osx10.8-x86_64/share/charsets/"},
{ScopeGlobal | ScopeSession, "query_cache_type", "OFF"},
Expand Down

0 comments on commit 808eab1

Please sign in to comment.