Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#53097
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
yibin87 authored and ti-chi-bot committed May 10, 2024
1 parent f907137 commit 10a3b20
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2958,6 +2958,21 @@ func (*executorBuilder) corColInDistPlan(plans []plannercore.PhysicalPlan) bool
return true
}
}
<<<<<<< HEAD
=======
case *plannercore.PhysicalProjection:
for _, expr := range x.Exprs {
if len(expression.ExtractCorColumns(expr)) > 0 {
return true
}
}
case *plannercore.PhysicalTopN:
for _, byItem := range x.ByItems {
if len(expression.ExtractCorColumns(byItem.Expr)) > 0 {
return true
}
}
>>>>>>> 203e5f2cff1 (executor: Fix push downed topN won't replace correlated column problem (#53097))
case *plannercore.PhysicalTableScan:
for _, cond := range x.LateMaterializationFilterCondition {
if len(expression.ExtractCorColumns(cond)) > 0 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/executor/test/issuetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ go_test(
"main_test.go",
],
flaky = True,
<<<<<<< HEAD
shard_count = 17,
=======
shard_count = 19,
>>>>>>> 203e5f2cff1 (executor: Fix push downed topN won't replace correlated column problem (#53097))
deps = [
"//pkg/autoid_service",
"//pkg/config",
Expand Down
57 changes: 57 additions & 0 deletions pkg/executor/test/issuetest/executor_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,60 @@ func TestIssue42662(t *testing.T) {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/executor/issue42662_1"))
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/util/servermemorylimit/issue42662_2"))
}
<<<<<<< HEAD
=======

func TestIssue50393(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("drop table if exists t1, t2")

tk.MustExec("create table t1 (a blob)")
tk.MustExec("create table t2 (a blob)")
tk.MustExec("insert into t1 values (0xC2A0)")
tk.MustExec("insert into t2 values (0xC2)")
tk.MustQuery("select count(*) from t1,t2 where t1.a like concat(\"%\",t2.a,\"%\")").Check(testkit.Rows("1"))
}

func TestIssue51874(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.Session().GetSessionVars().AllowProjectionPushDown = true

tk.MustExec("use test")
tk.MustExec("drop table if exists t, t2")
tk.MustExec("create table t (a int, b int)")
tk.MustExec("create table t2 (i int)")
tk.MustExec("insert into t values (5, 6), (1, 7)")
tk.MustExec("insert into t2 values (10), (100)")
tk.MustQuery("select (select sum(a) over () from t2 limit 1) from t;").Check(testkit.Rows("10", "2"))
}

func TestIssue51777(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.Session().GetSessionVars().AllowProjectionPushDown = true

tk.MustExec("use test")
tk.MustExec("drop table if exists t0, t1")
tk.MustExec("create table t0 (c_k int)")
tk.MustExec("create table t1 (c_pv int)")
tk.MustExec("insert into t0 values(-2127559046),(-190905159),(-171305020),(-59638845),(98004414),(2111663670),(2137868682),(2137868682),(2142611610)")
tk.MustExec("insert into t1 values(-2123227448), (2131706870), (-2071508387), (2135465388), (2052805244), (-2066000113)")
tk.MustQuery("SELECT ( select (ref_4.c_pv <= ref_3.c_k) as c0 from t1 as ref_4 order by c0 asc limit 1) as p2 FROM t0 as ref_3 order by p2;").Check(testkit.Rows("0", "0", "0", "0", "0", "0", "1", "1", "1"))
}

func TestIssue52978(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (a int)")
tk.MustExec("insert into t values (-1790816583),(2049821819), (-1366665321), (536581933), (-1613686445)")
tk.MustQuery("select min(truncate(cast(-26340 as double), ref_11.a)) as c3 from t as ref_11;").Check(testkit.Rows("-26340"))
tk.MustExec("drop table if exists t")
}
>>>>>>> 203e5f2cff1 (executor: Fix push downed topN won't replace correlated column problem (#53097))

0 comments on commit 10a3b20

Please sign in to comment.