Skip to content

Commit 68e70bf

Browse files
Ryan Lvzz-jason
Ryan Lv
authored andcommitted
executor,sessionctx: add correctness for system variables (#12… (#12588)
1 parent b103dff commit 68e70bf

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

executor/set_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,19 @@ func (s *testSuite2) TestValidateSetVar(c *C) {
484484
_, err = tk.Exec("set @@global.max_connections='hello'")
485485
c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue)
486486

487+
tk.MustExec("set @@global.thread_pool_size=65")
488+
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect thread_pool_size value: '65'"))
489+
result = tk.MustQuery("select @@global.thread_pool_size;")
490+
result.Check(testkit.Rows("64"))
491+
492+
tk.MustExec("set @@global.thread_pool_size=-1")
493+
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect thread_pool_size value: '-1'"))
494+
result = tk.MustQuery("select @@global.thread_pool_size;")
495+
result.Check(testkit.Rows("1"))
496+
497+
_, err = tk.Exec("set @@global.thread_pool_size='hello'")
498+
c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue)
499+
487500
tk.MustExec("set @@global.max_allowed_packet=-1")
488501
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect max_allowed_packet value: '-1'"))
489502
result = tk.MustQuery("select @@global.max_allowed_packet;")

sessionctx/variable/sysvar.go

+3
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ var defaultSysVars = []*SysVar{
637637
{ScopeGlobal, "innodb_online_alter_log_max_size", "134217728"},
638638
{ScopeSession, WarningCount, "0"},
639639
{ScopeSession, ErrorCount, "0"},
640+
{ScopeGlobal, "thread_pool_size", "16"},
640641
/* TiDB specific variables */
641642
{ScopeSession, TiDBSnapshot, ""},
642643
{ScopeSession, TiDBOptAggPushDown, BoolToIntStr(DefOptAggPushDown)},
@@ -947,6 +948,8 @@ const (
947948
InnodbTableLocks = "innodb_table_locks"
948949
// InnodbStatusOutput is the name for 'innodb_status_output' system variable.
949950
InnodbStatusOutput = "innodb_status_output"
951+
// ThreadPoolSize is the name of 'thread_pool_size' variable.
952+
ThreadPoolSize = "thread_pool_size"
950953
)
951954

952955
// GlobalVarAccessor is the interface for accessing global scope system and status variables.

sessionctx/variable/varsutil.go

+2
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
439439
return value, ErrWrongValueForVar.GenWithStackByArgs(name, value)
440440
case MaxExecutionTime:
441441
return checkUInt64SystemVar(name, value, 0, math.MaxUint64, vars)
442+
case ThreadPoolSize:
443+
return checkUInt64SystemVar(name, value, 1, 64, vars)
442444
case TiDBEnableTablePartition:
443445
switch {
444446
case strings.EqualFold(value, "ON") || value == "1":

0 commit comments

Comments
 (0)