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: support system variable interactive_timeout (#8487) #8573

Merged
merged 12 commits into from
Dec 14, 2018
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