Skip to content

Commit

Permalink
ddl: make the column type change switch transparent (#25213)
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored Jun 8, 2021
1 parent a7f3c4d commit 7538818
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ddl/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,8 @@ func (s *testColumnSuite) TestModifyColumn(c *C) {
WithLease(testLease),
)
ctx := testNewContext(d)
ctx.GetSessionVars().EnableChangeColumnType = false

defer func() {
err := d.Stop()
c.Assert(err, IsNil)
Expand Down
1 change: 1 addition & 0 deletions ddl/column_type_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,7 @@ func (s *testColumnTypeChangeSuite) TestRowFormat(c *C) {
func (s *testColumnTypeChangeSuite) TestColumnTypeChangeFlenErrorMsg(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.Se.GetSessionVars().EnableChangeColumnType = false

tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int4)")
Expand Down
5 changes: 5 additions & 0 deletions ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func (s *testStateChangeSuiteBase) SetUpSuite(c *C) {
c.Assert(err, IsNil)
_, err = s.se.Execute(context.Background(), "use test_db_state")
c.Assert(err, IsNil)
// Set the variable to default 0 as it was before in case of modifying the test.
_, err = s.se.Execute(context.Background(), "set @@global.tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
_, err = s.se.Execute(context.Background(), "set @@tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
s.p = parser.New()
}

Expand Down
4 changes: 4 additions & 0 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func setupIntegrationSuite(s *testIntegrationSuite, c *C) {
s.ctx = se.(sessionctx.Context)
_, err = se.Execute(context.Background(), "create database test_db")
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
}

func tearDownIntegrationSuiteTest(s *testIntegrationSuite, c *C) {
Expand Down
4 changes: 4 additions & 0 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func setUpSuite(s *testDBSuite, c *C) {
c.Assert(err, IsNil)
_, err = s.s.Execute(context.Background(), "set @@global.tidb_max_delta_schema_count= 4096")
c.Assert(err, IsNil)
_, err = s.s.Execute(context.Background(), "set @@global.tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
_, err = s.s.Execute(context.Background(), "set @@tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
}

func tearDownSuite(s *testDBSuite, c *C) {
Expand Down
7 changes: 7 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ func (s *baseTestSuite) SetUpSuite(c *C) {
}
d, err := session.BootstrapSession(s.store)
c.Assert(err, IsNil)
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
// Set the variable to default 0 as it was before in case of modifying the test.
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
d.SetStatsUpdating(true)
s.domain = d
config.UpdateGlobal(func(conf *config.Config) {
Expand Down
7 changes: 7 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ func (s *testIntegrationSuiteBase) SetUpSuite(c *C) {
s.store, s.dom, err = newStoreWithBootstrap()
c.Assert(err, IsNil)
s.ctx = mock.NewContext()
se, err := session.CreateSession4Test(s.store)
c.Assert(err, IsNil)
// Set the variable to default 0 as it was before in case of modifying the test.
_, err = se.Execute(context.Background(), "set @@global.tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
_, err = se.Execute(context.Background(), "set @@tidb_enable_change_column_type=0")
c.Assert(err, IsNil)
}

func (s *testIntegrationSuiteBase) TearDownSuite(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ const (
DefTiDBDDLReorgBatchSize = 256
DefTiDBDDLErrorCountLimit = 512
DefTiDBMaxDeltaSchemaCount = 1024
DefTiDBChangeColumnType = false
DefTiDBChangeColumnType = true
DefTiDBChangeMultiSchema = false
DefTiDBPointGetCache = false
DefTiDBEnableAlterPlacement = false
Expand Down

0 comments on commit 7538818

Please sign in to comment.