From a7c47e25731ddd40364204f884ac768b712dbc57 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 1 Mar 2023 20:14:45 +0800 Subject: [PATCH] session: check redact when log compile error Signed-off-by: lance6716 --- session/session.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/session/session.go b/session/session.go index 5b141d6f5e0c2..3b4ecb8ae3249 100644 --- a/session/session.go +++ b/session/session.go @@ -2153,8 +2153,12 @@ func (s *session) ExecuteStmt(ctx context.Context, stmtNode ast.StmtNode) (sqlex // Mute the warning for internal SQLs. if !s.sessionVars.InRestrictedSQL { 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", stmtNode.Text())) + zap.String("SQL", sql)) } } return nil, err