Skip to content

Commit

Permalink
*: add schema state check (pingcap#4801)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored and Haibin Xie committed Dec 22, 2017
1 parent 51a446c commit 82c34f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ func (d *ddl) onDropIndex(t *meta.Meta, job *model.Job) (ver int64, _ error) {
job.State = model.JobRollbackDone
} else {
job.State = model.JobDone
d.asyncNotifyEvent(&Event{Tp: model.ActionDropIndex, TableInfo: tblInfo, IndexInfo: indexInfo})
}
job.BinlogInfo.AddTableInfo(ver, tblInfo)
job.Args = append(job.Args, indexInfo.ID)
d.asyncNotifyEvent(&Event{Tp: model.ActionDropIndex, TableInfo: tblInfo, IndexInfo: indexInfo})
default:
err = ErrInvalidTableState.Gen("invalid table state %v", tblInfo.State)
}
Expand Down
6 changes: 6 additions & 0 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ func (e *ShowExec) fetchShowCreateTable() error {
buf.WriteString(fmt.Sprintf("CREATE TABLE `%s` (\n", tb.Meta().Name.O))
var pkCol *table.Column
for i, col := range tb.Cols() {
if col.State != model.StatePublic {
continue
}
buf.WriteString(fmt.Sprintf(" `%s` %s", col.Name.O, col.GetTypeDesc()))
if col.IsGenerated() {
// It's a generated column.
Expand Down Expand Up @@ -505,6 +508,9 @@ func (e *ShowExec) fetchShowCreateTable() error {

for i, idx := range tb.Indices() {
idxInfo := idx.Meta()
if idxInfo.State != model.StatePublic {
continue
}
if idxInfo.Primary {
buf.WriteString(" PRIMARY KEY ")
} else if idxInfo.Unique {
Expand Down
3 changes: 3 additions & 0 deletions statistics/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func (h *Handle) HandleAutoAnalyze(is infoschema.InfoSchema) error {
return errors.Trace(h.execAutoAnalyze(sql))
}
for _, idx := range tblInfo.Indices {
if idx.State != model.StatePublic {
continue
}
if _, ok := statsTbl.Indices[idx.ID]; !ok {
sql := fmt.Sprintf("analyze table %s index `%s`", tblName, idx.Name.O)
log.Infof("[stats] auto analyze index `%s` for table %s now", idx.Name.O, tblName)
Expand Down

0 comments on commit 82c34f5

Please sign in to comment.