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

*: support variable log_bin #9343

Merged
merged 21 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
62606d6
Support variable `log_bin`
aliiohs Feb 18, 2019
3eb96d3
Support variable `log_bin`,Because the scope is not determined,so the…
aliiohs Feb 18, 2019
b3af774
set ScopeNone as the scope of `log_bin`
aliiohs Feb 18, 2019
195eaa8
set `log_bin in setGlobalVars method
aliiohs Feb 18, 2019
af59973
Support variable `log_bin`
aliiohs Feb 18, 2019
b682f93
add a Blank in Comment of variable 'LogBin'
aliiohs Feb 18, 2019
6b8a504
abstract a method transfer bool to status str ,like "ON" or "OFF"
aliiohs Feb 18, 2019
13d63e9
add Comment for BoolToStatusStr
aliiohs Feb 18, 2019
8d8d596
add Comment for BoolToStatusStr
aliiohs Feb 18, 2019
4566842
import Alias
aliiohs Feb 18, 2019
054cb18
please add a blank after ,
aliiohs Feb 18, 2019
feea00e
add a test case for 'log_bin'
aliiohs Feb 19, 2019
f862b4c
move merge case 'LogBin' to case 'TiDBEnableTablePartition'
aliiohs Feb 19, 2019
82e7be3
'LogBin' still keep an independent case
aliiohs Feb 19, 2019
fe01745
change LogBin Status from "ON" or "OFF" to "0" or "1".
aliiohs Feb 19, 2019
c1c1748
Merge branch 'master' into support_log_bin_2019_02_18_1
aliiohs Feb 19, 2019
65943a9
change status of'LogBin' from 'on/off' to '0/1'.
aliiohs Feb 19, 2019
4f7b4b0
eep the sys libs seperate with the 3rd libs.
aliiohs Feb 20, 2019
bcbe263
Merge branch 'master' into support_log_bin_2019_02_18_1
jackysp Feb 20, 2019
889fbd9
Merge branch 'master' into support_log_bin_2019_02_18_1
ngaut Feb 20, 2019
1cde77b
Merge branch 'master' into support_log_bin_2019_02_18_1
zz-jason Feb 20, 2019
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
4 changes: 4 additions & 0 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

. "github.com/pingcap/check"
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/testkit"
Expand Down Expand Up @@ -231,6 +232,9 @@ func (s *testSuite2) TestSetVar(c *C) {
tk.MustExec("set @@sql_log_bin = on")
tk.MustQuery(`select @@session.sql_log_bin;`).Check(testkit.Rows("1"))

tk.MustQuery(`select @@global.log_bin;`).Check(testkit.Rows(variable.BoolToIntStr(config.GetGlobalConfig().Binlog.Enable)))
tk.MustQuery(`select @@log_bin;`).Check(testkit.Rows(variable.BoolToIntStr(config.GetGlobalConfig().Binlog.Enable)))

tk.MustExec("set @@tidb_general_log = 1")
tk.MustExec("set @@tidb_general_log = 0")

Expand Down
31 changes: 17 additions & 14 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func init() {
terror.ErrClassToMySQLCodes[terror.ClassVariable] = mySQLErrCodes
}

func boolToIntStr(b bool) string {
// BoolToIntStr converts bool to int string, for example "0" or "1".
func BoolToIntStr(b bool) string {
if b {
return "1"
}
Expand Down Expand Up @@ -386,7 +387,7 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal, "log_syslog_include_pid", ""},
{ScopeSession, "last_insert_id", ""},
{ScopeNone, "innodb_ft_cache_size", "8000000"},
{ScopeNone, "log_bin", "OFF"},
{ScopeNone, LogBin, "0"},
{ScopeGlobal, "innodb_disable_sort_file_cache", "OFF"},
{ScopeGlobal, "log_error_verbosity", ""},
{ScopeNone, "performance_schema_hosts_size", "100"},
Expand Down Expand Up @@ -627,24 +628,24 @@ var defaultSysVars = []*SysVar{
{ScopeSession, ErrorCount, "0"},
/* TiDB specific variables */
{ScopeSession, TiDBSnapshot, ""},
{ScopeSession, TiDBOptAggPushDown, boolToIntStr(DefOptAggPushDown)},
{ScopeSession, TiDBOptWriteRowID, boolToIntStr(DefOptWriteRowID)},
{ScopeSession, TiDBOptAggPushDown, BoolToIntStr(DefOptAggPushDown)},
{ScopeSession, TiDBOptWriteRowID, BoolToIntStr(DefOptWriteRowID)},
{ScopeGlobal | ScopeSession, TiDBBuildStatsConcurrency, strconv.Itoa(DefBuildStatsConcurrency)},
{ScopeGlobal, TiDBAutoAnalyzeRatio, strconv.FormatFloat(DefAutoAnalyzeRatio, 'f', -1, 64)},
{ScopeGlobal, TiDBAutoAnalyzeStartTime, DefAutoAnalyzeStartTime},
{ScopeGlobal, TiDBAutoAnalyzeEndTime, DefAutoAnalyzeEndTime},
{ScopeSession, TiDBChecksumTableConcurrency, strconv.Itoa(DefChecksumTableConcurrency)},
{ScopeGlobal | ScopeSession, TiDBDistSQLScanConcurrency, strconv.Itoa(DefDistSQLScanConcurrency)},
{ScopeGlobal | ScopeSession, TiDBOptInSubqToJoinAndAgg, boolToIntStr(DefOptInSubqToJoinAndAgg)},
{ScopeGlobal | ScopeSession, TiDBOptInSubqToJoinAndAgg, BoolToIntStr(DefOptInSubqToJoinAndAgg)},
{ScopeGlobal | ScopeSession, TiDBIndexJoinBatchSize, strconv.Itoa(DefIndexJoinBatchSize)},
{ScopeGlobal | ScopeSession, TiDBIndexLookupSize, strconv.Itoa(DefIndexLookupSize)},
{ScopeGlobal | ScopeSession, TiDBIndexLookupConcurrency, strconv.Itoa(DefIndexLookupConcurrency)},
{ScopeGlobal | ScopeSession, TiDBIndexLookupJoinConcurrency, strconv.Itoa(DefIndexLookupJoinConcurrency)},
{ScopeGlobal | ScopeSession, TiDBIndexSerialScanConcurrency, strconv.Itoa(DefIndexSerialScanConcurrency)},
{ScopeGlobal | ScopeSession, TiDBSkipUTF8Check, boolToIntStr(DefSkipUTF8Check)},
{ScopeSession, TiDBBatchInsert, boolToIntStr(DefBatchInsert)},
{ScopeSession, TiDBBatchDelete, boolToIntStr(DefBatchDelete)},
{ScopeSession, TiDBBatchCommit, boolToIntStr(DefBatchCommit)},
{ScopeGlobal | ScopeSession, TiDBSkipUTF8Check, BoolToIntStr(DefSkipUTF8Check)},
{ScopeSession, TiDBBatchInsert, BoolToIntStr(DefBatchInsert)},
{ScopeSession, TiDBBatchDelete, BoolToIntStr(DefBatchDelete)},
{ScopeSession, TiDBBatchCommit, BoolToIntStr(DefBatchCommit)},
{ScopeSession, TiDBDMLBatchSize, strconv.Itoa(DefDMLBatchSize)},
{ScopeSession, TiDBCurrentTS, strconv.Itoa(DefCurretTS)},
{ScopeGlobal | ScopeSession, TiDBMaxChunkSize, strconv.Itoa(DefMaxChunkSize)},
Expand All @@ -667,10 +668,10 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal | ScopeSession, TiDBHashAggFinalConcurrency, strconv.Itoa(DefTiDBHashAggFinalConcurrency)},
{ScopeGlobal | ScopeSession, TiDBBackoffLockFast, strconv.Itoa(kv.DefBackoffLockFast)},
{ScopeGlobal | ScopeSession, TiDBRetryLimit, strconv.Itoa(DefTiDBRetryLimit)},
{ScopeGlobal | ScopeSession, TiDBDisableTxnAutoRetry, boolToIntStr(DefTiDBDisableTxnAutoRetry)},
{ScopeGlobal | ScopeSession, TiDBConstraintCheckInPlace, boolToIntStr(DefTiDBConstraintCheckInPlace)},
{ScopeGlobal | ScopeSession, TiDBDisableTxnAutoRetry, BoolToIntStr(DefTiDBDisableTxnAutoRetry)},
{ScopeGlobal | ScopeSession, TiDBConstraintCheckInPlace, BoolToIntStr(DefTiDBConstraintCheckInPlace)},
{ScopeSession, TiDBOptimizerSelectivityLevel, strconv.Itoa(DefTiDBOptimizerSelectivityLevel)},
{ScopeGlobal | ScopeSession, TiDBEnableWindowFunction, boolToIntStr(DefEnableWindowFunction)},
{ScopeGlobal | ScopeSession, TiDBEnableWindowFunction, BoolToIntStr(DefEnableWindowFunction)},
/* The following variable is defined as session scope but is actually server scope. */
{ScopeSession, TiDBGeneralLog, strconv.Itoa(DefTiDBGeneralLog)},
{ScopeSession, TiDBSlowLogThreshold, strconv.Itoa(logutil.DefaultSlowThreshold)},
Expand All @@ -680,8 +681,8 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal, TiDBDDLReorgBatchSize, strconv.Itoa(DefTiDBDDLReorgBatchSize)},
{ScopeSession, TiDBDDLReorgPriority, "PRIORITY_LOW"},
{ScopeSession, TiDBForcePriority, mysql.Priority2Str[DefTiDBForcePriority]},
{ScopeSession, TiDBEnableRadixJoin, boolToIntStr(DefTiDBUseRadixJoin)},
{ScopeSession, TiDBCheckMb4ValueInUtf8, boolToIntStr(config.GetGlobalConfig().CheckMb4ValueInUtf8)},
{ScopeSession, TiDBEnableRadixJoin, BoolToIntStr(DefTiDBUseRadixJoin)},
{ScopeSession, TiDBCheckMb4ValueInUtf8, BoolToIntStr(config.GetGlobalConfig().CheckMb4ValueInUtf8)},
}

// SynonymsSysVariables is synonyms of system variables.
Expand Down Expand Up @@ -742,6 +743,8 @@ const (
InnodbLockWaitTimeout = "innodb_lock_wait_timeout"
// SQLLogBin is the name for 'sql_log_bin' system variable.
SQLLogBin = "sql_log_bin"
// LogBin is the name for 'log_bin' system variable.
LogBin = "log_bin"
// MaxSortLength is the name for 'max_sort_length' system variable.
MaxSortLength = "max_sort_length"
// MaxSpRecursionDepth is the name for 'max_sp_recursion_depth' system variable.
Expand Down
7 changes: 4 additions & 3 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GetSessionOnlySysVars(s *SessionVars, key string) (string, bool, error) {
case PluginLoad:
return config.GetGlobalConfig().Plugin.Load, true, nil
case TiDBCheckMb4ValueInUtf8:
return boolToIntStr(config.GetGlobalConfig().CheckMb4ValueInUtf8), true, nil
return BoolToIntStr(config.GetGlobalConfig().CheckMb4ValueInUtf8), true, nil
}
sVal, ok := s.systems[key]
if ok {
Expand Down Expand Up @@ -334,8 +334,9 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
return checkUInt64SystemVar(name, value, 0, math.MaxUint64, vars)
case WarningCount, ErrorCount:
return value, ErrReadOnly.GenWithStackByArgs(name)
case GeneralLog, TiDBGeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, CoreFile, EndMakersInJSON, SQLLogBin, OfflineMode,
PseudoSlaveMode, LowPriorityUpdates, SkipNameResolve, SQLSafeUpdates, TiDBConstraintCheckInPlace:
case GeneralLog, TiDBGeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, LogBin,
CoreFile, EndMakersInJSON, SQLLogBin, OfflineMode, PseudoSlaveMode, LowPriorityUpdates,
SkipNameResolve, SQLSafeUpdates, TiDBConstraintCheckInPlace:
if strings.EqualFold(value, "ON") || value == "1" {
return "1", nil
} else if strings.EqualFold(value, "OFF") || value == "0" {
Expand Down
1 change: 1 addition & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func setGlobalVars() {

variable.SysVars[variable.TIDBMemQuotaQuery].Value = strconv.FormatInt(cfg.MemQuotaQuery, 10)
variable.SysVars["lower_case_table_names"].Value = strconv.Itoa(cfg.LowerCaseTableNames)
variable.SysVars[variable.LogBin].Value = variable.BoolToIntStr(config.GetGlobalConfig().Binlog.Enable)

// For CI environment we default enable prepare-plan-cache.
plannercore.SetPreparedPlanCache(config.CheckTableBeforeDrop || cfg.PreparedPlanCache.Enabled)
Expand Down