Skip to content

Commit

Permalink
session: set request source to type of the prepared stmt for execute …
Browse files Browse the repository at this point in the history
…stmt (#46348) (#46362)

close #46349
  • Loading branch information
you06 authored and cfzjywxk committed Aug 29, 2023
1 parent 5dc9f2d commit d5089d8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit d5089d8

Please sign in to comment.