Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dk-lockdown committed Sep 22, 2021
1 parent 327ae11 commit 6a458df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ func (stmt *mysqlStmt) ExecContext(ctx context.Context, args []driver.NamedValue
return stmt.Exec(dargs)
}

func executable(mc *mysqlConn, sql string, args []driver.Value) (bool,error) {
func executable(mc *mysqlConn, sql string, args []driver.Value) (bool, error) {
parser := parser.New()
act, _ := parser.ParseOneStmt(sql, "", "")
deleteStmt, isDelete := act.(*ast.DeleteStmt)
Expand Down
10 changes: 5 additions & 5 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (executor *deleteExecutor) Execute() (driver.Result, error) {
}

func (executor *deleteExecutor) PrepareUndoLog(beforeImage, afterImage *schema.TableRecords) {
if len(beforeImage.Rows) == 0 {
if beforeImage == nil || len(beforeImage.Rows) == 0 {
return
}

Expand Down Expand Up @@ -379,7 +379,7 @@ func (executor *updateExecutor) Execute() (driver.Result, error) {
}

func (executor *updateExecutor) PrepareUndoLog(beforeImage, afterImage *schema.TableRecords) {
if len(beforeImage.Rows) == 0 &&
if (beforeImage == nil || len(beforeImage.Rows) == 0) &&
(afterImage == nil || len(afterImage.Rows) == 0) {
return
}
Expand All @@ -402,7 +402,7 @@ func (executor *updateExecutor) BeforeImage() (*schema.TableRecords, error) {
}

func (executor *updateExecutor) AfterImage(beforeImage *schema.TableRecords) (*schema.TableRecords, error) {
if beforeImage.Rows == nil || len(beforeImage.Rows) == 0 {
if beforeImage == nil || len(beforeImage.Rows) == 0 {
return nil, nil
}

Expand Down Expand Up @@ -553,7 +553,7 @@ func (executor *globalLockExecutor) Executable(lockRetryInterval time.Duration,
var err error
for i := 0; i < lockRetryTimes; i++ {
lockable, err = rm.GetResourceManager().LockQuery(context.Background(),
"", executor.mc.cfg.DBName, apis.AT, lockKeys )
"", executor.mc.cfg.DBName, apis.AT, lockKeys)
if lockable && err == nil {
return true, nil
}
Expand Down Expand Up @@ -648,4 +648,4 @@ func buildRecords(meta schema.TableMeta, rows driver.Rows) *schema.TableRecords
}
records.Rows = rs
return records
}
}

0 comments on commit 6a458df

Please sign in to comment.