Merge pull request #458 from pingcap/siddontang/fix-drop-table
fix drop table
This commit is contained in:
@ -111,6 +111,8 @@ func (s *DropTableStmt) Exec(ctx context.Context) (rset.Recordset, error) {
|
||||
var notExistTables []string
|
||||
for _, ti := range s.TableIdents {
|
||||
err := sessionctx.GetDomain(ctx).DDL().DropTable(ctx, ti.Full(ctx))
|
||||
// TODO: we should return special error for table not exist, checking "not exist" is not enough,
|
||||
// because some other errors may contain this error string too.
|
||||
if err != nil && strings.HasSuffix(err.Error(), "not exist") {
|
||||
notExistTables = append(notExistTables, ti.String())
|
||||
} else if err != nil {
|
||||
|
||||
@ -57,6 +57,8 @@ func (s *testStmtSuite) TestDropTable(c *C) {
|
||||
c.Assert(mf.Len(), Greater, 0)
|
||||
|
||||
mustExec(c, s.testDB, testSQL)
|
||||
mustExec(c, s.testDB, "create table if not exists t (c int)")
|
||||
mustExec(c, s.testDB, "drop table t")
|
||||
}
|
||||
|
||||
func (s *testStmtSuite) TestDropIndex(c *C) {
|
||||
|
||||
@ -140,7 +140,7 @@ func (t *TxStructure) HLen(key []byte) (int64, error) {
|
||||
func (t *TxStructure) HDel(key []byte, fields ...[]byte) error {
|
||||
metaKey := t.encodeHashMetaKey(key)
|
||||
meta, err := t.loadHashMeta(metaKey)
|
||||
if err != nil {
|
||||
if err != nil || meta.IsEmpty() {
|
||||
return errors.Trace(err)
|
||||
}
|
||||
|
||||
|
||||
@ -239,6 +239,9 @@ func (s *tesTxStructureSuite) TestHash(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(l, Equals, int64(0))
|
||||
|
||||
err = tx.HDel(key, []byte("fake_key"))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = tx.Commit()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user