From b652cd27ade546203cbbdfabd6f2ab5e8ebc473e Mon Sep 17 00:00:00 2001 From: qw4990 Date: Tue, 14 Feb 2023 16:51:23 +0800 Subject: [PATCH] fixup --- planner/core/plan_cache_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/planner/core/plan_cache_test.go b/planner/core/plan_cache_test.go index 8c6f4bb9d46de..858cce28bf96a 100644 --- a/planner/core/plan_cache_test.go +++ b/planner/core/plan_cache_test.go @@ -202,6 +202,23 @@ func TestNonPreparedPlanCacheHints(t *testing.T) { tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1")) } +func TestNonPreparedPlanCacheBinding(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec(`use test`) + tk.MustExec("create table t(a int, index(a))") + tk.MustExec("set tidb_enable_non_prepared_plan_cache=1") + + tk.MustExec("create binding for select * from t where a=1 using select /*+ use_index(t, a) */ * from t where a=1") + tk.MustExec("select * from t where a=1") + tk.MustExec("select * from t where a=1") + tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0")) + tk.MustExec("drop binding for select * from t where a=1") + tk.MustExec("select * from t where a=1") + tk.MustExec("select * from t where a=1") + tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1")) +} + func TestNonPreparedPlanCacheWithExplain(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store)