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
  • Loading branch information
you06 authored Aug 23, 2023
1 parent 82ab553 commit 6078d99
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 @@ -2189,7 +2189,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)

// Backup the original resource group name since sql hint might change it during optimization
Expand Down

0 comments on commit 6078d99

Please sign in to comment.