From 0a04a0414fb51d4e8fcc6b890c65698484276753 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Mon, 25 Sep 2023 16:00:25 +0800 Subject: [PATCH] *: move IT tests in `sessionctx`, `sessiontxn` to integrationtest (#47212) close pingcap/tidb#47211, close pingcap/tidb#47213 --- sessionctx/binloginfo/binloginfo_test.go | 5 +- sessionctx/variable/BUILD.bazel | 1 - sessionctx/variable/setvar_test.go | 186 -- sessiontxn/staleread/BUILD.bazel | 2 +- sessiontxn/staleread/externalts_test.go | 93 - .../r/sessionctx/setvar.result | 1673 +++++++++++++++++ .../r/sessiontxn/externals.result | 98 + .../integrationtest/t/sessionctx/setvar.test | 683 +++++++ .../t/sessiontxn/externals.test | 65 + 9 files changed, 2523 insertions(+), 283 deletions(-) delete mode 100644 sessionctx/variable/setvar_test.go create mode 100644 tests/integrationtest/r/sessionctx/setvar.result create mode 100644 tests/integrationtest/r/sessiontxn/externals.result create mode 100644 tests/integrationtest/t/sessionctx/setvar.test create mode 100644 tests/integrationtest/t/sessiontxn/externals.test diff --git a/sessionctx/binloginfo/binloginfo_test.go b/sessionctx/binloginfo/binloginfo_test.go index f6ca6bc059db8..2c77f8b5d66d7 100644 --- a/sessionctx/binloginfo/binloginfo_test.go +++ b/sessionctx/binloginfo/binloginfo_test.go @@ -530,10 +530,11 @@ func TestPessimisticLockThenCommit(t *testing.T) { } func TestDeleteSchema(t *testing.T) { - store := testkit.CreateMockStore(t) + s := createBinlogSuite(t) - tk := testkit.NewTestKit(t, store) + tk := testkit.NewTestKit(t, s.store) tk.MustExec("use test") + tk.Session().GetSessionVars().BinlogClient = s.client tk.MustExec("CREATE TABLE `b1` (`id` int(11) NOT NULL AUTO_INCREMENT, `job_id` varchar(50) NOT NULL, `split_job_id` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `b1` (`job_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;") tk.MustExec("CREATE TABLE `b2` (`id` int(11) NOT NULL AUTO_INCREMENT, `job_id` varchar(50) NOT NULL, `batch_class` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `bu` (`job_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4") tk.MustExec("insert into b2 (job_id, batch_class) values (2, 'TEST');") diff --git a/sessionctx/variable/BUILD.bazel b/sessionctx/variable/BUILD.bazel index 1a4ffc1258fc4..680cb87a43f72 100644 --- a/sessionctx/variable/BUILD.bazel +++ b/sessionctx/variable/BUILD.bazel @@ -88,7 +88,6 @@ go_test( "mock_globalaccessor_test.go", "removed_test.go", "session_test.go", - "setvar_test.go", "statusvar_test.go", "sysvar_test.go", "variable_test.go", diff --git a/sessionctx/variable/setvar_test.go b/sessionctx/variable/setvar_test.go deleted file mode 100644 index 1f82768886c4b..0000000000000 --- a/sessionctx/variable/setvar_test.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2023 PingCAP, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package variable_test - -import ( - "fmt" - "testing" - - "github.com/pingcap/tidb/testkit" -) - -func TestSetVarNonStringOrEnum(t *testing.T) { - testCases := []struct { - varName string - cases []string - }{ - {"tidb_opt_agg_push_down", []string{"0", "1"}}, - {"tidb_opt_derive_topn", []string{"0", "1"}}, - {"tidb_opt_broadcast_cartesian_join", []string{"0", "1"}}, - {"tidb_opt_mpp_outer_join_fixed_build_side", []string{"0", "1"}}, - {"tidb_opt_distinct_agg_push_down", []string{"0", "1"}}, - {"tidb_opt_skew_distinct_agg", []string{"0", "1"}}, - {"tidb_opt_three_stage_distinct_agg", []string{"0", "1"}}, - {"tidb_broadcast_join_threshold_size", []string{"0", "1"}}, - {"tidb_broadcast_join_threshold_count", []string{"0", "1"}}, - {"tidb_prefer_broadcast_join_by_exchange_data_size", []string{"0", "1"}}, - {"tidb_opt_write_row_id", []string{"0", "1"}}, - {"tidb_optimizer_selectivity_level", []string{"0", "1"}}, - {"tidb_enable_new_only_full_group_by_check", []string{"0", "1"}}, - {"tidb_enable_outer_join_reorder", []string{"0", "1"}}, - {"tidb_enable_null_aware_anti_join", []string{"0", "1"}}, - {"tidb_read_staleness", []string{"0", "-1"}}, - {"tidb_enable_paging", []string{"0", "1"}}, - {"tidb_distsql_scan_concurrency", []string{"1", "2"}}, - {"tidb_opt_insubq_to_join_and_agg", []string{"0", "1"}}, - {"tidb_opt_prefer_range_scan", []string{"0", "1"}}, - {"tidb_opt_enable_correlation_adjustment", []string{"0", "1"}}, - {"tidb_opt_limit_push_down_threshold", []string{"0", "1"}}, - {"tidb_opt_correlation_threshold", []string{"0", "1"}}, - {"tidb_opt_correlation_exp_factor", []string{"0", "1"}}, - {"tidb_opt_cpu_factor", []string{"0", "1"}}, - {"tidb_opt_copcpu_factor", []string{"0", "1"}}, - {"tidb_opt_tiflash_concurrency_factor", []string{"1", "2"}}, - {"tidb_opt_network_factor", []string{"0", "1"}}, - {"tidb_opt_scan_factor", []string{"0", "1"}}, - {"tidb_opt_desc_factor", []string{"0", "1"}}, - {"tidb_opt_seek_factor", []string{"0", "1"}}, - {"tidb_opt_memory_factor", []string{"0", "1"}}, - {"tidb_opt_disk_factor", []string{"0", "1"}}, - {"tidb_opt_concurrency_factor", []string{"1", "2"}}, - {"tidb_opt_force_inline_cte", []string{"0", "1"}}, - {"tidb_index_join_batch_size", []string{"1", "2"}}, - {"tidb_index_lookup_size", []string{"1", "2"}}, - {"tidb_index_serial_scan_concurrency", []string{"1", "2"}}, - {"tidb_allow_batch_cop", []string{"0", "1"}}, - {"tidb_allow_mpp", []string{"0", "1"}}, - {"tidb_enforce_mpp", []string{"0", "1"}}, - {"tidb_max_bytes_before_tiflash_external_join", []string{"0", "1"}}, - {"tidb_max_bytes_before_tiflash_external_group_by", []string{"0", "1"}}, - {"tidb_max_bytes_before_tiflash_external_sort", []string{"0", "1"}}, - {"tidb_min_paging_size", []string{"1", "2"}}, - {"tidb_max_paging_size", []string{"10", "20"}}, - {"tidb_enable_cascades_planner", []string{"0", "1"}}, - {"tidb_merge_join_concurrency", []string{"1", "2"}}, - {"tidb_index_merge_intersection_concurrency", []string{"1", "2"}}, - {"tidb_opt_projection_push_down", []string{"0", "1"}}, - {"tidb_enable_vectorized_expression", []string{"0", "1"}}, - {"tidb_opt_join_reorder_threshold", []string{"0", "1"}}, - {"tidb_enable_index_merge", []string{"0", "1"}}, - {"tidb_enable_extended_stats", []string{"0", "1"}}, - {"tidb_executor_concurrency", []string{"1", "2"}}, - {"tidb_enable_index_merge_join", []string{"0", "1"}}, - {"tidb_enable_ordered_result_mode", []string{"0", "1"}}, - {"tidb_enable_pseudo_for_outdated_stats", []string{"0", "1"}}, - {"tidb_stats_load_sync_wait", []string{"0", "1"}}, - {"tidb_cost_model_version", []string{"1", "2"}}, - {"tidb_index_join_double_read_penalty_cost_rate", []string{"0", "1"}}, - {"tidb_default_string_match_selectivity", []string{"0", "1"}}, - {"tidb_enable_prepared_plan_cache", []string{"0", "1"}}, - {"tidb_enable_non_prepared_plan_cache", []string{"0", "1"}}, - {"tidb_plan_cache_max_plan_size", []string{"0", "1"}}, - {"tidb_opt_range_max_size", []string{"0", "1"}}, - {"tidb_opt_advanced_join_hint", []string{"0", "1"}}, - {"tidb_opt_prefix_index_single_scan", []string{"0", "1"}}, - {"tidb_store_batch_size", []string{"1", "2"}}, - {"tidb_enable_inl_join_inner_multi_pattern", []string{"0", "1"}}, - {"tidb_opt_enable_late_materialization", []string{"0", "1"}}, - {"tidb_opt_ordering_index_selectivity_threshold", []string{"0", "1"}}, - {"tidb_opt_enable_mpp_shared_cte_execution", []string{"0", "1"}}, - } - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - for _, c := range testCases { - for _, setv := range c.cases { - tk.MustQuery(fmt.Sprintf("select /*+ set_var(%v=%v) */ @@%v", c.varName, setv, c.varName)).Check(testkit.Rows(setv)) - r := tk.MustQuery(fmt.Sprintf("select @@%v", c.varName)).Rows() - tk.MustExec(fmt.Sprintf("set @@%v=default", c.varName)) - tk.MustQuery(fmt.Sprintf("select @@%v", c.varName)).Check(r) - } - } - - tk.MustQuery("select @@max_execution_time").Check(testkit.Rows("0")) - tk.MustExec("set @@max_execution_time=1000") - tk.MustQuery("select @@max_execution_time").Check(testkit.Rows("1000")) - tk.MustQuery("select /*+ set_var(max_execution_time=100) */ @@max_execution_time").Check(testkit.Rows("100")) - // The value is the changed value 1000, not the default value 0. - tk.MustQuery("select @@max_execution_time").Check(testkit.Rows("1000")) - - tk.MustExec("set @@global.max_execution_time=1000") - - tk2 := testkit.NewTestKit(t, store) - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("1000")) - tk2.MustQuery("select /*+ set_var(max_execution_time=100) */ @@max_execution_time").Check(testkit.Rows("100")) - // The value is the global value 1000, not the default value 0. - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("1000")) - tk2.MustExec("set @@max_execution_time=2000") - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("2000")) - tk2.MustQuery("select /*+ set_var(max_execution_time=100) */ @@max_execution_time").Check(testkit.Rows("100")) - // The value is the changed value 2000, not the default value 0 or the global value 1000. - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("2000")) - - tk2.MustExec("explain analyze select /*+ set_var(max_execution_time=100) */ @@max_execution_time") - // The value is the changed value 2000, not the default value 0 or the global value 1000. - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("2000")) - - tk2.MustExec("use test") - tk2.MustExec("create table t(a int)") - tk2.MustExec("create global binding for select * from t where a = 1 and sleep(0.1) using select /*+ SET_VAR(max_execution_time=500) */ * from t where a = 1 and sleep(0.1)") - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("2000")) - tk2.MustQuery("select * from t where a = 1 and sleep(0.1)").Check(testkit.Rows()) - tk2.MustQuery("select @@last_plan_from_binding").Check(testkit.Rows("1")) - tk2.MustQuery("select @@max_execution_time").Check(testkit.Rows("2000")) -} - -func TestSetVarStringOrEnum(t *testing.T) { - testCases := []struct { - varName string - cases []string - }{ - {"tidb_read_consistency", []string{"strict", "weak"}}, - {"tidb_isolation_read_engines", []string{"tidb,tiflash", "tikv,tidb"}}, - {"tidb_replica_read", []string{"follower", "prefer-leader"}}, - {"tidb_partition_prune_mode", []string{"static", "dynamic"}}, - {"mpp_version", []string{"0", "1"}}, - {"tidb_opt_fix_control", []string{"44262:ON", "44389:ON,44823:ON"}}, - {"tidb_runtime_filter_mode", []string{"OFF", "LOCAL"}}, - {"sql_mode", []string{"", "ONLY_FULL_GROUP_BY"}}, - } - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - for _, c := range testCases { - for _, setv := range c.cases { - tk.MustQuery(fmt.Sprintf("select /*+ set_var(%v=\"%v\") */ @@%v", c.varName, setv, c.varName)).Check(testkit.Rows(setv)) - r := tk.MustQuery(fmt.Sprintf("select @@%v", c.varName)).Rows() - tk.MustExec(fmt.Sprintf("set @@%v=default", c.varName)) - tk.MustQuery(fmt.Sprintf("select @@%v", c.varName)).Check(r) - } - } -} - -func TestSetVarHintBreakCache(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - tk.MustExec("use test") - tk.MustExec("CREATE TABLE t (a INT, b INT, KEY(b));") - tk.MustExec("SET tidb_enable_non_prepared_plan_cache = true;") - tk.MustExec("SELECT * FROM t WHERE b < 10 AND a = 1;") - tk.MustExec("SELECT * FROM t WHERE b < 5 AND a = 2;") - tk.MustQuery("select @@last_plan_from_cache;").Check(testkit.Rows("1")) - tk.MustExec("SELECT /*+ SET_VAR(tidb_distsql_scan_concurrency=10) */ * FROM t WHERE b < 5 AND a = 2;") - tk.MustQuery("select @@last_plan_from_cache;").Check(testkit.Rows("0")) - tk.MustExec("SELECT * FROM t WHERE b < 5 AND a = 2;") - tk.MustQuery("select @@last_plan_from_cache;").Check(testkit.Rows("1")) -} diff --git a/sessiontxn/staleread/BUILD.bazel b/sessiontxn/staleread/BUILD.bazel index 3d9f6a7c69201..0fa1d89159ed3 100644 --- a/sessiontxn/staleread/BUILD.bazel +++ b/sessiontxn/staleread/BUILD.bazel @@ -44,7 +44,7 @@ go_test( "provider_test.go", ], flaky = True, - shard_count = 10, + shard_count = 6, deps = [ ":staleread", "//domain", diff --git a/sessiontxn/staleread/externalts_test.go b/sessiontxn/staleread/externalts_test.go index a0bd0b81a938c..683ec1f363045 100644 --- a/sessiontxn/staleread/externalts_test.go +++ b/sessiontxn/staleread/externalts_test.go @@ -24,40 +24,6 @@ import ( "github.com/stretchr/testify/require" ) -func TestReadWriteExternalTimestamp(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("0")) - tk.MustExec("set global tidb_external_ts=19980613") - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("19980613")) - tk.MustExec("set global tidb_external_ts=20220930") - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("20220930")) -} - -func TestExternalTimestampRead(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - - tk.MustExec("use test") - tk.MustExec("create table t (id INT NOT NULL,d double,PRIMARY KEY (id))") - tk.MustExec("insert into t values (0, 100)") - tk.MustExec("insert into t values (1, 100)") - tk.MustExec("insert into t values (2, 100)") - tk.MustExec("insert into t values (3, 100)") - tk.MustQuery("select * from t").Check(testkit.Rows("0 100", "1 100", "2 100", "3 100")) - - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("0")) - tk.MustExec("start transaction;set global tidb_external_ts=@@tidb_current_ts;commit;") - tk.MustExec("insert into t values (4, 100)") - // as the `tidb_external_ts` is set an old value, the newest row (4, 100) cannot be read - tk.MustExec("set tidb_enable_external_ts_read=ON") - tk.MustQuery("select * from t").Check(testkit.Rows("0 100", "1 100", "2 100", "3 100")) - - tk.MustExec("set tidb_enable_external_ts_read=OFF") - tk.MustQuery("select * from t").Check(testkit.Rows("0 100", "1 100", "2 100", "3 100", "4 100")) -} - func TestExternalTimestampReadonly(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) @@ -84,62 +50,3 @@ func TestExternalTimestampReadonly(t *testing.T) { tk.MustExecWithContext(ctx, "insert into t values (1)") tk.Session().GetSessionVars().InRestrictedSQL = false } - -func TestExternalTimestampReadWithTransaction(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil)) - - tk.MustExec("use test") - tk.MustExec("create table t (id INT NOT NULL,PRIMARY KEY (id))") - - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("0")) - tk.MustExec("start transaction;set global tidb_external_ts=@@tidb_current_ts;commit;") - - tk.MustExec("insert into t values (0)") - tk.MustQuery("select * from t").Check(testkit.Rows("0")) - - tk.MustExec("set tidb_enable_external_ts_read=ON") - tk.MustQuery("select * from t").Check(testkit.Rows()) - tk.MustExec("start transaction") - tk.MustQuery("select * from t").Check(testkit.Rows()) - tk.MustExec("commit") - - tk.MustExec("set tidb_enable_external_ts_read=OFF") - tk.MustExec("start transaction") - tk.MustQuery("select * from t").Check(testkit.Rows("0")) - tk.MustExec("commit") - - tk.MustExec("start transaction") - tk.MustQuery("select * from t").Check(testkit.Rows("0")) - tk.MustExec("set tidb_enable_external_ts_read=ON") - // `tidb_enable_external_ts_read` doesn't affect existing transaction - tk.MustQuery("select * from t").Check(testkit.Rows("0")) - tk.MustExec("set tidb_enable_external_ts_read=OFF") - tk.MustExec("commit") -} - -func TestExternalTimestampNotAffectPrepare(t *testing.T) { - store := testkit.CreateMockStore(t) - tk := testkit.NewTestKit(t, store) - require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil)) - - tk.MustExec("use test") - tk.MustExec("create table t (id INT NOT NULL,PRIMARY KEY (id))") - - tk.MustExec("insert into t values (0)") - tk.MustQuery("select * from t").Check(testkit.Rows("0")) - - tk.MustQuery("select @@tidb_external_ts").Check(testkit.Rows("0")) - tk.MustExec("start transaction;set global tidb_external_ts=@@tidb_current_ts;commit;") - - tk.MustExec("insert into t values (1)") - tk.MustQuery("select * from t").Check(testkit.Rows("0", "1")) - - tk.MustExec("set tidb_enable_external_ts_read=on") - tk.MustExec("prepare my_select from 'select * from t'") - tk.MustQuery("execute my_select").Check(testkit.Rows("0")) - tk.MustExec("set tidb_enable_external_ts_read=off") - - tk.MustQuery("execute my_select").Check(testkit.Rows("0", "1")) -} diff --git a/tests/integrationtest/r/sessionctx/setvar.result b/tests/integrationtest/r/sessionctx/setvar.result new file mode 100644 index 0000000000000..ae3db79da1a6f --- /dev/null +++ b/tests/integrationtest/r/sessionctx/setvar.result @@ -0,0 +1,1673 @@ +select /*+ set_var(tidb_read_consistency="strict") */ @@tidb_read_consistency; +@@tidb_read_consistency +strict +select @@tidb_read_consistency; +@@tidb_read_consistency +strict +set @@tidb_read_consistency=default; +select @@tidb_read_consistency; +@@tidb_read_consistency +strict +select /*+ set_var(tidb_read_consistency="weak") */ @@tidb_read_consistency; +@@tidb_read_consistency +weak +select @@tidb_read_consistency; +@@tidb_read_consistency +strict +set @@tidb_read_consistency=default; +select @@tidb_read_consistency; +@@tidb_read_consistency +strict +select /*+ set_var(tidb_isolation_read_engines="tidb,tiflash") */ @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tidb,tiflash +select @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tikv,tiflash,tidb +set @@tidb_isolation_read_engines=default; +select @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tikv,tiflash,tidb +select /*+ set_var(tidb_isolation_read_engines="tikv,tidb") */ @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tikv,tidb +select @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tikv,tiflash,tidb +set @@tidb_isolation_read_engines=default; +select @@tidb_isolation_read_engines; +@@tidb_isolation_read_engines +tikv,tiflash,tidb +select /*+ set_var(tidb_replica_read="follower") */ @@tidb_replica_read; +@@tidb_replica_read +follower +select @@tidb_replica_read; +@@tidb_replica_read +leader +set @@tidb_replica_read=default; +select @@tidb_replica_read; +@@tidb_replica_read +leader +select /*+ set_var(tidb_replica_read="prefer-leader") */ @@tidb_replica_read; +@@tidb_replica_read +prefer-leader +select @@tidb_replica_read; +@@tidb_replica_read +leader +set @@tidb_replica_read=default; +select @@tidb_replica_read; +@@tidb_replica_read +leader +select /*+ set_var(tidb_partition_prune_mode="static") */ @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +static +select @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +dynamic +set @@tidb_partition_prune_mode=default; +select @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +dynamic +select /*+ set_var(tidb_partition_prune_mode="dynamic") */ @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +dynamic +select @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +dynamic +set @@tidb_partition_prune_mode=default; +select @@tidb_partition_prune_mode; +@@tidb_partition_prune_mode +dynamic +select /*+ set_var(mpp_version="0") */ @@mpp_version; +@@mpp_version +0 +select @@mpp_version; +@@mpp_version +UNSPECIFIED +set @@mpp_version=default; +select @@mpp_version; +@@mpp_version +UNSPECIFIED +select /*+ set_var(mpp_version="1") */ @@mpp_version; +@@mpp_version +1 +select @@mpp_version; +@@mpp_version +UNSPECIFIED +set @@mpp_version=default; +select @@mpp_version; +@@mpp_version +UNSPECIFIED +select /*+ set_var(tidb_opt_fix_control="44262:ON") */ @@tidb_opt_fix_control; +@@tidb_opt_fix_control +44262:ON +select @@tidb_opt_fix_control; +@@tidb_opt_fix_control + +set @@tidb_opt_fix_control=default; +select @@tidb_opt_fix_control; +@@tidb_opt_fix_control + +select /*+ set_var(tidb_opt_fix_control="44389:ON,44823:ON") */ @@tidb_opt_fix_control; +@@tidb_opt_fix_control +44389:ON,44823:ON +select @@tidb_opt_fix_control; +@@tidb_opt_fix_control + +set @@tidb_opt_fix_control=default; +select @@tidb_opt_fix_control; +@@tidb_opt_fix_control + +select /*+ set_var(tidb_runtime_filter_mode="OFF") */ @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +OFF +select @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +OFF +set @@tidb_runtime_filter_mode=default; +select @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +OFF +select /*+ set_var(tidb_runtime_filter_mode="LOCAL") */ @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +LOCAL +select @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +OFF +set @@tidb_runtime_filter_mode=default; +select @@tidb_runtime_filter_mode; +@@tidb_runtime_filter_mode +OFF +select /*+ set_var(sql_mode="") */ @@sql_mode; +@@sql_mode + +select @@sql_mode; +@@sql_mode +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +set @@sql_mode=default; +select @@sql_mode; +@@sql_mode +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +select /*+ set_var(sql_mode="ONLY_FULL_GROUP_BY") */ @@sql_mode; +@@sql_mode +ONLY_FULL_GROUP_BY +select @@sql_mode; +@@sql_mode +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +set @@sql_mode=default; +select @@sql_mode; +@@sql_mode +ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION +CREATE TABLE t (a INT, b INT, KEY(b)); +SET tidb_enable_non_prepared_plan_cache = true; +SELECT * FROM t WHERE b < 10 AND a = 1; +a b +SELECT * FROM t WHERE b < 5 AND a = 2; +a b +select @@last_plan_from_cache; +@@last_plan_from_cache +0 +SELECT /*+ SET_VAR(tidb_distsql_scan_concurrency=10) */ * FROM t WHERE b < 5 AND a = 2; +a b +select @@last_plan_from_cache; +@@last_plan_from_cache +0 +SELECT * FROM t WHERE b < 5 AND a = 2; +a b +select @@last_plan_from_cache; +@@last_plan_from_cache +0 +select /*+ set_var(tidb_opt_agg_push_down=0) */ @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +0 +select @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +0 +set @@tidb_opt_agg_push_down=default; +select @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +0 +select /*+ set_var(tidb_opt_agg_push_down=1) */ @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +1 +select @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +0 +set @@tidb_opt_agg_push_down=default; +select @@tidb_opt_agg_push_down; +@@tidb_opt_agg_push_down +0 +select /*+ set_var(tidb_opt_derive_topn=0) */ @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +0 +select @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +0 +set @@tidb_opt_derive_topn=default; +select @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +0 +select /*+ set_var(tidb_opt_derive_topn=1) */ @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +1 +select @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +0 +set @@tidb_opt_derive_topn=default; +select @@tidb_opt_derive_topn; +@@tidb_opt_derive_topn +0 +select /*+ set_var(tidb_opt_broadcast_cartesian_join=0) */ @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +0 +select @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +1 +set @@tidb_opt_broadcast_cartesian_join=default; +select @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +1 +select /*+ set_var(tidb_opt_broadcast_cartesian_join=1) */ @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +1 +select @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +1 +set @@tidb_opt_broadcast_cartesian_join=default; +select @@tidb_opt_broadcast_cartesian_join; +@@tidb_opt_broadcast_cartesian_join +1 +select /*+ set_var(tidb_opt_mpp_outer_join_fixed_build_side=0) */ @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +0 +select @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +0 +set @@tidb_opt_mpp_outer_join_fixed_build_side=default; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +0 +select /*+ set_var(tidb_opt_mpp_outer_join_fixed_build_side=1) */ @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +1 +select @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +0 +set @@tidb_opt_mpp_outer_join_fixed_build_side=default; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +@@tidb_opt_mpp_outer_join_fixed_build_side +0 +select /*+ set_var(tidb_opt_distinct_agg_push_down=0) */ @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +0 +select @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +0 +set @@tidb_opt_distinct_agg_push_down=default; +select @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +0 +select /*+ set_var(tidb_opt_distinct_agg_push_down=1) */ @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +1 +select @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +0 +set @@tidb_opt_distinct_agg_push_down=default; +select @@tidb_opt_distinct_agg_push_down; +@@tidb_opt_distinct_agg_push_down +0 +select /*+ set_var(tidb_opt_skew_distinct_agg=0) */ @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +0 +select @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +0 +set @@tidb_opt_skew_distinct_agg=default; +select @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +0 +select /*+ set_var(tidb_opt_skew_distinct_agg=1) */ @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +1 +select @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +0 +set @@tidb_opt_skew_distinct_agg=default; +select @@tidb_opt_skew_distinct_agg; +@@tidb_opt_skew_distinct_agg +0 +select /*+ set_var(tidb_opt_three_stage_distinct_agg=0) */ @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +0 +select @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +1 +set @@tidb_opt_three_stage_distinct_agg=default; +select @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +1 +select /*+ set_var(tidb_opt_three_stage_distinct_agg=1) */ @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +1 +select @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +1 +set @@tidb_opt_three_stage_distinct_agg=default; +select @@tidb_opt_three_stage_distinct_agg; +@@tidb_opt_three_stage_distinct_agg +1 +select /*+ set_var(tidb_broadcast_join_threshold_size=0) */ @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +0 +select @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +104857600 +set @@tidb_broadcast_join_threshold_size=default; +select @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +104857600 +select /*+ set_var(tidb_broadcast_join_threshold_size=1) */ @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +1 +select @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +104857600 +set @@tidb_broadcast_join_threshold_size=default; +select @@tidb_broadcast_join_threshold_size; +@@tidb_broadcast_join_threshold_size +104857600 +select /*+ set_var(tidb_broadcast_join_threshold_count=0) */ @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +0 +select @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +10240 +set @@tidb_broadcast_join_threshold_count=default; +select @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +10240 +select /*+ set_var(tidb_broadcast_join_threshold_count=1) */ @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +1 +select @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +10240 +set @@tidb_broadcast_join_threshold_count=default; +select @@tidb_broadcast_join_threshold_count; +@@tidb_broadcast_join_threshold_count +10240 +select /*+ set_var(tidb_prefer_broadcast_join_by_exchange_data_size=0) */ @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +0 +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +0 +set @@tidb_prefer_broadcast_join_by_exchange_data_size=default; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +0 +select /*+ set_var(tidb_prefer_broadcast_join_by_exchange_data_size=1) */ @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +1 +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +0 +set @@tidb_prefer_broadcast_join_by_exchange_data_size=default; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +@@tidb_prefer_broadcast_join_by_exchange_data_size +0 +select /*+ set_var(tidb_opt_write_row_id=0) */ @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +0 +select @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +0 +set @@tidb_opt_write_row_id=default; +select @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +0 +select /*+ set_var(tidb_opt_write_row_id=1) */ @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +1 +select @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +0 +set @@tidb_opt_write_row_id=default; +select @@tidb_opt_write_row_id; +@@tidb_opt_write_row_id +0 +select /*+ set_var(tidb_optimizer_selectivity_level=0) */ @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +0 +select @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +0 +set @@tidb_optimizer_selectivity_level=default; +select @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +0 +select /*+ set_var(tidb_optimizer_selectivity_level=1) */ @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +1 +select @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +0 +set @@tidb_optimizer_selectivity_level=default; +select @@tidb_optimizer_selectivity_level; +@@tidb_optimizer_selectivity_level +0 +select /*+ set_var(tidb_enable_new_only_full_group_by_check=0) */ @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +0 +select @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +0 +set @@tidb_enable_new_only_full_group_by_check=default; +select @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +0 +select /*+ set_var(tidb_enable_new_only_full_group_by_check=1) */ @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +1 +select @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +0 +set @@tidb_enable_new_only_full_group_by_check=default; +select @@tidb_enable_new_only_full_group_by_check; +@@tidb_enable_new_only_full_group_by_check +0 +select /*+ set_var(tidb_enable_outer_join_reorder=0) */ @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +0 +select @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +1 +set @@tidb_enable_outer_join_reorder=default; +select @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +1 +select /*+ set_var(tidb_enable_outer_join_reorder=1) */ @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +1 +select @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +1 +set @@tidb_enable_outer_join_reorder=default; +select @@tidb_enable_outer_join_reorder; +@@tidb_enable_outer_join_reorder +1 +select /*+ set_var(tidb_enable_null_aware_anti_join=0) */ @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +0 +select @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +1 +set @@tidb_enable_null_aware_anti_join=default; +select @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +1 +select /*+ set_var(tidb_enable_null_aware_anti_join=1) */ @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +1 +select @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +1 +set @@tidb_enable_null_aware_anti_join=default; +select @@tidb_enable_null_aware_anti_join; +@@tidb_enable_null_aware_anti_join +1 +select /*+ set_var(tidb_read_staleness=0) */ @@tidb_read_staleness; +@@tidb_read_staleness +0 +select @@tidb_read_staleness; +@@tidb_read_staleness +0 +set @@tidb_read_staleness=default; +select @@tidb_read_staleness; +@@tidb_read_staleness +0 +select /*+ set_var(tidb_read_staleness=-1) */ @@tidb_read_staleness; +@@tidb_read_staleness +-1 +select @@tidb_read_staleness; +@@tidb_read_staleness +0 +set @@tidb_read_staleness=default; +select @@tidb_read_staleness; +@@tidb_read_staleness +0 +select /*+ set_var(tidb_enable_paging=0) */ @@tidb_enable_paging; +@@tidb_enable_paging +0 +select @@tidb_enable_paging; +@@tidb_enable_paging +1 +set @@tidb_enable_paging=default; +select @@tidb_enable_paging; +@@tidb_enable_paging +1 +select /*+ set_var(tidb_enable_paging=1) */ @@tidb_enable_paging; +@@tidb_enable_paging +1 +select @@tidb_enable_paging; +@@tidb_enable_paging +1 +set @@tidb_enable_paging=default; +select @@tidb_enable_paging; +@@tidb_enable_paging +1 +select /*+ set_var(tidb_distsql_scan_concurrency=1) */ @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +1 +select @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +15 +set @@tidb_distsql_scan_concurrency=default; +select @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +15 +select /*+ set_var(tidb_distsql_scan_concurrency=2) */ @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +2 +select @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +15 +set @@tidb_distsql_scan_concurrency=default; +select @@tidb_distsql_scan_concurrency; +@@tidb_distsql_scan_concurrency +15 +select /*+ set_var(tidb_opt_insubq_to_join_and_agg=0) */ @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +0 +select @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +1 +set @@tidb_opt_insubq_to_join_and_agg=default; +select @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +1 +select /*+ set_var(tidb_opt_insubq_to_join_and_agg=1) */ @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +1 +select @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +1 +set @@tidb_opt_insubq_to_join_and_agg=default; +select @@tidb_opt_insubq_to_join_and_agg; +@@tidb_opt_insubq_to_join_and_agg +1 +select /*+ set_var(tidb_opt_prefer_range_scan=0) */ @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +0 +select @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +0 +set @@tidb_opt_prefer_range_scan=default; +select @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +0 +select /*+ set_var(tidb_opt_prefer_range_scan=1) */ @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +1 +select @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +0 +set @@tidb_opt_prefer_range_scan=default; +select @@tidb_opt_prefer_range_scan; +@@tidb_opt_prefer_range_scan +0 +select /*+ set_var(tidb_opt_enable_correlation_adjustment=0) */ @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +0 +select @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +1 +set @@tidb_opt_enable_correlation_adjustment=default; +select @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +1 +select /*+ set_var(tidb_opt_enable_correlation_adjustment=1) */ @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +1 +select @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +1 +set @@tidb_opt_enable_correlation_adjustment=default; +select @@tidb_opt_enable_correlation_adjustment; +@@tidb_opt_enable_correlation_adjustment +1 +select /*+ set_var(tidb_opt_limit_push_down_threshold=0) */ @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +0 +select @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +100 +set @@tidb_opt_limit_push_down_threshold=default; +select @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +100 +select /*+ set_var(tidb_opt_limit_push_down_threshold=1) */ @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +1 +select @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +100 +set @@tidb_opt_limit_push_down_threshold=default; +select @@tidb_opt_limit_push_down_threshold; +@@tidb_opt_limit_push_down_threshold +100 +select /*+ set_var(tidb_opt_correlation_threshold=0) */ @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +0 +select @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +0.9 +set @@tidb_opt_correlation_threshold=default; +select @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +0.9 +select /*+ set_var(tidb_opt_correlation_threshold=1) */ @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +1 +select @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +0.9 +set @@tidb_opt_correlation_threshold=default; +select @@tidb_opt_correlation_threshold; +@@tidb_opt_correlation_threshold +0.9 +select /*+ set_var(tidb_opt_correlation_exp_factor=0) */ @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +0 +select @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +1 +set @@tidb_opt_correlation_exp_factor=default; +select @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +1 +select /*+ set_var(tidb_opt_correlation_exp_factor=1) */ @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +1 +select @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +1 +set @@tidb_opt_correlation_exp_factor=default; +select @@tidb_opt_correlation_exp_factor; +@@tidb_opt_correlation_exp_factor +1 +select /*+ set_var(tidb_opt_cpu_factor=0) */ @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +0 +select @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +3 +set @@tidb_opt_cpu_factor=default; +select @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +3 +select /*+ set_var(tidb_opt_cpu_factor=1) */ @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +1 +select @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +3 +set @@tidb_opt_cpu_factor=default; +select @@tidb_opt_cpu_factor; +@@tidb_opt_cpu_factor +3 +select /*+ set_var(tidb_opt_copcpu_factor=0) */ @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +0 +select @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +3 +set @@tidb_opt_copcpu_factor=default; +select @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +3 +select /*+ set_var(tidb_opt_copcpu_factor=1) */ @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +1 +select @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +3 +set @@tidb_opt_copcpu_factor=default; +select @@tidb_opt_copcpu_factor; +@@tidb_opt_copcpu_factor +3 +select /*+ set_var(tidb_opt_tiflash_concurrency_factor=1) */ @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +1 +select @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +24 +set @@tidb_opt_tiflash_concurrency_factor=default; +select @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +24 +select /*+ set_var(tidb_opt_tiflash_concurrency_factor=2) */ @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +2 +select @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +24 +set @@tidb_opt_tiflash_concurrency_factor=default; +select @@tidb_opt_tiflash_concurrency_factor; +@@tidb_opt_tiflash_concurrency_factor +24 +select /*+ set_var(tidb_opt_network_factor=0) */ @@tidb_opt_network_factor; +@@tidb_opt_network_factor +0 +select @@tidb_opt_network_factor; +@@tidb_opt_network_factor +1 +set @@tidb_opt_network_factor=default; +select @@tidb_opt_network_factor; +@@tidb_opt_network_factor +1 +select /*+ set_var(tidb_opt_network_factor=1) */ @@tidb_opt_network_factor; +@@tidb_opt_network_factor +1 +select @@tidb_opt_network_factor; +@@tidb_opt_network_factor +1 +set @@tidb_opt_network_factor=default; +select @@tidb_opt_network_factor; +@@tidb_opt_network_factor +1 +select /*+ set_var(tidb_opt_scan_factor=0) */ @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +0 +select @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +1.5 +set @@tidb_opt_scan_factor=default; +select @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +1.5 +select /*+ set_var(tidb_opt_scan_factor=1) */ @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +1 +select @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +1.5 +set @@tidb_opt_scan_factor=default; +select @@tidb_opt_scan_factor; +@@tidb_opt_scan_factor +1.5 +select /*+ set_var(tidb_opt_desc_factor=0) */ @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +0 +select @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +3 +set @@tidb_opt_desc_factor=default; +select @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +3 +select /*+ set_var(tidb_opt_desc_factor=1) */ @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +1 +select @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +3 +set @@tidb_opt_desc_factor=default; +select @@tidb_opt_desc_factor; +@@tidb_opt_desc_factor +3 +select /*+ set_var(tidb_opt_seek_factor=0) */ @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +0 +select @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +20 +set @@tidb_opt_seek_factor=default; +select @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +20 +select /*+ set_var(tidb_opt_seek_factor=1) */ @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +1 +select @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +20 +set @@tidb_opt_seek_factor=default; +select @@tidb_opt_seek_factor; +@@tidb_opt_seek_factor +20 +select /*+ set_var(tidb_opt_memory_factor=0) */ @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +0 +select @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +0.001 +set @@tidb_opt_memory_factor=default; +select @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +0.001 +select /*+ set_var(tidb_opt_memory_factor=1) */ @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +1 +select @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +0.001 +set @@tidb_opt_memory_factor=default; +select @@tidb_opt_memory_factor; +@@tidb_opt_memory_factor +0.001 +select /*+ set_var(tidb_opt_disk_factor=0) */ @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +0 +select @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +1.5 +set @@tidb_opt_disk_factor=default; +select @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +1.5 +select /*+ set_var(tidb_opt_disk_factor=1) */ @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +1 +select @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +1.5 +set @@tidb_opt_disk_factor=default; +select @@tidb_opt_disk_factor; +@@tidb_opt_disk_factor +1.5 +select /*+ set_var(tidb_opt_concurrency_factor=1) */ @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +1 +select @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +3 +set @@tidb_opt_concurrency_factor=default; +select @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +3 +select /*+ set_var(tidb_opt_concurrency_factor=2) */ @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +2 +select @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +3 +set @@tidb_opt_concurrency_factor=default; +select @@tidb_opt_concurrency_factor; +@@tidb_opt_concurrency_factor +3 +select /*+ set_var(tidb_opt_force_inline_cte=0) */ @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +0 +select @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +0 +set @@tidb_opt_force_inline_cte=default; +select @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +0 +select /*+ set_var(tidb_opt_force_inline_cte=1) */ @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +1 +select @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +0 +set @@tidb_opt_force_inline_cte=default; +select @@tidb_opt_force_inline_cte; +@@tidb_opt_force_inline_cte +0 +select /*+ set_var(tidb_index_join_batch_size=1) */ @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +1 +select @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +25000 +set @@tidb_index_join_batch_size=default; +select @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +25000 +select /*+ set_var(tidb_index_join_batch_size=2) */ @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +2 +select @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +25000 +set @@tidb_index_join_batch_size=default; +select @@tidb_index_join_batch_size; +@@tidb_index_join_batch_size +25000 +select /*+ set_var(tidb_index_lookup_size=1) */ @@tidb_index_lookup_size; +@@tidb_index_lookup_size +1 +select @@tidb_index_lookup_size; +@@tidb_index_lookup_size +20000 +set @@tidb_index_lookup_size=default; +select @@tidb_index_lookup_size; +@@tidb_index_lookup_size +20000 +select /*+ set_var(tidb_index_lookup_size=2) */ @@tidb_index_lookup_size; +@@tidb_index_lookup_size +2 +select @@tidb_index_lookup_size; +@@tidb_index_lookup_size +20000 +set @@tidb_index_lookup_size=default; +select @@tidb_index_lookup_size; +@@tidb_index_lookup_size +20000 +select /*+ set_var(tidb_index_serial_scan_concurrency=1) */ @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +1 +select @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +1 +set @@tidb_index_serial_scan_concurrency=default; +select @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +1 +select /*+ set_var(tidb_index_serial_scan_concurrency=2) */ @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +2 +select @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +1 +set @@tidb_index_serial_scan_concurrency=default; +select @@tidb_index_serial_scan_concurrency; +@@tidb_index_serial_scan_concurrency +1 +select /*+ set_var(tidb_allow_batch_cop=0) */ @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +0 +select @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +1 +set @@tidb_allow_batch_cop=default; +select @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +1 +select /*+ set_var(tidb_allow_batch_cop=1) */ @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +1 +select @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +1 +set @@tidb_allow_batch_cop=default; +select @@tidb_allow_batch_cop; +@@tidb_allow_batch_cop +1 +select /*+ set_var(tidb_allow_mpp=0) */ @@tidb_allow_mpp; +@@tidb_allow_mpp +0 +select @@tidb_allow_mpp; +@@tidb_allow_mpp +1 +set @@tidb_allow_mpp=default; +select @@tidb_allow_mpp; +@@tidb_allow_mpp +1 +select /*+ set_var(tidb_allow_mpp=1) */ @@tidb_allow_mpp; +@@tidb_allow_mpp +1 +select @@tidb_allow_mpp; +@@tidb_allow_mpp +1 +set @@tidb_allow_mpp=default; +select @@tidb_allow_mpp; +@@tidb_allow_mpp +1 +select /*+ set_var(tidb_enforce_mpp=0) */ @@tidb_enforce_mpp; +@@tidb_enforce_mpp +0 +select @@tidb_enforce_mpp; +@@tidb_enforce_mpp +0 +set @@tidb_enforce_mpp=default; +select @@tidb_enforce_mpp; +@@tidb_enforce_mpp +0 +select /*+ set_var(tidb_enforce_mpp=1) */ @@tidb_enforce_mpp; +@@tidb_enforce_mpp +1 +select @@tidb_enforce_mpp; +@@tidb_enforce_mpp +0 +set @@tidb_enforce_mpp=default; +select @@tidb_enforce_mpp; +@@tidb_enforce_mpp +0 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_join=0) */ @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +0 +select @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +-1 +set @@tidb_max_bytes_before_tiflash_external_join=default; +select @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +-1 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_join=1) */ @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +1 +select @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +-1 +set @@tidb_max_bytes_before_tiflash_external_join=default; +select @@tidb_max_bytes_before_tiflash_external_join; +@@tidb_max_bytes_before_tiflash_external_join +-1 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_group_by=0) */ @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +0 +select @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +-1 +set @@tidb_max_bytes_before_tiflash_external_group_by=default; +select @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +-1 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_group_by=1) */ @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +1 +select @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +-1 +set @@tidb_max_bytes_before_tiflash_external_group_by=default; +select @@tidb_max_bytes_before_tiflash_external_group_by; +@@tidb_max_bytes_before_tiflash_external_group_by +-1 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_sort=0) */ @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +0 +select @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +-1 +set @@tidb_max_bytes_before_tiflash_external_sort=default; +select @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +-1 +select /*+ set_var(tidb_max_bytes_before_tiflash_external_sort=1) */ @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +1 +select @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +-1 +set @@tidb_max_bytes_before_tiflash_external_sort=default; +select @@tidb_max_bytes_before_tiflash_external_sort; +@@tidb_max_bytes_before_tiflash_external_sort +-1 +select /*+ set_var(tidb_min_paging_size=1) */ @@tidb_min_paging_size; +@@tidb_min_paging_size +1 +select @@tidb_min_paging_size; +@@tidb_min_paging_size +128 +set @@tidb_min_paging_size=default; +select @@tidb_min_paging_size; +@@tidb_min_paging_size +128 +select /*+ set_var(tidb_min_paging_size=2) */ @@tidb_min_paging_size; +@@tidb_min_paging_size +2 +select @@tidb_min_paging_size; +@@tidb_min_paging_size +128 +set @@tidb_min_paging_size=default; +select @@tidb_min_paging_size; +@@tidb_min_paging_size +128 +select /*+ set_var(tidb_max_paging_size=10) */ @@tidb_max_paging_size; +@@tidb_max_paging_size +10 +select @@tidb_max_paging_size; +@@tidb_max_paging_size +50000 +set @@tidb_max_paging_size=default; +select @@tidb_max_paging_size; +@@tidb_max_paging_size +50000 +select /*+ set_var(tidb_max_paging_size=20) */ @@tidb_max_paging_size; +@@tidb_max_paging_size +20 +select @@tidb_max_paging_size; +@@tidb_max_paging_size +50000 +set @@tidb_max_paging_size=default; +select @@tidb_max_paging_size; +@@tidb_max_paging_size +50000 +select /*+ set_var(tidb_enable_cascades_planner=0) */ @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +0 +select @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +0 +set @@tidb_enable_cascades_planner=default; +select @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +0 +select /*+ set_var(tidb_enable_cascades_planner=1) */ @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +1 +select @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +0 +set @@tidb_enable_cascades_planner=default; +select @@tidb_enable_cascades_planner; +@@tidb_enable_cascades_planner +0 +select /*+ set_var(tidb_merge_join_concurrency=1) */ @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +1 +select @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +1 +set @@tidb_merge_join_concurrency=default; +select @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +1 +select /*+ set_var(tidb_merge_join_concurrency=2) */ @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +2 +select @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +1 +set @@tidb_merge_join_concurrency=default; +select @@tidb_merge_join_concurrency; +@@tidb_merge_join_concurrency +1 +select /*+ set_var(tidb_index_merge_intersection_concurrency=1) */ @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +1 +select @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +-1 +set @@tidb_index_merge_intersection_concurrency=default; +select @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +-1 +select /*+ set_var(tidb_index_merge_intersection_concurrency=2) */ @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +2 +select @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +-1 +set @@tidb_index_merge_intersection_concurrency=default; +select @@tidb_index_merge_intersection_concurrency; +@@tidb_index_merge_intersection_concurrency +-1 +select /*+ set_var(tidb_opt_projection_push_down=0) */ @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +0 +select @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +0 +set @@tidb_opt_projection_push_down=default; +select @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +0 +select /*+ set_var(tidb_opt_projection_push_down=1) */ @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +1 +select @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +0 +set @@tidb_opt_projection_push_down=default; +select @@tidb_opt_projection_push_down; +@@tidb_opt_projection_push_down +0 +select /*+ set_var(tidb_enable_vectorized_expression=0) */ @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +0 +select @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +1 +set @@tidb_enable_vectorized_expression=default; +select @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +1 +select /*+ set_var(tidb_enable_vectorized_expression=1) */ @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +1 +select @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +1 +set @@tidb_enable_vectorized_expression=default; +select @@tidb_enable_vectorized_expression; +@@tidb_enable_vectorized_expression +1 +select /*+ set_var(tidb_opt_join_reorder_threshold=0) */ @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +0 +select @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +0 +set @@tidb_opt_join_reorder_threshold=default; +select @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +0 +select /*+ set_var(tidb_opt_join_reorder_threshold=1) */ @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +1 +select @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +0 +set @@tidb_opt_join_reorder_threshold=default; +select @@tidb_opt_join_reorder_threshold; +@@tidb_opt_join_reorder_threshold +0 +select /*+ set_var(tidb_enable_index_merge=0) */ @@tidb_enable_index_merge; +@@tidb_enable_index_merge +0 +select @@tidb_enable_index_merge; +@@tidb_enable_index_merge +1 +set @@tidb_enable_index_merge=default; +select @@tidb_enable_index_merge; +@@tidb_enable_index_merge +1 +select /*+ set_var(tidb_enable_index_merge=1) */ @@tidb_enable_index_merge; +@@tidb_enable_index_merge +1 +select @@tidb_enable_index_merge; +@@tidb_enable_index_merge +1 +set @@tidb_enable_index_merge=default; +select @@tidb_enable_index_merge; +@@tidb_enable_index_merge +1 +select /*+ set_var(tidb_enable_extended_stats=0) */ @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +0 +select @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +0 +set @@tidb_enable_extended_stats=default; +select @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +0 +select /*+ set_var(tidb_enable_extended_stats=1) */ @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +1 +select @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +0 +set @@tidb_enable_extended_stats=default; +select @@tidb_enable_extended_stats; +@@tidb_enable_extended_stats +0 +select /*+ set_var(tidb_executor_concurrency=1) */ @@tidb_executor_concurrency; +@@tidb_executor_concurrency +1 +select @@tidb_executor_concurrency; +@@tidb_executor_concurrency +5 +set @@tidb_executor_concurrency=default; +select @@tidb_executor_concurrency; +@@tidb_executor_concurrency +5 +select /*+ set_var(tidb_executor_concurrency=2) */ @@tidb_executor_concurrency; +@@tidb_executor_concurrency +2 +select @@tidb_executor_concurrency; +@@tidb_executor_concurrency +5 +set @@tidb_executor_concurrency=default; +select @@tidb_executor_concurrency; +@@tidb_executor_concurrency +5 +select /*+ set_var(tidb_enable_index_merge_join=0) */ @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +0 +select @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +0 +set @@tidb_enable_index_merge_join=default; +select @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +0 +select /*+ set_var(tidb_enable_index_merge_join=1) */ @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +1 +select @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +0 +set @@tidb_enable_index_merge_join=default; +select @@tidb_enable_index_merge_join; +@@tidb_enable_index_merge_join +0 +select /*+ set_var(tidb_enable_ordered_result_mode=0) */ @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +0 +select @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +0 +set @@tidb_enable_ordered_result_mode=default; +select @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +0 +select /*+ set_var(tidb_enable_ordered_result_mode=1) */ @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +1 +select @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +0 +set @@tidb_enable_ordered_result_mode=default; +select @@tidb_enable_ordered_result_mode; +@@tidb_enable_ordered_result_mode +0 +select /*+ set_var(tidb_enable_pseudo_for_outdated_stats=0) */ @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +0 +select @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +0 +set @@tidb_enable_pseudo_for_outdated_stats=default; +select @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +0 +select /*+ set_var(tidb_enable_pseudo_for_outdated_stats=1) */ @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +1 +select @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +0 +set @@tidb_enable_pseudo_for_outdated_stats=default; +select @@tidb_enable_pseudo_for_outdated_stats; +@@tidb_enable_pseudo_for_outdated_stats +0 +select /*+ set_var(tidb_stats_load_sync_wait=0) */ @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +0 +select @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +100 +set @@tidb_stats_load_sync_wait=default; +select @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +100 +select /*+ set_var(tidb_stats_load_sync_wait=1) */ @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +1 +select @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +100 +set @@tidb_stats_load_sync_wait=default; +select @@tidb_stats_load_sync_wait; +@@tidb_stats_load_sync_wait +100 +select /*+ set_var(tidb_cost_model_version=1) */ @@tidb_cost_model_version; +@@tidb_cost_model_version +1 +select @@tidb_cost_model_version; +@@tidb_cost_model_version +2 +set @@tidb_cost_model_version=default; +select @@tidb_cost_model_version; +@@tidb_cost_model_version +2 +select /*+ set_var(tidb_cost_model_version=2) */ @@tidb_cost_model_version; +@@tidb_cost_model_version +2 +select @@tidb_cost_model_version; +@@tidb_cost_model_version +2 +set @@tidb_cost_model_version=default; +select @@tidb_cost_model_version; +@@tidb_cost_model_version +2 +select /*+ set_var(tidb_index_join_double_read_penalty_cost_rate=0) */ @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +0 +select @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +0 +set @@tidb_index_join_double_read_penalty_cost_rate=default; +select @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +0 +select /*+ set_var(tidb_index_join_double_read_penalty_cost_rate=1) */ @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +1 +select @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +0 +set @@tidb_index_join_double_read_penalty_cost_rate=default; +select @@tidb_index_join_double_read_penalty_cost_rate; +@@tidb_index_join_double_read_penalty_cost_rate +0 +select /*+ set_var(tidb_default_string_match_selectivity=0) */ @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +0 +select @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +0.8 +set @@tidb_default_string_match_selectivity=default; +select @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +0.8 +select /*+ set_var(tidb_default_string_match_selectivity=1) */ @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +1 +select @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +0.8 +set @@tidb_default_string_match_selectivity=default; +select @@tidb_default_string_match_selectivity; +@@tidb_default_string_match_selectivity +0.8 +select /*+ set_var(tidb_enable_prepared_plan_cache=0) */ @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +0 +select @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +1 +set @@tidb_enable_prepared_plan_cache=default; +select @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +1 +select /*+ set_var(tidb_enable_prepared_plan_cache=1) */ @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +1 +select @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +1 +set @@tidb_enable_prepared_plan_cache=default; +select @@tidb_enable_prepared_plan_cache; +@@tidb_enable_prepared_plan_cache +1 +select /*+ set_var(tidb_enable_non_prepared_plan_cache=0) */ @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +0 +select @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +1 +set @@tidb_enable_non_prepared_plan_cache=default; +select @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +0 +select /*+ set_var(tidb_enable_non_prepared_plan_cache=1) */ @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +1 +select @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +0 +set @@tidb_enable_non_prepared_plan_cache=default; +select @@tidb_enable_non_prepared_plan_cache; +@@tidb_enable_non_prepared_plan_cache +0 +select /*+ set_var(tidb_plan_cache_max_plan_size=0) */ @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +0 +select @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +2097152 +set @@tidb_plan_cache_max_plan_size=default; +select @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +2097152 +select /*+ set_var(tidb_plan_cache_max_plan_size=1) */ @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +1 +select @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +2097152 +set @@tidb_plan_cache_max_plan_size=default; +select @@tidb_plan_cache_max_plan_size; +@@tidb_plan_cache_max_plan_size +2097152 +select /*+ set_var(tidb_opt_range_max_size=0) */ @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +0 +select @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +67108864 +set @@tidb_opt_range_max_size=default; +select @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +67108864 +select /*+ set_var(tidb_opt_range_max_size=1) */ @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +1 +select @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +67108864 +set @@tidb_opt_range_max_size=default; +select @@tidb_opt_range_max_size; +@@tidb_opt_range_max_size +67108864 +select /*+ set_var(tidb_opt_advanced_join_hint=0) */ @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +0 +select @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +1 +set @@tidb_opt_advanced_join_hint=default; +select @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +1 +select /*+ set_var(tidb_opt_advanced_join_hint=1) */ @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +1 +select @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +1 +set @@tidb_opt_advanced_join_hint=default; +select @@tidb_opt_advanced_join_hint; +@@tidb_opt_advanced_join_hint +1 +select /*+ set_var(tidb_opt_prefix_index_single_scan=0) */ @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +0 +select @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +1 +set @@tidb_opt_prefix_index_single_scan=default; +select @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +1 +select /*+ set_var(tidb_opt_prefix_index_single_scan=1) */ @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +1 +select @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +1 +set @@tidb_opt_prefix_index_single_scan=default; +select @@tidb_opt_prefix_index_single_scan; +@@tidb_opt_prefix_index_single_scan +1 +select /*+ set_var(tidb_store_batch_size=1) */ @@tidb_store_batch_size; +@@tidb_store_batch_size +1 +select @@tidb_store_batch_size; +@@tidb_store_batch_size +4 +set @@tidb_store_batch_size=default; +select @@tidb_store_batch_size; +@@tidb_store_batch_size +4 +select /*+ set_var(tidb_store_batch_size=2) */ @@tidb_store_batch_size; +@@tidb_store_batch_size +2 +select @@tidb_store_batch_size; +@@tidb_store_batch_size +4 +set @@tidb_store_batch_size=default; +select @@tidb_store_batch_size; +@@tidb_store_batch_size +4 +select /*+ set_var(tidb_enable_inl_join_inner_multi_pattern=0) */ @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +0 +select @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +0 +set @@tidb_enable_inl_join_inner_multi_pattern=default; +select @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +0 +select /*+ set_var(tidb_enable_inl_join_inner_multi_pattern=1) */ @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +1 +select @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +0 +set @@tidb_enable_inl_join_inner_multi_pattern=default; +select @@tidb_enable_inl_join_inner_multi_pattern; +@@tidb_enable_inl_join_inner_multi_pattern +0 +select /*+ set_var(tidb_opt_enable_late_materialization=0) */ @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +0 +select @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +1 +set @@tidb_opt_enable_late_materialization=default; +select @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +1 +select /*+ set_var(tidb_opt_enable_late_materialization=1) */ @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +1 +select @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +1 +set @@tidb_opt_enable_late_materialization=default; +select @@tidb_opt_enable_late_materialization; +@@tidb_opt_enable_late_materialization +1 +select /*+ set_var(tidb_opt_ordering_index_selectivity_threshold=0) */ @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +0 +select @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +0 +set @@tidb_opt_ordering_index_selectivity_threshold=default; +select @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +0 +select /*+ set_var(tidb_opt_ordering_index_selectivity_threshold=1) */ @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +1 +select @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +0 +set @@tidb_opt_ordering_index_selectivity_threshold=default; +select @@tidb_opt_ordering_index_selectivity_threshold; +@@tidb_opt_ordering_index_selectivity_threshold +0 +select /*+ set_var(tidb_opt_enable_mpp_shared_cte_execution=0) */ @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +0 +select @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +0 +set @@tidb_opt_enable_mpp_shared_cte_execution=default; +select @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +0 +select /*+ set_var(tidb_opt_enable_mpp_shared_cte_execution=1) */ @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +1 +select @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +0 +set @@tidb_opt_enable_mpp_shared_cte_execution=default; +select @@tidb_opt_enable_mpp_shared_cte_execution; +@@tidb_opt_enable_mpp_shared_cte_execution +0 +select @@max_execution_time; +@@max_execution_time +0 +set @@max_execution_time=1000; +select @@max_execution_time; +@@max_execution_time +1000 +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +@@max_execution_time +100 +select @@max_execution_time; +@@max_execution_time +1000 +set @@global.max_execution_time=1000; +select @@max_execution_time; +@@max_execution_time +1000 +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +@@max_execution_time +100 +select @@max_execution_time; +@@max_execution_time +1000 +set @@max_execution_time=2000; +select @@max_execution_time; +@@max_execution_time +2000 +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +@@max_execution_time +100 +select @@max_execution_time; +@@max_execution_time +2000 +set @@global.max_execution_time=default; diff --git a/tests/integrationtest/r/sessiontxn/externals.result b/tests/integrationtest/r/sessiontxn/externals.result new file mode 100644 index 0000000000000..16a756619546d --- /dev/null +++ b/tests/integrationtest/r/sessiontxn/externals.result @@ -0,0 +1,98 @@ +select @@tidb_external_ts; +@@tidb_external_ts +0 +set global tidb_external_ts=19980613; +select @@tidb_external_ts; +@@tidb_external_ts +19980613 +set global tidb_external_ts=20220930; +select @@tidb_external_ts; +@@tidb_external_ts +20220930 +drop table if exists t; +create table t (id INT NOT NULL,d double,PRIMARY KEY (id)); +insert into t values (0, 100); +insert into t values (1, 100); +insert into t values (2, 100); +insert into t values (3, 100); +select * from t; +id d +0 100 +1 100 +2 100 +3 100 +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (4, 100); +set tidb_enable_external_ts_read=ON; +select * from t; +id d +0 100 +1 100 +2 100 +3 100 +set tidb_enable_external_ts_read=OFF; +select * from t; +id d +0 100 +1 100 +2 100 +3 100 +4 100 +drop table if exists t; +create table t (id INT NOT NULL,PRIMARY KEY (id)); +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (0); +select * from t; +id +0 +set tidb_enable_external_ts_read=ON; +select * from t; +id +start transaction; +select * from t; +id +commit; +set tidb_enable_external_ts_read=OFF; +start transaction; +select * from t; +id +0 +commit; +start transaction; +select * from t; +id +0 +set tidb_enable_external_ts_read=ON; +select * from t; +id +0 +set tidb_enable_external_ts_read=OFF; +commit; +drop table if exists t; +create table t (id INT NOT NULL,PRIMARY KEY (id)); +insert into t values (0); +select * from t; +id +0 +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (1); +select * from t; +id +0 +1 +set tidb_enable_external_ts_read=on; +prepare my_select from 'select * from t'; +execute my_select; +id +0 +set tidb_enable_external_ts_read=off; +execute my_select; +id +0 +1 diff --git a/tests/integrationtest/t/sessionctx/setvar.test b/tests/integrationtest/t/sessionctx/setvar.test new file mode 100644 index 0000000000000..b3f3342a8fe55 --- /dev/null +++ b/tests/integrationtest/t/sessionctx/setvar.test @@ -0,0 +1,683 @@ +# TestSetVarStringOrEnum +select /*+ set_var(tidb_read_consistency="strict") */ @@tidb_read_consistency; +select @@tidb_read_consistency; +set @@tidb_read_consistency=default; +select @@tidb_read_consistency; +select /*+ set_var(tidb_read_consistency="weak") */ @@tidb_read_consistency; +select @@tidb_read_consistency; +set @@tidb_read_consistency=default; +select @@tidb_read_consistency; +select /*+ set_var(tidb_isolation_read_engines="tidb,tiflash") */ @@tidb_isolation_read_engines; +select @@tidb_isolation_read_engines; +set @@tidb_isolation_read_engines=default; +select @@tidb_isolation_read_engines; +select /*+ set_var(tidb_isolation_read_engines="tikv,tidb") */ @@tidb_isolation_read_engines; +select @@tidb_isolation_read_engines; +set @@tidb_isolation_read_engines=default; +select @@tidb_isolation_read_engines; +select /*+ set_var(tidb_replica_read="follower") */ @@tidb_replica_read; +select @@tidb_replica_read; +set @@tidb_replica_read=default; +select @@tidb_replica_read; +select /*+ set_var(tidb_replica_read="prefer-leader") */ @@tidb_replica_read; +select @@tidb_replica_read; +set @@tidb_replica_read=default; +select @@tidb_replica_read; +select /*+ set_var(tidb_partition_prune_mode="static") */ @@tidb_partition_prune_mode; +select @@tidb_partition_prune_mode; +set @@tidb_partition_prune_mode=default; +select @@tidb_partition_prune_mode; +select /*+ set_var(tidb_partition_prune_mode="dynamic") */ @@tidb_partition_prune_mode; +select @@tidb_partition_prune_mode; +set @@tidb_partition_prune_mode=default; +select @@tidb_partition_prune_mode; +select /*+ set_var(mpp_version="0") */ @@mpp_version; +select @@mpp_version; +set @@mpp_version=default; +select @@mpp_version; +select /*+ set_var(mpp_version="1") */ @@mpp_version; +select @@mpp_version; +set @@mpp_version=default; +select @@mpp_version; +select /*+ set_var(tidb_opt_fix_control="44262:ON") */ @@tidb_opt_fix_control; +select @@tidb_opt_fix_control; +set @@tidb_opt_fix_control=default; +select @@tidb_opt_fix_control; +select /*+ set_var(tidb_opt_fix_control="44389:ON,44823:ON") */ @@tidb_opt_fix_control; +select @@tidb_opt_fix_control; +set @@tidb_opt_fix_control=default; +select @@tidb_opt_fix_control; +select /*+ set_var(tidb_runtime_filter_mode="OFF") */ @@tidb_runtime_filter_mode; +select @@tidb_runtime_filter_mode; +set @@tidb_runtime_filter_mode=default; +select @@tidb_runtime_filter_mode; +select /*+ set_var(tidb_runtime_filter_mode="LOCAL") */ @@tidb_runtime_filter_mode; +select @@tidb_runtime_filter_mode; +set @@tidb_runtime_filter_mode=default; +select @@tidb_runtime_filter_mode; +select /*+ set_var(sql_mode="") */ @@sql_mode; +select @@sql_mode; +set @@sql_mode=default; +select @@sql_mode; +select /*+ set_var(sql_mode="ONLY_FULL_GROUP_BY") */ @@sql_mode; +select @@sql_mode; +set @@sql_mode=default; +select @@sql_mode; + +# TestSetVarHintBreakCache +CREATE TABLE t (a INT, b INT, KEY(b)); +SET tidb_enable_non_prepared_plan_cache = true; +SELECT * FROM t WHERE b < 10 AND a = 1; +SELECT * FROM t WHERE b < 5 AND a = 2; +select @@last_plan_from_cache; +SELECT /*+ SET_VAR(tidb_distsql_scan_concurrency=10) */ * FROM t WHERE b < 5 AND a = 2; +select @@last_plan_from_cache; +SELECT * FROM t WHERE b < 5 AND a = 2; +select @@last_plan_from_cache; + +# TestSetVarNonStringOrEnum +select /*+ set_var(tidb_opt_agg_push_down=0) */ @@tidb_opt_agg_push_down; +select @@tidb_opt_agg_push_down; +set @@tidb_opt_agg_push_down=default; +select @@tidb_opt_agg_push_down; +select /*+ set_var(tidb_opt_agg_push_down=1) */ @@tidb_opt_agg_push_down; +select @@tidb_opt_agg_push_down; +set @@tidb_opt_agg_push_down=default; +select @@tidb_opt_agg_push_down; +select /*+ set_var(tidb_opt_derive_topn=0) */ @@tidb_opt_derive_topn; +select @@tidb_opt_derive_topn; +set @@tidb_opt_derive_topn=default; +select @@tidb_opt_derive_topn; +select /*+ set_var(tidb_opt_derive_topn=1) */ @@tidb_opt_derive_topn; +select @@tidb_opt_derive_topn; +set @@tidb_opt_derive_topn=default; +select @@tidb_opt_derive_topn; +select /*+ set_var(tidb_opt_broadcast_cartesian_join=0) */ @@tidb_opt_broadcast_cartesian_join; +select @@tidb_opt_broadcast_cartesian_join; +set @@tidb_opt_broadcast_cartesian_join=default; +select @@tidb_opt_broadcast_cartesian_join; +select /*+ set_var(tidb_opt_broadcast_cartesian_join=1) */ @@tidb_opt_broadcast_cartesian_join; +select @@tidb_opt_broadcast_cartesian_join; +set @@tidb_opt_broadcast_cartesian_join=default; +select @@tidb_opt_broadcast_cartesian_join; +select /*+ set_var(tidb_opt_mpp_outer_join_fixed_build_side=0) */ @@tidb_opt_mpp_outer_join_fixed_build_side; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +set @@tidb_opt_mpp_outer_join_fixed_build_side=default; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +select /*+ set_var(tidb_opt_mpp_outer_join_fixed_build_side=1) */ @@tidb_opt_mpp_outer_join_fixed_build_side; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +set @@tidb_opt_mpp_outer_join_fixed_build_side=default; +select @@tidb_opt_mpp_outer_join_fixed_build_side; +select /*+ set_var(tidb_opt_distinct_agg_push_down=0) */ @@tidb_opt_distinct_agg_push_down; +select @@tidb_opt_distinct_agg_push_down; +set @@tidb_opt_distinct_agg_push_down=default; +select @@tidb_opt_distinct_agg_push_down; +select /*+ set_var(tidb_opt_distinct_agg_push_down=1) */ @@tidb_opt_distinct_agg_push_down; +select @@tidb_opt_distinct_agg_push_down; +set @@tidb_opt_distinct_agg_push_down=default; +select @@tidb_opt_distinct_agg_push_down; +select /*+ set_var(tidb_opt_skew_distinct_agg=0) */ @@tidb_opt_skew_distinct_agg; +select @@tidb_opt_skew_distinct_agg; +set @@tidb_opt_skew_distinct_agg=default; +select @@tidb_opt_skew_distinct_agg; +select /*+ set_var(tidb_opt_skew_distinct_agg=1) */ @@tidb_opt_skew_distinct_agg; +select @@tidb_opt_skew_distinct_agg; +set @@tidb_opt_skew_distinct_agg=default; +select @@tidb_opt_skew_distinct_agg; +select /*+ set_var(tidb_opt_three_stage_distinct_agg=0) */ @@tidb_opt_three_stage_distinct_agg; +select @@tidb_opt_three_stage_distinct_agg; +set @@tidb_opt_three_stage_distinct_agg=default; +select @@tidb_opt_three_stage_distinct_agg; +select /*+ set_var(tidb_opt_three_stage_distinct_agg=1) */ @@tidb_opt_three_stage_distinct_agg; +select @@tidb_opt_three_stage_distinct_agg; +set @@tidb_opt_three_stage_distinct_agg=default; +select @@tidb_opt_three_stage_distinct_agg; +select /*+ set_var(tidb_broadcast_join_threshold_size=0) */ @@tidb_broadcast_join_threshold_size; +select @@tidb_broadcast_join_threshold_size; +set @@tidb_broadcast_join_threshold_size=default; +select @@tidb_broadcast_join_threshold_size; +select /*+ set_var(tidb_broadcast_join_threshold_size=1) */ @@tidb_broadcast_join_threshold_size; +select @@tidb_broadcast_join_threshold_size; +set @@tidb_broadcast_join_threshold_size=default; +select @@tidb_broadcast_join_threshold_size; +select /*+ set_var(tidb_broadcast_join_threshold_count=0) */ @@tidb_broadcast_join_threshold_count; +select @@tidb_broadcast_join_threshold_count; +set @@tidb_broadcast_join_threshold_count=default; +select @@tidb_broadcast_join_threshold_count; +select /*+ set_var(tidb_broadcast_join_threshold_count=1) */ @@tidb_broadcast_join_threshold_count; +select @@tidb_broadcast_join_threshold_count; +set @@tidb_broadcast_join_threshold_count=default; +select @@tidb_broadcast_join_threshold_count; +select /*+ set_var(tidb_prefer_broadcast_join_by_exchange_data_size=0) */ @@tidb_prefer_broadcast_join_by_exchange_data_size; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +set @@tidb_prefer_broadcast_join_by_exchange_data_size=default; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +select /*+ set_var(tidb_prefer_broadcast_join_by_exchange_data_size=1) */ @@tidb_prefer_broadcast_join_by_exchange_data_size; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +set @@tidb_prefer_broadcast_join_by_exchange_data_size=default; +select @@tidb_prefer_broadcast_join_by_exchange_data_size; +select /*+ set_var(tidb_opt_write_row_id=0) */ @@tidb_opt_write_row_id; +select @@tidb_opt_write_row_id; +set @@tidb_opt_write_row_id=default; +select @@tidb_opt_write_row_id; +select /*+ set_var(tidb_opt_write_row_id=1) */ @@tidb_opt_write_row_id; +select @@tidb_opt_write_row_id; +set @@tidb_opt_write_row_id=default; +select @@tidb_opt_write_row_id; +select /*+ set_var(tidb_optimizer_selectivity_level=0) */ @@tidb_optimizer_selectivity_level; +select @@tidb_optimizer_selectivity_level; +set @@tidb_optimizer_selectivity_level=default; +select @@tidb_optimizer_selectivity_level; +select /*+ set_var(tidb_optimizer_selectivity_level=1) */ @@tidb_optimizer_selectivity_level; +select @@tidb_optimizer_selectivity_level; +set @@tidb_optimizer_selectivity_level=default; +select @@tidb_optimizer_selectivity_level; +select /*+ set_var(tidb_enable_new_only_full_group_by_check=0) */ @@tidb_enable_new_only_full_group_by_check; +select @@tidb_enable_new_only_full_group_by_check; +set @@tidb_enable_new_only_full_group_by_check=default; +select @@tidb_enable_new_only_full_group_by_check; +select /*+ set_var(tidb_enable_new_only_full_group_by_check=1) */ @@tidb_enable_new_only_full_group_by_check; +select @@tidb_enable_new_only_full_group_by_check; +set @@tidb_enable_new_only_full_group_by_check=default; +select @@tidb_enable_new_only_full_group_by_check; +select /*+ set_var(tidb_enable_outer_join_reorder=0) */ @@tidb_enable_outer_join_reorder; +select @@tidb_enable_outer_join_reorder; +set @@tidb_enable_outer_join_reorder=default; +select @@tidb_enable_outer_join_reorder; +select /*+ set_var(tidb_enable_outer_join_reorder=1) */ @@tidb_enable_outer_join_reorder; +select @@tidb_enable_outer_join_reorder; +set @@tidb_enable_outer_join_reorder=default; +select @@tidb_enable_outer_join_reorder; +select /*+ set_var(tidb_enable_null_aware_anti_join=0) */ @@tidb_enable_null_aware_anti_join; +select @@tidb_enable_null_aware_anti_join; +set @@tidb_enable_null_aware_anti_join=default; +select @@tidb_enable_null_aware_anti_join; +select /*+ set_var(tidb_enable_null_aware_anti_join=1) */ @@tidb_enable_null_aware_anti_join; +select @@tidb_enable_null_aware_anti_join; +set @@tidb_enable_null_aware_anti_join=default; +select @@tidb_enable_null_aware_anti_join; +select /*+ set_var(tidb_read_staleness=0) */ @@tidb_read_staleness; +select @@tidb_read_staleness; +set @@tidb_read_staleness=default; +select @@tidb_read_staleness; +select /*+ set_var(tidb_read_staleness=-1) */ @@tidb_read_staleness; +select @@tidb_read_staleness; +set @@tidb_read_staleness=default; +select @@tidb_read_staleness; +select /*+ set_var(tidb_enable_paging=0) */ @@tidb_enable_paging; +select @@tidb_enable_paging; +set @@tidb_enable_paging=default; +select @@tidb_enable_paging; +select /*+ set_var(tidb_enable_paging=1) */ @@tidb_enable_paging; +select @@tidb_enable_paging; +set @@tidb_enable_paging=default; +select @@tidb_enable_paging; +select /*+ set_var(tidb_distsql_scan_concurrency=1) */ @@tidb_distsql_scan_concurrency; +select @@tidb_distsql_scan_concurrency; +set @@tidb_distsql_scan_concurrency=default; +select @@tidb_distsql_scan_concurrency; +select /*+ set_var(tidb_distsql_scan_concurrency=2) */ @@tidb_distsql_scan_concurrency; +select @@tidb_distsql_scan_concurrency; +set @@tidb_distsql_scan_concurrency=default; +select @@tidb_distsql_scan_concurrency; +select /*+ set_var(tidb_opt_insubq_to_join_and_agg=0) */ @@tidb_opt_insubq_to_join_and_agg; +select @@tidb_opt_insubq_to_join_and_agg; +set @@tidb_opt_insubq_to_join_and_agg=default; +select @@tidb_opt_insubq_to_join_and_agg; +select /*+ set_var(tidb_opt_insubq_to_join_and_agg=1) */ @@tidb_opt_insubq_to_join_and_agg; +select @@tidb_opt_insubq_to_join_and_agg; +set @@tidb_opt_insubq_to_join_and_agg=default; +select @@tidb_opt_insubq_to_join_and_agg; +select /*+ set_var(tidb_opt_prefer_range_scan=0) */ @@tidb_opt_prefer_range_scan; +select @@tidb_opt_prefer_range_scan; +set @@tidb_opt_prefer_range_scan=default; +select @@tidb_opt_prefer_range_scan; +select /*+ set_var(tidb_opt_prefer_range_scan=1) */ @@tidb_opt_prefer_range_scan; +select @@tidb_opt_prefer_range_scan; +set @@tidb_opt_prefer_range_scan=default; +select @@tidb_opt_prefer_range_scan; +select /*+ set_var(tidb_opt_enable_correlation_adjustment=0) */ @@tidb_opt_enable_correlation_adjustment; +select @@tidb_opt_enable_correlation_adjustment; +set @@tidb_opt_enable_correlation_adjustment=default; +select @@tidb_opt_enable_correlation_adjustment; +select /*+ set_var(tidb_opt_enable_correlation_adjustment=1) */ @@tidb_opt_enable_correlation_adjustment; +select @@tidb_opt_enable_correlation_adjustment; +set @@tidb_opt_enable_correlation_adjustment=default; +select @@tidb_opt_enable_correlation_adjustment; +select /*+ set_var(tidb_opt_limit_push_down_threshold=0) */ @@tidb_opt_limit_push_down_threshold; +select @@tidb_opt_limit_push_down_threshold; +set @@tidb_opt_limit_push_down_threshold=default; +select @@tidb_opt_limit_push_down_threshold; +select /*+ set_var(tidb_opt_limit_push_down_threshold=1) */ @@tidb_opt_limit_push_down_threshold; +select @@tidb_opt_limit_push_down_threshold; +set @@tidb_opt_limit_push_down_threshold=default; +select @@tidb_opt_limit_push_down_threshold; +select /*+ set_var(tidb_opt_correlation_threshold=0) */ @@tidb_opt_correlation_threshold; +select @@tidb_opt_correlation_threshold; +set @@tidb_opt_correlation_threshold=default; +select @@tidb_opt_correlation_threshold; +select /*+ set_var(tidb_opt_correlation_threshold=1) */ @@tidb_opt_correlation_threshold; +select @@tidb_opt_correlation_threshold; +set @@tidb_opt_correlation_threshold=default; +select @@tidb_opt_correlation_threshold; +select /*+ set_var(tidb_opt_correlation_exp_factor=0) */ @@tidb_opt_correlation_exp_factor; +select @@tidb_opt_correlation_exp_factor; +set @@tidb_opt_correlation_exp_factor=default; +select @@tidb_opt_correlation_exp_factor; +select /*+ set_var(tidb_opt_correlation_exp_factor=1) */ @@tidb_opt_correlation_exp_factor; +select @@tidb_opt_correlation_exp_factor; +set @@tidb_opt_correlation_exp_factor=default; +select @@tidb_opt_correlation_exp_factor; +select /*+ set_var(tidb_opt_cpu_factor=0) */ @@tidb_opt_cpu_factor; +select @@tidb_opt_cpu_factor; +set @@tidb_opt_cpu_factor=default; +select @@tidb_opt_cpu_factor; +select /*+ set_var(tidb_opt_cpu_factor=1) */ @@tidb_opt_cpu_factor; +select @@tidb_opt_cpu_factor; +set @@tidb_opt_cpu_factor=default; +select @@tidb_opt_cpu_factor; +select /*+ set_var(tidb_opt_copcpu_factor=0) */ @@tidb_opt_copcpu_factor; +select @@tidb_opt_copcpu_factor; +set @@tidb_opt_copcpu_factor=default; +select @@tidb_opt_copcpu_factor; +select /*+ set_var(tidb_opt_copcpu_factor=1) */ @@tidb_opt_copcpu_factor; +select @@tidb_opt_copcpu_factor; +set @@tidb_opt_copcpu_factor=default; +select @@tidb_opt_copcpu_factor; +select /*+ set_var(tidb_opt_tiflash_concurrency_factor=1) */ @@tidb_opt_tiflash_concurrency_factor; +select @@tidb_opt_tiflash_concurrency_factor; +set @@tidb_opt_tiflash_concurrency_factor=default; +select @@tidb_opt_tiflash_concurrency_factor; +select /*+ set_var(tidb_opt_tiflash_concurrency_factor=2) */ @@tidb_opt_tiflash_concurrency_factor; +select @@tidb_opt_tiflash_concurrency_factor; +set @@tidb_opt_tiflash_concurrency_factor=default; +select @@tidb_opt_tiflash_concurrency_factor; +select /*+ set_var(tidb_opt_network_factor=0) */ @@tidb_opt_network_factor; +select @@tidb_opt_network_factor; +set @@tidb_opt_network_factor=default; +select @@tidb_opt_network_factor; +select /*+ set_var(tidb_opt_network_factor=1) */ @@tidb_opt_network_factor; +select @@tidb_opt_network_factor; +set @@tidb_opt_network_factor=default; +select @@tidb_opt_network_factor; +select /*+ set_var(tidb_opt_scan_factor=0) */ @@tidb_opt_scan_factor; +select @@tidb_opt_scan_factor; +set @@tidb_opt_scan_factor=default; +select @@tidb_opt_scan_factor; +select /*+ set_var(tidb_opt_scan_factor=1) */ @@tidb_opt_scan_factor; +select @@tidb_opt_scan_factor; +set @@tidb_opt_scan_factor=default; +select @@tidb_opt_scan_factor; +select /*+ set_var(tidb_opt_desc_factor=0) */ @@tidb_opt_desc_factor; +select @@tidb_opt_desc_factor; +set @@tidb_opt_desc_factor=default; +select @@tidb_opt_desc_factor; +select /*+ set_var(tidb_opt_desc_factor=1) */ @@tidb_opt_desc_factor; +select @@tidb_opt_desc_factor; +set @@tidb_opt_desc_factor=default; +select @@tidb_opt_desc_factor; +select /*+ set_var(tidb_opt_seek_factor=0) */ @@tidb_opt_seek_factor; +select @@tidb_opt_seek_factor; +set @@tidb_opt_seek_factor=default; +select @@tidb_opt_seek_factor; +select /*+ set_var(tidb_opt_seek_factor=1) */ @@tidb_opt_seek_factor; +select @@tidb_opt_seek_factor; +set @@tidb_opt_seek_factor=default; +select @@tidb_opt_seek_factor; +select /*+ set_var(tidb_opt_memory_factor=0) */ @@tidb_opt_memory_factor; +select @@tidb_opt_memory_factor; +set @@tidb_opt_memory_factor=default; +select @@tidb_opt_memory_factor; +select /*+ set_var(tidb_opt_memory_factor=1) */ @@tidb_opt_memory_factor; +select @@tidb_opt_memory_factor; +set @@tidb_opt_memory_factor=default; +select @@tidb_opt_memory_factor; +select /*+ set_var(tidb_opt_disk_factor=0) */ @@tidb_opt_disk_factor; +select @@tidb_opt_disk_factor; +set @@tidb_opt_disk_factor=default; +select @@tidb_opt_disk_factor; +select /*+ set_var(tidb_opt_disk_factor=1) */ @@tidb_opt_disk_factor; +select @@tidb_opt_disk_factor; +set @@tidb_opt_disk_factor=default; +select @@tidb_opt_disk_factor; +select /*+ set_var(tidb_opt_concurrency_factor=1) */ @@tidb_opt_concurrency_factor; +select @@tidb_opt_concurrency_factor; +set @@tidb_opt_concurrency_factor=default; +select @@tidb_opt_concurrency_factor; +select /*+ set_var(tidb_opt_concurrency_factor=2) */ @@tidb_opt_concurrency_factor; +select @@tidb_opt_concurrency_factor; +set @@tidb_opt_concurrency_factor=default; +select @@tidb_opt_concurrency_factor; +select /*+ set_var(tidb_opt_force_inline_cte=0) */ @@tidb_opt_force_inline_cte; +select @@tidb_opt_force_inline_cte; +set @@tidb_opt_force_inline_cte=default; +select @@tidb_opt_force_inline_cte; +select /*+ set_var(tidb_opt_force_inline_cte=1) */ @@tidb_opt_force_inline_cte; +select @@tidb_opt_force_inline_cte; +set @@tidb_opt_force_inline_cte=default; +select @@tidb_opt_force_inline_cte; +select /*+ set_var(tidb_index_join_batch_size=1) */ @@tidb_index_join_batch_size; +select @@tidb_index_join_batch_size; +set @@tidb_index_join_batch_size=default; +select @@tidb_index_join_batch_size; +select /*+ set_var(tidb_index_join_batch_size=2) */ @@tidb_index_join_batch_size; +select @@tidb_index_join_batch_size; +set @@tidb_index_join_batch_size=default; +select @@tidb_index_join_batch_size; +select /*+ set_var(tidb_index_lookup_size=1) */ @@tidb_index_lookup_size; +select @@tidb_index_lookup_size; +set @@tidb_index_lookup_size=default; +select @@tidb_index_lookup_size; +select /*+ set_var(tidb_index_lookup_size=2) */ @@tidb_index_lookup_size; +select @@tidb_index_lookup_size; +set @@tidb_index_lookup_size=default; +select @@tidb_index_lookup_size; +select /*+ set_var(tidb_index_serial_scan_concurrency=1) */ @@tidb_index_serial_scan_concurrency; +select @@tidb_index_serial_scan_concurrency; +set @@tidb_index_serial_scan_concurrency=default; +select @@tidb_index_serial_scan_concurrency; +select /*+ set_var(tidb_index_serial_scan_concurrency=2) */ @@tidb_index_serial_scan_concurrency; +select @@tidb_index_serial_scan_concurrency; +set @@tidb_index_serial_scan_concurrency=default; +select @@tidb_index_serial_scan_concurrency; +select /*+ set_var(tidb_allow_batch_cop=0) */ @@tidb_allow_batch_cop; +select @@tidb_allow_batch_cop; +set @@tidb_allow_batch_cop=default; +select @@tidb_allow_batch_cop; +select /*+ set_var(tidb_allow_batch_cop=1) */ @@tidb_allow_batch_cop; +select @@tidb_allow_batch_cop; +set @@tidb_allow_batch_cop=default; +select @@tidb_allow_batch_cop; +select /*+ set_var(tidb_allow_mpp=0) */ @@tidb_allow_mpp; +select @@tidb_allow_mpp; +set @@tidb_allow_mpp=default; +select @@tidb_allow_mpp; +select /*+ set_var(tidb_allow_mpp=1) */ @@tidb_allow_mpp; +select @@tidb_allow_mpp; +set @@tidb_allow_mpp=default; +select @@tidb_allow_mpp; +select /*+ set_var(tidb_enforce_mpp=0) */ @@tidb_enforce_mpp; +select @@tidb_enforce_mpp; +set @@tidb_enforce_mpp=default; +select @@tidb_enforce_mpp; +select /*+ set_var(tidb_enforce_mpp=1) */ @@tidb_enforce_mpp; +select @@tidb_enforce_mpp; +set @@tidb_enforce_mpp=default; +select @@tidb_enforce_mpp; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_join=0) */ @@tidb_max_bytes_before_tiflash_external_join; +select @@tidb_max_bytes_before_tiflash_external_join; +set @@tidb_max_bytes_before_tiflash_external_join=default; +select @@tidb_max_bytes_before_tiflash_external_join; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_join=1) */ @@tidb_max_bytes_before_tiflash_external_join; +select @@tidb_max_bytes_before_tiflash_external_join; +set @@tidb_max_bytes_before_tiflash_external_join=default; +select @@tidb_max_bytes_before_tiflash_external_join; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_group_by=0) */ @@tidb_max_bytes_before_tiflash_external_group_by; +select @@tidb_max_bytes_before_tiflash_external_group_by; +set @@tidb_max_bytes_before_tiflash_external_group_by=default; +select @@tidb_max_bytes_before_tiflash_external_group_by; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_group_by=1) */ @@tidb_max_bytes_before_tiflash_external_group_by; +select @@tidb_max_bytes_before_tiflash_external_group_by; +set @@tidb_max_bytes_before_tiflash_external_group_by=default; +select @@tidb_max_bytes_before_tiflash_external_group_by; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_sort=0) */ @@tidb_max_bytes_before_tiflash_external_sort; +select @@tidb_max_bytes_before_tiflash_external_sort; +set @@tidb_max_bytes_before_tiflash_external_sort=default; +select @@tidb_max_bytes_before_tiflash_external_sort; +select /*+ set_var(tidb_max_bytes_before_tiflash_external_sort=1) */ @@tidb_max_bytes_before_tiflash_external_sort; +select @@tidb_max_bytes_before_tiflash_external_sort; +set @@tidb_max_bytes_before_tiflash_external_sort=default; +select @@tidb_max_bytes_before_tiflash_external_sort; +select /*+ set_var(tidb_min_paging_size=1) */ @@tidb_min_paging_size; +select @@tidb_min_paging_size; +set @@tidb_min_paging_size=default; +select @@tidb_min_paging_size; +select /*+ set_var(tidb_min_paging_size=2) */ @@tidb_min_paging_size; +select @@tidb_min_paging_size; +set @@tidb_min_paging_size=default; +select @@tidb_min_paging_size; +select /*+ set_var(tidb_max_paging_size=10) */ @@tidb_max_paging_size; +select @@tidb_max_paging_size; +set @@tidb_max_paging_size=default; +select @@tidb_max_paging_size; +select /*+ set_var(tidb_max_paging_size=20) */ @@tidb_max_paging_size; +select @@tidb_max_paging_size; +set @@tidb_max_paging_size=default; +select @@tidb_max_paging_size; +select /*+ set_var(tidb_enable_cascades_planner=0) */ @@tidb_enable_cascades_planner; +select @@tidb_enable_cascades_planner; +set @@tidb_enable_cascades_planner=default; +select @@tidb_enable_cascades_planner; +select /*+ set_var(tidb_enable_cascades_planner=1) */ @@tidb_enable_cascades_planner; +select @@tidb_enable_cascades_planner; +set @@tidb_enable_cascades_planner=default; +select @@tidb_enable_cascades_planner; +select /*+ set_var(tidb_merge_join_concurrency=1) */ @@tidb_merge_join_concurrency; +select @@tidb_merge_join_concurrency; +set @@tidb_merge_join_concurrency=default; +select @@tidb_merge_join_concurrency; +select /*+ set_var(tidb_merge_join_concurrency=2) */ @@tidb_merge_join_concurrency; +select @@tidb_merge_join_concurrency; +set @@tidb_merge_join_concurrency=default; +select @@tidb_merge_join_concurrency; +select /*+ set_var(tidb_index_merge_intersection_concurrency=1) */ @@tidb_index_merge_intersection_concurrency; +select @@tidb_index_merge_intersection_concurrency; +set @@tidb_index_merge_intersection_concurrency=default; +select @@tidb_index_merge_intersection_concurrency; +select /*+ set_var(tidb_index_merge_intersection_concurrency=2) */ @@tidb_index_merge_intersection_concurrency; +select @@tidb_index_merge_intersection_concurrency; +set @@tidb_index_merge_intersection_concurrency=default; +select @@tidb_index_merge_intersection_concurrency; +select /*+ set_var(tidb_opt_projection_push_down=0) */ @@tidb_opt_projection_push_down; +select @@tidb_opt_projection_push_down; +set @@tidb_opt_projection_push_down=default; +select @@tidb_opt_projection_push_down; +select /*+ set_var(tidb_opt_projection_push_down=1) */ @@tidb_opt_projection_push_down; +select @@tidb_opt_projection_push_down; +set @@tidb_opt_projection_push_down=default; +select @@tidb_opt_projection_push_down; +select /*+ set_var(tidb_enable_vectorized_expression=0) */ @@tidb_enable_vectorized_expression; +select @@tidb_enable_vectorized_expression; +set @@tidb_enable_vectorized_expression=default; +select @@tidb_enable_vectorized_expression; +select /*+ set_var(tidb_enable_vectorized_expression=1) */ @@tidb_enable_vectorized_expression; +select @@tidb_enable_vectorized_expression; +set @@tidb_enable_vectorized_expression=default; +select @@tidb_enable_vectorized_expression; +select /*+ set_var(tidb_opt_join_reorder_threshold=0) */ @@tidb_opt_join_reorder_threshold; +select @@tidb_opt_join_reorder_threshold; +set @@tidb_opt_join_reorder_threshold=default; +select @@tidb_opt_join_reorder_threshold; +select /*+ set_var(tidb_opt_join_reorder_threshold=1) */ @@tidb_opt_join_reorder_threshold; +select @@tidb_opt_join_reorder_threshold; +set @@tidb_opt_join_reorder_threshold=default; +select @@tidb_opt_join_reorder_threshold; +select /*+ set_var(tidb_enable_index_merge=0) */ @@tidb_enable_index_merge; +select @@tidb_enable_index_merge; +set @@tidb_enable_index_merge=default; +select @@tidb_enable_index_merge; +select /*+ set_var(tidb_enable_index_merge=1) */ @@tidb_enable_index_merge; +select @@tidb_enable_index_merge; +set @@tidb_enable_index_merge=default; +select @@tidb_enable_index_merge; +select /*+ set_var(tidb_enable_extended_stats=0) */ @@tidb_enable_extended_stats; +select @@tidb_enable_extended_stats; +set @@tidb_enable_extended_stats=default; +select @@tidb_enable_extended_stats; +select /*+ set_var(tidb_enable_extended_stats=1) */ @@tidb_enable_extended_stats; +select @@tidb_enable_extended_stats; +set @@tidb_enable_extended_stats=default; +select @@tidb_enable_extended_stats; +select /*+ set_var(tidb_executor_concurrency=1) */ @@tidb_executor_concurrency; +select @@tidb_executor_concurrency; +set @@tidb_executor_concurrency=default; +select @@tidb_executor_concurrency; +select /*+ set_var(tidb_executor_concurrency=2) */ @@tidb_executor_concurrency; +select @@tidb_executor_concurrency; +set @@tidb_executor_concurrency=default; +select @@tidb_executor_concurrency; +select /*+ set_var(tidb_enable_index_merge_join=0) */ @@tidb_enable_index_merge_join; +select @@tidb_enable_index_merge_join; +set @@tidb_enable_index_merge_join=default; +select @@tidb_enable_index_merge_join; +select /*+ set_var(tidb_enable_index_merge_join=1) */ @@tidb_enable_index_merge_join; +select @@tidb_enable_index_merge_join; +set @@tidb_enable_index_merge_join=default; +select @@tidb_enable_index_merge_join; +select /*+ set_var(tidb_enable_ordered_result_mode=0) */ @@tidb_enable_ordered_result_mode; +select @@tidb_enable_ordered_result_mode; +set @@tidb_enable_ordered_result_mode=default; +select @@tidb_enable_ordered_result_mode; +select /*+ set_var(tidb_enable_ordered_result_mode=1) */ @@tidb_enable_ordered_result_mode; +select @@tidb_enable_ordered_result_mode; +set @@tidb_enable_ordered_result_mode=default; +select @@tidb_enable_ordered_result_mode; +select /*+ set_var(tidb_enable_pseudo_for_outdated_stats=0) */ @@tidb_enable_pseudo_for_outdated_stats; +select @@tidb_enable_pseudo_for_outdated_stats; +set @@tidb_enable_pseudo_for_outdated_stats=default; +select @@tidb_enable_pseudo_for_outdated_stats; +select /*+ set_var(tidb_enable_pseudo_for_outdated_stats=1) */ @@tidb_enable_pseudo_for_outdated_stats; +select @@tidb_enable_pseudo_for_outdated_stats; +set @@tidb_enable_pseudo_for_outdated_stats=default; +select @@tidb_enable_pseudo_for_outdated_stats; +select /*+ set_var(tidb_stats_load_sync_wait=0) */ @@tidb_stats_load_sync_wait; +select @@tidb_stats_load_sync_wait; +set @@tidb_stats_load_sync_wait=default; +select @@tidb_stats_load_sync_wait; +select /*+ set_var(tidb_stats_load_sync_wait=1) */ @@tidb_stats_load_sync_wait; +select @@tidb_stats_load_sync_wait; +set @@tidb_stats_load_sync_wait=default; +select @@tidb_stats_load_sync_wait; +select /*+ set_var(tidb_cost_model_version=1) */ @@tidb_cost_model_version; +select @@tidb_cost_model_version; +set @@tidb_cost_model_version=default; +select @@tidb_cost_model_version; +select /*+ set_var(tidb_cost_model_version=2) */ @@tidb_cost_model_version; +select @@tidb_cost_model_version; +set @@tidb_cost_model_version=default; +select @@tidb_cost_model_version; +select /*+ set_var(tidb_index_join_double_read_penalty_cost_rate=0) */ @@tidb_index_join_double_read_penalty_cost_rate; +select @@tidb_index_join_double_read_penalty_cost_rate; +set @@tidb_index_join_double_read_penalty_cost_rate=default; +select @@tidb_index_join_double_read_penalty_cost_rate; +select /*+ set_var(tidb_index_join_double_read_penalty_cost_rate=1) */ @@tidb_index_join_double_read_penalty_cost_rate; +select @@tidb_index_join_double_read_penalty_cost_rate; +set @@tidb_index_join_double_read_penalty_cost_rate=default; +select @@tidb_index_join_double_read_penalty_cost_rate; +select /*+ set_var(tidb_default_string_match_selectivity=0) */ @@tidb_default_string_match_selectivity; +select @@tidb_default_string_match_selectivity; +set @@tidb_default_string_match_selectivity=default; +select @@tidb_default_string_match_selectivity; +select /*+ set_var(tidb_default_string_match_selectivity=1) */ @@tidb_default_string_match_selectivity; +select @@tidb_default_string_match_selectivity; +set @@tidb_default_string_match_selectivity=default; +select @@tidb_default_string_match_selectivity; +select /*+ set_var(tidb_enable_prepared_plan_cache=0) */ @@tidb_enable_prepared_plan_cache; +select @@tidb_enable_prepared_plan_cache; +set @@tidb_enable_prepared_plan_cache=default; +select @@tidb_enable_prepared_plan_cache; +select /*+ set_var(tidb_enable_prepared_plan_cache=1) */ @@tidb_enable_prepared_plan_cache; +select @@tidb_enable_prepared_plan_cache; +set @@tidb_enable_prepared_plan_cache=default; +select @@tidb_enable_prepared_plan_cache; +select /*+ set_var(tidb_enable_non_prepared_plan_cache=0) */ @@tidb_enable_non_prepared_plan_cache; +select @@tidb_enable_non_prepared_plan_cache; +set @@tidb_enable_non_prepared_plan_cache=default; +select @@tidb_enable_non_prepared_plan_cache; +select /*+ set_var(tidb_enable_non_prepared_plan_cache=1) */ @@tidb_enable_non_prepared_plan_cache; +select @@tidb_enable_non_prepared_plan_cache; +set @@tidb_enable_non_prepared_plan_cache=default; +select @@tidb_enable_non_prepared_plan_cache; +select /*+ set_var(tidb_plan_cache_max_plan_size=0) */ @@tidb_plan_cache_max_plan_size; +select @@tidb_plan_cache_max_plan_size; +set @@tidb_plan_cache_max_plan_size=default; +select @@tidb_plan_cache_max_plan_size; +select /*+ set_var(tidb_plan_cache_max_plan_size=1) */ @@tidb_plan_cache_max_plan_size; +select @@tidb_plan_cache_max_plan_size; +set @@tidb_plan_cache_max_plan_size=default; +select @@tidb_plan_cache_max_plan_size; +select /*+ set_var(tidb_opt_range_max_size=0) */ @@tidb_opt_range_max_size; +select @@tidb_opt_range_max_size; +set @@tidb_opt_range_max_size=default; +select @@tidb_opt_range_max_size; +select /*+ set_var(tidb_opt_range_max_size=1) */ @@tidb_opt_range_max_size; +select @@tidb_opt_range_max_size; +set @@tidb_opt_range_max_size=default; +select @@tidb_opt_range_max_size; +select /*+ set_var(tidb_opt_advanced_join_hint=0) */ @@tidb_opt_advanced_join_hint; +select @@tidb_opt_advanced_join_hint; +set @@tidb_opt_advanced_join_hint=default; +select @@tidb_opt_advanced_join_hint; +select /*+ set_var(tidb_opt_advanced_join_hint=1) */ @@tidb_opt_advanced_join_hint; +select @@tidb_opt_advanced_join_hint; +set @@tidb_opt_advanced_join_hint=default; +select @@tidb_opt_advanced_join_hint; +select /*+ set_var(tidb_opt_prefix_index_single_scan=0) */ @@tidb_opt_prefix_index_single_scan; +select @@tidb_opt_prefix_index_single_scan; +set @@tidb_opt_prefix_index_single_scan=default; +select @@tidb_opt_prefix_index_single_scan; +select /*+ set_var(tidb_opt_prefix_index_single_scan=1) */ @@tidb_opt_prefix_index_single_scan; +select @@tidb_opt_prefix_index_single_scan; +set @@tidb_opt_prefix_index_single_scan=default; +select @@tidb_opt_prefix_index_single_scan; +select /*+ set_var(tidb_store_batch_size=1) */ @@tidb_store_batch_size; +select @@tidb_store_batch_size; +set @@tidb_store_batch_size=default; +select @@tidb_store_batch_size; +select /*+ set_var(tidb_store_batch_size=2) */ @@tidb_store_batch_size; +select @@tidb_store_batch_size; +set @@tidb_store_batch_size=default; +select @@tidb_store_batch_size; +select /*+ set_var(tidb_enable_inl_join_inner_multi_pattern=0) */ @@tidb_enable_inl_join_inner_multi_pattern; +select @@tidb_enable_inl_join_inner_multi_pattern; +set @@tidb_enable_inl_join_inner_multi_pattern=default; +select @@tidb_enable_inl_join_inner_multi_pattern; +select /*+ set_var(tidb_enable_inl_join_inner_multi_pattern=1) */ @@tidb_enable_inl_join_inner_multi_pattern; +select @@tidb_enable_inl_join_inner_multi_pattern; +set @@tidb_enable_inl_join_inner_multi_pattern=default; +select @@tidb_enable_inl_join_inner_multi_pattern; +select /*+ set_var(tidb_opt_enable_late_materialization=0) */ @@tidb_opt_enable_late_materialization; +select @@tidb_opt_enable_late_materialization; +set @@tidb_opt_enable_late_materialization=default; +select @@tidb_opt_enable_late_materialization; +select /*+ set_var(tidb_opt_enable_late_materialization=1) */ @@tidb_opt_enable_late_materialization; +select @@tidb_opt_enable_late_materialization; +set @@tidb_opt_enable_late_materialization=default; +select @@tidb_opt_enable_late_materialization; +select /*+ set_var(tidb_opt_ordering_index_selectivity_threshold=0) */ @@tidb_opt_ordering_index_selectivity_threshold; +select @@tidb_opt_ordering_index_selectivity_threshold; +set @@tidb_opt_ordering_index_selectivity_threshold=default; +select @@tidb_opt_ordering_index_selectivity_threshold; +select /*+ set_var(tidb_opt_ordering_index_selectivity_threshold=1) */ @@tidb_opt_ordering_index_selectivity_threshold; +select @@tidb_opt_ordering_index_selectivity_threshold; +set @@tidb_opt_ordering_index_selectivity_threshold=default; +select @@tidb_opt_ordering_index_selectivity_threshold; +select /*+ set_var(tidb_opt_enable_mpp_shared_cte_execution=0) */ @@tidb_opt_enable_mpp_shared_cte_execution; +select @@tidb_opt_enable_mpp_shared_cte_execution; +set @@tidb_opt_enable_mpp_shared_cte_execution=default; +select @@tidb_opt_enable_mpp_shared_cte_execution; +select /*+ set_var(tidb_opt_enable_mpp_shared_cte_execution=1) */ @@tidb_opt_enable_mpp_shared_cte_execution; +select @@tidb_opt_enable_mpp_shared_cte_execution; +set @@tidb_opt_enable_mpp_shared_cte_execution=default; +select @@tidb_opt_enable_mpp_shared_cte_execution; +select @@max_execution_time; +set @@max_execution_time=1000; +select @@max_execution_time; +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +# The value is the changed value 1000, not the default value 0. +select @@max_execution_time; + +set @@global.max_execution_time=1000; +connect (conn1,localhost,root,,sessionctx__setvar); +connection conn1; +select @@max_execution_time; +# The value is the global value 1000, not the default value 0. +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +select @@max_execution_time; +set @@max_execution_time=2000; +select @@max_execution_time; +select /*+ set_var(max_execution_time=100) */ @@max_execution_time; +# The value is the changed value 2000, not the default value 0 or the global value 1000. +select @@max_execution_time; +set @@global.max_execution_time=default; +disconnect conn1; diff --git a/tests/integrationtest/t/sessiontxn/externals.test b/tests/integrationtest/t/sessiontxn/externals.test new file mode 100644 index 0000000000000..25aafbf9b07b4 --- /dev/null +++ b/tests/integrationtest/t/sessiontxn/externals.test @@ -0,0 +1,65 @@ +# TestReadWriteExternalTimestamp +select @@tidb_external_ts; +set global tidb_external_ts=19980613; +select @@tidb_external_ts; +set global tidb_external_ts=20220930; +select @@tidb_external_ts; + +# TestExternalTimestampRead +drop table if exists t; +create table t (id INT NOT NULL,d double,PRIMARY KEY (id)); +insert into t values (0, 100); +insert into t values (1, 100); +insert into t values (2, 100); +insert into t values (3, 100); +select * from t; +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (4, 100); +# as the `tidb_external_ts` is set an old value, the newest row (4, 100) cannot be read +set tidb_enable_external_ts_read=ON; +select * from t; +set tidb_enable_external_ts_read=OFF; +select * from t; + +# TestExternalTimestampReadWithTransaction +drop table if exists t; +create table t (id INT NOT NULL,PRIMARY KEY (id)); +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (0); +select * from t; +set tidb_enable_external_ts_read=ON; +select * from t; +start transaction; +select * from t; +commit; +set tidb_enable_external_ts_read=OFF; +start transaction; +select * from t; +commit; +start transaction; +select * from t; +set tidb_enable_external_ts_read=ON; +select * from t; +set tidb_enable_external_ts_read=OFF; +commit; + +# TestExternalTimestampNotAffectPrepare +drop table if exists t; +create table t (id INT NOT NULL,PRIMARY KEY (id)); +insert into t values (0); +select * from t; +start transaction; +set global tidb_external_ts=@@tidb_current_ts; +commit; +insert into t values (1); +select * from t; +set tidb_enable_external_ts_read=on; +prepare my_select from 'select * from t'; +execute my_select; +set tidb_enable_external_ts_read=off; +execute my_select; +