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

executor,sessionctx: refine output format for tidb-specific variables of boolean type #11239

Merged
merged 4 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 18 additions & 2 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,25 @@ func (s *testSuite2) TestValidateSetVar(c *C) {
c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err))

tk.MustExec("set @@tidb_batch_delete='On';")
tk.MustQuery("select @@tidb_batch_delete;").Check(testkit.Rows("1"))
tk.MustExec("set @@tidb_batch_delete='oFf';")
tk.MustQuery("select @@tidb_batch_delete;").Check(testkit.Rows("0"))
tk.MustExec("set @@tidb_batch_delete=1;")
tk.MustQuery("select @@tidb_batch_delete;").Check(testkit.Rows("1"))
tk.MustExec("set @@tidb_batch_delete=0;")
tk.MustQuery("select @@tidb_batch_delete;").Check(testkit.Rows("0"))

tk.MustExec("set @@tidb_opt_agg_push_down=off;")
tk.MustQuery("select @@tidb_opt_agg_push_down;").Check(testkit.Rows("0"))

tk.MustExec("set @@tidb_constraint_check_in_place=on;")
tk.MustQuery("select @@tidb_constraint_check_in_place;").Check(testkit.Rows("1"))

tk.MustExec("set @@tidb_general_log=0;")
tk.MustQuery("select @@tidb_general_log;").Check(testkit.Rows("0"))

tk.MustExec("set @@tidb_enable_streaming=1;")
tk.MustQuery("select @@tidb_enable_streaming;").Check(testkit.Rows("1"))

_, err = tk.Exec("set @@tidb_batch_delete=3;")
c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err))
Expand Down Expand Up @@ -789,9 +805,9 @@ func (s *testSuite2) TestEnableNoopFunctionsVar(c *C) {
_, err = tk.Exec(`set tidb_enable_noop_functions=11`)
c.Assert(err, NotNil)
tk.MustExec(`set tidb_enable_noop_functions="off";`)
tk.MustQuery(`select @@tidb_enable_noop_functions;`).Check(testkit.Rows("off"))
tk.MustQuery(`select @@tidb_enable_noop_functions;`).Check(testkit.Rows("0"))
tk.MustExec(`set tidb_enable_noop_functions="on";`)
tk.MustQuery(`select @@tidb_enable_noop_functions;`).Check(testkit.Rows("on"))
tk.MustQuery(`select @@tidb_enable_noop_functions;`).Check(testkit.Rows("1"))
tk.MustExec(`set tidb_enable_noop_functions=0;`)
tk.MustQuery(`select @@tidb_enable_noop_functions;`).Check(testkit.Rows("0"))
}
21 changes: 9 additions & 12 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,16 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
return "1", nil
}
return value, ErrWrongValueForVar.GenWithStackByArgs(name, value)
case GeneralLog, TiDBGeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, LogBin,
case TiDBSkipUTF8Check, TiDBOptAggPushDown,
TiDBOptInSubqToJoinAndAgg, TiDBEnableFastAnalyze,
TiDBBatchInsert, TiDBDisableTxnAutoRetry, TiDBEnableStreaming,
TiDBBatchDelete, TiDBBatchCommit, TiDBEnableCascadesPlanner, TiDBEnableWindowFunction,
TiDBCheckMb4ValueInUTF8, TiDBLowResolutionTSO, TiDBEnableIndexMerge, TiDBEnableNoopFuncs,
TiDBScatterRegion, TiDBGeneralLog, TiDBConstraintCheckInPlace:
fallthrough
case GeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, LogBin,
wshwsh12 marked this conversation as resolved.
Show resolved Hide resolved
CoreFile, EndMakersInJSON, SQLLogBin, OfflineMode, PseudoSlaveMode, LowPriorityUpdates,
SkipNameResolve, SQLSafeUpdates, TiDBConstraintCheckInPlace, serverReadOnly, SlaveAllowBatching,
SkipNameResolve, SQLSafeUpdates, serverReadOnly, SlaveAllowBatching,
Flush, PerformanceSchema, LocalInFile, ShowOldTemporals, KeepFilesOnCreate, AutoCommit,
SQLWarnings, UniqueChecks, OldAlterTable, LogBinTrustFunctionCreators, SQLBigSelects,
BinlogDirectNonTransactionalUpdates, SQLQuoteShowCreate, AutomaticSpPrivileges,
Expand Down Expand Up @@ -415,16 +422,6 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
}
}
return value, ErrWrongValueForVar.GenWithStackByArgs(name, value)
case TiDBSkipUTF8Check, TiDBOptAggPushDown,
TiDBOptInSubqToJoinAndAgg, TiDBEnableFastAnalyze,
TiDBBatchInsert, TiDBDisableTxnAutoRetry, TiDBEnableStreaming,
TiDBBatchDelete, TiDBBatchCommit, TiDBEnableCascadesPlanner, TiDBEnableWindowFunction,
TiDBCheckMb4ValueInUTF8, TiDBLowResolutionTSO, TiDBEnableIndexMerge, TiDBEnableNoopFuncs,
TiDBScatterRegion:
if strings.EqualFold(value, "ON") || value == "1" || strings.EqualFold(value, "OFF") || value == "0" {
return value, nil
}
return value, ErrWrongValueForVar.GenWithStackByArgs(name, value)
case MaxExecutionTime:
return checkUInt64SystemVar(name, value, 0, math.MaxUint64, vars)
case TiDBEnableTablePartition:
Expand Down