Skip to content

Commit

Permalink
*: Remove tidb_enable_default_list_partition variable (#45701)
Browse files Browse the repository at this point in the history
close #45700
  • Loading branch information
mjonss authored Aug 1, 2023
1 parent 0e068ed commit 2e8de8d
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 49 deletions.
13 changes: 0 additions & 13 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,6 @@ func TestCreateTableWithListPartition(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("set @@session.tidb_enable_list_partition = ON")
tk.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk.MustExec("drop table if exists t")
type errorCase struct {
sql string
Expand Down Expand Up @@ -1067,7 +1066,6 @@ func TestCreateTableWithListColumnsPartition(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("set @@session.tidb_enable_list_partition = ON")
tk.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk.MustExec("drop table if exists t")
type errorCase struct {
sql string
Expand Down Expand Up @@ -1291,9 +1289,6 @@ func TestAlterTableAddPartitionByList(t *testing.T) {

tk.MustContainErrMsg(`alter table t add partition (partition p6 values in (null, 6))`,
"[ddl:1495]Multiple definition of same constant in list partitioning")
tk.MustContainErrMsg(`alter table t add partition (partition pDef values in (default, 6))`,
"[ddl:8200]VALUES IN (DEFAULT) is not supported, please use 'tidb_enable_default_list_partition'")
tk.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk.MustExec(`alter table t add partition (partition pDef values in (default, 6))`)
tk.MustContainErrMsg(`alter table t add partition (partition pDef2 values in (10, default))`, `[ddl:8200]Unsupported ADD List partition, already contains DEFAULT partition. Please use REORGANIZE PARTITION instead`)
tk.MustContainErrMsg(`alter table t add partition (partition pDef2 values in (10))`, `[ddl:8200]Unsupported ADD List partition, already contains DEFAULT partition. Please use REORGANIZE PARTITION instead`)
Expand Down Expand Up @@ -1427,10 +1422,6 @@ func TestAlterTableAddPartitionByListColumns(t *testing.T) {
partition p5 values in ((8,'a')));`)
// We only support a single DEFAULT (catch-all),
// Not a DEFAULT per column in LIST COLUMNS!
tk.MustGetErrMsg(`alter table t add partition (
partition pDef values in (10, default))`,
"[ddl:8200]VALUES IN (DEFAULT) is not supported, please use 'tidb_enable_default_list_partition'")
tk.MustExec(`set tidb_enable_default_list_partition = ON`)
tk.MustGetErrMsg(`alter table t add partition (
partition pDef values in (10, default))`, `[ddl:1653]Inconsistency in usage of column lists for partitioning`)
tk.MustGetErrCode(`alter table t add partition (
Expand Down Expand Up @@ -1595,7 +1586,6 @@ func TestDefaultListPartition(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("create database defaultPartition")
tk.MustExec("use defaultPartition")
tk.MustExec(`set @@session.tidb_enable_default_list_partition=ON`)

tk.MustExec(`create table t (a int, b varchar(255), unique key (a), key (b)) partition by list (a) (partition p0 values in (0,4), partition p1 values in (1, null, default), partition p2 values in (2,7,10))`)
tk.MustExec(`insert into t values (1, "1"), (2, "2"), (3,'3'), (null, "null"), (4, "4"), (11, "11")`)
Expand Down Expand Up @@ -1650,7 +1640,6 @@ func TestDefaultListColumnPartition(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("create database defaultPartition")
tk.MustExec("use defaultPartition")
tk.MustExec(`set @@session.tidb_enable_default_list_partition=ON`)

tk.MustExec(`create table t (b int, a varchar(255)) partition by list columns (a) (partition p0 values in (0,4), partition p1 values in (1, null, default), partition p2 values in (2,7,10))`)
tk.MustQuery(`show create table t`).Check(testkit.Rows("" +
Expand Down Expand Up @@ -1756,7 +1745,6 @@ func TestDefaultListErrors(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("create schema defaultListErrors")
tk.MustExec("use defaultListErrors")
tk.MustExec(`set tidb_enable_default_list_partition=ON`)
tk.MustContainErrMsg(`create table t (a int) partition by range (a) (partition p0 values less than (default))`,
"[parser:1064]You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 86 near ")
tk.MustContainErrMsg(`create table t (a int) partition by range (a) (partition p0 values less than ("default"))`,
Expand Down Expand Up @@ -1832,7 +1820,6 @@ func TestAlterTableDropPartitionByListColumns(t *testing.T) {
tk.MustExec("use test;")
tk.MustExec("drop table if exists t;")
tk.MustExec("set @@session.tidb_enable_list_partition = ON")
tk.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk.MustExec(`create table t (id int, name varchar(10)) partition by list columns (id,name) (
partition p0 values in ((1,'a'),(2,'b')),
partition p1 values in ((3,'a'),(4,'b')),
Expand Down
2 changes: 1 addition & 1 deletion ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7486,7 +7486,7 @@ func BuildAddedPartitionInfo(ctx sessionctx.Context, meta *model.TableInfo, spec
if len(spec.PartDefinitions) == 0 {
return nil, ast.ErrPartitionsMustBeDefined.GenWithStackByArgs(meta.Partition.Type)
}
err := checkListPartitions(ctx, spec.PartDefinitions)
err := checkListPartitions(spec.PartDefinitions)
if err != nil {
return nil, err
}
Expand Down
13 changes: 3 additions & 10 deletions ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ func storeHasEngineTiFlashLabel(store *metapb.Store) bool {
return false
}

func checkListPartitions(ctx sessionctx.Context, defs []*ast.PartitionDefinition) error {
func checkListPartitions(defs []*ast.PartitionDefinition) error {
for _, def := range defs {
valIn, ok := def.Clause.(*ast.PartitionDefinitionClauseIn)
_, ok := def.Clause.(*ast.PartitionDefinitionClauseIn)
if !ok {
switch def.Clause.(type) {
case *ast.PartitionDefinitionClauseLessThan:
Expand All @@ -492,13 +492,6 @@ func checkListPartitions(ctx sessionctx.Context, defs []*ast.PartitionDefinition
return dbterror.ErrUnsupportedCreatePartition.GenWithStack("Only VALUES IN () is supported for LIST partitioning")
}
}
if !ctx.GetSessionVars().EnableDefaultListPartition {
for _, val := range valIn.Values {
if _, ok := val[0].(*ast.DefaultExpr); ok {
return dbterror.ErrUnsupportedCreatePartition.GenWithStack("VALUES IN (DEFAULT) is not supported, please use 'tidb_enable_default_list_partition'")
}
}
}
}
return nil
}
Expand All @@ -522,7 +515,7 @@ func buildTablePartitionInfo(ctx sessionctx.Context, s *ast.PartitionOptions, tb
// Partition by list is enabled only when tidb_enable_list_partition is 'ON'.
enable = ctx.GetSessionVars().EnableListTablePartition
if enable {
err := checkListPartitions(ctx, s.Definitions)
err := checkListPartitions(s.Definitions)
if err != nil {
return err
}
Expand Down
3 changes: 0 additions & 3 deletions planner/core/casetest/partition/partition_pruner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func TestListDefaultPartitionPruner(t *testing.T) {
tk := testkit.NewTestKit(t, store)
tk.MustExec("create database default_partition")
tk.MustExec("use default_partition")
tk.MustExec(`set tidb_enable_default_list_partition=1`)
tk.MustExec("" +
`create table t (a int, b varchar(255), key (b)) partition by list (a)` +
`(partition p0 values in (0, 10),` +
Expand Down Expand Up @@ -379,7 +378,6 @@ func TestListColumnsDefaultPartitionPruner(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("set tidb_cost_model_version=2")
tk.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk.MustExec("drop database if exists test_partition;")
tk.MustExec("create database test_partition")
tk.MustExec("use test_partition")
Expand All @@ -399,7 +397,6 @@ func TestListColumnsDefaultPartitionPruner(t *testing.T) {
tk1.MustExec(`set @@session.tidb_regard_null_as_point=false`)
tk1.MustExec("create database test_partition_1")
tk1.MustExec("use test_partition_1")
tk1.MustExec("set @@session.tidb_enable_default_list_partition = ON")
tk1.MustExec("create table t1 (id int, a int, b int, unique key (a,b,id)) partition by list columns (b,a) (partition p0 values in ((1,1),(2,2),(4,4),(5,5)), partition pDef values in (default), partition p1 values in ((6,6),(7,7),(8,8),(9,9),(null,10)))")
tk1.MustExec("create table t2 (id int, a int, b int, unique key (a,b,id)) partition by list columns (id,a,b) (partition p0 values in ((1,1,1),(2,2,2),(4,4,4),(5,5,5)), partition p1 values in ((6,6,6),(7,7,7),(8,8,8),(9,9,9),(null,null,null)), partition pDef default)")
tk1.MustExec(insertT1)
Expand Down
1 change: 0 additions & 1 deletion planner/core/partition_pruner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ func TestIssue33231(t *testing.T) {
func TestListDefaultPruning(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec(`set tidb_enable_default_list_partition=1`)
tk.MustExec("create database ListDefaultPrune")
tk.MustExec("use ListDefaultPrune")
tk.MustExec(`create table t (a int, b int) partition by list columns (a,b) (partition p1 values in ((1,1)), partition p2 values in ((2,2)), partition pDef default)`)
Expand Down
8 changes: 0 additions & 8 deletions session/sessiontest/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,18 +1229,10 @@ func TestEnablePartition(t *testing.T) {
tk.MustExec("set global tidb_enable_list_partition=on")
tk.MustQuery("show global variables like 'tidb_enable_list_partition'").Check(testkit.Rows("tidb_enable_list_partition ON"))

tk.MustQuery("show variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition OFF"))
tk.MustExec("set GLOBAL tidb_enable_default_list_partition=on")
tk.MustQuery("show variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition OFF"))
tk.MustQuery("show global variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition ON"))
tk.MustExec("set tidb_enable_default_list_partition=on")
tk.MustQuery("show variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition ON"))
tk.MustQuery("show global variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition ON"))
tk1 := testkit.NewTestKit(t, store)
tk1.MustExec("use test")
tk1.MustQuery("show variables like 'tidb_enable_table_partition'").Check(testkit.Rows("tidb_enable_table_partition ON"))
tk1.MustQuery("show variables like 'tidb_enable_list_partition'").Check(testkit.Rows("tidb_enable_list_partition ON"))
tk1.MustQuery("show variables like 'tidb_enable_default_list_partition'").Check(testkit.Rows("tidb_enable_default_list_partition ON"))
}

func TestRollbackOnCompileError(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,6 @@ type SessionVars struct {
// use the ExpectedCnt to adjust the estimated row count for index scan.
OptOrderingIdxSelThresh float64

// EnableDefaultListPartition enables DEFAULT list partition
EnableDefaultListPartition bool

// EnableMPPSharedCTEExecution indicates whether we enable the shared CTE execution strategy on MPP side.
EnableMPPSharedCTEExecution bool

Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2515,10 +2515,6 @@ var defaultSysVars = []*SysVar{
s.OptOrderingIdxSelThresh = tidbOptFloat64(val, DefTiDBOptOrderingIdxSelThresh)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBEnableDefaultListPartition, Value: BoolToOnOff(DefTiDBEnableDefaultListPartition), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.EnableDefaultListPartition = TiDBOptOn(val)
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBOptEnableMPPSharedCTEExecution, Value: BoolToOnOff(DefTiDBOptEnableMPPSharedCTEExecution), Type: TypeBool, SetSession: func(s *SessionVars, val string) error {
s.EnableMPPSharedCTEExecution = TiDBOptOn(val)
return nil
Expand Down
6 changes: 0 additions & 6 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,6 @@ const (
// TiDBUseAlloc indicates whether the last statement used chunk alloc
TiDBUseAlloc = "last_sql_use_alloc"

// TiDBEnableDefaultListPartition is used to control
// table partition DEFAULT list partition feature.
// The valid value include on/off
TiDBEnableDefaultListPartition = "tidb_enable_default_list_partition"

// TiDBExplicitRequestSourceType indicates the source of the request, it's a complement of RequestSourceType.
// The value maybe "lightning", "br", "dumpling" etc.
TiDBExplicitRequestSourceType = "tidb_request_source_type"
Expand Down Expand Up @@ -1391,7 +1386,6 @@ const (
DefRuntimeFilterMode = "OFF"
DefTiDBLockUnchangedKeys = true
DefTiDBEnableCheckConstraint = false
DefTiDBEnableDefaultListPartition = false
DefTiDBSkipMissingPartitionStats = true
)

Expand Down

0 comments on commit 2e8de8d

Please sign in to comment.