From dae0a4104a92cfa8dcbfd49421dfb39703773664 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Fri, 27 May 2022 06:22:47 +0200 Subject: [PATCH] sessionctx: enable list partition by default (#34954) close pingcap/tidb#34953 --- executor/partition_table_test.go | 12 +++++++----- planner/core/integration_partition_test.go | 1 + planner/core/integration_test.go | 2 +- sessionctx/variable/sysvar.go | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/executor/partition_table_test.go b/executor/partition_table_test.go index c740dec5d93b1..e2d098c622f8f 100644 --- a/executor/partition_table_test.go +++ b/executor/partition_table_test.go @@ -899,12 +899,12 @@ func TestGlobalStatsAndSQLBinding(t *testing.T) { partition p2 values less than (600), partition p3 values less than (800), partition p4 values less than (1001))`) - tk.MustExec(`create table tlist(a int, b int, key(a)) partition by list (a) ( + tk.MustExec(`create table tlist (a int, b int, key(a)) partition by list (a) ( partition p0 values in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), - partition p0 values in (10, 11, 12, 13, 14, 15, 16, 17, 18, 19), - partition p0 values in (20, 21, 22, 23, 24, 25, 26, 27, 28, 29), - partition p0 values in (30, 31, 32, 33, 34, 35, 36, 37, 38, 39), - partition p0 values in (40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50))`) + partition p1 values in (10, 11, 12, 13, 14, 15, 16, 17, 18, 19), + partition p2 values in (20, 21, 22, 23, 24, 25, 26, 27, 28, 29), + partition p3 values in (30, 31, 32, 33, 34, 35, 36, 37, 38, 39), + partition p4 values in (40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50))`) // construct some special data distribution vals := make([]string, 0, 1000) @@ -3019,6 +3019,8 @@ func TestIssue21731(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("use test") tk.MustExec("drop table if exists p, t") + tk.MustExec("set @@tidb_enable_list_partition = OFF") + // Notice that this does not really test the issue #21731 tk.MustExec("create table t (a int, b int, unique index idx(a)) partition by list columns(b) (partition p0 values in (1), partition p1 values in (2));") } diff --git a/planner/core/integration_partition_test.go b/planner/core/integration_partition_test.go index e9a82d9f96169..be088c7023742 100644 --- a/planner/core/integration_partition_test.go +++ b/planner/core/integration_partition_test.go @@ -1068,6 +1068,7 @@ func TestIssue27070(t *testing.T) { tk := testkit.NewTestKit(t, store) tk.MustExec("create database issue_27070") tk.MustExec("use issue_27070") + tk.MustExec("set @@tidb_enable_list_partition = OFF") tk.MustExec(`create table if not exists t (id int, create_date date NOT NULL DEFAULT '2000-01-01', PRIMARY KEY (id,create_date) ) PARTITION BY list COLUMNS(create_date) ( PARTITION p20210506 VALUES IN ("20210507"), PARTITION p20210507 VALUES IN ("20210508") )`) tk.MustQuery("show warnings").Check(testkit.Rows("Warning 8200 Unsupported partition type LIST, treat as normal table")) } diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 1c4b1675b0869..7d66336c947c2 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -1097,7 +1097,7 @@ func TestPartitionTableDynamicModeUnderNewCollation(t *testing.T) { tk.MustQuery("select * from strrange where a in ('a', 'y')").Sort().Check(testkit.Rows("A 1", "Y 1", "a 1", "y 1")) // list partition and partitioned by utf8mb4_general_ci - tk.MustExec(`create table strlist(a varchar(10) charset utf8mb4 collate utf8mb4_general_ci, b int) partition by list(a) ( + tk.MustExec(`create table strlist(a varchar(10) charset utf8mb4 collate utf8mb4_general_ci, b int) partition by list columns (a) ( partition p0 values in ('a', 'b'), partition p1 values in ('c', 'd'), partition p2 values in ('e', 'f'))`) diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index f4c169aa22bfc..fcf689ea4493b 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -1160,7 +1160,7 @@ var defaultSysVars = []*SysVar{ s.EnableTablePartition = val return nil }}, - {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableListTablePartition, Value: Off, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { + {Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableListTablePartition, Value: On, Type: TypeBool, SetSession: func(s *SessionVars, val string) error { s.EnableListTablePartition = TiDBOptOn(val) return nil }},