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) (#46353)

close #46349
  • Loading branch information
ti-chi-bot authored Nov 24, 2023
1 parent 175edc2 commit 99cb7c3
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 99cb7c3

Please sign in to comment.