From 4a3c290c0b6f80d9d3eea430a59bfc2f9cb9c78f Mon Sep 17 00:00:00 2001 From: sylzd Date: Tue, 17 Aug 2021 17:42:00 +0800 Subject: [PATCH] planner: add test case for sql binding in the local temporary (#27206) --- bindinfo/bind_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bindinfo/bind_test.go b/bindinfo/bind_test.go index 9e1642978d868..0ac21c45209b5 100644 --- a/bindinfo/bind_test.go +++ b/bindinfo/bind_test.go @@ -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()