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/core: add tests for prepare show statements #36458

Merged
merged 3 commits into from
Jul 26, 2022
Merged
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions planner/core/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3113,3 +3113,21 @@ func TestPointGetForUpdateAutoCommitCache(t *testing.T) {
tk1.ResultSetToResult(rs, fmt.Sprintf("%v", rs)).Check(testkit.Rows())
tk1.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("1"))
}

func TestPreparedShowStatements(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")

tk.MustExec(`prepare p1 from 'show variables like "tidb_snapshot"';`)
tk.MustQuery(`execute p1;`).Check(testkit.Rows("tidb_snapshot "))

tk.MustExec("create table t (a int, b int);")
tk.MustExec(`prepare p2 from "show columns from t where field = 'a'";`) // Only column `a` is selected.
tk.MustQuery(`execute p2;`).Check(testkit.Rows("a int(11) YES <nil> "))

tk.MustExec("create table t1 (a int, b int);")
tk.MustExec(`prepare p3 from "show tables where tables_in_test = 't1'";`) // Only table `t1` is selected.
tk.MustQuery("execute p3;").Check(testkit.Rows("t1"))
}