From b0b2e46afd42dcea67950a4f644091d081537c85 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 12 Jul 2021 16:01:32 +0800 Subject: [PATCH 1/4] cherry pick #26093 to release-4.0 Signed-off-by: ti-srebot --- executor/set_test.go | 114 ++ planner/core/optimizer.go | 2 +- ...lize_results.go => rule_result_reorder.go} | 31 +- ...ts_test.go => rule_result_reorder_test.go} | 102 +- ...json => ordered_result_mode_suite_in.json} | 12 +- ...son => ordered_result_mode_suite_out.json} | 12 +- sessionctx/variable/sysvar.go | 1157 +++++++++++++++++ sessionctx/variable/tidb_vars.go | 25 +- 8 files changed, 1398 insertions(+), 57 deletions(-) rename planner/core/{rule_stabilize_results.go => rule_result_reorder.go} (77%) rename planner/core/{rule_stabilize_results_test.go => rule_result_reorder_test.go} (57%) rename planner/core/testdata/{stable_result_mode_suite_in.json => ordered_result_mode_suite_in.json} (91%) rename planner/core/testdata/{stable_result_mode_suite_out.json => ordered_result_mode_suite_out.json} (98%) diff --git a/executor/set_test.go b/executor/set_test.go index b5f19ab5162a5..bc8e3b18e632a 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -429,6 +429,7 @@ func (s *testSuite5) TestSetVar(c *C) { tk.MustExec("set session tidb_slow_log_masking = 1") tk.MustQuery(`select @@session.tidb_slow_log_masking;`).Check(testkit.Rows("1")) +<<<<<<< HEAD // test for tidb_enable_stable_result_mode tk.MustQuery(`select @@tidb_enable_stable_result_mode`).Check(testkit.Rows("0")) tk.MustExec(`set global tidb_enable_stable_result_mode = 1`) @@ -438,6 +439,119 @@ func (s *testSuite5) TestSetVar(c *C) { tk.MustExec(`set tidb_enable_stable_result_mode=1`) tk.MustQuery(`select @@global.tidb_enable_stable_result_mode`).Check(testkit.Rows("0")) tk.MustQuery(`select @@tidb_enable_stable_result_mode`).Check(testkit.Rows("1")) +======= + tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("0")) + tk.MustExec("set @@session.tidb_dml_batch_size = 120") + tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("120")) + c.Assert(tk.ExecToErr("set @@session.tidb_dml_batch_size = -120"), NotNil) + c.Assert(tk.ExecToErr("set @@global.tidb_dml_batch_size = 200"), IsNil) // now permitted due to TiDB #19809 + tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("120")) // global only applies to new sessions + + _, err = tk.Exec("set tidb_enable_parallel_apply=-1") + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + + // test for tidb_mem_quota_apply_cache + defVal := fmt.Sprintf("%v", variable.DefTiDBMemQuotaApplyCache) + tk.MustQuery(`select @@tidb_mem_quota_apply_cache`).Check(testkit.Rows(defVal)) + tk.MustExec(`set global tidb_mem_quota_apply_cache = 1`) + tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("1")) + tk.MustExec(`set global tidb_mem_quota_apply_cache = 0`) + tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("0")) + tk.MustExec(`set tidb_mem_quota_apply_cache = 123`) + tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("0")) + tk.MustQuery(`select @@tidb_mem_quota_apply_cache`).Check(testkit.Rows("123")) + + // test for tidb_enable_parallel_apply + tk.MustQuery(`select @@tidb_enable_parallel_apply`).Check(testkit.Rows("0")) + tk.MustExec(`set global tidb_enable_parallel_apply = 1`) + tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("1")) + tk.MustExec(`set global tidb_enable_parallel_apply = 0`) + tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("0")) + tk.MustExec(`set tidb_enable_parallel_apply=1`) + tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("0")) + tk.MustQuery(`select @@tidb_enable_parallel_apply`).Check(testkit.Rows("1")) + + tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) + tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) + tk.MustExec("set tidb_general_log = 1") + tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("1")) + tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log ON")) + tk.MustExec("set tidb_general_log = 0") + tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) + tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) + tk.MustExec("set tidb_general_log = on") + tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("1")) + tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log ON")) + tk.MustExec("set tidb_general_log = off") + tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) + tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) + c.Assert(tk.ExecToErr("set tidb_general_log = abc"), NotNil) + c.Assert(tk.ExecToErr("set tidb_general_log = 123"), NotNil) + + tk.MustExec(`SET @@character_set_results = NULL;`) + tk.MustQuery(`select @@character_set_results;`).Check(testkit.Rows("")) + + varList := []string{"character_set_server", "character_set_client", "character_set_filesystem", "character_set_database"} + for _, v := range varList { + tk.MustGetErrCode(fmt.Sprintf("SET @@global.%s = @global_start_value;", v), mysql.ErrWrongValueForVar) + tk.MustGetErrCode(fmt.Sprintf("SET @@%s = @global_start_value;", v), mysql.ErrWrongValueForVar) + tk.MustGetErrCode(fmt.Sprintf("SET @@%s = NULL;", v), mysql.ErrWrongValueForVar) + tk.MustGetErrCode(fmt.Sprintf("SET @@%s = \"\";", v), mysql.ErrWrongValueForVar) + tk.MustGetErrMsg(fmt.Sprintf("SET @@%s = \"somecharset\";", v), "Unknown charset somecharset") + // we do not support set character_set_xxx or collation_xxx to a collation id. + tk.MustGetErrMsg(fmt.Sprintf("SET @@global.%s = 46;", v), "Unknown charset 46") + tk.MustGetErrMsg(fmt.Sprintf("SET @@%s = 46;", v), "Unknown charset 46") + } + + tk.MustExec("SET SESSION tidb_enable_extended_stats = on") + tk.MustQuery("select @@session.tidb_enable_extended_stats").Check(testkit.Rows("1")) + tk.MustExec("SET SESSION tidb_enable_extended_stats = off") + tk.MustQuery("select @@session.tidb_enable_extended_stats").Check(testkit.Rows("0")) + tk.MustExec("SET GLOBAL tidb_enable_extended_stats = on") + tk.MustQuery("select @@global.tidb_enable_extended_stats").Check(testkit.Rows("1")) + tk.MustExec("SET GLOBAL tidb_enable_extended_stats = off") + tk.MustQuery("select @@global.tidb_enable_extended_stats").Check(testkit.Rows("0")) + + tk.MustExec("SET SESSION tidb_allow_fallback_to_tikv = 'tiflash'") + tk.MustQuery("select @@session.tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) + tk.MustExec("SET SESSION tidb_allow_fallback_to_tikv = ''") + tk.MustQuery("select @@session.tidb_allow_fallback_to_tikv").Check(testkit.Rows("")) + tk.MustExec("SET GLOBAL tidb_allow_fallback_to_tikv = 'tiflash'") + tk.MustQuery("select @@global.tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) + tk.MustExec("SET GLOBAL tidb_allow_fallback_to_tikv = ''") + tk.MustQuery("select @@global.tidb_allow_fallback_to_tikv").Check(testkit.Rows("")) + tk.MustExec("set @@tidb_allow_fallback_to_tikv = 'tiflash, tiflash, tiflash'") + tk.MustQuery("select @@tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) + + tk.MustGetErrMsg("SET SESSION tidb_allow_fallback_to_tikv = 'tikv,tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tikv,tiflash'") + tk.MustGetErrMsg("SET GLOBAL tidb_allow_fallback_to_tikv = 'tikv,tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tikv,tiflash'") + tk.MustGetErrMsg("set @@tidb_allow_fallback_to_tikv = 'tidb, tiflash, tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tidb, tiflash, tiflash'") + tk.MustGetErrMsg("set @@tidb_allow_fallback_to_tikv = 'unknown, tiflash, tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'unknown, tiflash, tiflash'") + + // Test issue #22145 + tk.MustExec(`set global sync_relay_log = "'"`) + + tk.MustExec(`set @@global.tidb_enable_clustered_index = 'int_only'`) + tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1287 'INT_ONLY' is deprecated and will be removed in a future release. Please use 'ON' or 'OFF' instead")) + tk.MustExec(`set @@global.tidb_enable_clustered_index = 'off'`) + tk.MustQuery(`show warnings`).Check(testkit.Rows()) + tk.MustExec("set @@tidb_enable_clustered_index = 'off'") + tk.MustQuery(`show warnings`).Check(testkit.Rows()) + tk.MustExec("set @@tidb_enable_clustered_index = 'on'") + tk.MustQuery(`show warnings`).Check(testkit.Rows()) + tk.MustExec("set @@tidb_enable_clustered_index = 'int_only'") + tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1287 'INT_ONLY' is deprecated and will be removed in a future release. Please use 'ON' or 'OFF' instead")) + + // test for tidb_enable_ordered_result_mode + tk.MustQuery(`select @@tidb_enable_ordered_result_mode`).Check(testkit.Rows("0")) + tk.MustExec(`set global tidb_enable_ordered_result_mode = 1`) + tk.MustQuery(`select @@global.tidb_enable_ordered_result_mode`).Check(testkit.Rows("1")) + tk.MustExec(`set global tidb_enable_ordered_result_mode = 0`) + tk.MustQuery(`select @@global.tidb_enable_ordered_result_mode`).Check(testkit.Rows("0")) + tk.MustExec(`set tidb_enable_ordered_result_mode=1`) + tk.MustQuery(`select @@global.tidb_enable_ordered_result_mode`).Check(testkit.Rows("0")) + tk.MustQuery(`select @@tidb_enable_ordered_result_mode`).Check(testkit.Rows("1")) +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) } func (s *testSuite5) TestTruncateIncorrectIntSessionVar(c *C) { diff --git a/planner/core/optimizer.go b/planner/core/optimizer.go index a66de9cb8cbb5..46018bb45b615 100644 --- a/planner/core/optimizer.go +++ b/planner/core/optimizer.go @@ -60,7 +60,7 @@ const ( var optRuleList = []logicalOptRule{ &gcSubstituter{}, &columnPruner{}, - &resultsStabilizer{}, + &resultReorder{}, &buildKeySolver{}, &decorrelateSolver{}, &aggregationEliminator{}, diff --git a/planner/core/rule_stabilize_results.go b/planner/core/rule_result_reorder.go similarity index 77% rename from planner/core/rule_stabilize_results.go rename to planner/core/rule_result_reorder.go index 87c84bf85b42d..abbcb65fb4af4 100644 --- a/planner/core/rule_stabilize_results.go +++ b/planner/core/rule_result_reorder.go @@ -21,29 +21,34 @@ import ( ) /* - resultsStabilizer stabilizes query results. + resultReorder reorder query results. NOTE: it's not a common rule for all queries, it's specially implemented for a few customers. +<<<<<<< HEAD:planner/core/rule_stabilize_results.go Results of some queries are not stable, for example: +======= + + Results of some queries are not ordered, for example: +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder.go create table t (a int); insert into t values (1), (2); select a from t; - In the case above, the result can be `1 2` or `2 1`, which is not stable. - This rule stabilizes results by modifying or injecting a Sort operator: + In the case above, the result can be `1 2` or `2 1`, which is not ordered. + This rule reorders results by modifying or injecting a Sort operator: 1. iterate the plan from the root, and ignore all input-order operators (Sel/Proj/Limit); 2. when meeting the first non-input-order operator, 2.1. if it's a Sort, update it by appending all output columns into its order-by list, 2.2. otherwise, inject a new Sort upon this operator. */ -type resultsStabilizer struct { +type resultReorder struct { } -func (rs *resultsStabilizer) optimize(ctx context.Context, lp LogicalPlan) (LogicalPlan, error) { - stable := rs.completeSort(lp) - if !stable { +func (rs *resultReorder) optimize(ctx context.Context, lp LogicalPlan) (LogicalPlan, error) { + ordered := rs.completeSort(lp) + if !ordered { lp = rs.injectSort(lp) } return lp, nil } -func (rs *resultsStabilizer) completeSort(lp LogicalPlan) bool { +func (rs *resultReorder) completeSort(lp LogicalPlan) bool { if rs.isInputOrderKeeper(lp) { return rs.completeSort(lp.Children()[0]) } else if sort, ok := lp.(*LogicalSort); ok { @@ -68,7 +73,7 @@ func (rs *resultsStabilizer) completeSort(lp LogicalPlan) bool { return false } -func (rs *resultsStabilizer) injectSort(lp LogicalPlan) LogicalPlan { +func (rs *resultReorder) injectSort(lp LogicalPlan) LogicalPlan { if rs.isInputOrderKeeper(lp) { lp.SetChildren(rs.injectSort(lp.Children()[0])) return lp @@ -89,7 +94,7 @@ func (rs *resultsStabilizer) injectSort(lp LogicalPlan) LogicalPlan { return sort } -func (rs *resultsStabilizer) isInputOrderKeeper(lp LogicalPlan) bool { +func (rs *resultReorder) isInputOrderKeeper(lp LogicalPlan) bool { switch lp.(type) { case *LogicalSelection, *LogicalProjection, *LogicalLimit: return true @@ -98,7 +103,7 @@ func (rs *resultsStabilizer) isInputOrderKeeper(lp LogicalPlan) bool { } // extractHandleCols does the best effort to get the handle column. -func (rs *resultsStabilizer) extractHandleCol(lp LogicalPlan) *expression.Column { +func (rs *resultReorder) extractHandleCol(lp LogicalPlan) *expression.Column { switch x := lp.(type) { case *LogicalSelection, *LogicalLimit: handleCol := rs.extractHandleCol(lp.Children()[0]) @@ -115,6 +120,6 @@ func (rs *resultsStabilizer) extractHandleCol(lp LogicalPlan) *expression.Column return nil } -func (rs *resultsStabilizer) name() string { - return "stabilize_results" +func (rs *resultReorder) name() string { + return "result_reorder" } diff --git a/planner/core/rule_stabilize_results_test.go b/planner/core/rule_result_reorder_test.go similarity index 57% rename from planner/core/rule_stabilize_results_test.go rename to planner/core/rule_result_reorder_test.go index 4da03906c38e9..12648ada7fc6e 100644 --- a/planner/core/rule_stabilize_results_test.go +++ b/planner/core/rule_result_reorder_test.go @@ -26,21 +26,21 @@ import ( "github.com/pingcap/tidb/util/testutil" ) -var _ = Suite(&testRuleStabilizeResults{}) -var _ = SerialSuites(&testRuleStabilizeResultsSerial{}) +var _ = Suite(&testRuleReorderResults{}) +var _ = SerialSuites(&testRuleReorderResultsSerial{}) -type testRuleStabilizeResultsSerial struct { +type testRuleReorderResultsSerial struct { store kv.Storage dom *domain.Domain } -func (s *testRuleStabilizeResultsSerial) SetUpTest(c *C) { +func (s *testRuleReorderResultsSerial) SetUpTest(c *C) { var err error s.store, s.dom, err = newStoreWithBootstrap() c.Assert(err, IsNil) } -func (s *testRuleStabilizeResultsSerial) TestPlanCache(c *C) { +func (s *testRuleReorderResultsSerial) TestPlanCache(c *C) { tk := testkit.NewTestKit(c, s.store) orgEnable := plannercore.PreparedPlanCacheEnabled() defer func() { @@ -54,7 +54,7 @@ func (s *testRuleStabilizeResultsSerial) TestPlanCache(c *C) { c.Assert(err, IsNil) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int primary key, b int, c int, d int, key(b))") tk.MustExec("prepare s1 from 'select * from t where a > ? limit 10'") @@ -65,10 +65,10 @@ func (s *testRuleStabilizeResultsSerial) TestPlanCache(c *C) { tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1")) // plan cache is still working } -func (s *testRuleStabilizeResultsSerial) TestSQLBinding(c *C) { +func (s *testRuleReorderResultsSerial) TestSQLBinding(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int primary key, b int, c int, d int, key(b))") tk.MustQuery("explain select * from t where a > 0 limit 1").Check(testkit.Rows( @@ -79,35 +79,59 @@ func (s *testRuleStabilizeResultsSerial) TestSQLBinding(c *C) { tk.MustExec("create session binding for select * from t where a>0 limit 1 using select * from t use index(b) where a>0 limit 1") tk.MustQuery("explain select * from t where a > 0 limit 1").Check(testkit.Rows( +<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go "TopN_9 1.00 root test.t.a:asc, offset:0, count:1", "└─IndexLookUp_18 1.00 root ", " ├─TopN_17(Build) 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", " │ └─Selection_16 3333.33 cop[tikv] gt(test.t.a, 0)", " │ └─IndexFullScan_14 10000.00 cop[tikv] table:t, index:b(b) keep order:false, stats:pseudo", " └─TableRowIDScan_15(Probe) 1.00 cop[tikv] table:t keep order:false, stats:pseudo")) +======= + "TopN_9 1.00 root test.t.a, offset:0, count:1", + "└─IndexLookUp_19 1.00 root ", + " ├─TopN_18(Build) 1.00 cop[tikv] test.t.a, offset:0, count:1", + " │ └─Selection_17 3333.33 cop[tikv] gt(test.t.a, 0)", + " │ └─IndexFullScan_15 10000.00 cop[tikv] table:t, index:b(b) keep order:false, stats:pseudo", + " └─TableRowIDScan_16(Probe) 1.00 cop[tikv] table:t keep order:false, stats:pseudo")) } -type testRuleStabilizeResults struct { +func (s *testRuleReorderResultsSerial) TestClusteredIndex(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("set tidb_enable_ordered_result_mode=1") + tk.Se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOn + tk.MustExec("drop table if exists t") + tk.MustExec("CREATE TABLE t (a int,b int,c int, PRIMARY KEY (a,b))") + tk.MustQuery("explain select * from t limit 10").Check(testkit.Rows( + "TopN_7 10.00 root test.t.a, test.t.b, test.t.c, offset:0, count:10", + "└─TableReader_16 10.00 root data:TopN_15", + " └─TopN_15 10.00 cop[tikv] test.t.a, test.t.b, test.t.c, offset:0, count:10", + " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo")) + tk.Se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOff +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go +} + +type testRuleReorderResults struct { store kv.Storage dom *domain.Domain testData testutil.TestData } -func (s *testRuleStabilizeResults) SetUpSuite(c *C) { +func (s *testRuleReorderResults) SetUpSuite(c *C) { var err error s.store, s.dom, err = newStoreWithBootstrap() c.Assert(err, IsNil) - s.testData, err = testutil.LoadTestSuiteData("testdata", "stable_result_mode_suite") + s.testData, err = testutil.LoadTestSuiteData("testdata", "ordered_result_mode_suite") c.Assert(err, IsNil) } -func (s *testRuleStabilizeResults) TearDownSuite(c *C) { +func (s *testRuleReorderResults) TearDownSuite(c *C) { c.Assert(s.testData.GenerateOutputIfNeeded(), IsNil) } -func (s *testRuleStabilizeResults) runTestData(c *C, tk *testkit.TestKit, name string) { +func (s *testRuleReorderResults) runTestData(c *C, tk *testkit.TestKit, name string) { var input []string var output []struct { Plan []string @@ -122,61 +146,66 @@ func (s *testRuleStabilizeResults) runTestData(c *C, tk *testkit.TestKit, name s } } -func (s *testRuleStabilizeResults) TestStableResultMode(c *C) { +func (s *testRuleReorderResults) TestOrderedResultMode(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int primary key, b int, c int, d int, key(b))") - s.runTestData(c, tk, "TestStableResultMode") + s.runTestData(c, tk, "TestOrderedResultMode") } -func (s *testRuleStabilizeResults) TestStableResultModeOnDML(c *C) { +func (s *testRuleReorderResults) TestOrderedResultModeOnDML(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int primary key, b int, c int, key(b))") - s.runTestData(c, tk, "TestStableResultModeOnDML") + s.runTestData(c, tk, "TestOrderedResultModeOnDML") } -func (s *testRuleStabilizeResults) TestStableResultModeOnSubQuery(c *C) { +func (s *testRuleReorderResults) TestOrderedResultModeOnSubQuery(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t1") tk.MustExec("drop table if exists t2") tk.MustExec("create table t1 (a int primary key, b int, c int, d int, key(b))") tk.MustExec("create table t2 (a int primary key, b int, c int, d int, key(b))") - s.runTestData(c, tk, "TestStableResultModeOnSubQuery") + s.runTestData(c, tk, "TestOrderedResultModeOnSubQuery") } -func (s *testRuleStabilizeResults) TestStableResultModeOnJoin(c *C) { +func (s *testRuleReorderResults) TestOrderedResultModeOnJoin(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t1") tk.MustExec("drop table if exists t2") tk.MustExec("create table t1 (a int primary key, b int, c int, d int, key(b))") tk.MustExec("create table t2 (a int primary key, b int, c int, d int, key(b))") - s.runTestData(c, tk, "TestStableResultModeOnJoin") + s.runTestData(c, tk, "TestOrderedResultModeOnJoin") } -func (s *testRuleStabilizeResults) TestStableResultModeOnOtherOperators(c *C) { +func (s *testRuleReorderResults) TestOrderedResultModeOnOtherOperators(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") - tk.MustExec("set tidb_enable_stable_result_mode=1") + tk.MustExec("set tidb_enable_ordered_result_mode=1") tk.MustExec("drop table if exists t1") tk.MustExec("drop table if exists t2") tk.MustExec("create table t1 (a int primary key, b int, c int, d int, unique key(b))") tk.MustExec("create table t2 (a int primary key, b int, c int, d int, unique key(b))") - s.runTestData(c, tk, "TestStableResultModeOnOtherOperators") + s.runTestData(c, tk, "TestOrderedResultModeOnOtherOperators") } -func (s *testRuleStabilizeResults) TestStableResultModeOnPartitionTable(c *C) { +func (s *testRuleReorderResults) TestOrderedResultModeOnPartitionTable(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") +<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go tk.MustExec("set tidb_enable_stable_result_mode=1") +======= + tk.MustExec(fmt.Sprintf(`set tidb_partition_prune_mode='%v'`, variable.DefTiDBPartitionPruneMode)) + tk.MustExec("set tidb_enable_ordered_result_mode=1") +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go tk.MustExec("drop table if exists thash") tk.MustExec("drop table if exists trange") tk.MustExec("create table thash (a int primary key, b int, c int, d int) partition by hash(a) partitions 4") @@ -185,5 +214,20 @@ func (s *testRuleStabilizeResults) TestStableResultModeOnPartitionTable(c *C) { partition p1 values less than (200), partition p2 values less than (300), partition p3 values less than (400))`) +<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go s.runTestData(c, tk, "TestStableResultModeOnPartitionTable") } +======= + tk.MustQuery("select @@tidb_partition_prune_mode").Check(testkit.Rows("static")) + s.runTestData(c, tk, "TestOrderedResultModeOnPartitionTable") +} + +func (s *testRuleReorderResults) TestHideStableResultSwitch(c *C) { + tk := testkit.NewTestKit(c, s.store) + rs := tk.MustQuery("show variables").Rows() + for _, r := range rs { + c.Assert(strings.ToLower(r[0].(string)), Not(Equals), "tidb_enable_ordered_result_mode") + } + c.Assert(len(tk.MustQuery("show variables where variable_name like '%tidb_enable_ordered_result_mode%'").Rows()), Equals, 0) +} +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go diff --git a/planner/core/testdata/stable_result_mode_suite_in.json b/planner/core/testdata/ordered_result_mode_suite_in.json similarity index 91% rename from planner/core/testdata/stable_result_mode_suite_in.json rename to planner/core/testdata/ordered_result_mode_suite_in.json index 6ec585e9f594d..1ffc5939461fb 100644 --- a/planner/core/testdata/stable_result_mode_suite_in.json +++ b/planner/core/testdata/ordered_result_mode_suite_in.json @@ -1,6 +1,6 @@ [ { - "name": "TestStableResultMode", + "name": "TestOrderedResultMode", "cases": [ "select * from t use index(primary)", "select b from t use index(b)", @@ -19,7 +19,7 @@ ] }, { - "name": "TestStableResultModeOnDML", + "name": "TestOrderedResultModeOnDML", "cases": [ "insert into t select * from t", "insert into t select * from t where a>1", @@ -32,7 +32,7 @@ ] }, { - "name": "TestStableResultModeOnSubQuery", + "name": "TestOrderedResultModeOnSubQuery", "cases": [ "select * from t1 where t1.a in (select b from t2)", "select * from t1 where t1.a not in (select b from t2)", @@ -46,7 +46,7 @@ ] }, { - "name": "TestStableResultModeOnJoin", + "name": "TestOrderedResultModeOnJoin", "cases": [ "select * from t1, t2 where t1.a = t2.a", "select * from t1, t2 where t1.a > t2.a and t1.b = t2.b and t1.c < t2.c", @@ -55,7 +55,7 @@ ] }, { - "name": "TestStableResultModeOnOtherOperators", + "name": "TestOrderedResultModeOnOtherOperators", "cases": [ "select * from t1 where a = 1 or a = 222 or a = 33333", "select * from t1 where a in (1, 2, 3, 4)", @@ -70,7 +70,7 @@ ] }, { - "name": "TestStableResultModeOnPartitionTable", + "name": "TestOrderedResultModeOnPartitionTable", "cases": [ "select * from thash where a in (1, 200)", "select * from thash where a >= 50 and a <= 150", diff --git a/planner/core/testdata/stable_result_mode_suite_out.json b/planner/core/testdata/ordered_result_mode_suite_out.json similarity index 98% rename from planner/core/testdata/stable_result_mode_suite_out.json rename to planner/core/testdata/ordered_result_mode_suite_out.json index a2b40531dd2de..2135d34171d4b 100644 --- a/planner/core/testdata/stable_result_mode_suite_out.json +++ b/planner/core/testdata/ordered_result_mode_suite_out.json @@ -1,6 +1,6 @@ [ { - "Name": "TestStableResultMode", + "Name": "TestOrderedResultMode", "Cases": [ { "Plan": [ @@ -113,7 +113,7 @@ ] }, { - "Name": "TestStableResultModeOnDML", + "Name": "TestOrderedResultModeOnDML", "Cases": [ { "Plan": [ @@ -179,7 +179,7 @@ ] }, { - "Name": "TestStableResultModeOnSubQuery", + "Name": "TestOrderedResultModeOnSubQuery", "Cases": [ { "Plan": [ @@ -283,7 +283,7 @@ ] }, { - "Name": "TestStableResultModeOnJoin", + "Name": "TestOrderedResultModeOnJoin", "Cases": [ { "Plan": [ @@ -330,7 +330,7 @@ ] }, { - "Name": "TestStableResultModeOnOtherOperators", + "Name": "TestOrderedResultModeOnOtherOperators", "Cases": [ { "Plan": [ @@ -414,7 +414,7 @@ ] }, { - "Name": "TestStableResultModeOnPartitionTable", + "Name": "TestOrderedResultModeOnPartitionTable", "Cases": [ { "Plan": [ diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 5fcb5e6bf5979..260439412c8e4 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -756,9 +756,1166 @@ func addSynonymsSysVariables(synonyms ...string) { } } +<<<<<<< HEAD func initSynonymsSysVariables() { addSynonymsSysVariables(TxnIsolation, TransactionIsolation) addSynonymsSysVariables(TxReadOnly, TransactionReadOnly) +======= +var defaultSysVars = []*SysVar{ + {Scope: ScopeGlobal, Name: MaxConnections, Value: "151", Type: TypeUnsigned, MinValue: 1, MaxValue: 100000, AutoConvertOutOfRange: true}, + {Scope: ScopeGlobal | ScopeSession, Name: SQLSelectLimit, Value: "18446744073709551615", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxUint64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + result, err := strconv.ParseUint(val, 10, 64) + if err != nil { + return errors.Trace(err) + } + s.SelectLimit = result + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: DefaultWeekFormat, Value: "0", Type: TypeUnsigned, MinValue: 0, MaxValue: 7, AutoConvertOutOfRange: true}, + {Scope: ScopeGlobal | ScopeSession, Name: SQLModeVar, Value: mysql.DefaultSQLMode, IsHintUpdatable: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + // Ensure the SQL mode parses + normalizedValue = mysql.FormatSQLModeStr(normalizedValue) + if _, err := mysql.GetSQLMode(normalizedValue); err != nil { + return originalValue, err + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + val = mysql.FormatSQLModeStr(val) + // Modes is a list of different modes separated by commas. + sqlMode, err := mysql.GetSQLMode(val) + if err != nil { + return errors.Trace(err) + } + s.StrictSQLMode = sqlMode.HasStrictMode() + s.SQLMode = sqlMode + s.SetStatusFlag(mysql.ServerStatusNoBackslashEscaped, sqlMode.HasNoBackslashEscapesMode()) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: MaxExecutionTime, Value: "0", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, AutoConvertOutOfRange: true, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { + timeoutMS := tidbOptPositiveInt32(val, 0) + s.MaxExecutionTime = uint64(timeoutMS) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CollationServer, Value: mysql.DefaultCollationName, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCollation(vars, normalizedValue, originalValue, scope) + }, SetSession: func(s *SessionVars, val string) error { + if coll, err := collate.GetCollationByName(val); err == nil { + s.systems[CharacterSetServer] = coll.CharsetName + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: SQLLogBin, Value: On, Type: TypeBool, skipInit: true}, + {Scope: ScopeGlobal | ScopeSession, Name: TimeZone, Value: "SYSTEM", IsHintUpdatable: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if strings.EqualFold(normalizedValue, "SYSTEM") { + return "SYSTEM", nil + } + _, err := parseTimeZone(normalizedValue) + return normalizedValue, err + }, SetSession: func(s *SessionVars, val string) error { + tz, err := parseTimeZone(val) + if err != nil { + return err + } + s.TimeZone = tz + return nil + }}, + {Scope: ScopeNone, Name: SystemTimeZone, Value: "CST"}, + {Scope: ScopeGlobal | ScopeSession, Name: ForeignKeyChecks, Value: Off, Type: TypeBool, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if TiDBOptOn(normalizedValue) { + // TiDB does not yet support foreign keys. + // Return the original value in the warning, so that users are not confused. + vars.StmtCtx.AppendWarning(ErrUnsupportedValueForVar.GenWithStackByArgs(ForeignKeyChecks, originalValue)) + return Off, nil + } else if !TiDBOptOn(normalizedValue) { + return Off, nil + } + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(ForeignKeyChecks, originalValue) + }}, + {Scope: ScopeNone, Name: Hostname, Value: DefHostname}, + {Scope: ScopeSession, Name: Timestamp, Value: "", skipInit: true}, + {Scope: ScopeGlobal | ScopeSession, Name: CollationDatabase, Value: mysql.DefaultCollationName, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCollation(vars, normalizedValue, originalValue, scope) + }, SetSession: func(s *SessionVars, val string) error { + if coll, err := collate.GetCollationByName(val); err == nil { + s.systems[CharsetDatabase] = coll.CharsetName + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: AutoIncrementIncrement, Value: strconv.FormatInt(DefAutoIncrementIncrement, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxUint16, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + // AutoIncrementIncrement is valid in [1, 65535]. + s.AutoIncrementIncrement = tidbOptPositiveInt32(val, DefAutoIncrementIncrement) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: AutoIncrementOffset, Value: strconv.FormatInt(DefAutoIncrementOffset, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxUint16, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + // AutoIncrementOffset is valid in [1, 65535]. + s.AutoIncrementOffset = tidbOptPositiveInt32(val, DefAutoIncrementOffset) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetClient, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCharacterSet(normalizedValue, CharacterSetClient) + }}, + {Scope: ScopeNone, Name: Port, Value: "4000", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxUint16}, + {Scope: ScopeNone, Name: LowerCaseTableNames, Value: "2"}, + {Scope: ScopeNone, Name: LogBin, Value: Off, Type: TypeBool}, + {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetResults, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == "" { + return normalizedValue, nil + } + return checkCharacterSet(normalizedValue, "") + }}, + {Scope: ScopeNone, Name: VersionComment, Value: "TiDB Server (Apache License 2.0) " + versioninfo.TiDBEdition + " Edition, MySQL 5.7 compatible"}, + {Scope: ScopeGlobal | ScopeSession, Name: TxnIsolation, Value: "REPEATABLE-READ", Type: TypeEnum, Aliases: []string{TransactionIsolation}, PossibleValues: []string{"READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + // MySQL appends a warning here for tx_isolation is deprecated + // TiDB doesn't currently, but may in future. It is still commonly used by applications + // So it might be noisy to do so. + return checkIsolationLevel(vars, normalizedValue, originalValue, scope) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TransactionIsolation, Value: "REPEATABLE-READ", Type: TypeEnum, Aliases: []string{TxnIsolation}, PossibleValues: []string{"READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkIsolationLevel(vars, normalizedValue, originalValue, scope) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CollationConnection, Value: mysql.DefaultCollationName, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCollation(vars, normalizedValue, originalValue, scope) + }, SetSession: func(s *SessionVars, val string) error { + if coll, err := collate.GetCollationByName(val); err == nil { + s.systems[CharacterSetConnection] = coll.CharsetName + } + return nil + }}, + {Scope: ScopeNone, Name: Version, Value: mysql.ServerVersion}, + {Scope: ScopeGlobal | ScopeSession, Name: AutoCommit, Value: On, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + isAutocommit := TiDBOptOn(val) + s.SetStatusFlag(mysql.ServerStatusAutocommit, isAutocommit) + if isAutocommit { + s.SetInTxn(false) + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CharsetDatabase, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCharacterSet(normalizedValue, CharsetDatabase) + }, SetSession: func(s *SessionVars, val string) error { + if _, coll, err := charset.GetCharsetInfo(val); err == nil { + s.systems[CollationDatabase] = coll + } + return nil + }}, + {Scope: ScopeGlobal, Name: MaxPreparedStmtCount, Value: strconv.FormatInt(DefMaxPreparedStmtCount, 10), Type: TypeInt, MinValue: -1, MaxValue: 1048576, AutoConvertOutOfRange: true}, + {Scope: ScopeNone, Name: DataDir, Value: "/usr/local/mysql/data/"}, + {Scope: ScopeGlobal | ScopeSession, Name: WaitTimeout, Value: strconv.FormatInt(DefWaitTimeout, 10), Type: TypeUnsigned, MinValue: 0, MaxValue: secondsPerYear, AutoConvertOutOfRange: true}, + {Scope: ScopeGlobal | ScopeSession, Name: InteractiveTimeout, Value: "28800", Type: TypeUnsigned, MinValue: 1, MaxValue: secondsPerYear, AutoConvertOutOfRange: true}, + {Scope: ScopeGlobal | ScopeSession, Name: InnodbLockWaitTimeout, Value: strconv.FormatInt(DefInnodbLockWaitTimeout, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: 1073741824, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + lockWaitSec := tidbOptInt64(val, DefInnodbLockWaitTimeout) + s.LockWaitTimeout = lockWaitSec * 1000 + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: GroupConcatMaxLen, Value: "1024", AutoConvertOutOfRange: true, IsHintUpdatable: true, skipInit: true, Type: TypeUnsigned, MinValue: 4, MaxValue: math.MaxUint64, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + // https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_group_concat_max_len + // Minimum Value 4 + // Maximum Value (64-bit platforms) 18446744073709551615 + // Maximum Value (32-bit platforms) 4294967295 + if mathutil.IntBits == 32 { + if val, err := strconv.ParseUint(normalizedValue, 10, 64); err == nil { + if val > uint64(math.MaxUint32) { + vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(GroupConcatMaxLen, originalValue)) + return fmt.Sprintf("%d", math.MaxUint32), nil + } + } + } + return normalizedValue, nil + }}, + {Scope: ScopeNone, Name: Socket, Value: ""}, + {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetConnection, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCharacterSet(normalizedValue, CharacterSetConnection) + }, SetSession: func(s *SessionVars, val string) error { + if _, coll, err := charset.GetCharsetInfo(val); err == nil { + s.systems[CollationConnection] = coll + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetServer, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkCharacterSet(normalizedValue, CharacterSetServer) + }, SetSession: func(s *SessionVars, val string) error { + if _, coll, err := charset.GetCharsetInfo(val); err == nil { + s.systems[CollationServer] = coll + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: MaxAllowedPacket, Value: "67108864", Type: TypeUnsigned, MinValue: 1024, MaxValue: MaxOfMaxAllowedPacket, AutoConvertOutOfRange: true}, + {Scope: ScopeSession, Name: WarningCount, Value: "0", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.Itoa(s.SysWarningCount), nil + }}, + {Scope: ScopeSession, Name: ErrorCount, Value: "0", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.Itoa(int(s.SysErrorCount)), nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: WindowingUseHighPrecision, Value: On, Type: TypeBool, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { + s.WindowingUseHighPrecision = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeNone, Name: "license", Value: "Apache License 2.0"}, + {Scope: ScopeGlobal | ScopeSession, Name: BlockEncryptionMode, Value: "aes-128-ecb"}, + {Scope: ScopeSession, Name: "last_insert_id", Value: "", skipInit: true}, + {Scope: ScopeNone, Name: "have_ssl", Value: "DISABLED"}, + {Scope: ScopeNone, Name: "have_openssl", Value: "DISABLED"}, + {Scope: ScopeNone, Name: "ssl_ca", Value: ""}, + {Scope: ScopeNone, Name: "ssl_cert", Value: ""}, + {Scope: ScopeNone, Name: "ssl_key", Value: ""}, + {Scope: ScopeGlobal, Name: InitConnect, Value: ""}, + + /* TiDB specific variables */ + {Scope: ScopeGlobal, Name: TiDBEnableLocalTxn, Value: BoolToOnOff(DefTiDBEnableLocalTxn), Hidden: true, Type: TypeBool, GetSession: func(sv *SessionVars) (string, error) { + return BoolToOnOff(EnableLocalTxn.Load()), nil + }, SetGlobal: func(s *SessionVars, val string) error { + oldVal := EnableLocalTxn.Load() + newVal := TiDBOptOn(val) + // Make sure the TxnScope is always Global when disable the Local Txn. + // ON -> OFF + if oldVal && !newVal { + s.TxnScope = kv.NewGlobalTxnScopeVar() + } + EnableLocalTxn.Store(newVal) + return nil + }}, + // TODO: TiDBTxnScope is hidden because local txn feature is not done. + {Scope: ScopeSession, Name: TiDBTxnScope, skipInit: true, Hidden: true, Value: kv.GlobalTxnScope, SetSession: func(s *SessionVars, val string) error { + switch val { + case kv.GlobalTxnScope: + s.TxnScope = kv.NewGlobalTxnScopeVar() + case kv.LocalTxnScope: + if !EnableLocalTxn.Load() { + return ErrWrongValueForVar.GenWithStack("@@txn_scope can not be set to local when tidb_enable_local_txn is off") + } + txnScope := config.GetTxnScopeFromConfig() + if txnScope == kv.GlobalTxnScope { + return ErrWrongValueForVar.GenWithStack("@@txn_scope can not be set to local when zone label is empty or \"global\"") + } + s.TxnScope = kv.NewLocalTxnScopeVar(txnScope) + default: + return ErrWrongValueForVar.GenWithStack("@@txn_scope value should be global or local") + } + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return s.TxnScope.GetVarValue(), nil + }}, + {Scope: ScopeSession, Name: TiDBTxnReadTS, Value: "", Hidden: true, SetSession: func(s *SessionVars, val string) error { + return setTxnReadTS(s, val) + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowMPPExecution, Type: TypeBool, Value: BoolToOnOff(DefTiDBAllowMPPExecution), SetSession: func(s *SessionVars, val string) error { + s.allowMPPExecution = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBEnforceMPPExecution, Type: TypeBool, Value: BoolToOnOff(config.GetGlobalConfig().Performance.EnforceMPP), Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if TiDBOptOn(normalizedValue) && !vars.allowMPPExecution { + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("tidb_enforce_mpp", "1' but tidb_allow_mpp is 0, please activate tidb_allow_mpp at first.") + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.enforceMPPExecution = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBBCJThresholdCount, Value: strconv.Itoa(DefBroadcastJoinThresholdCount), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.BroadcastJoinThresholdCount = tidbOptInt64(val, DefBroadcastJoinThresholdCount) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBBCJThresholdSize, Value: strconv.Itoa(DefBroadcastJoinThresholdSize), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.BroadcastJoinThresholdSize = tidbOptInt64(val, DefBroadcastJoinThresholdSize) + return nil + }}, + {Scope: ScopeSession, Name: TiDBSnapshot, Value: "", skipInit: true, SetSession: func(s *SessionVars, val string) error { + err := setSnapshotTS(s, val) + if err != nil { + return err + } + return nil + }}, + {Scope: ScopeSession, Name: TiDBOptAggPushDown, Value: BoolToOnOff(DefOptAggPushDown), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.AllowAggPushDown = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptBCJ, Value: BoolToOnOff(DefOptBCJ), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if TiDBOptOn(normalizedValue) && vars.AllowBatchCop == 0 { + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("Can't set Broadcast Join to 1 but tidb_allow_batch_cop is 0, please active batch cop at first.") + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.AllowBCJ = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBOptDistinctAggPushDown, Value: BoolToOnOff(config.GetGlobalConfig().Performance.DistinctAggPushDown), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.AllowDistinctAggPushDown = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBOptWriteRowID, Value: BoolToOnOff(DefOptWriteRowID), skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.AllowWriteRowID = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBBuildStatsConcurrency, skipInit: true, Value: strconv.Itoa(DefBuildStatsConcurrency)}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCartesianBCJ, Value: strconv.Itoa(DefOptCartesianBCJ), Type: TypeInt, MinValue: 0, MaxValue: 2, SetSession: func(s *SessionVars, val string) error { + s.AllowCartesianBCJ = tidbOptInt(val, DefOptCartesianBCJ) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptMPPOuterJoinFixedBuildSide, Value: BoolToOnOff(DefOptMPPOuterJoinFixedBuildSide), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.MPPOuterJoinFixedBuildSide = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeRatio, Value: strconv.FormatFloat(DefAutoAnalyzeRatio, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64}, + {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeStartTime, Value: DefAutoAnalyzeStartTime, Type: TypeTime}, + {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeEndTime, Value: DefAutoAnalyzeEndTime, Type: TypeTime}, + {Scope: ScopeSession, Name: TiDBChecksumTableConcurrency, skipInit: true, Value: strconv.Itoa(DefChecksumTableConcurrency)}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBExecutorConcurrency, Value: strconv.Itoa(DefExecutorConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.ExecutorConcurrency = tidbOptPositiveInt32(val, DefExecutorConcurrency) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBDistSQLScanConcurrency, Value: strconv.Itoa(DefDistSQLScanConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.distSQLScanConcurrency = tidbOptPositiveInt32(val, DefDistSQLScanConcurrency) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptInSubqToJoinAndAgg, Value: BoolToOnOff(DefOptInSubqToJoinAndAgg), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.SetAllowInSubqToJoinAndAgg(TiDBOptOn(val)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBOptPreferRangeScan, Value: BoolToOnOff(DefOptPreferRangeScan), Type: TypeBool, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { + s.SetAllowPreferRangeScan(TiDBOptOn(val)) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCorrelationThreshold, Value: strconv.FormatFloat(DefOptCorrelationThreshold, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: 1, SetSession: func(s *SessionVars, val string) error { + s.CorrelationThreshold = tidbOptFloat64(val, DefOptCorrelationThreshold) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCorrelationExpFactor, Value: strconv.Itoa(DefOptCorrelationExpFactor), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.CorrelationExpFactor = int(tidbOptInt64(val, DefOptCorrelationExpFactor)) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCPUFactor, Value: strconv.FormatFloat(DefOptCPUFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.CPUFactor = tidbOptFloat64(val, DefOptCPUFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptTiFlashConcurrencyFactor, Value: strconv.FormatFloat(DefOptTiFlashConcurrencyFactor, 'f', -1, 64), skipInit: true, Type: TypeFloat, MinValue: 1, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.CopTiFlashConcurrencyFactor = tidbOptFloat64(val, DefOptTiFlashConcurrencyFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCopCPUFactor, Value: strconv.FormatFloat(DefOptCopCPUFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.CopCPUFactor = tidbOptFloat64(val, DefOptCopCPUFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptNetworkFactor, Value: strconv.FormatFloat(DefOptNetworkFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.networkFactor = tidbOptFloat64(val, DefOptNetworkFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptScanFactor, Value: strconv.FormatFloat(DefOptScanFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.scanFactor = tidbOptFloat64(val, DefOptScanFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptDescScanFactor, Value: strconv.FormatFloat(DefOptDescScanFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.descScanFactor = tidbOptFloat64(val, DefOptDescScanFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptSeekFactor, Value: strconv.FormatFloat(DefOptSeekFactor, 'f', -1, 64), skipInit: true, Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.seekFactor = tidbOptFloat64(val, DefOptSeekFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptMemoryFactor, Value: strconv.FormatFloat(DefOptMemoryFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.MemoryFactor = tidbOptFloat64(val, DefOptMemoryFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptDiskFactor, Value: strconv.FormatFloat(DefOptDiskFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.DiskFactor = tidbOptFloat64(val, DefOptDiskFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptConcurrencyFactor, Value: strconv.FormatFloat(DefOptConcurrencyFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { + s.ConcurrencyFactor = tidbOptFloat64(val, DefOptConcurrencyFactor) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexJoinBatchSize, Value: strconv.Itoa(DefIndexJoinBatchSize), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.IndexJoinBatchSize = tidbOptPositiveInt32(val, DefIndexJoinBatchSize) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupSize, Value: strconv.Itoa(DefIndexLookupSize), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.IndexLookupSize = tidbOptPositiveInt32(val, DefIndexLookupSize) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupConcurrency, Value: strconv.Itoa(DefIndexLookupConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.indexLookupConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBIndexLookupConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupJoinConcurrency, Value: strconv.Itoa(DefIndexLookupJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.indexLookupJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBIndexLookupJoinConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexSerialScanConcurrency, Value: strconv.Itoa(DefIndexSerialScanConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.indexSerialScanConcurrency = tidbOptPositiveInt32(val, DefIndexSerialScanConcurrency) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipUTF8Check, Value: BoolToOnOff(DefSkipUTF8Check), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.SkipUTF8Check = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipASCIICheck, Value: BoolToOnOff(DefSkipASCIICheck), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.SkipASCIICheck = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBBatchInsert, Value: BoolToOnOff(DefBatchInsert), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.BatchInsert = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBBatchDelete, Value: BoolToOnOff(DefBatchDelete), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.BatchDelete = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBBatchCommit, Value: BoolToOnOff(DefBatchCommit), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.BatchCommit = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBDMLBatchSize, Value: strconv.Itoa(DefDMLBatchSize), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.DMLBatchSize = int(tidbOptInt64(val, DefDMLBatchSize)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBCurrentTS, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + return fmt.Sprintf("%d", s.TxnCtx.StartTS), nil + }}, + {Scope: ScopeSession, Name: TiDBLastTxnInfo, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + return s.LastTxnInfo, nil + }}, + {Scope: ScopeSession, Name: TiDBLastQueryInfo, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + info, err := json.Marshal(s.LastQueryInfo) + if err != nil { + return "", err + } + return string(info), nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBMaxChunkSize, Value: strconv.Itoa(DefMaxChunkSize), Type: TypeUnsigned, MinValue: maxChunkSizeLowerBound, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.MaxChunkSize = tidbOptPositiveInt32(val, DefMaxChunkSize) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowBatchCop, Value: strconv.Itoa(DefTiDBAllowBatchCop), Type: TypeInt, MinValue: 0, MaxValue: 2, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == "0" && vars.AllowBCJ { + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("Can't set batch cop 0 but tidb_opt_broadcast_join is 1, please set tidb_opt_broadcast_join 0 at first") + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.AllowBatchCop = int(tidbOptInt64(val, DefTiDBAllowBatchCop)) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBInitChunkSize, Value: strconv.Itoa(DefInitChunkSize), Type: TypeUnsigned, MinValue: 1, MaxValue: initChunkSizeUpperBound, SetSession: func(s *SessionVars, val string) error { + s.InitChunkSize = tidbOptPositiveInt32(val, DefInitChunkSize) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableCascadesPlanner, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.SetEnableCascadesPlanner(TiDBOptOn(val)) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableIndexMerge, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.SetEnableIndexMerge(TiDBOptOn(val)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaQuery, Value: strconv.FormatInt(config.GetGlobalConfig().MemQuotaQuery, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaQuery = tidbOptInt64(val, config.GetGlobalConfig().MemQuotaQuery) + return nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaHashJoin, Value: strconv.FormatInt(DefTiDBMemQuotaHashJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaHashJoin = tidbOptInt64(val, DefTiDBMemQuotaHashJoin) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaHashJoin, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaMergeJoin, Value: strconv.FormatInt(DefTiDBMemQuotaMergeJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaMergeJoin = tidbOptInt64(val, DefTiDBMemQuotaMergeJoin) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaMergeJoin, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaSort, Value: strconv.FormatInt(DefTiDBMemQuotaSort, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaSort = tidbOptInt64(val, DefTiDBMemQuotaSort) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaSort, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaTopn, Value: strconv.FormatInt(DefTiDBMemQuotaTopn, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaTopn = tidbOptInt64(val, DefTiDBMemQuotaTopn) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaTopn, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaIndexLookupReader, Value: strconv.FormatInt(DefTiDBMemQuotaIndexLookupReader, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaIndexLookupReader = tidbOptInt64(val, DefTiDBMemQuotaIndexLookupReader) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaIndexLookupReader, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBMemQuotaIndexLookupJoin, Value: strconv.FormatInt(DefTiDBMemQuotaIndexLookupJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaIndexLookupJoin = tidbOptInt64(val, DefTiDBMemQuotaIndexLookupJoin) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMemQuotaIndexLookupJoin, TiDBMemQuotaQuery) + return normalizedValue, nil + }}, + {Scope: ScopeSession, Name: TiDBEnableStreaming, Value: Off, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.EnableStreaming = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBEnableChunkRPC, Value: On, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.EnableChunkRPC = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TxnIsolationOneShot, Value: "", skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + return checkIsolationLevel(vars, normalizedValue, originalValue, scope) + }, SetSession: func(s *SessionVars, val string) error { + s.txnIsolationLevelOneShot.state = oneShotSet + s.txnIsolationLevelOneShot.value = val + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableTablePartition, Value: On, Type: TypeEnum, PossibleValues: []string{Off, On, "AUTO"}, SetSession: func(s *SessionVars, val string) error { + s.EnableTablePartition = val + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableListTablePartition, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableListTablePartition = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashJoinConcurrency, Value: strconv.Itoa(DefTiDBHashJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.hashJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBHashJoinConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBProjectionConcurrency, Value: strconv.Itoa(DefTiDBProjectionConcurrency), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.projectionConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBProjectionConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashAggPartialConcurrency, Value: strconv.Itoa(DefTiDBHashAggPartialConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.hashAggPartialConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBHashAggPartialConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashAggFinalConcurrency, Value: strconv.Itoa(DefTiDBHashAggFinalConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.hashAggFinalConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBHashAggFinalConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBWindowConcurrency, Value: strconv.Itoa(DefTiDBWindowConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.windowConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBWindowConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBMergeJoinConcurrency, Value: strconv.Itoa(DefTiDBMergeJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.mergeJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBMergeJoinConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStreamAggConcurrency, Value: strconv.Itoa(DefTiDBStreamAggConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { + s.streamAggConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) + return nil + }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBStreamAggConcurrency, TiDBExecutorConcurrency) + return normalizedValue, nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableParallelApply, Value: BoolToOnOff(DefTiDBEnableParallelApply), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableParallelApply = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBMemQuotaApplyCache, Value: strconv.Itoa(DefTiDBMemQuotaApplyCache), Type: TypeUnsigned, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.MemQuotaApplyCache = tidbOptInt64(val, DefTiDBMemQuotaApplyCache) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBBackoffLockFast, Value: strconv.Itoa(tikvstore.DefBackoffLockFast), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.KVVars.BackoffLockFast = tidbOptPositiveInt32(val, tikvstore.DefBackoffLockFast) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBBackOffWeight, Value: strconv.Itoa(tikvstore.DefBackOffWeight), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.KVVars.BackOffWeight = tidbOptPositiveInt32(val, tikvstore.DefBackOffWeight) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBRetryLimit, Value: strconv.Itoa(DefTiDBRetryLimit), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + s.RetryLimit = tidbOptInt64(val, DefTiDBRetryLimit) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBDisableTxnAutoRetry, Value: BoolToOnOff(DefTiDBDisableTxnAutoRetry), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.DisableTxnAutoRetry = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBConstraintCheckInPlace, Value: BoolToOnOff(DefTiDBConstraintCheckInPlace), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.ConstraintCheckInPlace = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBTxnMode, Value: DefTiDBTxnMode, AllowEmptyAll: true, Type: TypeEnum, PossibleValues: []string{"pessimistic", "optimistic"}, SetSession: func(s *SessionVars, val string) error { + s.TxnMode = strings.ToUpper(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBRowFormatVersion, Value: strconv.Itoa(DefTiDBRowFormatV1), Type: TypeUnsigned, MinValue: 1, MaxValue: 2, SetSession: func(s *SessionVars, val string) error { + formatVersion := int(tidbOptInt64(val, DefTiDBRowFormatV1)) + if formatVersion == DefTiDBRowFormatV1 { + s.RowEncoder.Enable = false + } else if formatVersion == DefTiDBRowFormatV2 { + s.RowEncoder.Enable = true + } + SetDDLReorgRowFormat(tidbOptInt64(val, DefTiDBRowFormatV2)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBOptimizerSelectivityLevel, Value: strconv.Itoa(DefTiDBOptimizerSelectivityLevel), skipInit: true, Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.OptimizerSelectivityLevel = tidbOptPositiveInt32(val, DefTiDBOptimizerSelectivityLevel) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableWindowFunction, Value: BoolToOnOff(DefEnableWindowFunction), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableWindowFunction = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnablePipelinedWindowFunction, Value: BoolToOnOff(DefEnablePipelinedWindowFunction), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnablePipelinedWindowExec = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableStrictDoubleTypeCheck, Value: BoolToOnOff(DefEnableStrictDoubleTypeCheck), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableStrictDoubleTypeCheck = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableVectorizedExpression, Value: BoolToOnOff(DefEnableVectorizedExpression), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableVectorizedExpression = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableFastAnalyze, Value: BoolToOnOff(DefTiDBUseFastAnalyze), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableFastAnalyze = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipIsolationLevelCheck, skipInit: true, Value: BoolToOnOff(DefTiDBSkipIsolationLevelCheck), Type: TypeBool}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableRateLimitAction, Value: BoolToOnOff(DefTiDBEnableRateLimitAction), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnabledRateLimitAction = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowFallbackToTiKV, Value: "", Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == "" { + return "", nil + } + engines := strings.Split(normalizedValue, ",") + var formatVal string + storeTypes := make(map[kv.StoreType]struct{}) + for i, engine := range engines { + engine = strings.TrimSpace(engine) + switch { + case strings.EqualFold(engine, kv.TiFlash.Name()): + if _, ok := storeTypes[kv.TiFlash]; !ok { + if i != 0 { + formatVal += "," + } + formatVal += kv.TiFlash.Name() + storeTypes[kv.TiFlash] = struct{}{} + } + default: + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(TiDBAllowFallbackToTiKV, normalizedValue) + } + } + return formatVal, nil + }, SetSession: func(s *SessionVars, val string) error { + s.AllowFallbackToTiKV = make(map[kv.StoreType]struct{}) + for _, engine := range strings.Split(val, ",") { + switch engine { + case kv.TiFlash.Name(): + s.AllowFallbackToTiKV[kv.TiFlash] = struct{}{} + } + } + return nil + }}, + /* The following variable is defined as session scope but is actually server scope. */ + {Scope: ScopeSession, Name: TiDBGeneralLog, Value: BoolToOnOff(DefTiDBGeneralLog), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + ProcessGeneralLog.Store(TiDBOptOn(val)) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(ProcessGeneralLog.Load()), nil + }}, + {Scope: ScopeSession, Name: TiDBPProfSQLCPU, Value: strconv.Itoa(DefTiDBPProfSQLCPU), Type: TypeInt, skipInit: true, MinValue: 0, MaxValue: 1, SetSession: func(s *SessionVars, val string) error { + EnablePProfSQLCPU.Store(uint32(tidbOptPositiveInt32(val, DefTiDBPProfSQLCPU)) > 0) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + val := "0" + if EnablePProfSQLCPU.Load() { + val = "1" + } + return val, nil + }}, + {Scope: ScopeSession, Name: TiDBDDLSlowOprThreshold, Value: strconv.Itoa(DefTiDBDDLSlowOprThreshold), skipInit: true, SetSession: func(s *SessionVars, val string) error { + atomic.StoreUint32(&DDLSlowOprThreshold, uint32(tidbOptPositiveInt32(val, DefTiDBDDLSlowOprThreshold))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatUint(uint64(atomic.LoadUint32(&DDLSlowOprThreshold)), 10), nil + }}, + {Scope: ScopeSession, Name: TiDBConfig, Value: "", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + conf := config.GetGlobalConfig() + j, err := json.MarshalIndent(conf, "", "\t") + if err != nil { + return "", err + } + return config.HideConfig(string(j)), nil + }}, + {Scope: ScopeGlobal, Name: TiDBDDLReorgWorkerCount, Value: strconv.Itoa(DefTiDBDDLReorgWorkerCount), Type: TypeUnsigned, MinValue: 1, MaxValue: uint64(maxDDLReorgWorkerCount), SetSession: func(s *SessionVars, val string) error { + SetDDLReorgWorkerCounter(int32(tidbOptPositiveInt32(val, DefTiDBDDLReorgWorkerCount))) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBDDLReorgBatchSize, Value: strconv.Itoa(DefTiDBDDLReorgBatchSize), Type: TypeUnsigned, MinValue: int64(MinDDLReorgBatchSize), MaxValue: uint64(MaxDDLReorgBatchSize), AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + SetDDLReorgBatchSize(int32(tidbOptPositiveInt32(val, DefTiDBDDLReorgBatchSize))) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBDDLErrorCountLimit, Value: strconv.Itoa(DefTiDBDDLErrorCountLimit), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + SetDDLErrorCountLimit(tidbOptInt64(val, DefTiDBDDLErrorCountLimit)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBDDLReorgPriority, Value: "PRIORITY_LOW", skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.setDDLReorgPriority(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBMaxDeltaSchemaCount, Value: strconv.Itoa(DefTiDBMaxDeltaSchemaCount), Type: TypeUnsigned, MinValue: 100, MaxValue: 16384, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + // It's a global variable, but it also wants to be cached in server. + SetMaxDeltaSchemaCount(tidbOptInt64(val, DefTiDBMaxDeltaSchemaCount)) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBEnableChangeMultiSchema, Value: BoolToOnOff(DefTiDBChangeMultiSchema), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableChangeMultiSchema = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBEnablePointGetCache, Value: BoolToOnOff(DefTiDBPointGetCache), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnablePointGetCache = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBEnableAlterPlacement, Value: BoolToOnOff(DefTiDBEnableAlterPlacement), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableAlterPlacement = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBForcePriority, skipInit: true, Value: mysql.Priority2Str[DefTiDBForcePriority], SetSession: func(s *SessionVars, val string) error { + atomic.StoreInt32(&ForcePriority, int32(mysql.Str2Priority(val))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return mysql.Priority2Str[mysql.PriorityEnum(atomic.LoadInt32(&ForcePriority))], nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptJoinReorderThreshold, Value: strconv.Itoa(DefTiDBOptJoinReorderThreshold), skipInit: true, Type: TypeUnsigned, MinValue: 0, MaxValue: 63, SetSession: func(s *SessionVars, val string) error { + s.TiDBOptJoinReorderThreshold = tidbOptPositiveInt32(val, DefTiDBOptJoinReorderThreshold) + return nil + }}, + {Scope: ScopeSession, Name: TiDBSlowQueryFile, Value: "", skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.SlowQueryFile = val + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBScatterRegion, Value: BoolToOnOff(DefTiDBScatterRegion), Type: TypeBool}, + {Scope: ScopeSession, Name: TiDBWaitSplitRegionFinish, Value: BoolToOnOff(DefTiDBWaitSplitRegionFinish), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.WaitSplitRegionFinish = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBWaitSplitRegionTimeout, Value: strconv.Itoa(DefWaitSplitRegionTimeout), skipInit: true, Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { + s.WaitSplitRegionTimeout = uint64(tidbOptPositiveInt32(val, DefWaitSplitRegionTimeout)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBLowResolutionTSO, Value: Off, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.LowResolutionTSO = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBExpensiveQueryTimeThreshold, Value: strconv.Itoa(DefTiDBExpensiveQueryTimeThreshold), Type: TypeUnsigned, MinValue: int64(MinExpensiveQueryTimeThreshold), MaxValue: math.MaxInt32, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + atomic.StoreUint64(&ExpensiveQueryTimeThreshold, uint64(tidbOptPositiveInt32(val, DefTiDBExpensiveQueryTimeThreshold))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return fmt.Sprintf("%d", atomic.LoadUint64(&ExpensiveQueryTimeThreshold)), nil + }}, + {Scope: ScopeSession, Name: TiDBMemoryUsageAlarmRatio, Value: strconv.FormatFloat(config.GetGlobalConfig().Performance.MemoryUsageAlarmRatio, 'f', -1, 64), Type: TypeFloat, MinValue: 0.0, MaxValue: 1.0, skipInit: true, SetSession: func(s *SessionVars, val string) error { + MemoryUsageAlarmRatio.Store(tidbOptFloat64(val, 0.8)) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return fmt.Sprintf("%g", MemoryUsageAlarmRatio.Load()), nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableNoopFuncs, Value: BoolToOnOff(DefTiDBEnableNoopFuncs), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + + // The behavior is very weird if someone can turn TiDBEnableNoopFuncs OFF, but keep any of the following on: + // TxReadOnly, TransactionReadOnly, OfflineMode, SuperReadOnly, serverReadOnly + // To prevent this strange position, prevent setting to OFF when any of these sysVars are ON of the same scope. + + if normalizedValue == Off { + for _, potentialIncompatibleSysVar := range []string{TxReadOnly, TransactionReadOnly, OfflineMode, SuperReadOnly, ReadOnly} { + val, _ := vars.GetSystemVar(potentialIncompatibleSysVar) // session scope + if scope == ScopeGlobal { // global scope + var err error + val, err = vars.GlobalVarsAccessor.GetGlobalSysVar(potentialIncompatibleSysVar) + if err != nil { + return originalValue, errUnknownSystemVariable.GenWithStackByArgs(potentialIncompatibleSysVar) + } + } + if TiDBOptOn(val) { + return originalValue, errValueNotSupportedWhen.GenWithStackByArgs(TiDBEnableNoopFuncs, potentialIncompatibleSysVar) + } + } + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.EnableNoopFuncs = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeSession, Name: TiDBReplicaRead, Value: "leader", Type: TypeEnum, PossibleValues: []string{"leader", "follower", "leader-and-follower"}, skipInit: true, SetSession: func(s *SessionVars, val string) error { + if strings.EqualFold(val, "follower") { + s.SetReplicaRead(kv.ReplicaReadFollower) + } else if strings.EqualFold(val, "leader-and-follower") { + s.SetReplicaRead(kv.ReplicaReadMixed) + } else if strings.EqualFold(val, "leader") || len(val) == 0 { + s.SetReplicaRead(kv.ReplicaReadLeader) + } + return nil + }}, + {Scope: ScopeSession, Name: TiDBAllowRemoveAutoInc, Value: BoolToOnOff(DefTiDBAllowRemoveAutoInc), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.AllowRemoveAutoInc = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableStmtSummary, Value: BoolToOnOff(config.GetGlobalConfig().StmtSummary.Enable), skipInit: true, Type: TypeBool, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetEnabled(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetEnabled(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryInternalQuery, Value: BoolToOnOff(config.GetGlobalConfig().StmtSummary.EnableInternalQuery), skipInit: true, Type: TypeBool, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryRefreshInterval, Value: strconv.Itoa(config.GetGlobalConfig().StmtSummary.RefreshInterval), skipInit: true, Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryHistorySize, Value: strconv.Itoa(config.GetGlobalConfig().StmtSummary.HistorySize), skipInit: true, Type: TypeInt, MinValue: 0, MaxValue: math.MaxUint8, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetHistorySize(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetHistorySize(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryMaxStmtCount, Value: strconv.FormatUint(uint64(config.GetGlobalConfig().StmtSummary.MaxStmtCount), 10), skipInit: true, Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt16, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetMaxStmtCount(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetMaxStmtCount(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryMaxSQLLength, Value: strconv.FormatUint(uint64(config.GetGlobalConfig().StmtSummary.MaxSQLLength), 10), skipInit: true, Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt32, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetMaxSQLLength(val, true) + }, SetGlobal: func(s *SessionVars, val string) error { + return stmtsummary.StmtSummaryByDigestMap.SetMaxSQLLength(val, false) + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBCapturePlanBaseline, Value: Off, Type: TypeBool, AllowEmptyAll: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { + return CapturePlanBaseline.GetVal(), nil + }, SetSession: func(s *SessionVars, val string) error { + CapturePlanBaseline.Set(val, true) + return nil + }, SetGlobal: func(s *SessionVars, val string) error { + CapturePlanBaseline.Set(val, false) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBUsePlanBaselines, Value: BoolToOnOff(DefTiDBUsePlanBaselines), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.UsePlanBaselines = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEvolvePlanBaselines, Value: BoolToOnOff(DefTiDBEvolvePlanBaselines), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EvolvePlanBaselines = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableExtendedStats, Value: BoolToOnOff(false), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableExtendedStats = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskMaxTime, Value: strconv.Itoa(DefTiDBEvolvePlanTaskMaxTime), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64}, + {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskStartTime, Value: DefTiDBEvolvePlanTaskStartTime, Type: TypeTime}, + {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskEndTime, Value: DefTiDBEvolvePlanTaskEndTime, Type: TypeTime}, + {Scope: ScopeSession, Name: TiDBIsolationReadEngines, Value: strings.Join(config.GetGlobalConfig().IsolationRead.Engines, ","), Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + engines := strings.Split(normalizedValue, ",") + var formatVal string + for i, engine := range engines { + engine = strings.TrimSpace(engine) + if i != 0 { + formatVal += "," + } + switch { + case strings.EqualFold(engine, kv.TiKV.Name()): + formatVal += kv.TiKV.Name() + case strings.EqualFold(engine, kv.TiFlash.Name()): + formatVal += kv.TiFlash.Name() + case strings.EqualFold(engine, kv.TiDB.Name()): + formatVal += kv.TiDB.Name() + default: + return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(TiDBIsolationReadEngines, normalizedValue) + } + } + return formatVal, nil + }, SetSession: func(s *SessionVars, val string) error { + s.IsolationReadEngines = make(map[kv.StoreType]struct{}) + for _, engine := range strings.Split(val, ",") { + switch engine { + case kv.TiKV.Name(): + s.IsolationReadEngines[kv.TiKV] = struct{}{} + case kv.TiFlash.Name(): + s.IsolationReadEngines[kv.TiFlash] = struct{}{} + case kv.TiDB.Name(): + s.IsolationReadEngines[kv.TiDB] = struct{}{} + } + } + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBStoreLimit, Value: strconv.FormatInt(atomic.LoadInt64(&config.GetGlobalConfig().TiKVClient.StoreLimit), 10), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + tikvstore.StoreLimit.Store(tidbOptInt64(val, DefTiDBStoreLimit)) + return nil + }}, + {Scope: ScopeSession, Name: TiDBMetricSchemaStep, Value: strconv.Itoa(DefTiDBMetricSchemaStep), Type: TypeUnsigned, skipInit: true, MinValue: 10, MaxValue: 60 * 60 * 60, SetSession: func(s *SessionVars, val string) error { + s.MetricSchemaStep = tidbOptInt64(val, DefTiDBMetricSchemaStep) + return nil + }}, + {Scope: ScopeSession, Name: TiDBMetricSchemaRangeDuration, Value: strconv.Itoa(DefTiDBMetricSchemaRangeDuration), skipInit: true, Type: TypeUnsigned, MinValue: 10, MaxValue: 60 * 60 * 60, SetSession: func(s *SessionVars, val string) error { + s.MetricSchemaRangeDuration = tidbOptInt64(val, DefTiDBMetricSchemaRangeDuration) + return nil + }}, + {Scope: ScopeSession, Name: TiDBSlowLogThreshold, Value: strconv.Itoa(logutil.DefaultSlowThreshold), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { + atomic.StoreUint64(&config.GetGlobalConfig().Log.SlowThreshold, uint64(tidbOptInt64(val, logutil.DefaultSlowThreshold))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatUint(atomic.LoadUint64(&config.GetGlobalConfig().Log.SlowThreshold), 10), nil + }}, + {Scope: ScopeSession, Name: TiDBRecordPlanInSlowLog, Value: int32ToBoolStr(logutil.DefaultRecordPlanInSlowLog), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + atomic.StoreUint32(&config.GetGlobalConfig().Log.RecordPlanInSlowLog, uint32(tidbOptInt64(val, logutil.DefaultRecordPlanInSlowLog))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatUint(uint64(atomic.LoadUint32(&config.GetGlobalConfig().Log.RecordPlanInSlowLog)), 10), nil + }}, + {Scope: ScopeSession, Name: TiDBEnableSlowLog, Value: BoolToOnOff(logutil.DefaultTiDBEnableSlowLog), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { + config.GetGlobalConfig().Log.EnableSlowLog = TiDBOptOn(val) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(config.GetGlobalConfig().Log.EnableSlowLog), nil + }}, + {Scope: ScopeSession, Name: TiDBQueryLogMaxLen, Value: strconv.Itoa(logutil.DefaultQueryLogMaxLen), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, skipInit: true, SetSession: func(s *SessionVars, val string) error { + atomic.StoreUint64(&config.GetGlobalConfig().Log.QueryLogMaxLen, uint64(tidbOptInt64(val, logutil.DefaultQueryLogMaxLen))) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatUint(atomic.LoadUint64(&config.GetGlobalConfig().Log.QueryLogMaxLen), 10), nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: CTEMaxRecursionDepth, Value: strconv.Itoa(DefCTEMaxRecursionDepth), Type: TypeInt, MinValue: 0, MaxValue: 4294967295, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + s.CTEMaxRecursionDepth = tidbOptInt(val, DefCTEMaxRecursionDepth) + return nil + }}, + {Scope: ScopeSession, Name: TiDBCheckMb4ValueInUTF8, Value: BoolToOnOff(config.GetGlobalConfig().CheckMb4ValueInUTF8), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + config.GetGlobalConfig().CheckMb4ValueInUTF8 = TiDBOptOn(val) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(config.GetGlobalConfig().CheckMb4ValueInUTF8), nil + }}, + {Scope: ScopeSession, Name: TiDBFoundInPlanCache, Value: BoolToOnOff(DefTiDBFoundInPlanCache), Type: TypeBool, ReadOnly: true, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.FoundInPlanCache = TiDBOptOn(val) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(s.PrevFoundInPlanCache), nil + }}, + {Scope: ScopeSession, Name: TiDBFoundInBinding, Value: BoolToOnOff(DefTiDBFoundInBinding), Type: TypeBool, ReadOnly: true, skipInit: true, SetSession: func(s *SessionVars, val string) error { + s.FoundInBinding = TiDBOptOn(val) + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(s.PrevFoundInBinding), nil + }}, + {Scope: ScopeSession, Name: TiDBEnableCollectExecutionInfo, Value: BoolToOnOff(DefTiDBEnableCollectExecutionInfo), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + oldConfig := config.GetGlobalConfig() + newValue := TiDBOptOn(val) + if oldConfig.EnableCollectExecutionInfo != newValue { + newConfig := *oldConfig + newConfig.EnableCollectExecutionInfo = newValue + config.StoreGlobalConfig(&newConfig) + } + return nil + }, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(config.GetGlobalConfig().EnableCollectExecutionInfo), nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowAutoRandExplicitInsert, Value: BoolToOnOff(DefTiDBAllowAutoRandExplicitInsert), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.AllowAutoRandExplicitInsert = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableClusteredIndex, Value: IntOnly, Type: TypeEnum, PossibleValues: []string{Off, On, IntOnly}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == IntOnly { + vars.StmtCtx.AppendWarning(errWarnDeprecatedSyntax.FastGenByArgs(normalizedValue, fmt.Sprintf("'%s' or '%s'", On, Off))) + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.EnableClusteredIndex = TiDBOptEnableClustered(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBPartitionPruneMode, Value: DefTiDBPartitionPruneMode, Hidden: true, Type: TypeStr, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + mode := PartitionPruneMode(normalizedValue).Update() + if !mode.Valid() { + return normalizedValue, ErrWrongTypeForVar.GenWithStackByArgs(TiDBPartitionPruneMode) + } + return string(mode), nil + }, SetSession: func(s *SessionVars, val string) error { + s.PartitionPruneMode.Store(strings.ToLower(strings.TrimSpace(val))) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBSlowLogMasking, Value: BoolToOnOff(DefTiDBRedactLog), Aliases: []string{TiDBRedactLog}, skipInit: true, Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + appendDeprecationWarning(vars, TiDBSlowLogMasking, TiDBRedactLog) + return normalizedValue, nil + }, GetSession: func(s *SessionVars) (string, error) { + return s.systems[TiDBRedactLog], nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBRedactLog, Value: BoolToOnOff(DefTiDBRedactLog), Aliases: []string{TiDBSlowLogMasking}, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableRedactLog = TiDBOptOn(val) + errors.RedactLogEnabled.Store(s.EnableRedactLog) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBShardAllocateStep, Value: strconv.Itoa(DefTiDBShardAllocateStep), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { + s.ShardAllocateStep = tidbOptInt64(val, DefTiDBShardAllocateStep) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBEnableTelemetry, Value: BoolToOnOff(DefTiDBEnableTelemetry), Type: TypeBool}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableAmendPessimisticTxn, Value: BoolToOnOff(DefTiDBEnableAmendPessimisticTxn), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableAmendPessimisticTxn = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableAsyncCommit, Value: BoolToOnOff(DefTiDBEnableAsyncCommit), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableAsyncCommit = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnable1PC, Value: BoolToOnOff(DefTiDBEnable1PC), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.Enable1PC = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBGuaranteeLinearizability, Value: BoolToOnOff(DefTiDBGuaranteeLinearizability), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.GuaranteeLinearizability = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBAnalyzeVersion, Value: strconv.Itoa(DefTiDBAnalyzeVersion), Hidden: false, Type: TypeInt, MinValue: 1, MaxValue: 2, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { + if normalizedValue == "2" && FeedbackProbability != nil && FeedbackProbability.Load() > 0 { + var original string + var err error + if scope == ScopeGlobal { + original, err = vars.GlobalVarsAccessor.GetGlobalSysVar(TiDBAnalyzeVersion) + if err != nil { + return normalizedValue, nil + } + } else { + original = strconv.Itoa(vars.AnalyzeVersion) + } + vars.StmtCtx.AppendError(errors.New("variable tidb_analyze_version not updated because analyze version 2 is incompatible with query feedback. Please consider setting feedback-probability to 0.0 in config file to disable query feedback")) + return original, nil + } + return normalizedValue, nil + }, SetSession: func(s *SessionVars, val string) error { + s.AnalyzeVersion = tidbOptPositiveInt32(val, DefTiDBAnalyzeVersion) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableIndexMergeJoin, Value: BoolToOnOff(DefTiDBEnableIndexMergeJoin), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableIndexMergeJoin = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBTrackAggregateMemoryUsage, Value: BoolToOnOff(DefTiDBTrackAggregateMemoryUsage), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.TrackAggregateMemoryUsage = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBMultiStatementMode, Value: Off, Type: TypeEnum, PossibleValues: []string{Off, On, Warn}, SetSession: func(s *SessionVars, val string) error { + s.MultiStatementMode = TiDBOptMultiStmt(val) + return nil + }}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableExchangePartition, Value: BoolToOnOff(DefTiDBEnableExchangePartition), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.TiDBEnableExchangePartition = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeNone, Name: TiDBEnableEnhancedSecurity, Value: Off, Type: TypeBool}, + {Scope: ScopeSession, Name: PluginLoad, Value: "", GetSession: func(s *SessionVars) (string, error) { + return config.GetGlobalConfig().Plugin.Dir, nil + }}, + {Scope: ScopeSession, Name: PluginDir, Value: "/data/deploy/plugin", GetSession: func(s *SessionVars) (string, error) { + return config.GetGlobalConfig().Plugin.Load, nil + }}, + + /* tikv gc metrics */ + {Scope: ScopeGlobal, Name: TiDBGCEnable, Value: On, Type: TypeBool}, + {Scope: ScopeGlobal, Name: TiDBGCRunInterval, Value: "10m0s", Type: TypeDuration, MinValue: int64(time.Minute * 10), MaxValue: uint64(time.Hour * 24 * 365)}, + {Scope: ScopeGlobal, Name: TiDBGCLifetime, Value: "10m0s", Type: TypeDuration, MinValue: int64(time.Minute * 10), MaxValue: uint64(time.Hour * 24 * 365)}, + {Scope: ScopeGlobal, Name: TiDBGCConcurrency, Value: "-1", Type: TypeInt, MinValue: 1, MaxValue: 128, AllowAutoValue: true}, + {Scope: ScopeGlobal, Name: TiDBGCScanLockMode, Value: "PHYSICAL", Type: TypeEnum, PossibleValues: []string{"PHYSICAL", "LEGACY"}}, + {Scope: ScopeGlobal, Name: TiDBGCScanLockMode, Value: "LEGACY", Type: TypeEnum, PossibleValues: []string{"PHYSICAL", "LEGACY"}}, + + // See https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmp_table_size + {Scope: ScopeGlobal | ScopeSession, Name: TMPTableSize, Value: strconv.Itoa(DefTMPTableSize), Type: TypeUnsigned, MinValue: 1024, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, IsHintUpdatable: true, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { + s.TMPTableSize = tidbOptInt64(val, DefTMPTableSize) + return nil + }}, + // variable for top SQL feature. + {Scope: ScopeGlobal, Name: TiDBEnableTopSQL, Value: BoolToOnOff(DefTiDBTopSQLEnable), Type: TypeBool, Hidden: true, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return BoolToOnOff(TopSQLVariable.Enable.Load()), nil + }, SetGlobal: func(vars *SessionVars, s string) error { + TopSQLVariable.Enable.Store(TiDBOptOn(s)) + return nil + }}, + // TODO(crazycs520): Add validation + {Scope: ScopeSession, Name: TiDBTopSQLAgentAddress, Value: DefTiDBTopSQLAgentAddress, Type: TypeStr, Hidden: true, skipInit: true, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return TopSQLVariable.AgentAddress.Load(), nil + }, SetSession: func(vars *SessionVars, s string) error { + TopSQLVariable.AgentAddress.Store(s) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBTopSQLPrecisionSeconds, Value: strconv.Itoa(DefTiDBTopSQLPrecisionSeconds), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: math.MaxInt64, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatInt(TopSQLVariable.PrecisionSeconds.Load(), 10), nil + }, SetGlobal: func(vars *SessionVars, s string) error { + val, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + TopSQLVariable.PrecisionSeconds.Store(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBTopSQLMaxStatementCount, Value: strconv.Itoa(DefTiDBTopSQLMaxStatementCount), Type: TypeInt, Hidden: true, MinValue: 0, MaxValue: 5000, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatInt(TopSQLVariable.MaxStatementCount.Load(), 10), nil + }, SetGlobal: func(vars *SessionVars, s string) error { + val, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + TopSQLVariable.MaxStatementCount.Store(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBTopSQLMaxCollect, Value: strconv.Itoa(DefTiDBTopSQLMaxCollect), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: 500000, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatInt(TopSQLVariable.MaxCollect.Load(), 10), nil + }, SetGlobal: func(vars *SessionVars, s string) error { + val, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + TopSQLVariable.MaxCollect.Store(val) + return nil + }}, + {Scope: ScopeGlobal, Name: TiDBTopSQLReportIntervalSeconds, Value: strconv.Itoa(DefTiDBTopSQLReportIntervalSeconds), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: 1 * 60 * 60, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { + return strconv.FormatInt(TopSQLVariable.ReportIntervalSeconds.Load(), 10), nil + }, SetGlobal: func(vars *SessionVars, s string) error { + val, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + TopSQLVariable.ReportIntervalSeconds.Store(val) + return nil + }}, + + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableGlobalTemporaryTable, Value: BoolToOnOff(DefTiDBEnableGlobalTemporaryTable), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableGlobalTemporaryTable = TiDBOptOn(val) + return nil + }}, + {Scope: ScopeGlobal, Name: SkipNameResolve, Value: Off, Type: TypeBool}, + {Scope: ScopeGlobal, Name: DefaultAuthPlugin, Value: mysql.AuthNativePassword, Type: TypeEnum, PossibleValues: []string{mysql.AuthNativePassword, mysql.AuthCachingSha2Password}}, + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableOrderedResultMode, Value: BoolToOnOff(DefTiDBEnableOrderedResultMode), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + s.EnableStableResultMode = TiDBOptOn(val) + return nil + }}, +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) } // SetNamesVariables is the system variable names related to set names statements. diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index dbc6d524d3cb2..767517899d48a 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -436,8 +436,8 @@ const ( // TiDBMemoryUsageAlarmRatio indicates the alarm threshold when memory usage of the tidb-server exceeds. TiDBMemoryUsageAlarmRatio = "tidb_memory_usage_alarm_ratio" - // TiDBEnableStableResultMode indicates if stabilize query results. - TiDBEnableStableResultMode = "tidb_enable_stable_result_mode" + // TiDBEnableOrderedResultMode indicates if stabilize query results. + TiDBEnableOrderedResultMode = "tidb_enable_ordered_result_mode" ) // Default TiDB system variable values. @@ -541,7 +541,28 @@ const ( DefTiDBEnableTelemetry = true DefTiDBEnableAmendPessimisticTxn = false DefTiDBEnableRateLimitAction = true +<<<<<<< HEAD DefTiDBEnableStableResultMode = false +======= + DefTiDBEnableAsyncCommit = false + DefTiDBEnable1PC = false + DefTiDBGuaranteeLinearizability = true + DefTiDBAnalyzeVersion = 2 + DefTiDBEnableIndexMergeJoin = false + DefTiDBTrackAggregateMemoryUsage = true + DefTiDBEnableExchangePartition = false + DefCTEMaxRecursionDepth = 1000 + DefTiDBTopSQLEnable = false + DefTiDBTopSQLAgentAddress = "" + DefTiDBTopSQLPrecisionSeconds = 1 + DefTiDBTopSQLMaxStatementCount = 200 + DefTiDBTopSQLMaxCollect = 10000 + DefTiDBTopSQLReportIntervalSeconds = 60 + DefTiDBEnableGlobalTemporaryTable = false + DefTMPTableSize = 16777216 + DefTiDBEnableLocalTxn = false + DefTiDBEnableOrderedResultMode = false +>>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) ) // Process global variables. From 7c8fb658445157b77c55a8195b55d5ebc8fab274 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 12 Jul 2021 20:58:42 +0800 Subject: [PATCH 2/4] fix conflicts --- executor/set_test.go | 114 --- planner/core/rule_result_reorder.go | 4 - planner/core/rule_result_reorder_test.go | 46 +- sessionctx/variable/sysvar.go | 1157 ---------------------- sessionctx/variable/tidb_vars.go | 21 - 5 files changed, 1 insertion(+), 1341 deletions(-) diff --git a/executor/set_test.go b/executor/set_test.go index bc8e3b18e632a..cb7830373dc9c 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -429,119 +429,6 @@ func (s *testSuite5) TestSetVar(c *C) { tk.MustExec("set session tidb_slow_log_masking = 1") tk.MustQuery(`select @@session.tidb_slow_log_masking;`).Check(testkit.Rows("1")) -<<<<<<< HEAD - // test for tidb_enable_stable_result_mode - tk.MustQuery(`select @@tidb_enable_stable_result_mode`).Check(testkit.Rows("0")) - tk.MustExec(`set global tidb_enable_stable_result_mode = 1`) - tk.MustQuery(`select @@global.tidb_enable_stable_result_mode`).Check(testkit.Rows("1")) - tk.MustExec(`set global tidb_enable_stable_result_mode = 0`) - tk.MustQuery(`select @@global.tidb_enable_stable_result_mode`).Check(testkit.Rows("0")) - tk.MustExec(`set tidb_enable_stable_result_mode=1`) - tk.MustQuery(`select @@global.tidb_enable_stable_result_mode`).Check(testkit.Rows("0")) - tk.MustQuery(`select @@tidb_enable_stable_result_mode`).Check(testkit.Rows("1")) -======= - tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("0")) - tk.MustExec("set @@session.tidb_dml_batch_size = 120") - tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("120")) - c.Assert(tk.ExecToErr("set @@session.tidb_dml_batch_size = -120"), NotNil) - c.Assert(tk.ExecToErr("set @@global.tidb_dml_batch_size = 200"), IsNil) // now permitted due to TiDB #19809 - tk.MustQuery("select @@tidb_dml_batch_size;").Check(testkit.Rows("120")) // global only applies to new sessions - - _, err = tk.Exec("set tidb_enable_parallel_apply=-1") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) - - // test for tidb_mem_quota_apply_cache - defVal := fmt.Sprintf("%v", variable.DefTiDBMemQuotaApplyCache) - tk.MustQuery(`select @@tidb_mem_quota_apply_cache`).Check(testkit.Rows(defVal)) - tk.MustExec(`set global tidb_mem_quota_apply_cache = 1`) - tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("1")) - tk.MustExec(`set global tidb_mem_quota_apply_cache = 0`) - tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("0")) - tk.MustExec(`set tidb_mem_quota_apply_cache = 123`) - tk.MustQuery(`select @@global.tidb_mem_quota_apply_cache`).Check(testkit.Rows("0")) - tk.MustQuery(`select @@tidb_mem_quota_apply_cache`).Check(testkit.Rows("123")) - - // test for tidb_enable_parallel_apply - tk.MustQuery(`select @@tidb_enable_parallel_apply`).Check(testkit.Rows("0")) - tk.MustExec(`set global tidb_enable_parallel_apply = 1`) - tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("1")) - tk.MustExec(`set global tidb_enable_parallel_apply = 0`) - tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("0")) - tk.MustExec(`set tidb_enable_parallel_apply=1`) - tk.MustQuery(`select @@global.tidb_enable_parallel_apply`).Check(testkit.Rows("0")) - tk.MustQuery(`select @@tidb_enable_parallel_apply`).Check(testkit.Rows("1")) - - tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) - tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) - tk.MustExec("set tidb_general_log = 1") - tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("1")) - tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log ON")) - tk.MustExec("set tidb_general_log = 0") - tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) - tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) - tk.MustExec("set tidb_general_log = on") - tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("1")) - tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log ON")) - tk.MustExec("set tidb_general_log = off") - tk.MustQuery(`select @@session.tidb_general_log;`).Check(testkit.Rows("0")) - tk.MustQuery(`show variables like 'tidb_general_log';`).Check(testkit.Rows("tidb_general_log OFF")) - c.Assert(tk.ExecToErr("set tidb_general_log = abc"), NotNil) - c.Assert(tk.ExecToErr("set tidb_general_log = 123"), NotNil) - - tk.MustExec(`SET @@character_set_results = NULL;`) - tk.MustQuery(`select @@character_set_results;`).Check(testkit.Rows("")) - - varList := []string{"character_set_server", "character_set_client", "character_set_filesystem", "character_set_database"} - for _, v := range varList { - tk.MustGetErrCode(fmt.Sprintf("SET @@global.%s = @global_start_value;", v), mysql.ErrWrongValueForVar) - tk.MustGetErrCode(fmt.Sprintf("SET @@%s = @global_start_value;", v), mysql.ErrWrongValueForVar) - tk.MustGetErrCode(fmt.Sprintf("SET @@%s = NULL;", v), mysql.ErrWrongValueForVar) - tk.MustGetErrCode(fmt.Sprintf("SET @@%s = \"\";", v), mysql.ErrWrongValueForVar) - tk.MustGetErrMsg(fmt.Sprintf("SET @@%s = \"somecharset\";", v), "Unknown charset somecharset") - // we do not support set character_set_xxx or collation_xxx to a collation id. - tk.MustGetErrMsg(fmt.Sprintf("SET @@global.%s = 46;", v), "Unknown charset 46") - tk.MustGetErrMsg(fmt.Sprintf("SET @@%s = 46;", v), "Unknown charset 46") - } - - tk.MustExec("SET SESSION tidb_enable_extended_stats = on") - tk.MustQuery("select @@session.tidb_enable_extended_stats").Check(testkit.Rows("1")) - tk.MustExec("SET SESSION tidb_enable_extended_stats = off") - tk.MustQuery("select @@session.tidb_enable_extended_stats").Check(testkit.Rows("0")) - tk.MustExec("SET GLOBAL tidb_enable_extended_stats = on") - tk.MustQuery("select @@global.tidb_enable_extended_stats").Check(testkit.Rows("1")) - tk.MustExec("SET GLOBAL tidb_enable_extended_stats = off") - tk.MustQuery("select @@global.tidb_enable_extended_stats").Check(testkit.Rows("0")) - - tk.MustExec("SET SESSION tidb_allow_fallback_to_tikv = 'tiflash'") - tk.MustQuery("select @@session.tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) - tk.MustExec("SET SESSION tidb_allow_fallback_to_tikv = ''") - tk.MustQuery("select @@session.tidb_allow_fallback_to_tikv").Check(testkit.Rows("")) - tk.MustExec("SET GLOBAL tidb_allow_fallback_to_tikv = 'tiflash'") - tk.MustQuery("select @@global.tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) - tk.MustExec("SET GLOBAL tidb_allow_fallback_to_tikv = ''") - tk.MustQuery("select @@global.tidb_allow_fallback_to_tikv").Check(testkit.Rows("")) - tk.MustExec("set @@tidb_allow_fallback_to_tikv = 'tiflash, tiflash, tiflash'") - tk.MustQuery("select @@tidb_allow_fallback_to_tikv").Check(testkit.Rows("tiflash")) - - tk.MustGetErrMsg("SET SESSION tidb_allow_fallback_to_tikv = 'tikv,tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tikv,tiflash'") - tk.MustGetErrMsg("SET GLOBAL tidb_allow_fallback_to_tikv = 'tikv,tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tikv,tiflash'") - tk.MustGetErrMsg("set @@tidb_allow_fallback_to_tikv = 'tidb, tiflash, tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'tidb, tiflash, tiflash'") - tk.MustGetErrMsg("set @@tidb_allow_fallback_to_tikv = 'unknown, tiflash, tiflash'", "[variable:1231]Variable 'tidb_allow_fallback_to_tikv' can't be set to the value of 'unknown, tiflash, tiflash'") - - // Test issue #22145 - tk.MustExec(`set global sync_relay_log = "'"`) - - tk.MustExec(`set @@global.tidb_enable_clustered_index = 'int_only'`) - tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1287 'INT_ONLY' is deprecated and will be removed in a future release. Please use 'ON' or 'OFF' instead")) - tk.MustExec(`set @@global.tidb_enable_clustered_index = 'off'`) - tk.MustQuery(`show warnings`).Check(testkit.Rows()) - tk.MustExec("set @@tidb_enable_clustered_index = 'off'") - tk.MustQuery(`show warnings`).Check(testkit.Rows()) - tk.MustExec("set @@tidb_enable_clustered_index = 'on'") - tk.MustQuery(`show warnings`).Check(testkit.Rows()) - tk.MustExec("set @@tidb_enable_clustered_index = 'int_only'") - tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1287 'INT_ONLY' is deprecated and will be removed in a future release. Please use 'ON' or 'OFF' instead")) - // test for tidb_enable_ordered_result_mode tk.MustQuery(`select @@tidb_enable_ordered_result_mode`).Check(testkit.Rows("0")) tk.MustExec(`set global tidb_enable_ordered_result_mode = 1`) @@ -551,7 +438,6 @@ func (s *testSuite5) TestSetVar(c *C) { tk.MustExec(`set tidb_enable_ordered_result_mode=1`) tk.MustQuery(`select @@global.tidb_enable_ordered_result_mode`).Check(testkit.Rows("0")) tk.MustQuery(`select @@tidb_enable_ordered_result_mode`).Check(testkit.Rows("1")) ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) } func (s *testSuite5) TestTruncateIncorrectIntSessionVar(c *C) { diff --git a/planner/core/rule_result_reorder.go b/planner/core/rule_result_reorder.go index abbcb65fb4af4..ba51576ed85c9 100644 --- a/planner/core/rule_result_reorder.go +++ b/planner/core/rule_result_reorder.go @@ -23,12 +23,8 @@ import ( /* resultReorder reorder query results. NOTE: it's not a common rule for all queries, it's specially implemented for a few customers. -<<<<<<< HEAD:planner/core/rule_stabilize_results.go - Results of some queries are not stable, for example: -======= Results of some queries are not ordered, for example: ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder.go create table t (a int); insert into t values (1), (2); select a from t; In the case above, the result can be `1 2` or `2 1`, which is not ordered. This rule reorders results by modifying or injecting a Sort operator: diff --git a/planner/core/rule_result_reorder_test.go b/planner/core/rule_result_reorder_test.go index 12648ada7fc6e..8a092e2b32467 100644 --- a/planner/core/rule_result_reorder_test.go +++ b/planner/core/rule_result_reorder_test.go @@ -14,8 +14,6 @@ package core_test import ( - "math" - . "github.com/pingcap/check" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" @@ -24,6 +22,7 @@ import ( "github.com/pingcap/tidb/util/kvcache" "github.com/pingcap/tidb/util/testkit" "github.com/pingcap/tidb/util/testutil" + "math" ) var _ = Suite(&testRuleReorderResults{}) @@ -79,36 +78,12 @@ func (s *testRuleReorderResultsSerial) TestSQLBinding(c *C) { tk.MustExec("create session binding for select * from t where a>0 limit 1 using select * from t use index(b) where a>0 limit 1") tk.MustQuery("explain select * from t where a > 0 limit 1").Check(testkit.Rows( -<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go "TopN_9 1.00 root test.t.a:asc, offset:0, count:1", "└─IndexLookUp_18 1.00 root ", " ├─TopN_17(Build) 1.00 cop[tikv] test.t.a:asc, offset:0, count:1", " │ └─Selection_16 3333.33 cop[tikv] gt(test.t.a, 0)", " │ └─IndexFullScan_14 10000.00 cop[tikv] table:t, index:b(b) keep order:false, stats:pseudo", " └─TableRowIDScan_15(Probe) 1.00 cop[tikv] table:t keep order:false, stats:pseudo")) -======= - "TopN_9 1.00 root test.t.a, offset:0, count:1", - "└─IndexLookUp_19 1.00 root ", - " ├─TopN_18(Build) 1.00 cop[tikv] test.t.a, offset:0, count:1", - " │ └─Selection_17 3333.33 cop[tikv] gt(test.t.a, 0)", - " │ └─IndexFullScan_15 10000.00 cop[tikv] table:t, index:b(b) keep order:false, stats:pseudo", - " └─TableRowIDScan_16(Probe) 1.00 cop[tikv] table:t keep order:false, stats:pseudo")) -} - -func (s *testRuleReorderResultsSerial) TestClusteredIndex(c *C) { - tk := testkit.NewTestKit(c, s.store) - tk.MustExec("use test") - tk.MustExec("set tidb_enable_ordered_result_mode=1") - tk.Se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOn - tk.MustExec("drop table if exists t") - tk.MustExec("CREATE TABLE t (a int,b int,c int, PRIMARY KEY (a,b))") - tk.MustQuery("explain select * from t limit 10").Check(testkit.Rows( - "TopN_7 10.00 root test.t.a, test.t.b, test.t.c, offset:0, count:10", - "└─TableReader_16 10.00 root data:TopN_15", - " └─TopN_15 10.00 cop[tikv] test.t.a, test.t.b, test.t.c, offset:0, count:10", - " └─TableFullScan_14 10000.00 cop[tikv] table:t keep order:false, stats:pseudo")) - tk.Se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOff ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go } type testRuleReorderResults struct { @@ -200,12 +175,7 @@ func (s *testRuleReorderResults) TestOrderedResultModeOnOtherOperators(c *C) { func (s *testRuleReorderResults) TestOrderedResultModeOnPartitionTable(c *C) { tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") -<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go - tk.MustExec("set tidb_enable_stable_result_mode=1") -======= - tk.MustExec(fmt.Sprintf(`set tidb_partition_prune_mode='%v'`, variable.DefTiDBPartitionPruneMode)) tk.MustExec("set tidb_enable_ordered_result_mode=1") ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go tk.MustExec("drop table if exists thash") tk.MustExec("drop table if exists trange") tk.MustExec("create table thash (a int primary key, b int, c int, d int) partition by hash(a) partitions 4") @@ -214,20 +184,6 @@ func (s *testRuleReorderResults) TestOrderedResultModeOnPartitionTable(c *C) { partition p1 values less than (200), partition p2 values less than (300), partition p3 values less than (400))`) -<<<<<<< HEAD:planner/core/rule_stabilize_results_test.go - s.runTestData(c, tk, "TestStableResultModeOnPartitionTable") -} -======= tk.MustQuery("select @@tidb_partition_prune_mode").Check(testkit.Rows("static")) s.runTestData(c, tk, "TestOrderedResultModeOnPartitionTable") } - -func (s *testRuleReorderResults) TestHideStableResultSwitch(c *C) { - tk := testkit.NewTestKit(c, s.store) - rs := tk.MustQuery("show variables").Rows() - for _, r := range rs { - c.Assert(strings.ToLower(r[0].(string)), Not(Equals), "tidb_enable_ordered_result_mode") - } - c.Assert(len(tk.MustQuery("show variables where variable_name like '%tidb_enable_ordered_result_mode%'").Rows()), Equals, 0) -} ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093):planner/core/rule_result_reorder_test.go diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 260439412c8e4..5fcb5e6bf5979 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -756,1166 +756,9 @@ func addSynonymsSysVariables(synonyms ...string) { } } -<<<<<<< HEAD func initSynonymsSysVariables() { addSynonymsSysVariables(TxnIsolation, TransactionIsolation) addSynonymsSysVariables(TxReadOnly, TransactionReadOnly) -======= -var defaultSysVars = []*SysVar{ - {Scope: ScopeGlobal, Name: MaxConnections, Value: "151", Type: TypeUnsigned, MinValue: 1, MaxValue: 100000, AutoConvertOutOfRange: true}, - {Scope: ScopeGlobal | ScopeSession, Name: SQLSelectLimit, Value: "18446744073709551615", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxUint64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - result, err := strconv.ParseUint(val, 10, 64) - if err != nil { - return errors.Trace(err) - } - s.SelectLimit = result - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: DefaultWeekFormat, Value: "0", Type: TypeUnsigned, MinValue: 0, MaxValue: 7, AutoConvertOutOfRange: true}, - {Scope: ScopeGlobal | ScopeSession, Name: SQLModeVar, Value: mysql.DefaultSQLMode, IsHintUpdatable: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - // Ensure the SQL mode parses - normalizedValue = mysql.FormatSQLModeStr(normalizedValue) - if _, err := mysql.GetSQLMode(normalizedValue); err != nil { - return originalValue, err - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - val = mysql.FormatSQLModeStr(val) - // Modes is a list of different modes separated by commas. - sqlMode, err := mysql.GetSQLMode(val) - if err != nil { - return errors.Trace(err) - } - s.StrictSQLMode = sqlMode.HasStrictMode() - s.SQLMode = sqlMode - s.SetStatusFlag(mysql.ServerStatusNoBackslashEscaped, sqlMode.HasNoBackslashEscapesMode()) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: MaxExecutionTime, Value: "0", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, AutoConvertOutOfRange: true, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { - timeoutMS := tidbOptPositiveInt32(val, 0) - s.MaxExecutionTime = uint64(timeoutMS) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CollationServer, Value: mysql.DefaultCollationName, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCollation(vars, normalizedValue, originalValue, scope) - }, SetSession: func(s *SessionVars, val string) error { - if coll, err := collate.GetCollationByName(val); err == nil { - s.systems[CharacterSetServer] = coll.CharsetName - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: SQLLogBin, Value: On, Type: TypeBool, skipInit: true}, - {Scope: ScopeGlobal | ScopeSession, Name: TimeZone, Value: "SYSTEM", IsHintUpdatable: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if strings.EqualFold(normalizedValue, "SYSTEM") { - return "SYSTEM", nil - } - _, err := parseTimeZone(normalizedValue) - return normalizedValue, err - }, SetSession: func(s *SessionVars, val string) error { - tz, err := parseTimeZone(val) - if err != nil { - return err - } - s.TimeZone = tz - return nil - }}, - {Scope: ScopeNone, Name: SystemTimeZone, Value: "CST"}, - {Scope: ScopeGlobal | ScopeSession, Name: ForeignKeyChecks, Value: Off, Type: TypeBool, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if TiDBOptOn(normalizedValue) { - // TiDB does not yet support foreign keys. - // Return the original value in the warning, so that users are not confused. - vars.StmtCtx.AppendWarning(ErrUnsupportedValueForVar.GenWithStackByArgs(ForeignKeyChecks, originalValue)) - return Off, nil - } else if !TiDBOptOn(normalizedValue) { - return Off, nil - } - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(ForeignKeyChecks, originalValue) - }}, - {Scope: ScopeNone, Name: Hostname, Value: DefHostname}, - {Scope: ScopeSession, Name: Timestamp, Value: "", skipInit: true}, - {Scope: ScopeGlobal | ScopeSession, Name: CollationDatabase, Value: mysql.DefaultCollationName, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCollation(vars, normalizedValue, originalValue, scope) - }, SetSession: func(s *SessionVars, val string) error { - if coll, err := collate.GetCollationByName(val); err == nil { - s.systems[CharsetDatabase] = coll.CharsetName - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: AutoIncrementIncrement, Value: strconv.FormatInt(DefAutoIncrementIncrement, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxUint16, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - // AutoIncrementIncrement is valid in [1, 65535]. - s.AutoIncrementIncrement = tidbOptPositiveInt32(val, DefAutoIncrementIncrement) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: AutoIncrementOffset, Value: strconv.FormatInt(DefAutoIncrementOffset, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxUint16, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - // AutoIncrementOffset is valid in [1, 65535]. - s.AutoIncrementOffset = tidbOptPositiveInt32(val, DefAutoIncrementOffset) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetClient, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCharacterSet(normalizedValue, CharacterSetClient) - }}, - {Scope: ScopeNone, Name: Port, Value: "4000", Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxUint16}, - {Scope: ScopeNone, Name: LowerCaseTableNames, Value: "2"}, - {Scope: ScopeNone, Name: LogBin, Value: Off, Type: TypeBool}, - {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetResults, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if normalizedValue == "" { - return normalizedValue, nil - } - return checkCharacterSet(normalizedValue, "") - }}, - {Scope: ScopeNone, Name: VersionComment, Value: "TiDB Server (Apache License 2.0) " + versioninfo.TiDBEdition + " Edition, MySQL 5.7 compatible"}, - {Scope: ScopeGlobal | ScopeSession, Name: TxnIsolation, Value: "REPEATABLE-READ", Type: TypeEnum, Aliases: []string{TransactionIsolation}, PossibleValues: []string{"READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - // MySQL appends a warning here for tx_isolation is deprecated - // TiDB doesn't currently, but may in future. It is still commonly used by applications - // So it might be noisy to do so. - return checkIsolationLevel(vars, normalizedValue, originalValue, scope) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TransactionIsolation, Value: "REPEATABLE-READ", Type: TypeEnum, Aliases: []string{TxnIsolation}, PossibleValues: []string{"READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE"}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkIsolationLevel(vars, normalizedValue, originalValue, scope) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CollationConnection, Value: mysql.DefaultCollationName, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCollation(vars, normalizedValue, originalValue, scope) - }, SetSession: func(s *SessionVars, val string) error { - if coll, err := collate.GetCollationByName(val); err == nil { - s.systems[CharacterSetConnection] = coll.CharsetName - } - return nil - }}, - {Scope: ScopeNone, Name: Version, Value: mysql.ServerVersion}, - {Scope: ScopeGlobal | ScopeSession, Name: AutoCommit, Value: On, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - isAutocommit := TiDBOptOn(val) - s.SetStatusFlag(mysql.ServerStatusAutocommit, isAutocommit) - if isAutocommit { - s.SetInTxn(false) - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CharsetDatabase, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCharacterSet(normalizedValue, CharsetDatabase) - }, SetSession: func(s *SessionVars, val string) error { - if _, coll, err := charset.GetCharsetInfo(val); err == nil { - s.systems[CollationDatabase] = coll - } - return nil - }}, - {Scope: ScopeGlobal, Name: MaxPreparedStmtCount, Value: strconv.FormatInt(DefMaxPreparedStmtCount, 10), Type: TypeInt, MinValue: -1, MaxValue: 1048576, AutoConvertOutOfRange: true}, - {Scope: ScopeNone, Name: DataDir, Value: "/usr/local/mysql/data/"}, - {Scope: ScopeGlobal | ScopeSession, Name: WaitTimeout, Value: strconv.FormatInt(DefWaitTimeout, 10), Type: TypeUnsigned, MinValue: 0, MaxValue: secondsPerYear, AutoConvertOutOfRange: true}, - {Scope: ScopeGlobal | ScopeSession, Name: InteractiveTimeout, Value: "28800", Type: TypeUnsigned, MinValue: 1, MaxValue: secondsPerYear, AutoConvertOutOfRange: true}, - {Scope: ScopeGlobal | ScopeSession, Name: InnodbLockWaitTimeout, Value: strconv.FormatInt(DefInnodbLockWaitTimeout, 10), Type: TypeUnsigned, MinValue: 1, MaxValue: 1073741824, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - lockWaitSec := tidbOptInt64(val, DefInnodbLockWaitTimeout) - s.LockWaitTimeout = lockWaitSec * 1000 - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: GroupConcatMaxLen, Value: "1024", AutoConvertOutOfRange: true, IsHintUpdatable: true, skipInit: true, Type: TypeUnsigned, MinValue: 4, MaxValue: math.MaxUint64, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - // https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_group_concat_max_len - // Minimum Value 4 - // Maximum Value (64-bit platforms) 18446744073709551615 - // Maximum Value (32-bit platforms) 4294967295 - if mathutil.IntBits == 32 { - if val, err := strconv.ParseUint(normalizedValue, 10, 64); err == nil { - if val > uint64(math.MaxUint32) { - vars.StmtCtx.AppendWarning(ErrTruncatedWrongValue.GenWithStackByArgs(GroupConcatMaxLen, originalValue)) - return fmt.Sprintf("%d", math.MaxUint32), nil - } - } - } - return normalizedValue, nil - }}, - {Scope: ScopeNone, Name: Socket, Value: ""}, - {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetConnection, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCharacterSet(normalizedValue, CharacterSetConnection) - }, SetSession: func(s *SessionVars, val string) error { - if _, coll, err := charset.GetCharsetInfo(val); err == nil { - s.systems[CollationConnection] = coll - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CharacterSetServer, Value: mysql.DefaultCharset, skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkCharacterSet(normalizedValue, CharacterSetServer) - }, SetSession: func(s *SessionVars, val string) error { - if _, coll, err := charset.GetCharsetInfo(val); err == nil { - s.systems[CollationServer] = coll - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: MaxAllowedPacket, Value: "67108864", Type: TypeUnsigned, MinValue: 1024, MaxValue: MaxOfMaxAllowedPacket, AutoConvertOutOfRange: true}, - {Scope: ScopeSession, Name: WarningCount, Value: "0", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.Itoa(s.SysWarningCount), nil - }}, - {Scope: ScopeSession, Name: ErrorCount, Value: "0", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.Itoa(int(s.SysErrorCount)), nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: WindowingUseHighPrecision, Value: On, Type: TypeBool, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { - s.WindowingUseHighPrecision = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeNone, Name: "license", Value: "Apache License 2.0"}, - {Scope: ScopeGlobal | ScopeSession, Name: BlockEncryptionMode, Value: "aes-128-ecb"}, - {Scope: ScopeSession, Name: "last_insert_id", Value: "", skipInit: true}, - {Scope: ScopeNone, Name: "have_ssl", Value: "DISABLED"}, - {Scope: ScopeNone, Name: "have_openssl", Value: "DISABLED"}, - {Scope: ScopeNone, Name: "ssl_ca", Value: ""}, - {Scope: ScopeNone, Name: "ssl_cert", Value: ""}, - {Scope: ScopeNone, Name: "ssl_key", Value: ""}, - {Scope: ScopeGlobal, Name: InitConnect, Value: ""}, - - /* TiDB specific variables */ - {Scope: ScopeGlobal, Name: TiDBEnableLocalTxn, Value: BoolToOnOff(DefTiDBEnableLocalTxn), Hidden: true, Type: TypeBool, GetSession: func(sv *SessionVars) (string, error) { - return BoolToOnOff(EnableLocalTxn.Load()), nil - }, SetGlobal: func(s *SessionVars, val string) error { - oldVal := EnableLocalTxn.Load() - newVal := TiDBOptOn(val) - // Make sure the TxnScope is always Global when disable the Local Txn. - // ON -> OFF - if oldVal && !newVal { - s.TxnScope = kv.NewGlobalTxnScopeVar() - } - EnableLocalTxn.Store(newVal) - return nil - }}, - // TODO: TiDBTxnScope is hidden because local txn feature is not done. - {Scope: ScopeSession, Name: TiDBTxnScope, skipInit: true, Hidden: true, Value: kv.GlobalTxnScope, SetSession: func(s *SessionVars, val string) error { - switch val { - case kv.GlobalTxnScope: - s.TxnScope = kv.NewGlobalTxnScopeVar() - case kv.LocalTxnScope: - if !EnableLocalTxn.Load() { - return ErrWrongValueForVar.GenWithStack("@@txn_scope can not be set to local when tidb_enable_local_txn is off") - } - txnScope := config.GetTxnScopeFromConfig() - if txnScope == kv.GlobalTxnScope { - return ErrWrongValueForVar.GenWithStack("@@txn_scope can not be set to local when zone label is empty or \"global\"") - } - s.TxnScope = kv.NewLocalTxnScopeVar(txnScope) - default: - return ErrWrongValueForVar.GenWithStack("@@txn_scope value should be global or local") - } - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return s.TxnScope.GetVarValue(), nil - }}, - {Scope: ScopeSession, Name: TiDBTxnReadTS, Value: "", Hidden: true, SetSession: func(s *SessionVars, val string) error { - return setTxnReadTS(s, val) - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowMPPExecution, Type: TypeBool, Value: BoolToOnOff(DefTiDBAllowMPPExecution), SetSession: func(s *SessionVars, val string) error { - s.allowMPPExecution = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBEnforceMPPExecution, Type: TypeBool, Value: BoolToOnOff(config.GetGlobalConfig().Performance.EnforceMPP), Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if TiDBOptOn(normalizedValue) && !vars.allowMPPExecution { - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("tidb_enforce_mpp", "1' but tidb_allow_mpp is 0, please activate tidb_allow_mpp at first.") - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.enforceMPPExecution = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBBCJThresholdCount, Value: strconv.Itoa(DefBroadcastJoinThresholdCount), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.BroadcastJoinThresholdCount = tidbOptInt64(val, DefBroadcastJoinThresholdCount) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBBCJThresholdSize, Value: strconv.Itoa(DefBroadcastJoinThresholdSize), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.BroadcastJoinThresholdSize = tidbOptInt64(val, DefBroadcastJoinThresholdSize) - return nil - }}, - {Scope: ScopeSession, Name: TiDBSnapshot, Value: "", skipInit: true, SetSession: func(s *SessionVars, val string) error { - err := setSnapshotTS(s, val) - if err != nil { - return err - } - return nil - }}, - {Scope: ScopeSession, Name: TiDBOptAggPushDown, Value: BoolToOnOff(DefOptAggPushDown), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.AllowAggPushDown = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptBCJ, Value: BoolToOnOff(DefOptBCJ), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if TiDBOptOn(normalizedValue) && vars.AllowBatchCop == 0 { - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("Can't set Broadcast Join to 1 but tidb_allow_batch_cop is 0, please active batch cop at first.") - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.AllowBCJ = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBOptDistinctAggPushDown, Value: BoolToOnOff(config.GetGlobalConfig().Performance.DistinctAggPushDown), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.AllowDistinctAggPushDown = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBOptWriteRowID, Value: BoolToOnOff(DefOptWriteRowID), skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.AllowWriteRowID = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBBuildStatsConcurrency, skipInit: true, Value: strconv.Itoa(DefBuildStatsConcurrency)}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCartesianBCJ, Value: strconv.Itoa(DefOptCartesianBCJ), Type: TypeInt, MinValue: 0, MaxValue: 2, SetSession: func(s *SessionVars, val string) error { - s.AllowCartesianBCJ = tidbOptInt(val, DefOptCartesianBCJ) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptMPPOuterJoinFixedBuildSide, Value: BoolToOnOff(DefOptMPPOuterJoinFixedBuildSide), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.MPPOuterJoinFixedBuildSide = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeRatio, Value: strconv.FormatFloat(DefAutoAnalyzeRatio, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64}, - {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeStartTime, Value: DefAutoAnalyzeStartTime, Type: TypeTime}, - {Scope: ScopeGlobal, Name: TiDBAutoAnalyzeEndTime, Value: DefAutoAnalyzeEndTime, Type: TypeTime}, - {Scope: ScopeSession, Name: TiDBChecksumTableConcurrency, skipInit: true, Value: strconv.Itoa(DefChecksumTableConcurrency)}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBExecutorConcurrency, Value: strconv.Itoa(DefExecutorConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.ExecutorConcurrency = tidbOptPositiveInt32(val, DefExecutorConcurrency) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBDistSQLScanConcurrency, Value: strconv.Itoa(DefDistSQLScanConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.distSQLScanConcurrency = tidbOptPositiveInt32(val, DefDistSQLScanConcurrency) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptInSubqToJoinAndAgg, Value: BoolToOnOff(DefOptInSubqToJoinAndAgg), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.SetAllowInSubqToJoinAndAgg(TiDBOptOn(val)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBOptPreferRangeScan, Value: BoolToOnOff(DefOptPreferRangeScan), Type: TypeBool, IsHintUpdatable: true, SetSession: func(s *SessionVars, val string) error { - s.SetAllowPreferRangeScan(TiDBOptOn(val)) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCorrelationThreshold, Value: strconv.FormatFloat(DefOptCorrelationThreshold, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: 1, SetSession: func(s *SessionVars, val string) error { - s.CorrelationThreshold = tidbOptFloat64(val, DefOptCorrelationThreshold) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCorrelationExpFactor, Value: strconv.Itoa(DefOptCorrelationExpFactor), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.CorrelationExpFactor = int(tidbOptInt64(val, DefOptCorrelationExpFactor)) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCPUFactor, Value: strconv.FormatFloat(DefOptCPUFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.CPUFactor = tidbOptFloat64(val, DefOptCPUFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptTiFlashConcurrencyFactor, Value: strconv.FormatFloat(DefOptTiFlashConcurrencyFactor, 'f', -1, 64), skipInit: true, Type: TypeFloat, MinValue: 1, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.CopTiFlashConcurrencyFactor = tidbOptFloat64(val, DefOptTiFlashConcurrencyFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptCopCPUFactor, Value: strconv.FormatFloat(DefOptCopCPUFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.CopCPUFactor = tidbOptFloat64(val, DefOptCopCPUFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptNetworkFactor, Value: strconv.FormatFloat(DefOptNetworkFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.networkFactor = tidbOptFloat64(val, DefOptNetworkFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptScanFactor, Value: strconv.FormatFloat(DefOptScanFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.scanFactor = tidbOptFloat64(val, DefOptScanFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptDescScanFactor, Value: strconv.FormatFloat(DefOptDescScanFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.descScanFactor = tidbOptFloat64(val, DefOptDescScanFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptSeekFactor, Value: strconv.FormatFloat(DefOptSeekFactor, 'f', -1, 64), skipInit: true, Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.seekFactor = tidbOptFloat64(val, DefOptSeekFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptMemoryFactor, Value: strconv.FormatFloat(DefOptMemoryFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.MemoryFactor = tidbOptFloat64(val, DefOptMemoryFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptDiskFactor, Value: strconv.FormatFloat(DefOptDiskFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.DiskFactor = tidbOptFloat64(val, DefOptDiskFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptConcurrencyFactor, Value: strconv.FormatFloat(DefOptConcurrencyFactor, 'f', -1, 64), Type: TypeFloat, MinValue: 0, MaxValue: math.MaxUint64, SetSession: func(s *SessionVars, val string) error { - s.ConcurrencyFactor = tidbOptFloat64(val, DefOptConcurrencyFactor) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexJoinBatchSize, Value: strconv.Itoa(DefIndexJoinBatchSize), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.IndexJoinBatchSize = tidbOptPositiveInt32(val, DefIndexJoinBatchSize) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupSize, Value: strconv.Itoa(DefIndexLookupSize), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.IndexLookupSize = tidbOptPositiveInt32(val, DefIndexLookupSize) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupConcurrency, Value: strconv.Itoa(DefIndexLookupConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.indexLookupConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBIndexLookupConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexLookupJoinConcurrency, Value: strconv.Itoa(DefIndexLookupJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.indexLookupJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBIndexLookupJoinConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBIndexSerialScanConcurrency, Value: strconv.Itoa(DefIndexSerialScanConcurrency), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.indexSerialScanConcurrency = tidbOptPositiveInt32(val, DefIndexSerialScanConcurrency) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipUTF8Check, Value: BoolToOnOff(DefSkipUTF8Check), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.SkipUTF8Check = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipASCIICheck, Value: BoolToOnOff(DefSkipASCIICheck), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.SkipASCIICheck = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBBatchInsert, Value: BoolToOnOff(DefBatchInsert), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.BatchInsert = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBBatchDelete, Value: BoolToOnOff(DefBatchDelete), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.BatchDelete = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBBatchCommit, Value: BoolToOnOff(DefBatchCommit), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.BatchCommit = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBDMLBatchSize, Value: strconv.Itoa(DefDMLBatchSize), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.DMLBatchSize = int(tidbOptInt64(val, DefDMLBatchSize)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBCurrentTS, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - return fmt.Sprintf("%d", s.TxnCtx.StartTS), nil - }}, - {Scope: ScopeSession, Name: TiDBLastTxnInfo, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - return s.LastTxnInfo, nil - }}, - {Scope: ScopeSession, Name: TiDBLastQueryInfo, Value: strconv.Itoa(DefCurretTS), ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - info, err := json.Marshal(s.LastQueryInfo) - if err != nil { - return "", err - } - return string(info), nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBMaxChunkSize, Value: strconv.Itoa(DefMaxChunkSize), Type: TypeUnsigned, MinValue: maxChunkSizeLowerBound, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.MaxChunkSize = tidbOptPositiveInt32(val, DefMaxChunkSize) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowBatchCop, Value: strconv.Itoa(DefTiDBAllowBatchCop), Type: TypeInt, MinValue: 0, MaxValue: 2, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if normalizedValue == "0" && vars.AllowBCJ { - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs("Can't set batch cop 0 but tidb_opt_broadcast_join is 1, please set tidb_opt_broadcast_join 0 at first") - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.AllowBatchCop = int(tidbOptInt64(val, DefTiDBAllowBatchCop)) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBInitChunkSize, Value: strconv.Itoa(DefInitChunkSize), Type: TypeUnsigned, MinValue: 1, MaxValue: initChunkSizeUpperBound, SetSession: func(s *SessionVars, val string) error { - s.InitChunkSize = tidbOptPositiveInt32(val, DefInitChunkSize) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableCascadesPlanner, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.SetEnableCascadesPlanner(TiDBOptOn(val)) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableIndexMerge, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.SetEnableIndexMerge(TiDBOptOn(val)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaQuery, Value: strconv.FormatInt(config.GetGlobalConfig().MemQuotaQuery, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaQuery = tidbOptInt64(val, config.GetGlobalConfig().MemQuotaQuery) - return nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaHashJoin, Value: strconv.FormatInt(DefTiDBMemQuotaHashJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaHashJoin = tidbOptInt64(val, DefTiDBMemQuotaHashJoin) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaHashJoin, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaMergeJoin, Value: strconv.FormatInt(DefTiDBMemQuotaMergeJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaMergeJoin = tidbOptInt64(val, DefTiDBMemQuotaMergeJoin) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaMergeJoin, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaSort, Value: strconv.FormatInt(DefTiDBMemQuotaSort, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaSort = tidbOptInt64(val, DefTiDBMemQuotaSort) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaSort, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaTopn, Value: strconv.FormatInt(DefTiDBMemQuotaTopn, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaTopn = tidbOptInt64(val, DefTiDBMemQuotaTopn) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaTopn, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaIndexLookupReader, Value: strconv.FormatInt(DefTiDBMemQuotaIndexLookupReader, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaIndexLookupReader = tidbOptInt64(val, DefTiDBMemQuotaIndexLookupReader) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaIndexLookupReader, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBMemQuotaIndexLookupJoin, Value: strconv.FormatInt(DefTiDBMemQuotaIndexLookupJoin, 10), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaIndexLookupJoin = tidbOptInt64(val, DefTiDBMemQuotaIndexLookupJoin) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMemQuotaIndexLookupJoin, TiDBMemQuotaQuery) - return normalizedValue, nil - }}, - {Scope: ScopeSession, Name: TiDBEnableStreaming, Value: Off, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.EnableStreaming = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBEnableChunkRPC, Value: On, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.EnableChunkRPC = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TxnIsolationOneShot, Value: "", skipInit: true, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - return checkIsolationLevel(vars, normalizedValue, originalValue, scope) - }, SetSession: func(s *SessionVars, val string) error { - s.txnIsolationLevelOneShot.state = oneShotSet - s.txnIsolationLevelOneShot.value = val - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableTablePartition, Value: On, Type: TypeEnum, PossibleValues: []string{Off, On, "AUTO"}, SetSession: func(s *SessionVars, val string) error { - s.EnableTablePartition = val - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableListTablePartition, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableListTablePartition = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashJoinConcurrency, Value: strconv.Itoa(DefTiDBHashJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.hashJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBHashJoinConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBProjectionConcurrency, Value: strconv.Itoa(DefTiDBProjectionConcurrency), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.projectionConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBProjectionConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashAggPartialConcurrency, Value: strconv.Itoa(DefTiDBHashAggPartialConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.hashAggPartialConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBHashAggPartialConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBHashAggFinalConcurrency, Value: strconv.Itoa(DefTiDBHashAggFinalConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.hashAggFinalConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBHashAggFinalConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBWindowConcurrency, Value: strconv.Itoa(DefTiDBWindowConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.windowConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBWindowConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBMergeJoinConcurrency, Value: strconv.Itoa(DefTiDBMergeJoinConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.mergeJoinConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBMergeJoinConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStreamAggConcurrency, Value: strconv.Itoa(DefTiDBStreamAggConcurrency), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowAutoValue: true, SetSession: func(s *SessionVars, val string) error { - s.streamAggConcurrency = tidbOptPositiveInt32(val, ConcurrencyUnset) - return nil - }, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBStreamAggConcurrency, TiDBExecutorConcurrency) - return normalizedValue, nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableParallelApply, Value: BoolToOnOff(DefTiDBEnableParallelApply), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableParallelApply = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBMemQuotaApplyCache, Value: strconv.Itoa(DefTiDBMemQuotaApplyCache), Type: TypeUnsigned, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.MemQuotaApplyCache = tidbOptInt64(val, DefTiDBMemQuotaApplyCache) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBBackoffLockFast, Value: strconv.Itoa(tikvstore.DefBackoffLockFast), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.KVVars.BackoffLockFast = tidbOptPositiveInt32(val, tikvstore.DefBackoffLockFast) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBBackOffWeight, Value: strconv.Itoa(tikvstore.DefBackOffWeight), Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.KVVars.BackOffWeight = tidbOptPositiveInt32(val, tikvstore.DefBackOffWeight) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBRetryLimit, Value: strconv.Itoa(DefTiDBRetryLimit), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - s.RetryLimit = tidbOptInt64(val, DefTiDBRetryLimit) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBDisableTxnAutoRetry, Value: BoolToOnOff(DefTiDBDisableTxnAutoRetry), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.DisableTxnAutoRetry = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBConstraintCheckInPlace, Value: BoolToOnOff(DefTiDBConstraintCheckInPlace), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.ConstraintCheckInPlace = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBTxnMode, Value: DefTiDBTxnMode, AllowEmptyAll: true, Type: TypeEnum, PossibleValues: []string{"pessimistic", "optimistic"}, SetSession: func(s *SessionVars, val string) error { - s.TxnMode = strings.ToUpper(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBRowFormatVersion, Value: strconv.Itoa(DefTiDBRowFormatV1), Type: TypeUnsigned, MinValue: 1, MaxValue: 2, SetSession: func(s *SessionVars, val string) error { - formatVersion := int(tidbOptInt64(val, DefTiDBRowFormatV1)) - if formatVersion == DefTiDBRowFormatV1 { - s.RowEncoder.Enable = false - } else if formatVersion == DefTiDBRowFormatV2 { - s.RowEncoder.Enable = true - } - SetDDLReorgRowFormat(tidbOptInt64(val, DefTiDBRowFormatV2)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBOptimizerSelectivityLevel, Value: strconv.Itoa(DefTiDBOptimizerSelectivityLevel), skipInit: true, Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.OptimizerSelectivityLevel = tidbOptPositiveInt32(val, DefTiDBOptimizerSelectivityLevel) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableWindowFunction, Value: BoolToOnOff(DefEnableWindowFunction), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableWindowFunction = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnablePipelinedWindowFunction, Value: BoolToOnOff(DefEnablePipelinedWindowFunction), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnablePipelinedWindowExec = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableStrictDoubleTypeCheck, Value: BoolToOnOff(DefEnableStrictDoubleTypeCheck), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableStrictDoubleTypeCheck = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableVectorizedExpression, Value: BoolToOnOff(DefEnableVectorizedExpression), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableVectorizedExpression = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableFastAnalyze, Value: BoolToOnOff(DefTiDBUseFastAnalyze), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableFastAnalyze = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBSkipIsolationLevelCheck, skipInit: true, Value: BoolToOnOff(DefTiDBSkipIsolationLevelCheck), Type: TypeBool}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableRateLimitAction, Value: BoolToOnOff(DefTiDBEnableRateLimitAction), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnabledRateLimitAction = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowFallbackToTiKV, Value: "", Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if normalizedValue == "" { - return "", nil - } - engines := strings.Split(normalizedValue, ",") - var formatVal string - storeTypes := make(map[kv.StoreType]struct{}) - for i, engine := range engines { - engine = strings.TrimSpace(engine) - switch { - case strings.EqualFold(engine, kv.TiFlash.Name()): - if _, ok := storeTypes[kv.TiFlash]; !ok { - if i != 0 { - formatVal += "," - } - formatVal += kv.TiFlash.Name() - storeTypes[kv.TiFlash] = struct{}{} - } - default: - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(TiDBAllowFallbackToTiKV, normalizedValue) - } - } - return formatVal, nil - }, SetSession: func(s *SessionVars, val string) error { - s.AllowFallbackToTiKV = make(map[kv.StoreType]struct{}) - for _, engine := range strings.Split(val, ",") { - switch engine { - case kv.TiFlash.Name(): - s.AllowFallbackToTiKV[kv.TiFlash] = struct{}{} - } - } - return nil - }}, - /* The following variable is defined as session scope but is actually server scope. */ - {Scope: ScopeSession, Name: TiDBGeneralLog, Value: BoolToOnOff(DefTiDBGeneralLog), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - ProcessGeneralLog.Store(TiDBOptOn(val)) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(ProcessGeneralLog.Load()), nil - }}, - {Scope: ScopeSession, Name: TiDBPProfSQLCPU, Value: strconv.Itoa(DefTiDBPProfSQLCPU), Type: TypeInt, skipInit: true, MinValue: 0, MaxValue: 1, SetSession: func(s *SessionVars, val string) error { - EnablePProfSQLCPU.Store(uint32(tidbOptPositiveInt32(val, DefTiDBPProfSQLCPU)) > 0) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - val := "0" - if EnablePProfSQLCPU.Load() { - val = "1" - } - return val, nil - }}, - {Scope: ScopeSession, Name: TiDBDDLSlowOprThreshold, Value: strconv.Itoa(DefTiDBDDLSlowOprThreshold), skipInit: true, SetSession: func(s *SessionVars, val string) error { - atomic.StoreUint32(&DDLSlowOprThreshold, uint32(tidbOptPositiveInt32(val, DefTiDBDDLSlowOprThreshold))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatUint(uint64(atomic.LoadUint32(&DDLSlowOprThreshold)), 10), nil - }}, - {Scope: ScopeSession, Name: TiDBConfig, Value: "", ReadOnly: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - conf := config.GetGlobalConfig() - j, err := json.MarshalIndent(conf, "", "\t") - if err != nil { - return "", err - } - return config.HideConfig(string(j)), nil - }}, - {Scope: ScopeGlobal, Name: TiDBDDLReorgWorkerCount, Value: strconv.Itoa(DefTiDBDDLReorgWorkerCount), Type: TypeUnsigned, MinValue: 1, MaxValue: uint64(maxDDLReorgWorkerCount), SetSession: func(s *SessionVars, val string) error { - SetDDLReorgWorkerCounter(int32(tidbOptPositiveInt32(val, DefTiDBDDLReorgWorkerCount))) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBDDLReorgBatchSize, Value: strconv.Itoa(DefTiDBDDLReorgBatchSize), Type: TypeUnsigned, MinValue: int64(MinDDLReorgBatchSize), MaxValue: uint64(MaxDDLReorgBatchSize), AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - SetDDLReorgBatchSize(int32(tidbOptPositiveInt32(val, DefTiDBDDLReorgBatchSize))) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBDDLErrorCountLimit, Value: strconv.Itoa(DefTiDBDDLErrorCountLimit), Type: TypeUnsigned, MinValue: 0, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - SetDDLErrorCountLimit(tidbOptInt64(val, DefTiDBDDLErrorCountLimit)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBDDLReorgPriority, Value: "PRIORITY_LOW", skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.setDDLReorgPriority(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBMaxDeltaSchemaCount, Value: strconv.Itoa(DefTiDBMaxDeltaSchemaCount), Type: TypeUnsigned, MinValue: 100, MaxValue: 16384, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - // It's a global variable, but it also wants to be cached in server. - SetMaxDeltaSchemaCount(tidbOptInt64(val, DefTiDBMaxDeltaSchemaCount)) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBEnableChangeMultiSchema, Value: BoolToOnOff(DefTiDBChangeMultiSchema), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableChangeMultiSchema = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBEnablePointGetCache, Value: BoolToOnOff(DefTiDBPointGetCache), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnablePointGetCache = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBEnableAlterPlacement, Value: BoolToOnOff(DefTiDBEnableAlterPlacement), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableAlterPlacement = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBForcePriority, skipInit: true, Value: mysql.Priority2Str[DefTiDBForcePriority], SetSession: func(s *SessionVars, val string) error { - atomic.StoreInt32(&ForcePriority, int32(mysql.Str2Priority(val))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return mysql.Priority2Str[mysql.PriorityEnum(atomic.LoadInt32(&ForcePriority))], nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBOptJoinReorderThreshold, Value: strconv.Itoa(DefTiDBOptJoinReorderThreshold), skipInit: true, Type: TypeUnsigned, MinValue: 0, MaxValue: 63, SetSession: func(s *SessionVars, val string) error { - s.TiDBOptJoinReorderThreshold = tidbOptPositiveInt32(val, DefTiDBOptJoinReorderThreshold) - return nil - }}, - {Scope: ScopeSession, Name: TiDBSlowQueryFile, Value: "", skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.SlowQueryFile = val - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBScatterRegion, Value: BoolToOnOff(DefTiDBScatterRegion), Type: TypeBool}, - {Scope: ScopeSession, Name: TiDBWaitSplitRegionFinish, Value: BoolToOnOff(DefTiDBWaitSplitRegionFinish), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.WaitSplitRegionFinish = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBWaitSplitRegionTimeout, Value: strconv.Itoa(DefWaitSplitRegionTimeout), skipInit: true, Type: TypeUnsigned, MinValue: 1, MaxValue: math.MaxInt32, SetSession: func(s *SessionVars, val string) error { - s.WaitSplitRegionTimeout = uint64(tidbOptPositiveInt32(val, DefWaitSplitRegionTimeout)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBLowResolutionTSO, Value: Off, Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.LowResolutionTSO = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBExpensiveQueryTimeThreshold, Value: strconv.Itoa(DefTiDBExpensiveQueryTimeThreshold), Type: TypeUnsigned, MinValue: int64(MinExpensiveQueryTimeThreshold), MaxValue: math.MaxInt32, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - atomic.StoreUint64(&ExpensiveQueryTimeThreshold, uint64(tidbOptPositiveInt32(val, DefTiDBExpensiveQueryTimeThreshold))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return fmt.Sprintf("%d", atomic.LoadUint64(&ExpensiveQueryTimeThreshold)), nil - }}, - {Scope: ScopeSession, Name: TiDBMemoryUsageAlarmRatio, Value: strconv.FormatFloat(config.GetGlobalConfig().Performance.MemoryUsageAlarmRatio, 'f', -1, 64), Type: TypeFloat, MinValue: 0.0, MaxValue: 1.0, skipInit: true, SetSession: func(s *SessionVars, val string) error { - MemoryUsageAlarmRatio.Store(tidbOptFloat64(val, 0.8)) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return fmt.Sprintf("%g", MemoryUsageAlarmRatio.Load()), nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableNoopFuncs, Value: BoolToOnOff(DefTiDBEnableNoopFuncs), Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - - // The behavior is very weird if someone can turn TiDBEnableNoopFuncs OFF, but keep any of the following on: - // TxReadOnly, TransactionReadOnly, OfflineMode, SuperReadOnly, serverReadOnly - // To prevent this strange position, prevent setting to OFF when any of these sysVars are ON of the same scope. - - if normalizedValue == Off { - for _, potentialIncompatibleSysVar := range []string{TxReadOnly, TransactionReadOnly, OfflineMode, SuperReadOnly, ReadOnly} { - val, _ := vars.GetSystemVar(potentialIncompatibleSysVar) // session scope - if scope == ScopeGlobal { // global scope - var err error - val, err = vars.GlobalVarsAccessor.GetGlobalSysVar(potentialIncompatibleSysVar) - if err != nil { - return originalValue, errUnknownSystemVariable.GenWithStackByArgs(potentialIncompatibleSysVar) - } - } - if TiDBOptOn(val) { - return originalValue, errValueNotSupportedWhen.GenWithStackByArgs(TiDBEnableNoopFuncs, potentialIncompatibleSysVar) - } - } - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.EnableNoopFuncs = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeSession, Name: TiDBReplicaRead, Value: "leader", Type: TypeEnum, PossibleValues: []string{"leader", "follower", "leader-and-follower"}, skipInit: true, SetSession: func(s *SessionVars, val string) error { - if strings.EqualFold(val, "follower") { - s.SetReplicaRead(kv.ReplicaReadFollower) - } else if strings.EqualFold(val, "leader-and-follower") { - s.SetReplicaRead(kv.ReplicaReadMixed) - } else if strings.EqualFold(val, "leader") || len(val) == 0 { - s.SetReplicaRead(kv.ReplicaReadLeader) - } - return nil - }}, - {Scope: ScopeSession, Name: TiDBAllowRemoveAutoInc, Value: BoolToOnOff(DefTiDBAllowRemoveAutoInc), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.AllowRemoveAutoInc = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableStmtSummary, Value: BoolToOnOff(config.GetGlobalConfig().StmtSummary.Enable), skipInit: true, Type: TypeBool, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetEnabled(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetEnabled(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryInternalQuery, Value: BoolToOnOff(config.GetGlobalConfig().StmtSummary.EnableInternalQuery), skipInit: true, Type: TypeBool, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetEnabledInternalQuery(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryRefreshInterval, Value: strconv.Itoa(config.GetGlobalConfig().StmtSummary.RefreshInterval), skipInit: true, Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt32, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetRefreshInterval(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryHistorySize, Value: strconv.Itoa(config.GetGlobalConfig().StmtSummary.HistorySize), skipInit: true, Type: TypeInt, MinValue: 0, MaxValue: math.MaxUint8, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetHistorySize(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetHistorySize(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryMaxStmtCount, Value: strconv.FormatUint(uint64(config.GetGlobalConfig().StmtSummary.MaxStmtCount), 10), skipInit: true, Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt16, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetMaxStmtCount(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetMaxStmtCount(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStmtSummaryMaxSQLLength, Value: strconv.FormatUint(uint64(config.GetGlobalConfig().StmtSummary.MaxSQLLength), 10), skipInit: true, Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt32, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetMaxSQLLength(val, true) - }, SetGlobal: func(s *SessionVars, val string) error { - return stmtsummary.StmtSummaryByDigestMap.SetMaxSQLLength(val, false) - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBCapturePlanBaseline, Value: Off, Type: TypeBool, AllowEmptyAll: true, skipInit: true, GetSession: func(s *SessionVars) (string, error) { - return CapturePlanBaseline.GetVal(), nil - }, SetSession: func(s *SessionVars, val string) error { - CapturePlanBaseline.Set(val, true) - return nil - }, SetGlobal: func(s *SessionVars, val string) error { - CapturePlanBaseline.Set(val, false) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBUsePlanBaselines, Value: BoolToOnOff(DefTiDBUsePlanBaselines), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.UsePlanBaselines = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEvolvePlanBaselines, Value: BoolToOnOff(DefTiDBEvolvePlanBaselines), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EvolvePlanBaselines = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableExtendedStats, Value: BoolToOnOff(false), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableExtendedStats = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskMaxTime, Value: strconv.Itoa(DefTiDBEvolvePlanTaskMaxTime), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64}, - {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskStartTime, Value: DefTiDBEvolvePlanTaskStartTime, Type: TypeTime}, - {Scope: ScopeGlobal, Name: TiDBEvolvePlanTaskEndTime, Value: DefTiDBEvolvePlanTaskEndTime, Type: TypeTime}, - {Scope: ScopeSession, Name: TiDBIsolationReadEngines, Value: strings.Join(config.GetGlobalConfig().IsolationRead.Engines, ","), Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - engines := strings.Split(normalizedValue, ",") - var formatVal string - for i, engine := range engines { - engine = strings.TrimSpace(engine) - if i != 0 { - formatVal += "," - } - switch { - case strings.EqualFold(engine, kv.TiKV.Name()): - formatVal += kv.TiKV.Name() - case strings.EqualFold(engine, kv.TiFlash.Name()): - formatVal += kv.TiFlash.Name() - case strings.EqualFold(engine, kv.TiDB.Name()): - formatVal += kv.TiDB.Name() - default: - return normalizedValue, ErrWrongValueForVar.GenWithStackByArgs(TiDBIsolationReadEngines, normalizedValue) - } - } - return formatVal, nil - }, SetSession: func(s *SessionVars, val string) error { - s.IsolationReadEngines = make(map[kv.StoreType]struct{}) - for _, engine := range strings.Split(val, ",") { - switch engine { - case kv.TiKV.Name(): - s.IsolationReadEngines[kv.TiKV] = struct{}{} - case kv.TiFlash.Name(): - s.IsolationReadEngines[kv.TiFlash] = struct{}{} - case kv.TiDB.Name(): - s.IsolationReadEngines[kv.TiDB] = struct{}{} - } - } - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBStoreLimit, Value: strconv.FormatInt(atomic.LoadInt64(&config.GetGlobalConfig().TiKVClient.StoreLimit), 10), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - tikvstore.StoreLimit.Store(tidbOptInt64(val, DefTiDBStoreLimit)) - return nil - }}, - {Scope: ScopeSession, Name: TiDBMetricSchemaStep, Value: strconv.Itoa(DefTiDBMetricSchemaStep), Type: TypeUnsigned, skipInit: true, MinValue: 10, MaxValue: 60 * 60 * 60, SetSession: func(s *SessionVars, val string) error { - s.MetricSchemaStep = tidbOptInt64(val, DefTiDBMetricSchemaStep) - return nil - }}, - {Scope: ScopeSession, Name: TiDBMetricSchemaRangeDuration, Value: strconv.Itoa(DefTiDBMetricSchemaRangeDuration), skipInit: true, Type: TypeUnsigned, MinValue: 10, MaxValue: 60 * 60 * 60, SetSession: func(s *SessionVars, val string) error { - s.MetricSchemaRangeDuration = tidbOptInt64(val, DefTiDBMetricSchemaRangeDuration) - return nil - }}, - {Scope: ScopeSession, Name: TiDBSlowLogThreshold, Value: strconv.Itoa(logutil.DefaultSlowThreshold), skipInit: true, Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error { - atomic.StoreUint64(&config.GetGlobalConfig().Log.SlowThreshold, uint64(tidbOptInt64(val, logutil.DefaultSlowThreshold))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatUint(atomic.LoadUint64(&config.GetGlobalConfig().Log.SlowThreshold), 10), nil - }}, - {Scope: ScopeSession, Name: TiDBRecordPlanInSlowLog, Value: int32ToBoolStr(logutil.DefaultRecordPlanInSlowLog), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - atomic.StoreUint32(&config.GetGlobalConfig().Log.RecordPlanInSlowLog, uint32(tidbOptInt64(val, logutil.DefaultRecordPlanInSlowLog))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatUint(uint64(atomic.LoadUint32(&config.GetGlobalConfig().Log.RecordPlanInSlowLog)), 10), nil - }}, - {Scope: ScopeSession, Name: TiDBEnableSlowLog, Value: BoolToOnOff(logutil.DefaultTiDBEnableSlowLog), Type: TypeBool, skipInit: true, SetSession: func(s *SessionVars, val string) error { - config.GetGlobalConfig().Log.EnableSlowLog = TiDBOptOn(val) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(config.GetGlobalConfig().Log.EnableSlowLog), nil - }}, - {Scope: ScopeSession, Name: TiDBQueryLogMaxLen, Value: strconv.Itoa(logutil.DefaultQueryLogMaxLen), Type: TypeInt, MinValue: -1, MaxValue: math.MaxInt64, skipInit: true, SetSession: func(s *SessionVars, val string) error { - atomic.StoreUint64(&config.GetGlobalConfig().Log.QueryLogMaxLen, uint64(tidbOptInt64(val, logutil.DefaultQueryLogMaxLen))) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatUint(atomic.LoadUint64(&config.GetGlobalConfig().Log.QueryLogMaxLen), 10), nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: CTEMaxRecursionDepth, Value: strconv.Itoa(DefCTEMaxRecursionDepth), Type: TypeInt, MinValue: 0, MaxValue: 4294967295, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - s.CTEMaxRecursionDepth = tidbOptInt(val, DefCTEMaxRecursionDepth) - return nil - }}, - {Scope: ScopeSession, Name: TiDBCheckMb4ValueInUTF8, Value: BoolToOnOff(config.GetGlobalConfig().CheckMb4ValueInUTF8), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - config.GetGlobalConfig().CheckMb4ValueInUTF8 = TiDBOptOn(val) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(config.GetGlobalConfig().CheckMb4ValueInUTF8), nil - }}, - {Scope: ScopeSession, Name: TiDBFoundInPlanCache, Value: BoolToOnOff(DefTiDBFoundInPlanCache), Type: TypeBool, ReadOnly: true, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.FoundInPlanCache = TiDBOptOn(val) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(s.PrevFoundInPlanCache), nil - }}, - {Scope: ScopeSession, Name: TiDBFoundInBinding, Value: BoolToOnOff(DefTiDBFoundInBinding), Type: TypeBool, ReadOnly: true, skipInit: true, SetSession: func(s *SessionVars, val string) error { - s.FoundInBinding = TiDBOptOn(val) - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(s.PrevFoundInBinding), nil - }}, - {Scope: ScopeSession, Name: TiDBEnableCollectExecutionInfo, Value: BoolToOnOff(DefTiDBEnableCollectExecutionInfo), skipInit: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - oldConfig := config.GetGlobalConfig() - newValue := TiDBOptOn(val) - if oldConfig.EnableCollectExecutionInfo != newValue { - newConfig := *oldConfig - newConfig.EnableCollectExecutionInfo = newValue - config.StoreGlobalConfig(&newConfig) - } - return nil - }, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(config.GetGlobalConfig().EnableCollectExecutionInfo), nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBAllowAutoRandExplicitInsert, Value: BoolToOnOff(DefTiDBAllowAutoRandExplicitInsert), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.AllowAutoRandExplicitInsert = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableClusteredIndex, Value: IntOnly, Type: TypeEnum, PossibleValues: []string{Off, On, IntOnly}, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if normalizedValue == IntOnly { - vars.StmtCtx.AppendWarning(errWarnDeprecatedSyntax.FastGenByArgs(normalizedValue, fmt.Sprintf("'%s' or '%s'", On, Off))) - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.EnableClusteredIndex = TiDBOptEnableClustered(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBPartitionPruneMode, Value: DefTiDBPartitionPruneMode, Hidden: true, Type: TypeStr, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - mode := PartitionPruneMode(normalizedValue).Update() - if !mode.Valid() { - return normalizedValue, ErrWrongTypeForVar.GenWithStackByArgs(TiDBPartitionPruneMode) - } - return string(mode), nil - }, SetSession: func(s *SessionVars, val string) error { - s.PartitionPruneMode.Store(strings.ToLower(strings.TrimSpace(val))) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBSlowLogMasking, Value: BoolToOnOff(DefTiDBRedactLog), Aliases: []string{TiDBRedactLog}, skipInit: true, Type: TypeBool, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - appendDeprecationWarning(vars, TiDBSlowLogMasking, TiDBRedactLog) - return normalizedValue, nil - }, GetSession: func(s *SessionVars) (string, error) { - return s.systems[TiDBRedactLog], nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBRedactLog, Value: BoolToOnOff(DefTiDBRedactLog), Aliases: []string{TiDBSlowLogMasking}, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableRedactLog = TiDBOptOn(val) - errors.RedactLogEnabled.Store(s.EnableRedactLog) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBShardAllocateStep, Value: strconv.Itoa(DefTiDBShardAllocateStep), Type: TypeInt, MinValue: 1, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, SetSession: func(s *SessionVars, val string) error { - s.ShardAllocateStep = tidbOptInt64(val, DefTiDBShardAllocateStep) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBEnableTelemetry, Value: BoolToOnOff(DefTiDBEnableTelemetry), Type: TypeBool}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableAmendPessimisticTxn, Value: BoolToOnOff(DefTiDBEnableAmendPessimisticTxn), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableAmendPessimisticTxn = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableAsyncCommit, Value: BoolToOnOff(DefTiDBEnableAsyncCommit), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableAsyncCommit = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnable1PC, Value: BoolToOnOff(DefTiDBEnable1PC), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.Enable1PC = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBGuaranteeLinearizability, Value: BoolToOnOff(DefTiDBGuaranteeLinearizability), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.GuaranteeLinearizability = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBAnalyzeVersion, Value: strconv.Itoa(DefTiDBAnalyzeVersion), Hidden: false, Type: TypeInt, MinValue: 1, MaxValue: 2, Validation: func(vars *SessionVars, normalizedValue string, originalValue string, scope ScopeFlag) (string, error) { - if normalizedValue == "2" && FeedbackProbability != nil && FeedbackProbability.Load() > 0 { - var original string - var err error - if scope == ScopeGlobal { - original, err = vars.GlobalVarsAccessor.GetGlobalSysVar(TiDBAnalyzeVersion) - if err != nil { - return normalizedValue, nil - } - } else { - original = strconv.Itoa(vars.AnalyzeVersion) - } - vars.StmtCtx.AppendError(errors.New("variable tidb_analyze_version not updated because analyze version 2 is incompatible with query feedback. Please consider setting feedback-probability to 0.0 in config file to disable query feedback")) - return original, nil - } - return normalizedValue, nil - }, SetSession: func(s *SessionVars, val string) error { - s.AnalyzeVersion = tidbOptPositiveInt32(val, DefTiDBAnalyzeVersion) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableIndexMergeJoin, Value: BoolToOnOff(DefTiDBEnableIndexMergeJoin), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableIndexMergeJoin = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBTrackAggregateMemoryUsage, Value: BoolToOnOff(DefTiDBTrackAggregateMemoryUsage), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.TrackAggregateMemoryUsage = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBMultiStatementMode, Value: Off, Type: TypeEnum, PossibleValues: []string{Off, On, Warn}, SetSession: func(s *SessionVars, val string) error { - s.MultiStatementMode = TiDBOptMultiStmt(val) - return nil - }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableExchangePartition, Value: BoolToOnOff(DefTiDBEnableExchangePartition), Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.TiDBEnableExchangePartition = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeNone, Name: TiDBEnableEnhancedSecurity, Value: Off, Type: TypeBool}, - {Scope: ScopeSession, Name: PluginLoad, Value: "", GetSession: func(s *SessionVars) (string, error) { - return config.GetGlobalConfig().Plugin.Dir, nil - }}, - {Scope: ScopeSession, Name: PluginDir, Value: "/data/deploy/plugin", GetSession: func(s *SessionVars) (string, error) { - return config.GetGlobalConfig().Plugin.Load, nil - }}, - - /* tikv gc metrics */ - {Scope: ScopeGlobal, Name: TiDBGCEnable, Value: On, Type: TypeBool}, - {Scope: ScopeGlobal, Name: TiDBGCRunInterval, Value: "10m0s", Type: TypeDuration, MinValue: int64(time.Minute * 10), MaxValue: uint64(time.Hour * 24 * 365)}, - {Scope: ScopeGlobal, Name: TiDBGCLifetime, Value: "10m0s", Type: TypeDuration, MinValue: int64(time.Minute * 10), MaxValue: uint64(time.Hour * 24 * 365)}, - {Scope: ScopeGlobal, Name: TiDBGCConcurrency, Value: "-1", Type: TypeInt, MinValue: 1, MaxValue: 128, AllowAutoValue: true}, - {Scope: ScopeGlobal, Name: TiDBGCScanLockMode, Value: "PHYSICAL", Type: TypeEnum, PossibleValues: []string{"PHYSICAL", "LEGACY"}}, - {Scope: ScopeGlobal, Name: TiDBGCScanLockMode, Value: "LEGACY", Type: TypeEnum, PossibleValues: []string{"PHYSICAL", "LEGACY"}}, - - // See https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmp_table_size - {Scope: ScopeGlobal | ScopeSession, Name: TMPTableSize, Value: strconv.Itoa(DefTMPTableSize), Type: TypeUnsigned, MinValue: 1024, MaxValue: math.MaxInt64, AutoConvertOutOfRange: true, IsHintUpdatable: true, AllowEmpty: true, SetSession: func(s *SessionVars, val string) error { - s.TMPTableSize = tidbOptInt64(val, DefTMPTableSize) - return nil - }}, - // variable for top SQL feature. - {Scope: ScopeGlobal, Name: TiDBEnableTopSQL, Value: BoolToOnOff(DefTiDBTopSQLEnable), Type: TypeBool, Hidden: true, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return BoolToOnOff(TopSQLVariable.Enable.Load()), nil - }, SetGlobal: func(vars *SessionVars, s string) error { - TopSQLVariable.Enable.Store(TiDBOptOn(s)) - return nil - }}, - // TODO(crazycs520): Add validation - {Scope: ScopeSession, Name: TiDBTopSQLAgentAddress, Value: DefTiDBTopSQLAgentAddress, Type: TypeStr, Hidden: true, skipInit: true, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return TopSQLVariable.AgentAddress.Load(), nil - }, SetSession: func(vars *SessionVars, s string) error { - TopSQLVariable.AgentAddress.Store(s) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBTopSQLPrecisionSeconds, Value: strconv.Itoa(DefTiDBTopSQLPrecisionSeconds), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: math.MaxInt64, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatInt(TopSQLVariable.PrecisionSeconds.Load(), 10), nil - }, SetGlobal: func(vars *SessionVars, s string) error { - val, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return err - } - TopSQLVariable.PrecisionSeconds.Store(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBTopSQLMaxStatementCount, Value: strconv.Itoa(DefTiDBTopSQLMaxStatementCount), Type: TypeInt, Hidden: true, MinValue: 0, MaxValue: 5000, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatInt(TopSQLVariable.MaxStatementCount.Load(), 10), nil - }, SetGlobal: func(vars *SessionVars, s string) error { - val, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return err - } - TopSQLVariable.MaxStatementCount.Store(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBTopSQLMaxCollect, Value: strconv.Itoa(DefTiDBTopSQLMaxCollect), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: 500000, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatInt(TopSQLVariable.MaxCollect.Load(), 10), nil - }, SetGlobal: func(vars *SessionVars, s string) error { - val, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return err - } - TopSQLVariable.MaxCollect.Store(val) - return nil - }}, - {Scope: ScopeGlobal, Name: TiDBTopSQLReportIntervalSeconds, Value: strconv.Itoa(DefTiDBTopSQLReportIntervalSeconds), Type: TypeInt, Hidden: true, MinValue: 1, MaxValue: 1 * 60 * 60, AllowEmpty: true, GetSession: func(s *SessionVars) (string, error) { - return strconv.FormatInt(TopSQLVariable.ReportIntervalSeconds.Load(), 10), nil - }, SetGlobal: func(vars *SessionVars, s string) error { - val, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return err - } - TopSQLVariable.ReportIntervalSeconds.Store(val) - return nil - }}, - - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableGlobalTemporaryTable, Value: BoolToOnOff(DefTiDBEnableGlobalTemporaryTable), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableGlobalTemporaryTable = TiDBOptOn(val) - return nil - }}, - {Scope: ScopeGlobal, Name: SkipNameResolve, Value: Off, Type: TypeBool}, - {Scope: ScopeGlobal, Name: DefaultAuthPlugin, Value: mysql.AuthNativePassword, Type: TypeEnum, PossibleValues: []string{mysql.AuthNativePassword, mysql.AuthCachingSha2Password}}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableOrderedResultMode, Value: BoolToOnOff(DefTiDBEnableOrderedResultMode), Hidden: true, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { - s.EnableStableResultMode = TiDBOptOn(val) - return nil - }}, ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) } // SetNamesVariables is the system variable names related to set names statements. diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 767517899d48a..694fb1143604f 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -541,28 +541,7 @@ const ( DefTiDBEnableTelemetry = true DefTiDBEnableAmendPessimisticTxn = false DefTiDBEnableRateLimitAction = true -<<<<<<< HEAD - DefTiDBEnableStableResultMode = false -======= - DefTiDBEnableAsyncCommit = false - DefTiDBEnable1PC = false - DefTiDBGuaranteeLinearizability = true - DefTiDBAnalyzeVersion = 2 - DefTiDBEnableIndexMergeJoin = false - DefTiDBTrackAggregateMemoryUsage = true - DefTiDBEnableExchangePartition = false - DefCTEMaxRecursionDepth = 1000 - DefTiDBTopSQLEnable = false - DefTiDBTopSQLAgentAddress = "" - DefTiDBTopSQLPrecisionSeconds = 1 - DefTiDBTopSQLMaxStatementCount = 200 - DefTiDBTopSQLMaxCollect = 10000 - DefTiDBTopSQLReportIntervalSeconds = 60 - DefTiDBEnableGlobalTemporaryTable = false - DefTMPTableSize = 16777216 - DefTiDBEnableLocalTxn = false DefTiDBEnableOrderedResultMode = false ->>>>>>> 0db5df550... planner: rename stable-result-mode to ordered-result-mode (#26093) ) // Process global variables. From dc4b6abfcb3df92f0062e3b6bdc6b73b98c9f4a8 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 12 Jul 2021 21:06:06 +0800 Subject: [PATCH 3/4] fix ci --- planner/core/rule_result_reorder_test.go | 3 ++- session/session.go | 2 +- sessionctx/variable/session.go | 2 +- sessionctx/variable/sysvar.go | 2 +- sessionctx/variable/varsutil.go | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/planner/core/rule_result_reorder_test.go b/planner/core/rule_result_reorder_test.go index 8a092e2b32467..381892b81e0cd 100644 --- a/planner/core/rule_result_reorder_test.go +++ b/planner/core/rule_result_reorder_test.go @@ -14,6 +14,8 @@ package core_test import ( + "math" + . "github.com/pingcap/check" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" @@ -22,7 +24,6 @@ import ( "github.com/pingcap/tidb/util/kvcache" "github.com/pingcap/tidb/util/testkit" "github.com/pingcap/tidb/util/testutil" - "math" ) var _ = Suite(&testRuleReorderResults{}) diff --git a/session/session.go b/session/session.go index 3e8a37cffb45f..bf96f9f632908 100644 --- a/session/session.go +++ b/session/session.go @@ -2228,7 +2228,7 @@ var builtinGlobalVariable = []string{ variable.TiDBEnableRateLimitAction, variable.TiDBMemoryUsageAlarmRatio, variable.TiDBMultiStatementMode, - variable.TiDBEnableStableResultMode, + variable.TiDBEnableOrderedResultMode, } var ( diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index fc37b6acc5256..37c892191c70a 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -1415,7 +1415,7 @@ func (s *SessionVars) SetSystemVar(name string, val string) error { MemoryUsageAlarmRatio.Store(floatVal) case TiDBMultiStatementMode: s.MultiStatementMode = TiDBOptMultiStmt(val) - case TiDBEnableStableResultMode: + case TiDBEnableOrderedResultMode: s.EnableStableResultMode = TiDBOptOn(val) } s.systems[name] = val diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 5fcb5e6bf5979..51a47365a2706 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -744,7 +744,7 @@ var defaultSysVars = []*SysVar{ {ScopeGlobal, TiDBEnableTelemetry, BoolToIntStr(DefTiDBEnableTelemetry)}, {ScopeGlobal | ScopeSession, TiDBEnableAmendPessimisticTxn, boolToOnOff(DefTiDBEnableAmendPessimisticTxn)}, {ScopeGlobal | ScopeSession, TiDBMultiStatementMode, Off}, - {ScopeGlobal | ScopeSession, TiDBEnableStableResultMode, boolToOnOff(DefTiDBEnableStableResultMode)}, + {ScopeGlobal | ScopeSession, TiDBEnableOrderedResultMode, boolToOnOff(DefTiDBEnableOrderedResultMode)}, } // SynonymsSysVariables is synonyms of system variables. diff --git a/sessionctx/variable/varsutil.go b/sessionctx/variable/varsutil.go index dc948e58dcdcb..81c4c81553357 100644 --- a/sessionctx/variable/varsutil.go +++ b/sessionctx/variable/varsutil.go @@ -465,7 +465,7 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string, scope Sc TiDBCheckMb4ValueInUTF8, TiDBEnableSlowLog, TiDBRecordPlanInSlowLog, TiDBScatterRegion, TiDBGeneralLog, TiDBConstraintCheckInPlace, TiDBEnableVectorizedExpression, TiDBFoundInPlanCache, TiDBEnableCollectExecutionInfo, - TiDBAllowAutoRandExplicitInsert, TiDBEnableTelemetry, TiDBEnableAmendPessimisticTxn, TiDBEnableStableResultMode: + TiDBAllowAutoRandExplicitInsert, TiDBEnableTelemetry, TiDBEnableAmendPessimisticTxn, TiDBEnableOrderedResultMode: fallthrough case GeneralLog, AvoidTemporalUpgrade, BigTables, CheckProxyUsers, LogBin, CoreFile, EndMakersInJSON, SQLLogBin, OfflineMode, PseudoSlaveMode, LowPriorityUpdates, From 3e621cc20328f2d0d83e17dadfa9cc4afdc40769 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 12 Jul 2021 21:19:38 +0800 Subject: [PATCH 4/4] fixup --- planner/core/rule_result_reorder_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/planner/core/rule_result_reorder_test.go b/planner/core/rule_result_reorder_test.go index 381892b81e0cd..a030c2d3d8ebf 100644 --- a/planner/core/rule_result_reorder_test.go +++ b/planner/core/rule_result_reorder_test.go @@ -185,6 +185,5 @@ func (s *testRuleReorderResults) TestOrderedResultModeOnPartitionTable(c *C) { partition p1 values less than (200), partition p2 values less than (300), partition p3 values less than (400))`) - tk.MustQuery("select @@tidb_partition_prune_mode").Check(testkit.Rows("static")) s.runTestData(c, tk, "TestOrderedResultModeOnPartitionTable") }