diff --git a/session/session.go b/session/session.go index 15e29a9523ab8..d79710fe93ad7 100644 --- a/session/session.go +++ b/session/session.go @@ -2270,7 +2270,7 @@ func (s *session) cachedPlanExec(ctx context.Context, // IsPointGetWithPKOrUniqueKeyByAutoCommit func (s *session) IsCachedExecOk(ctx context.Context, preparedStmt *plannercore.CachedPrepareStmt, isStaleness bool) (bool, error) { prepared := preparedStmt.PreparedAst - if isStaleness { + if prepared.CachedPlan == nil || isStaleness { return false, nil } // check auto commit