MCPcopy
hub / github.com/pingcap/tidb / TestIssue38533

Function TestIssue38533

pkg/planner/core/plan_cache_test.go:298–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

296}
297
298func TestIssue38533(t *testing.T) {
299 store := testkit.CreateMockStore(t)
300 tk := testkit.NewTestKit(t, store)
301 tk.MustExec("use test")
302 tk.MustExec("create table t (a int, key (a))")
303 tk.MustExec(`prepare st from "select /*+ use_index(t, a) */ a from t where a=? and a=?"`)
304 tk.MustExec(`set @a=1`)
305 tk.MustExec(`execute st using @a, @a`)
306 tkProcess := tk.Session().ShowProcess()
307 ps := []*util.ProcessInfo{tkProcess}
308 tk.Session().SetSessionManager(&testkit.MockSessionManager{PS: ps})
309 plan := tk.MustQuery(fmt.Sprintf("explain for connection %d", tkProcess.ID)).Rows()
310 require.True(t, strings.Contains(plan[1][0].(string), "RangeScan")) // range-scan instead of full-scan
311
312 tk.MustExec(`execute st using @a, @a`)
313 tk.MustExec(`execute st using @a, @a`)
314 tk.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0"))
315}
316
317func TestInvalidRange(t *testing.T) {
318 store := testkit.CreateMockStore(t)

Callers

nothing calls this directly

Calls 11

MustExecMethod · 0.95
SessionMethod · 0.95
MustQueryMethod · 0.95
CreateMockStoreFunction · 0.92
NewTestKitFunction · 0.92
RowsFunction · 0.92
ShowProcessMethod · 0.65
SetSessionManagerMethod · 0.65
RowsMethod · 0.65
ContainsMethod · 0.65
CheckMethod · 0.65

Tested by

no test coverage detected