diff --git a/statistics/selectivity.go b/statistics/selectivity.go index cdb5d862324ca..4d257713f4f09 100644 --- a/statistics/selectivity.go +++ b/statistics/selectivity.go @@ -305,10 +305,10 @@ func getMaskAndRanges(ctx sessionctx.Context, exprs []expression.Expression, ran } var res *ranger.DetachRangeResult res, err = ranger.DetachCondAndBuildRangeForIndex(ctx, exprs, cols, lengths) - ranges, accessConds, remainedConds, isDNF = res.Ranges, res.AccessConds, res.RemainedConds, res.IsDNFCond if err != nil { return 0, nil, false, err } + ranges, accessConds, remainedConds, isDNF = res.Ranges, res.AccessConds, res.RemainedConds, res.IsDNFCond default: panic("should never be here") } diff --git a/statistics/selectivity_test.go b/statistics/selectivity_test.go index c1be105d3ccc6..7218711b4881c 100644 --- a/statistics/selectivity_test.go +++ b/statistics/selectivity_test.go @@ -667,3 +667,13 @@ func (s *testStatsSuite) TestCollationColumnEstimate(c *C) { tk.MustQuery(input[i]).Check(testkit.Rows(output[i]...)) } } + +func (s *testStatsSuite) TestIssue27294(c *C) { + defer cleanEnv(c, s.store, s.do) + testKit := testkit.NewTestKit(c, s.store) + + testKit.MustExec("use test") + testKit.MustExec("drop table if exists tt") + testKit.MustExec("create table tt (COL1 blob DEFAULT NULL,COL2 decimal(37,4) DEFAULT NULL,COL3 timestamp NULL DEFAULT NULL,COL4 int(11) DEFAULT NULL,UNIQUE KEY U_M_COL4(COL1(10),COL2), UNIQUE KEY U_M_COL5(COL3,COL2));") + testKit.MustExec("explain select * from tt where col1 is not null or col2 not between 454623814170074.2771 and -975540642273402.9269 and col3 not between '2039-1-19 10:14:57' and '2002-3-27 14:40:23';") +}