Skip to content

Commit

Permalink
planner: add test case for sql binding in the local temporary (#27206)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylzd authored Aug 17, 2021
1 parent 867dd7b commit 4a3c290
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,20 @@ func (s *testSuite) TestTemporaryTable(c *C) {
tk.MustGetErrCode("create binding for delete from t where b = 1 and c > 1 using delete /*+ use_index(t, c) */ from t where b = 1 and c > 1", errno.ErrOptOnTemporaryTable)
}

func (s *testSuite) TestLocalTemporaryTable(c *C) {
tk := testkit.NewTestKit(c, s.store)
s.cleanBindingEnv(tk)
tk.MustExec("set @@tidb_enable_noop_functions=1;")
tk.MustExec("use test")
tk.MustExec("drop table if exists tmp2")
tk.MustExec("create temporary table tmp2 (a int, b int, key(a), key(b));")
tk.MustGetErrCode("create session binding for select * from tmp2 where b = 123 using select * from t ignore index(b) where b = 123;", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create binding for insert into tmp2 select * from t2 where t2.b = 1 and t2.c > 1 using insert into t select /*+ use_index(t2,c) */ * from t2 where t2.b = 1 and t2.c > 1", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create binding for replace into tmp2 select * from t2 where t2.b = 1 and t2.c > 1 using replace into t select /*+ use_index(t2,c) */ * from t2 where t2.b = 1 and t2.c > 1", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create binding for update tmp2 set a = 1 where b = 1 and c > 1 using update /*+ use_index(t, c) */ t set a = 1 where b = 1 and c > 1", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create binding for delete from tmp2 where b = 1 and c > 1 using delete /*+ use_index(t, c) */ from t where b = 1 and c > 1", errno.ErrOptOnTemporaryTable)
}

func (s *testSuite) TestIssue25505(c *C) {
tk := testkit.NewTestKit(c, s.store)
stmtsummary.StmtSummaryByDigestMap.Clear()
Expand Down

0 comments on commit 4a3c290

Please sign in to comment.