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

Function convertQueryToPrepExecStmt

pkg/planner/core/plan_cache_test.go:589–604  ·  view source on GitHub ↗
(q string)

Source from the content-addressed store, hash-verified

587}
588
589func convertQueryToPrepExecStmt(q string) (normalQuery, prepStmt string, parameters []string) {
590 // select ... from t where a = #?1# and b = #?2#
591 normalQuery = strings.ReplaceAll(q, "#", "")
592 normalQuery = strings.ReplaceAll(normalQuery, "?", "")
593 vs := strings.Split(q, "#")
594 for i := 0; i < len(vs); i++ {
595 if len(vs[i]) == 0 {
596 continue
597 }
598 if vs[i][0] == '?' {
599 parameters = append(parameters, vs[i][1:])
600 vs[i] = "?"
601 }
602 }
603 return normalQuery, fmt.Sprintf(`prepare st from '%v'`, strings.Join(vs, "")), parameters
604}
605
606func planCachePointGetPrepareData(tk *testkit.TestKit) {
607 tk.MustExec(`use test`)

Callers 1

testRandomPlanCacheCasesFunction · 0.85

Calls 2

JoinMethod · 0.65
SplitMethod · 0.45

Tested by

no test coverage detected