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

executor: record prepared stmt in handle_query_duration (#11753) #12331

Merged
merged 2 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) {
maxExecutionTime := getMaxExecutionTime(sctx, a.StmtNode)
// Update processinfo, ShowProcess() will use it.
pi.SetProcessInfo(sql, time.Now(), cmd, maxExecutionTime)
a.Ctx.GetSessionVars().StmtCtx.StmtType = GetStmtLabel(a.StmtNode)
if a.Ctx.GetSessionVars().StmtCtx.StmtType == "" {
a.Ctx.GetSessionVars().StmtCtx.StmtType = GetStmtLabel(a.StmtNode)
}
}

isPessimistic := sctx.GetSessionVars().TxnCtx.IsPessimistic
Expand Down
1 change: 1 addition & 0 deletions executor/prepared.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func (e *PrepareExec) Next(ctx context.Context, req *chunk.Chunk) error {
}
prepared := &ast.Prepared{
Stmt: stmt,
StmtType: GetStmtLabel(stmt),
Params: sorter.markers,
SchemaVersion: e.is.SchemaMetaVersion(),
}
Expand Down
2 changes: 2 additions & 0 deletions planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type Execute struct {
UsingVars []expression.Expression
ExecID uint32
Stmt ast.StmtNode
StmtType string
Plan Plan
}

Expand All @@ -192,6 +193,7 @@ func (e *Execute) OptimizePreparedPlan(ctx context.Context, sctx sessionctx.Cont
if !ok {
return errors.Trace(ErrStmtNotFound)
}
vars.StmtCtx.StmtType = prepared.StmtType

if len(prepared.Params) != len(e.UsingVars) {
return errors.Trace(ErrWrongParamCount)
Expand Down