Skip to content

Commit

Permalink
cherry pick pingcap#24359 to release-4.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
morgo authored and ti-srebot committed Jul 8, 2021
1 parent 6f46f2d commit b5fe608
Show file tree
Hide file tree
Showing 14 changed files with 973 additions and 27 deletions.
18 changes: 18 additions & 0 deletions cmd/explaintest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,24 @@ func main() {
if _, err = mdb.Exec("set @@tidb_hash_join_concurrency=1"); err != nil {
log.Fatal("set @@tidb_hash_join_concurrency=1 failed", zap.Error(err))
}
<<<<<<< HEAD
=======
resets := []string{
"set @@tidb_index_lookup_concurrency=4",
"set @@tidb_index_lookup_join_concurrency=4",
"set @@tidb_hashagg_final_concurrency=4",
"set @@tidb_hashagg_partial_concurrency=4",
"set @@tidb_window_concurrency=4",
"set @@tidb_projection_concurrency=4",
"set @@tidb_distsql_scan_concurrency=15",
"set @@global.tidb_enable_clustered_index=0;",
}
for _, sql := range resets {
if _, err = mdb.Exec(sql); err != nil {
log.Fatal(fmt.Sprintf("%s failed", sql), zap.Error(err))
}
}
>>>>>>> 0f10bef47... domain, session: Add new sysvarcache to replace global values cache (#24359)

if _, err = mdb.Exec("set sql_mode='STRICT_TRANS_TABLES'"); err != nil {
log.Fatal("set sql_mode='STRICT_TRANS_TABLES' failed", zap.Error(err))
Expand Down
41 changes: 41 additions & 0 deletions ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,47 @@ func (s *testStateChangeSuite) TestParallelAlterModifyColumn(c *C) {
s.testControlParallelExecSQL(c, sql, sql, f)
}

<<<<<<< HEAD
=======
func (s *testStateChangeSuite) TestParallelAddGeneratedColumnAndAlterModifyColumn(c *C) {
_, err := s.se.Execute(context.Background(), "set global tidb_enable_change_column_type = 1")
c.Assert(err, IsNil)
defer func() {
_, err = s.se.Execute(context.Background(), "set global tidb_enable_change_column_type = 0")
c.Assert(err, IsNil)
}()

sql1 := "ALTER TABLE t ADD COLUMN f INT GENERATED ALWAYS AS(a+1);"
sql2 := "ALTER TABLE t MODIFY COLUMN a tinyint;"
f := func(c *C, err1, err2 error) {
c.Assert(err1, IsNil)
c.Assert(err2.Error(), Equals, "[ddl:8200]Unsupported modify column: tidb_enable_change_column_type is true, oldCol is a dependent column 'a' for generated column")
_, err := s.se.Execute(context.Background(), "select * from t")
c.Assert(err, IsNil)
}
s.testControlParallelExecSQL(c, sql1, sql2, f)
}

func (s *testStateChangeSuite) TestParallelAlterModifyColumnAndAddPK(c *C) {
_, err := s.se.Execute(context.Background(), "set global tidb_enable_change_column_type = 1")
c.Assert(err, IsNil)
defer func() {
_, err = s.se.Execute(context.Background(), "set global tidb_enable_change_column_type = 0")
c.Assert(err, IsNil)
}()

sql1 := "ALTER TABLE t ADD PRIMARY KEY (b) NONCLUSTERED;"
sql2 := "ALTER TABLE t MODIFY COLUMN b tinyint;"
f := func(c *C, err1, err2 error) {
c.Assert(err1, IsNil)
c.Assert(err2.Error(), Equals, "[ddl:8200]Unsupported modify column: tidb_enable_change_column_type is true and this column has primary key flag")
_, err := s.se.Execute(context.Background(), "select * from t")
c.Assert(err, IsNil)
}
s.testControlParallelExecSQL(c, sql1, sql2, f)
}

>>>>>>> 0f10bef47... domain, session: Add new sysvarcache to replace global values cache (#24359)
// TODO: This test is not a test that performs two DDLs in parallel.
// So we should not use the function of testControlParallelExecSQL. We will handle this test in the next PR.
// func (s *testStateChangeSuite) TestParallelColumnModifyingDefinition(c *C) {
Expand Down
Loading

0 comments on commit b5fe608

Please sign in to comment.