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: Fix txn.onStmtEnd is not called when some special error occurs in ExecutePreparedStmt #26056

Merged
merged 2 commits into from
Jul 9, 2021
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
9 changes: 3 additions & 6 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ func (s *session) ExecutePreparedStmt(ctx context.Context, stmtID uint32, args [
return nil, err
}
s.txn.onStmtStart(preparedStmt.SQLDigest.String())
defer s.txn.onStmtEnd()
var is infoschema.InfoSchema
var snapshotTS uint64
if preparedStmt.ForUpdateRead {
Expand All @@ -1928,14 +1929,10 @@ func (s *session) ExecutePreparedStmt(ctx context.Context, stmtID uint32, args [
} else {
is = s.GetInfoSchema().(infoschema.InfoSchema)
}
var rs sqlexec.RecordSet
if ok {
rs, err = s.cachedPlanExec(ctx, is, snapshotTS, stmtID, preparedStmt, args)
} else {
rs, err = s.preparedStmtExec(ctx, is, snapshotTS, stmtID, preparedStmt, args)
return s.cachedPlanExec(ctx, is, snapshotTS, stmtID, preparedStmt, args)
}
s.txn.onStmtEnd()
return rs, err
return s.preparedStmtExec(ctx, is, snapshotTS, stmtID, preparedStmt, args)
}

func (s *session) DropPreparedStmt(stmtID uint32) error {
Expand Down