drop foreign key that does not exist error (#1874)
This commit is contained in:
@ -174,6 +174,28 @@ func (s *testDDLSuite) TestTableError(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *testDDLSuite) TestForeignKeyError(c *C) {
|
||||
defer testleak.AfterTest(c)()
|
||||
store := testCreateStore(c, "test_foreign_key_error")
|
||||
defer store.Close()
|
||||
|
||||
d := newDDL(store, nil, nil, testLease)
|
||||
defer d.close()
|
||||
|
||||
ctx := testNewContext(c, d)
|
||||
|
||||
doDDLJobErr(c, -1, 1, model.ActionAddForeignKey, nil, ctx, d)
|
||||
doDDLJobErr(c, -1, 1, model.ActionDropForeignKey, nil, ctx, d)
|
||||
|
||||
dbInfo := testSchemaInfo(c, d, "test")
|
||||
tblInfo := testTableInfo(c, d, "t", 3)
|
||||
|
||||
testCreateSchema(c, ctx, d, dbInfo)
|
||||
testCreateTable(c, ctx, d, dbInfo, tblInfo)
|
||||
|
||||
doDDLJobErr(c, dbInfo.ID, tblInfo.ID, model.ActionDropForeignKey, []interface{}{model.NewCIStr("c1_foreign_key")}, ctx, d)
|
||||
}
|
||||
|
||||
func (s *testDDLSuite) TestIndexError(c *C) {
|
||||
defer testleak.AfterTest(c)()
|
||||
store := testCreateStore(c, "test_index_error")
|
||||
|
||||
@ -85,6 +85,7 @@ func (d *ddl) onDropForeignKey(t *meta.Meta, job *model.Job) error {
|
||||
}
|
||||
|
||||
if !found {
|
||||
job.State = model.JobCancelled
|
||||
return infoschema.ErrForeignKeyNotExists.Gen("foreign key doesn't exist", fkName)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user