Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#47078
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
qw4990 authored and ti-chi-bot committed Sep 19, 2023
1 parent 71bcc44 commit 64c77b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ func TestINLJHintSmallTable(t *testing.T) {
tk.MustExec("explain format = 'brief' select /*+ TIDB_INLJ(t1) */ * from t1 join t2 on t1.a = t2.a")
}

<<<<<<< HEAD
func TestIndexJoinUniqueCompositeIndex(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
Expand Down Expand Up @@ -1975,6 +1976,20 @@ func TestIndexMergeHint4CNF(t *testing.T) {
})
tk.MustQuery(tt).Check(testkit.Rows(output[i].Plan...))
}
=======
func TestIssue46580(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`CREATE TABLE t0(c0 INT);`)
tk.MustExec(`CREATE TABLE t1(c0 BOOL, c1 BOOL);`)
tk.MustExec(`INSERT INTO t1 VALUES (false, true);`)
tk.MustExec(`INSERT INTO t1 VALUES (true, true);`)
tk.MustExec(`CREATE definer='root'@'localhost' VIEW v0(c0, c1, c2) AS SELECT t1.c0, LOG10(t0.c0), t1.c0 FROM t0, t1;`)
tk.MustExec(`INSERT INTO t0(c0) VALUES (3);`)
tk.MustQuery(`SELECT /*+ MERGE_JOIN(t1, t0, v0)*/v0.c2, t1.c0 FROM v0, t0 CROSS JOIN t1 ORDER BY -v0.c1;`).Sort().Check(
testkit.Rows(`0 0`, `0 1`, `1 0`, `1 1`))
>>>>>>> 51f6bb90d98 (planner: fix Uncertain Results caused by MERGE_JOIN (#47078))
}

func TestInvisibleIndex(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions planner/core/rule_inject_extra_projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ func InjectProjBelowSort(p PhysicalPlan, orderByItems []*util.ByItems) PhysicalP
if origChildProj, isChildProj := childPlan.(*PhysicalProjection); isChildProj {
refine4NeighbourProj(bottomProj, origChildProj)
}
refine4NeighbourProj(topProj, bottomProj)

return topProj
}
Expand Down Expand Up @@ -336,6 +337,7 @@ func TurnNominalSortIntoProj(p PhysicalPlan, onlyColumn bool, orderByItems []*ut
if origChildProj, isChildProj := childPlan.(*PhysicalProjection); isChildProj {
refine4NeighbourProj(bottomProj, origChildProj)
}
refine4NeighbourProj(topProj, bottomProj)

return topProj
}

0 comments on commit 64c77b4

Please sign in to comment.