Skip to content

Commit

Permalink
session: Fix txn.onStmtEnd is not called when some special error occu…
Browse files Browse the repository at this point in the history
…rs in ExecutePreparedStmt (#26056) (#26080)
  • Loading branch information
ti-srebot authored Jul 19, 2021
1 parent 4150216 commit a823398
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,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 @@ -1924,14 +1925,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

0 comments on commit a823398

Please sign in to comment.