Skip to content

Commit

Permalink
cherry pick pingcap#35325 to release-6.1
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
winoros authored and ti-srebot committed Aug 22, 2022
1 parent 7ddd028 commit 24a9265
Show file tree
Hide file tree
Showing 22 changed files with 1,147 additions and 20 deletions.
23 changes: 23 additions & 0 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,29 @@ func TestExplain(t *testing.T) {
tk.MustExec("drop global binding for SELECT * from t1 union SELECT * from t1")
}

func TestBindSemiJoinRewrite(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t1(id int)")
tk.MustExec("create table t2(id int)")
require.True(t, tk.HasKeywordInOperatorInfo("select * from t1 where exists(select 1 from t2 where t1.id=t2.id)", "semi join"))
require.True(t, tk.NotHasKeywordInOperatorInfo("select * from t1 where exists(select /*+ SEMI_JOIN_REWRITE() */ 1 from t2 where t1.id=t2.id)", "semi join"))

tk.MustExec(`
create global binding for
select * from t1 where exists(select 1 from t2 where t1.id=t2.id)
using
select * from t1 where exists(select /*+ SEMI_JOIN_REWRITE() */ 1 from t2 where t1.id=t2.id)
`)

require.True(t, tk.NotHasKeywordInOperatorInfo("select * from t1 where exists(select 1 from t2 where t1.id=t2.id)", "semi join"))
}

// TestBindingSymbolList tests sql with "?, ?, ?, ?", fixes #13871
func TestBindingSymbolList(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
Expand Down
Loading

0 comments on commit 24a9265

Please sign in to comment.