summaryrefslogtreecommitdiffstats
path: root/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test
diff options
context:
space:
mode:
Diffstat (limited to 'storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test')
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test88
1 files changed, 88 insertions, 0 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test
new file mode 100644
index 00000000..ee325b34
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/type_decimal.test
@@ -0,0 +1,88 @@
+--source include/have_rocksdb.inc
+--source include/have_debug.inc
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+--echo #
+--echo # Check that DECIMAL datatype supports 'index-only' scans and is decoded correctly.
+--echo # (Decoding happens from the mem-comparable image in the index, regardless
+--echo # of whether the value part has original value or not)
+--echo #
+
+create table t1 (
+ pk int not null primary key,
+ col1 decimal (2,1) signed,
+ col2 decimal (2,1) unsigned,
+ filler varchar(100),
+ key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-9.1, 0.7, 'filler'),
+(2,-8.2, 1.6, 'filler'),
+(3, 0.3, 2.5, 'filler'),
+(4, 1.4, 3.4, 'filler'),
+(5, 2.5, 4.3, 'filler'),
+(6, 3.3, 5.3, 'filler');
+insert into t1 select pk+100, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+200, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+1000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+10000, 9.0, 9.0, 'extra-data' from t1;
+insert into t1 select pk+100000, 9.0, 9.0, 'extra-data' from t1;
+analyze table t1;
+
+--echo # The following can't use index-only:
+--replace_column 9 #
+explain select * from t1 where col1 between -8 and 8;
+
+--echo # This will use index-only:
+--replace_column 9 #
+explain
+select col1, col2 from t1 where col1 between -8 and 8;
+select col1, col2 from t1 where col1 between -8 and 8;
+
+insert into t1 values (11, NULL, 0.9, 'row1-with-null');
+insert into t1 values (10, -8.4, NULL, 'row2-with-null');
+--replace_column 9 #
+explain
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+select col1, col2 from t1 force index(key1) where col1 is null or col1 < -7;
+
+--echo # Try an UPDATE
+select * from t1 where pk in (3,4);
+update t1 set col2= col2+0.2 where pk in (3,4);
+select * from t1 where pk in (3,4);
+
+drop table t1;
+
+--echo #
+--echo # Try another DECIMAL-based type that takes more space
+--echo #
+create table t1 (
+ pk int not null primary key,
+ col1 decimal (12,6) signed,
+ col2 decimal (12,6) unsigned,
+ filler varchar(100),
+ key key1(col1, col2)
+)engine=rocksdb;
+insert into t1 values
+(1,-900.001, 000.007, 'filler'),
+(2,-700.002, 100.006, 'filler'),
+(3, 000.003, 200.005, 'filler'),
+(4, 100.004, 300.004, 'filler'),
+(5, 200.005, 400.003, 'filler'),
+(6, 300.003, 500.003, 'filler');
+insert into t1 select pk+100, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+200, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+1000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+10000, col1+20000, col2+20000, 'extra-data' from t1;
+insert into t1 select pk+100000, col1+20000, col2+20000, 'extra-data' from t1;
+analyze table t1;
+
+--replace_column 9 #
+explain
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+select col1, col2 from t1 force index(key1) where col1 between -800 and 800;
+drop table t1;
+