diff --git a/ddl/column.go b/ddl/column.go index 68d3005ae836a..3137af944e93f 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -345,7 +345,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) } diff --git a/ddl/db_change_test.go b/ddl/db_change_test.go index 3f3cd1fba7869..f7284968484e2 100644 --- a/ddl/db_change_test.go +++ b/ddl/db_change_test.go @@ -882,6 +882,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 *testStateChangeSuiteBase) prepareTestControlParallelExecSQL(c *C) (session.Session, session.Session, chan struct{}, ddl.Callback) { diff --git a/ddl/index.go b/ddl/index.go index 0f63c1403db9b..2c9d16808e8b1 100755 --- a/ddl/index.go +++ b/ddl/index.go @@ -327,7 +327,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 } diff --git a/ddl/schema.go b/ddl/schema.go index 6349edff917f5..88d91a7ceb01c 100644 --- a/ddl/schema.go +++ b/ddl/schema.go @@ -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) }