Skip to content

Commit

Permalink
record type of the prepared stmt for execute stmt
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <you1474600@gmail.com>
  • Loading branch information
you06 committed Aug 23, 2023
1 parent 14fb817 commit 6f40422
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 6f40422

Please sign in to comment.