diff --git a/statistics/scalar.go b/statistics/scalar.go index 42b98143e9cee..53073e16967ce 100644 --- a/statistics/scalar.go +++ b/statistics/scalar.go @@ -195,8 +195,8 @@ func enumRangeValues(low, high types.Datum, lowExclude, highExclude bool) []type case types.KindInt64: // Overflow check. lowVal, highVal := low.GetInt64(), high.GetInt64() - if lowVal < 0 && highVal > 0 { - if lowVal <= -maxNumStep || highVal >= maxNumStep { + if lowVal <= 0 && highVal >= 0 { + if lowVal < -maxNumStep || highVal > maxNumStep { return nil } } diff --git a/statistics/scalar_test.go b/statistics/scalar_test.go index ee91e935a53bd..adafa96fb0649 100644 --- a/statistics/scalar_test.go +++ b/statistics/scalar_test.go @@ -241,11 +241,19 @@ func (s *testStatisticsSuite) TestEnumRangeValues(c *C) { highExclude: true, res: "(2017-01-01 00:00:00, 2017-01-01 00:00:01, 2017-01-01 00:00:02, 2017-01-01 00:00:03, 2017-01-01 00:00:04)", }, + // fix issue 11610 + { + low: types.NewIntDatum(math.MinInt64), + high: types.NewIntDatum(0), + lowExclude: false, + highExclude: false, + res: "", + }, } for _, t := range tests { vals := enumRangeValues(t.low, t.high, t.lowExclude, t.highExclude) str, err := types.DatumsToString(vals, true) c.Assert(err, IsNil) - c.Assert(t.res, Equals, str) + c.Assert(str, Equals, t.res) } }