diff --git a/mysql-test/suite/rocksdb/r/rocksdb.result b/mysql-test/suite/rocksdb/r/rocksdb.result index 82168f46d635..09bb56e21766 100644 --- a/mysql-test/suite/rocksdb/r/rocksdb.result +++ b/mysql-test/suite/rocksdb/r/rocksdb.result @@ -2172,4 +2172,15 @@ insert into t2 select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B; update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004'; drop table t1,t2; +# +# Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed +# +CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB; +INSERT INTO t2 VALUES (1,1,1,1,1,1,1); +SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; +c1 c2 c3 c4 c5 c6 c7 +EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +drop table t2; SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; diff --git a/mysql-test/suite/rocksdb/t/rocksdb.test b/mysql-test/suite/rocksdb/t/rocksdb.test index ef8c098b028e..518ba0edd15a 100644 --- a/mysql-test/suite/rocksdb/t/rocksdb.test +++ b/mysql-test/suite/rocksdb/t/rocksdb.test @@ -1744,4 +1744,13 @@ update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004'; drop table t1,t2; +--echo # +--echo # Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed +--echo # +CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB; +INSERT INTO t2 VALUES (1,1,1,1,1,1,1); +SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; +EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; +drop table t2; + SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 9582a9786210..cf471c66b172 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -6436,6 +6436,12 @@ ha_rows ha_rocksdb::records_in_range(uint inx, key_range *min_key, rocksdb::Slice slice1((const char*) sec_key_packed_tuple, size1); rocksdb::Slice slice2((const char*) sec_key_packed_tuple_old, size2); + // slice1 >= slice2 means no row will match + if (slice1.compare(slice2) >= 0) + { + DBUG_RETURN(0); + } + rocksdb::Range r( kd->is_reverse_cf ? slice2 : slice1, kd->is_reverse_cf ? slice1 : slice2