Skip to content

Commit

Permalink
rename droptable to droptableOrView
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDi committed Jan 5, 2019
1 parent a3b701a commit 5ae5902
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ddl/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func onCreateView(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ error)
tbInfo.State = model.StatePublic
tbInfo.UpdateTS = t.StartTS
if oldTbInfoID > 0 && orReplace {
err = t.DropTable(schemaID, oldTbInfoID, true)
err = t.DropTableOrView(schemaID, oldTbInfoID, true)
if err != nil {
return ver, errors.Trace(err)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func onDropTableOrView(t *meta.Meta, job *model.Job) (ver int64, _ error) {
if err != nil {
return ver, errors.Trace(err)
}
if err = t.DropTable(job.SchemaID, job.TableID, true); err != nil {
if err = t.DropTableOrView(job.SchemaID, job.TableID, true); err != nil {
break
}
// Finish this job.
Expand Down Expand Up @@ -232,7 +232,7 @@ func onTruncateTable(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ erro
return ver, errors.Trace(err)
}

err = t.DropTable(schemaID, tblInfo.ID, true)
err = t.DropTableOrView(schemaID, tblInfo.ID, true)
if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
Expand Down Expand Up @@ -362,7 +362,7 @@ func onRenameTable(t *meta.Meta, job *model.Job) (ver int64, _ error) {
tblInfo.OldSchemaID = 0
}

err = t.DropTable(oldSchemaID, tblInfo.ID, shouldDelAutoID)
err = t.DropTableOrView(oldSchemaID, tblInfo.ID, shouldDelAutoID)
if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
Expand Down
2 changes: 1 addition & 1 deletion infoschema/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (b *Builder) ApplyDiff(m *meta.Meta, diff *model.SchemaDiff) ([]int64, erro
}
}
if tableIDIsValid(newTableID) {
// All types except DropTable.
// All types except DropTableOrView.
err := b.applyCreateTable(m, dbInfo, newTableID, alloc)
if err != nil {
return nil, errors.Trace(err)
Expand Down
4 changes: 2 additions & 2 deletions meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ func (m *Meta) DropDatabase(dbID int64) error {
return nil
}

// DropTable drops table in database.
// DropTableOrView drops table in database.
// If delAutoID is true, it will delete the auto_increment id key-value of the table.
// For rename table, we do not need to rename auto_increment id key-value.
func (m *Meta) DropTable(dbID int64, tblID int64, delAutoID bool) error {
func (m *Meta) DropTableOrView(dbID int64, tblID int64, delAutoID bool) error {
// Check if db exists.
dbKey := m.dbKey(dbID)
if err := m.checkDBExists(dbKey); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (s *testSuite) TestMeta(c *C) {
c.Assert(err, IsNil)
c.Assert(n, Equals, int64(10))

err = t.DropTable(1, tbInfo2.ID, true)
err = t.DropTableOrView(1, tbInfo2.ID, true)
c.Assert(err, IsNil)
// Make sure auto id key-value entry is gone.
n, err = t.GetAutoTableID(1, 2)
Expand Down

0 comments on commit 5ae5902

Please sign in to comment.