From f99b886d40319cee7c88bc83bdc311914e177b7c 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 c713f5bcce764..697b64d333355 100644 --- a/session/session.go +++ b/session/session.go @@ -2182,8 +2182,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