Skip to content

Commit

Permalink
Revert "planner: show un-cacheable reasons for execute statements (#4…
Browse files Browse the repository at this point in the history
…0651)"

This reverts commit a879ba2.
  • Loading branch information
qw4990 authored Jan 18, 2023
1 parent a761c02 commit f4930cd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 1 addition & 1 deletion planner/core/plan_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func GetPlanFromSessionPlanCache(ctx context.Context, sctx sessionctx.Context,
sessVars := sctx.GetSessionVars()
stmtCtx := sessVars.StmtCtx
stmtAst := stmt.PreparedAst
stmtCtx.UseCache = true
stmtCtx.UseCache = stmt.StmtCacheable
if !stmt.StmtCacheable {
stmtCtx.SetSkipPlanCache(errors.Errorf("skip plan-cache: %s", stmt.UncacheableReason))
}
Expand Down
15 changes: 0 additions & 15 deletions planner/core/plan_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,18 +503,3 @@ func TestPlanCacheWithLimit(t *testing.T) {
tk.MustExec("execute stmt using @a")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: limit count more than 10000"))
}

func TestUncacheableReason(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")

tk.MustExec("prepare st from 'select /*+ ignore_plan_cache() */ * from t'")
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: ignore plan cache by hint"))
tk.MustExec("execute st") // show the un-cacheable reason when executing the statement
tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 skip plan-cache: ignore plan cache by hint"))
tk.MustExec("execute st")
tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
}

0 comments on commit f4930cd

Please sign in to comment.