Skip to content

Commit

Permalink
session: check redact when log compile error (#41832) (#41924)
Browse files Browse the repository at this point in the history
close #41831
  • Loading branch information
ti-chi-bot authored Jun 29, 2023
1 parent 2a463d7 commit bd94fb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,14 @@ func (s *session) ExecuteStmt(ctx context.Context, stmtNode ast.StmtNode) (sqlex
// Only print log message when this SQL is from the user.
// Mute the warning for internal SQLs.
if !s.sessionVars.InRestrictedSQL {
logutil.Logger(ctx).Warn("compile SQL failed", zap.Error(err), zap.String("SQL", stmtNode.Text()))
if !variable.ErrUnknownSystemVar.Equal(err) {
sql := stmtNode.Text()
if s.sessionVars.EnableRedactLog {
sql = parser.Normalize(sql)
}
logutil.Logger(ctx).Warn("compile SQL failed", zap.Error(err),
zap.String("SQL", sql))
}
}
return nil, err
}
Expand Down

0 comments on commit bd94fb8

Please sign in to comment.