Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session: set request source to type of the prepared stmt for execute stmt (#46348) #46354

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,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