Skip to content

Commit 1f7bf35

Browse files
committed
45783
1 parent 6928519 commit 1f7bf35

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

pkg/planner/core/plan_cache_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,3 +1797,14 @@ partition by hash (a) partitions 3`)
17971797
require.False(t, tk.Session().GetSessionVars().FoundInPlanCache)
17981798
tk.MustQuery(`show warnings`).Check(testkit.Rows("Warning 1105 skip prepared plan-cache: query accesses partitioned tables is un-cacheable if tidb_partition_pruning_mode = 'static'"))
17991799
}
1800+
1801+
func TestIndexRange(t *testing.T) {
1802+
store := testkit.CreateMockStore(t)
1803+
tk := testkit.NewTestKit(t, store)
1804+
tk.MustExec(`use test`)
1805+
1806+
tk.MustExec(`CREATE TABLE posts (id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY)`)
1807+
tk.MustExec(`INSERT INTO posts (id) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);`)
1808+
tk.MustExec(`set tidb_enable_non_prepared_plan_cache=1;`)
1809+
tk.MustQuery(`SELECT posts.* FROM posts WHERE (id = 1 or id = 9223372036854775808);`).Check(testkit.Rows("1"))
1810+
}

pkg/util/ranger/ranger.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ func convertPoint(sctx *rangerctx.RangerContext, point *point, newTp *types.Fiel
172172
// see issue #20101: overflow when converting integer to year
173173
} else if newTp.GetType() == mysql.TypeBit && terror.ErrorEqual(err, types.ErrDataTooLong) {
174174
// see issue #19067: we should ignore the types.ErrDataTooLong when we convert value to TypeBit value
175-
} else if newTp.GetType() == mysql.TypeNewDecimal && terror.ErrorEqual(err, types.ErrOverflow) {
176-
// Ignore the types.ErrOverflow when we convert TypeNewDecimal values.
175+
} else if (newTp.GetType() == mysql.TypeNewDecimal || newTp.GetType() == mysql.TypeLonglong) && terror.ErrorEqual(err, types.ErrOverflow) {
176+
// Ignore the types.ErrOverflow when we convert TypeNewDecimal/TypeLonglong values.
177177
// A trimmed valid boundary point value would be returned then. Accordingly, the `excl` of the point
178178
// would be adjusted. Impossible ranges would be skipped by the `validInterval` call later.
179+
// tests in TestIndexRange/TestIndexRangeForDecimal
179180
} else if point.value.Kind() == types.KindMysqlTime && newTp.GetType() == mysql.TypeTimestamp && terror.ErrorEqual(err, types.ErrWrongValue) {
180181
// See issue #28424: query failed after add index
181182
// Ignore conversion from Date[Time] to Timestamp since it must be either out of range or impossible date, which will not match a point select

tests/integrationtest/r/planner/core/partition_pruner.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,6 +3253,6 @@ TableReader_7 0.00 root partition:dual data:Selection_6
32533253
└─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
32543254
desc select * from t where a in (-6895222, 3125507, 9223372036854775809);
32553255
id estRows task access object operator info
3256-
TableReader_7 8000.00 root partition:p0 data:Selection_6
3257-
└─Selection_6 8000.00 cop[tikv] in(planner__core__partition_pruner.t.a, -6895222, 3125507, 9223372036854775809)
3256+
TableReader_7 20.00 root partition:p0 data:Selection_6
3257+
└─Selection_6 20.00 cop[tikv] in(planner__core__partition_pruner.t.a, -6895222, 3125507, 9223372036854775809)
32583258
└─TableFullScan_5 10000.00 cop[tikv] table:t keep order:false, stats:pseudo

0 commit comments

Comments
 (0)