diff --git a/session/session.go b/session/session.go index ac26339953ffd..c705acd0ce1b2 100644 --- a/session/session.go +++ b/session/session.go @@ -2197,7 +2197,16 @@ func (s *session) ExecuteStmt(ctx context.Context, stmtNode ast.StmtNode) (sqlex } }) - stmtLabel := ast.GetStmtLabel(stmtNode) + var stmtLabel string + if execStmt, ok := stmtNode.(*ast.ExecuteStmt); ok { + prepareStmt, err := plannercore.GetPreparedStmt(execStmt, s.sessionVars) + if err == nil && prepareStmt.PreparedAst != nil { + stmtLabel = ast.GetStmtLabel(prepareStmt.PreparedAst.Stmt) + } + } + if stmtLabel == "" { + stmtLabel = ast.GetStmtLabel(stmtNode) + } s.setRequestSource(ctx, stmtLabel, stmtNode) // Transform abstract syntax tree to a physical plan(stored in executor.ExecStmt).