Skip to content

Commit

Permalink
fix a bug introduced in ce1c811
Browse files Browse the repository at this point in the history
ignore 'use' query if event.CurrentSchema is empty
  • Loading branch information
ffffwh committed Oct 23, 2018
1 parent 51595e4 commit 56e5da9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/client/driver/mysql/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,16 +1119,18 @@ func (a *Applier) ApplyBinlogEvent(workerIdx int, binlogEntry *binlog.BinlogEntr
var err error
a.logger.Debugf("mysql.applier: ApplyBinlogEvent: not dml: %v", event.Query)

// TODO escape schema name?
query := fmt.Sprintf("USE %s", event.CurrentSchema)
a.logger.Debugf("mysql.applier: query: %v", query)
_, err = tx.Exec(query)
if err != nil {
if !sql.IgnoreError(err) {
a.logger.Errorf("mysql.applier: Exec sql error: %v", err)
return err
} else {
a.logger.Warnf("mysql.applier: Ignore error: %v", err)
if event.CurrentSchema != "" {
// TODO escape schema name?
query := fmt.Sprintf("USE %s", event.CurrentSchema)
a.logger.Debugf("mysql.applier: query: %v", query)
_, err = tx.Exec(query)
if err != nil {
if !sql.IgnoreError(err) {
a.logger.Errorf("mysql.applier: Exec sql error: %v", err)
return err
} else {
a.logger.Warnf("mysql.applier: Ignore error: %v", err)
}
}
}

Expand Down

0 comments on commit 56e5da9

Please sign in to comment.