Skip to content

Commit

Permalink
add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
time-and-fate committed Jan 4, 2023
1 parent bcb795d commit 70760b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1611,8 +1611,10 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) {
}

func extractMsgFromSQLWarn(SQLWarn *stmtctx.SQLWarn) string {
// Currently, this function is only used in extractMsgFromSQLWarn().
// extractMsgFromSQLWarn() can make sure SQLWarn is not nil so no need to add a nil check here.
warn := errors.Cause(SQLWarn.Err)
if x, ok := warn.(*terror.Error); ok {
if x, ok := warn.(*terror.Error); ok && x != nil {
sqlErr := terror.ToSQLError(x)
return sqlErr.Message
}
Expand Down

0 comments on commit 70760b8

Please sign in to comment.