diff --git a/planner/core/common_plans.go b/planner/core/common_plans.go index e7efa7db28665..16cc40ad1d1c7 100644 --- a/planner/core/common_plans.go +++ b/planner/core/common_plans.go @@ -280,6 +280,7 @@ func (e *Execute) OptimizePreparedPlan(ctx context.Context, sctx sessionctx.Cont // schema version like prepared plan cache key prepared.CachedPlan = nil preparedObj.Executor = nil + preparedObj.ColumnInfos = nil // If the schema version has changed we need to preprocess it again, // if this time it failed, the real reason for the error is schema changed. // Example: diff --git a/session/session.go b/session/session.go index 31a835a3c12b9..16e6ccce6a057 100644 --- a/session/session.go +++ b/session/session.go @@ -2013,6 +2013,7 @@ func (s *session) IsCachedExecOk(ctx context.Context, preparedStmt *plannercore. if !plannercore.IsAutoCommitTxn(s) { return false, nil } +<<<<<<< HEAD // SnapshotTSEvaluator != nil, it is stale read // stale read expect a stale infoschema // so skip infoschema check @@ -2023,6 +2024,13 @@ func (s *session) IsCachedExecOk(ctx context.Context, preparedStmt *plannercore. prepared.CachedPlan = nil return false, nil } +======= + is := s.GetInfoSchema().(infoschema.InfoSchema) + if prepared.SchemaVersion != is.SchemaMetaVersion() { + prepared.CachedPlan = nil + preparedStmt.ColumnInfos = nil + return false, nil +>>>>>>> 1f9d34aee... *: Revert #33519 for performance fallback and fix the #33509 in another way (#34425) } // maybe we'd better check cached plan type here, current // only point select/update will be cached, see "getPhysicalPlan" func