Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session: support 'GLOBAL SCOPE' for tidb_enable_table_partition #14062

Merged
merged 4 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var (
// ErrUnsupportedPartitionByRangeColumns returns for does unsupported partition by range columns.
ErrUnsupportedPartitionByRangeColumns = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "partition by range columns"))
errUnsupportedCreatePartition = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "partition type, treat as normal table"))
errTablePartitionDisabled = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, "Partitions are ignored because Table Partition is disabled, please set 'tidb_enable_table_partition' if you need to need to enable it")
errUnsupportedIndexType = terror.ClassDDL.New(mysql.ErrUnsupportedDDLOperation, fmt.Sprintf(mysql.MySQLErrName[mysql.ErrUnsupportedDDLOperation], "index type"))

// ErrDupKeyName returns for duplicated key name
Expand Down
2 changes: 1 addition & 1 deletion ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func buildTablePartitionInfo(ctx sessionctx.Context, d *ddl, s *ast.CreateTableS
}
}
if !enable {
ctx.GetSessionVars().StmtCtx.AppendWarning(errUnsupportedCreatePartition)
ctx.GetSessionVars().StmtCtx.AppendWarning(errTablePartitionDisabled)
}

pi := &model.PartitionInfo{
Expand Down
1 change: 1 addition & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,7 @@ var builtinGlobalVariable = []string{
variable.TiDBRetryLimit,
variable.TiDBDisableTxnAutoRetry,
variable.TiDBEnableWindowFunction,
variable.TiDBEnableTablePartition,
variable.TiDBEnableVectorizedExpression,
variable.TiDBEnableFastAnalyze,
variable.TiDBExpensiveQueryTimeThreshold,
Expand Down
16 changes: 16 additions & 0 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,22 @@ func (s *testSessionSuite2) TestCommitRetryCount(c *C) {
c.Assert(err, NotNil)
}

func (s *testSessionSuite2) TestEnablePartition(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("set tidb_enable_table_partition=off")
tk.MustQuery("show variables like 'tidb_enable_table_partition'").Check(testkit.Rows("tidb_enable_table_partition off"))

tk.MustExec("set global tidb_enable_table_partition = on")

tk.MustQuery("show variables like 'tidb_enable_table_partition'").Check(testkit.Rows("tidb_enable_table_partition off"))
tk.MustQuery("show global variables like 'tidb_enable_table_partition'").Check(testkit.Rows("tidb_enable_table_partition on"))

// Disable global variable cache, so load global session variable take effect immediate.
s.dom.GetGlobalVarsCache().Disable()
tk1 := testkit.NewTestKitWithInit(c, s.store)
tk1.MustQuery("show variables like 'tidb_enable_table_partition'").Check(testkit.Rows("tidb_enable_table_partition on"))
}

func (s *testSessionSuite2) TestTxnRetryErrMsg(c *C) {
tk1 := testkit.NewTestKitWithInit(c, s.store)
tk2 := testkit.NewTestKitWithInit(c, s.store)
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ var defaultSysVars = []*SysVar{
{ScopeSession, TiDBEnableStreaming, "0"},
{ScopeSession, TiDBEnableChunkRPC, "1"},
{ScopeSession, TxnIsolationOneShot, ""},
{ScopeSession, TiDBEnableTablePartition, "auto"},
{ScopeGlobal | ScopeSession, TiDBEnableTablePartition, "auto"},
{ScopeGlobal | ScopeSession, TiDBHashJoinConcurrency, strconv.Itoa(DefTiDBHashJoinConcurrency)},
{ScopeGlobal | ScopeSession, TiDBProjectionConcurrency, strconv.Itoa(DefTiDBProjectionConcurrency)},
{ScopeGlobal | ScopeSession, TiDBHashAggPartialConcurrency, strconv.Itoa(DefTiDBHashAggPartialConcurrency)},
Expand Down