diff --git a/pkg/executor/builder.go b/pkg/executor/builder.go index 066a80da4c7a9..5cf29d32ce2ba 100644 --- a/pkg/executor/builder.go +++ b/pkg/executor/builder.go @@ -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 { diff --git a/pkg/executor/test/issuetest/BUILD.bazel b/pkg/executor/test/issuetest/BUILD.bazel index 3810bcaefa89c..54853fc33aa2c 100644 --- a/pkg/executor/test/issuetest/BUILD.bazel +++ b/pkg/executor/test/issuetest/BUILD.bazel @@ -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", diff --git a/pkg/executor/test/issuetest/executor_issue_test.go b/pkg/executor/test/issuetest/executor_issue_test.go index f47d02e592c57..eaeb3209afca7 100644 --- a/pkg/executor/test/issuetest/executor_issue_test.go +++ b/pkg/executor/test/issuetest/executor_issue_test.go @@ -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))