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: enable fix control for enforced | tidb-test=pr/2404 #56414

Merged
merged 32 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c8c92c3
testcase10
terry1purcell Sep 22, 2024
515e929
planner: remove fix control 46177
terry1purcell Sep 29, 2024
436a82f
testcase1
terry1purcell Sep 29, 2024
3d8ca9c
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 1, 2024
61b219b
testcase new1
terry1purcell Oct 1, 2024
fa1bc43
testcase new2
terry1purcell Oct 2, 2024
92f5cd9
testcase new3
terry1purcell Oct 2, 2024
10cf646
testcase new4
terry1purcell Oct 2, 2024
779f4e5
testcase new5
terry1purcell Oct 2, 2024
6ea7992
testcase new6
terry1purcell Oct 3, 2024
980d725
revert2
terry1purcell Oct 7, 2024
7379c37
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 15, 2024
df26bc7
comment change1
terry1purcell Oct 15, 2024
5b866fd
new testcase1
terry1purcell Oct 15, 2024
cf0a8b4
new testcase2
terry1purcell Oct 15, 2024
4de1f9a
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 15, 2024
8e27d24
new testcase3
terry1purcell Oct 15, 2024
816280e
new testcase4
terry1purcell Oct 16, 2024
64c2488
new testcase5
terry1purcell Oct 16, 2024
b2a99e3
new testcase6
terry1purcell Oct 16, 2024
070f975
new testcase7
terry1purcell Oct 16, 2024
f31bdbc
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 20, 2024
d5a02f1
new testcase8
terry1purcell Oct 20, 2024
b1ffeee
new testcase9
terry1purcell Oct 20, 2024
228b43e
new testcase10
terry1purcell Oct 20, 2024
7fa4bdd
new testcase11
terry1purcell Oct 22, 2024
de1e807
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 22, 2024
e79fcac
rebase
terry1purcell Oct 22, 2024
e5c3123
Merge branch 'pingcap:master' into enforced
terry1purcell Oct 22, 2024
2b3849b
test after rebase
terry1purcell Oct 22, 2024
2792500
test2 after rebase
terry1purcell Oct 22, 2024
4bae7a9
test3 after rebase
terry1purcell Oct 22, 2024
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
36 changes: 18 additions & 18 deletions pkg/executor/test/cte/cte_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ func TestCTEIterationMemTracker(t *testing.T) {
tk.MustQuery(fmt.Sprintf("explain analyze with recursive cte1 as (select c1 from t1 union all select c1 + 1 c1 from cte1 where c1 < %d) select * from cte1", maxIter))
}

func TestCTETableInvaildTask(t *testing.T) {
func TestCTETableInvalidTask(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE p ( groupid bigint(20) DEFAULT NULL, KEY k1 (groupid));")
tk.MustExec(`CREATE TABLE g (groupid bigint(20) DEFAULT NULL,parentid bigint(20) NOT NULL,KEY k1 (parentid),KEY k2 (groupid,parentid));`)
tk.MustExec(`set tidb_opt_enable_hash_join=off;`)
tk.MustQuery(`explain WITH RECURSIVE w(gid) AS (
tk.MustQuery(`explain format='brief' WITH RECURSIVE w(gid) AS (
SELECT
groupId
FROM
Expand All @@ -261,22 +261,22 @@ WHERE
FROM
w
);`).Check(testkit.Rows(
"Projection_54 9990.00 root 1->Column#17",
"└─IndexJoin_59 9990.00 root inner join, inner:IndexReader_58, outer key:test.p.groupid, inner key:test.g.groupid, equal cond:eq(test.p.groupid, test.g.groupid)",
" ├─HashAgg_75(Build) 12800.00 root group by:test.p.groupid, funcs:firstrow(test.p.groupid)->test.p.groupid",
" │ └─Selection_72 12800.00 root not(isnull(test.p.groupid))",
" │ └─CTEFullScan_73 16000.00 root CTE:w data:CTE_0",
" └─IndexReader_58(Probe) 9990.00 root index:Selection_57",
" └─Selection_57 9990.00 cop[tikv] not(isnull(test.g.groupid))",
" └─IndexRangeScan_56 10000.00 cop[tikv] table:g, index:k2(groupid, parentid) range: decided by [eq(test.g.groupid, test.p.groupid)], keep order:false, stats:pseudo",
"Projection 9990.00 root 1->Column#17",
"└─IndexJoin 9990.00 root inner join, inner:IndexReader, outer key:test.p.groupid, inner key:test.g.groupid, equal cond:eq(test.p.groupid, test.g.groupid)",
" ├─HashAgg(Build) 12800.00 root group by:test.p.groupid, funcs:firstrow(test.p.groupid)->test.p.groupid",
" │ └─Selection 12800.00 root not(isnull(test.p.groupid))",
" │ └─CTEFullScan 16000.00 root CTE:w data:CTE_0",
" └─IndexReader(Probe) 9990.00 root index:Selection",
" └─Selection 9990.00 cop[tikv] not(isnull(test.g.groupid))",
" └─IndexRangeScan 10000.00 cop[tikv] table:g, index:k2(groupid, parentid) range: decided by [eq(test.g.groupid, test.p.groupid)], keep order:false, stats:pseudo",
"CTE_0 16000.00 root Recursive CTE",
"├─IndexReader_24(Seed Part) 10000.00 root index:IndexFullScan_23",
"│ └─IndexFullScan_23 10000.00 cop[tikv] table:p, index:k1(groupid) keep order:false, stats:pseudo",
"└─IndexHashJoin_34(Recursive Part) 10000.00 root inner join, inner:IndexLookUp_31, outer key:test.p.groupid, inner key:test.g.parentid, equal cond:eq(test.p.groupid, test.g.parentid)",
" ├─Selection_51(Build) 8000.00 root not(isnull(test.p.groupid))",
" │ └─CTETable_52 10000.00 root Scan on CTE_0",
" └─IndexLookUp_31(Probe) 10000.00 root ",
" ├─IndexRangeScan_29(Build) 10000.00 cop[tikv] table:g, index:k1(parentid) range: decided by [eq(test.g.parentid, test.p.groupid)], keep order:false, stats:pseudo",
" └─TableRowIDScan_30(Probe) 10000.00 cop[tikv] table:g keep order:false, stats:pseudo"))
"├─IndexReader(Seed Part) 10000.00 root index:IndexFullScan",
"│ └─IndexFullScan 10000.00 cop[tikv] table:p, index:k1(groupid) keep order:false, stats:pseudo",
"└─IndexHashJoin(Recursive Part) 10000.00 root inner join, inner:IndexLookUp, outer key:test.p.groupid, inner key:test.g.parentid, equal cond:eq(test.p.groupid, test.g.parentid)",
" ├─Selection(Build) 8000.00 root not(isnull(test.p.groupid))",
" │ └─CTETable 10000.00 root Scan on CTE_0",
" └─IndexLookUp(Probe) 10000.00 root ",
" ├─IndexRangeScan(Build) 10000.00 cop[tikv] table:g, index:k1(parentid) range: decided by [eq(test.g.parentid, test.p.groupid)], keep order:false, stats:pseudo",
" └─TableRowIDScan(Probe) 10000.00 cop[tikv] table:g keep order:false, stats:pseudo"))
tk.MustQuery(`show warnings`).Check(testkit.Rows())
}
1 change: 1 addition & 0 deletions pkg/executor/test/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ func TestUnreasonablyClose(t *testing.T) {
for i, tc := range []string{
"select /*+ hash_join(t1)*/ * from t t1 join t t2 on t1.a = t2.a",
"select /*+ merge_join(t1)*/ * from t t1 join t t2 on t1.f = t2.f",
"select /*+ merge_join(t1)*/ t1.f, t2.f from t t1 join t t2 on t1.f = t2.f",
"select t.f from t use index(f)",
"select /*+ inl_join(t1) */ * from t t1 join t t2 on t1.f=t2.f",
"select /*+ inl_hash_join(t1) */ * from t t1 join t t2 on t1.f=t2.f",
Expand Down
8 changes: 4 additions & 4 deletions pkg/planner/core/casetest/dag/testdata/plan_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@
},
{
"SQL": "select /*+ TIDB_SMJ(t1,t2,t3)*/ * from t t1, t t2, t t3 where t1.c = t2.c and t1.d = t2.d and t3.c = t1.c and t3.d = t1.d",
"Best": "MergeInnerJoin{MergeInnerJoin{IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))->IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))}(test.t.c,test.t.c)(test.t.d,test.t.d)->IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))}(test.t.c,test.t.c)(test.t.d,test.t.d)"
"Best": "MergeInnerJoin{MergeInnerJoin{TableReader(Table(t))->Sort->TableReader(Table(t))->Sort}(test.t.c,test.t.c)(test.t.d,test.t.d)->TableReader(Table(t))->Sort}(test.t.c,test.t.c)(test.t.d,test.t.d)"
},
{
"SQL": "select /*+ TIDB_SMJ(t1,t2,t3)*/ * from t t1, t t2, t t3 where t1.c = t2.c and t1.d = t2.d and t3.c = t1.c and t3.d = t1.d order by t1.c",
"Best": "MergeInnerJoin{MergeInnerJoin{IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))->IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))}(test.t.c,test.t.c)(test.t.d,test.t.d)->IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))}(test.t.c,test.t.c)(test.t.d,test.t.d)"
"Best": "MergeInnerJoin{MergeInnerJoin{TableReader(Table(t))->Sort->TableReader(Table(t))->Sort}(test.t.c,test.t.c)(test.t.d,test.t.d)->TableReader(Table(t))->Sort}(test.t.c,test.t.c)(test.t.d,test.t.d)"
},
{
"SQL": "select /*+ TIDB_SMJ(t1,t2,t3)*/ * from t t1 left outer join t t2 on t1.a = t2.a left outer join t t3 on t2.a = t3.a",
Expand Down Expand Up @@ -436,8 +436,8 @@
},
{
"SQL": "delete /*+ TIDB_SMJ(t1, t2) */ from t1 using t t1, t t2 where t1.c=t2.c",
"Best": "MergeInnerJoin{IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))->IndexLookUp(Index(t.c_d_e)[[NULL,+inf]], Table(t))}(test.t.c,test.t.c)->Delete",
"Hints": "merge_join(`test`.`t1`), use_index(@`del_1` `test`.`t1` `c_d_e`), order_index(@`del_1` `test`.`t1` `c_d_e`), use_index(@`del_1` `test`.`t2` `c_d_e`), order_index(@`del_1` `test`.`t2` `c_d_e`)"
"Best": "MergeInnerJoin{TableReader(Table(t))->Sort->TableReader(Table(t))->Sort}(test.t.c,test.t.c)->Delete",
"Hints": "merge_join(`test`.`t1`), use_index(@`del_1` `test`.`t1` ), no_order_index(@`del_1` `test`.`t1` `primary`), use_index(@`del_1` `test`.`t2` ), no_order_index(@`del_1` `test`.`t2` `primary`)"
},
{
"SQL": "update /*+ TIDB_SMJ(t1, t2) */ t t1, t t2 set t1.c=1, t2.c=1 where t1.a=t2.a",
Expand Down
Loading