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

planner: output a warning if plan rebuilding fails when reusing a cached plan (#46278) #46281

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion planner/core/plan_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func RebuildPlan4CachedPlan(p Plan) (ok bool) {
sc.InPreparedPlanBuilding = true
defer func() { sc.InPreparedPlanBuilding = false }()
if err := rebuildRange(p); err != nil {
// TODO: log or warn this error.
sc.AppendWarning(errors.Errorf("skip plan-cache: plan rebuild failed, %s", err.Error()))
return false // fail to rebuild ranges
}
if !sc.UseCache {
Expand Down
12 changes: 12 additions & 0 deletions planner/core/plan_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,18 @@ func TestIssue45378(t *testing.T) {
tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("1"))
}

func TestIssue46159(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`create table t (a varchar(10), key(a(5)))`)
tk.MustExec(`prepare st from 'select a from t use index(a) where a=?'`)
tk.MustExec(`set @a='a'`)
tk.MustQuery(`execute st using @a`).Check(testkit.Rows())
tk.MustQuery(`execute st using @a`).Check(testkit.Rows())
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1105 skip plan-cache: plan rebuild failed, rebuild to get an unsafe range"))
}

func TestNonPreparedPlanCacheBuiltinFuncs(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down