Skip to content

Commit

Permalink
cherry pick pingcap#17566 to release-3.1
Browse files Browse the repository at this point in the history
Signed-off-by: sre-bot <sre-bot@pingcap.com>
  • Loading branch information
zimulala authored and sre-bot committed Jun 4, 2020
1 parent 871ab59 commit ee17948
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (w *worker) onModifyColumn(t *meta.Meta, job *model.Job) (ver int64, _ erro

// doModifyColumn updates the column information and reorders all columns.
func (w *worker) doModifyColumn(t *meta.Meta, job *model.Job, newCol *model.ColumnInfo, oldName *model.CIStr, pos *ast.ColumnPosition, modifyColumnTp byte) (ver int64, _ error) {
dbInfo, err := t.GetDatabase(job.SchemaID)
dbInfo, err := checkSchemaExistAndCancelNotExistJob(t, job)
if err != nil {
return ver, errors.Trace(err)
}
Expand Down
13 changes: 13 additions & 0 deletions ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,19 @@ func (s *testStateChangeSuite) TestParallelCreateAndRename(c *C) {
s.testControlParallelExecSQL(c, sql1, sql2, f)
}

func (s *testStateChangeSuite) TestParallelAlterAndDropSchema(c *C) {
_, err := s.se.Execute(context.Background(), "create database db_drop_db")
c.Assert(err, IsNil)
sql1 := "DROP SCHEMA db_drop_db"
sql2 := "ALTER SCHEMA db_drop_db CHARSET utf8mb4 COLLATE utf8mb4_general_ci"
f := func(c *C, err1, err2 error) {
c.Assert(err1, IsNil)
c.Assert(err2, NotNil)
c.Assert(err2.Error(), Equals, "[schema:1008]Can't drop database ''; database doesn't exist")
}
s.testControlParallelExecSQL(c, sql1, sql2, f)
}

type checkRet func(c *C, err1, err2 error)

func (s *testStateChangeSuite) prepareTestControlParallelExecSQL(c *C) (session.Session, session.Session, chan struct{}, ddl.Callback) {
Expand Down
2 changes: 1 addition & 1 deletion ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func checkPrimaryKeyNotNull(w *worker, sqlMode mysql.SQLMode, t *meta.Meta, job
return nil, nil
}

dbInfo, err := t.GetDatabase(job.SchemaID)
dbInfo, err := checkSchemaExistAndCancelNotExistJob(t, job)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions ddl/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ func onModifySchemaCharsetAndCollate(t *meta.Meta, job *model.Job) (ver int64, _
return ver, errors.Trace(err)
}

dbInfo, err := t.GetDatabase(job.SchemaID)
dbInfo, err := checkSchemaExistAndCancelNotExistJob(t, job)
if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
}

Expand Down

0 comments on commit ee17948

Please sign in to comment.