Move .Kill()
func from inspector to go/mysql
(#1148)
This commit is contained in:
parent
ae02941f67
commit
f527d63c86
@ -533,14 +533,6 @@ func (this *Inspector) estimateTableRowsViaExplain() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill kills a query for connectionID.
|
|
||||||
// - @amason: this should go somewhere _other_ than `logic`, but I couldn't decide
|
|
||||||
// between `base`, `sql`, or `mysql`.
|
|
||||||
func Kill(db *gosql.DB, connectionID string) error {
|
|
||||||
_, err := db.Exec(`KILL QUERY %s`, connectionID)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// CountTableRows counts exact number of rows on the original table
|
// CountTableRows counts exact number of rows on the original table
|
||||||
func (this *Inspector) CountTableRows(ctx context.Context) error {
|
func (this *Inspector) CountTableRows(ctx context.Context) error {
|
||||||
atomic.StoreInt64(&this.migrationContext.CountingRowsFlag, 1)
|
atomic.StoreInt64(&this.migrationContext.CountingRowsFlag, 1)
|
||||||
@ -565,7 +557,7 @@ func (this *Inspector) CountTableRows(ctx context.Context) error {
|
|||||||
switch err {
|
switch err {
|
||||||
case context.Canceled, context.DeadlineExceeded:
|
case context.Canceled, context.DeadlineExceeded:
|
||||||
this.migrationContext.Log.Infof("exact row count cancelled (%s), likely because I'm about to cut over. I'm going to kill that query.", ctx.Err())
|
this.migrationContext.Log.Infof("exact row count cancelled (%s), likely because I'm about to cut over. I'm going to kill that query.", ctx.Err())
|
||||||
return Kill(this.db, connectionID)
|
return mysql.Kill(this.db, connectionID)
|
||||||
default:
|
default:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -205,3 +205,9 @@ func GetTableColumns(db *gosql.DB, databaseName, tableName string) (*sql.ColumnL
|
|||||||
}
|
}
|
||||||
return sql.NewColumnList(columnNames), sql.NewColumnList(virtualColumnNames), nil
|
return sql.NewColumnList(columnNames), sql.NewColumnList(virtualColumnNames), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kill executes a KILL QUERY by connection id
|
||||||
|
func Kill(db *gosql.DB, connectionID string) error {
|
||||||
|
_, err := db.Exec(`KILL QUERY %s`, connectionID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user