diff options
Diffstat (limited to '')
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test new file mode 100644 index 00000000..d231236b --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test @@ -0,0 +1,126 @@ +--source include/have_rocksdb.inc +--source include/have_debug.inc + +# Test if unknown collation works. +set session debug_dbug= "+d,myrocks_enable_unknown_collation_index_only_scans"; +create table t (id int not null auto_increment primary key, + c varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci, + key sk (c)); +insert into t (c) values ('☀'), ('ß'); +--replace_column 9 # +explain select c from t; +select c from t; +drop table t; +set session debug_dbug= "-d,myrocks_enable_unknown_collation_index_only_scans"; + +# Testing if all characters in latin1 charset get restored correctly. This is +# done by comparing results from a PK scan. +create table t (id int not null auto_increment, + c1 varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci, + c2 char(1) CHARACTER SET latin1 COLLATE latin1_general_ci, + primary key (id), + key sk1 (c1), + key sk2 (c2)); + +let $i = 0; + +--disable_query_log +while ($i < 256) +{ + --eval insert into t (c1, c2) values (CHAR('$i'), CHAR('$i')) + inc $i; +} +--enable_query_log + +--replace_column 9 # +explain select hex(c1) from t order by c1; +--replace_column 9 # +explain select hex(c1) from t IGNORE INDEX (sk1) order by c1; + +--replace_column 9 # +explain select hex(c2) from t order by c2; +--replace_column 9 # +explain select hex(c2) from t IGNORE INDEX (sk1) order by c2; + +--let $file1=$MYSQLTEST_VARDIR/tmp/filesort_order +--let $file2=$MYSQLTEST_VARDIR/tmp/sk_order +--disable_query_log +--eval select hex(weight_string(c1)) INTO OUTFILE '$file1' from t order by c1 +--eval select hex(weight_string(c1)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c1 +--enable_query_log + +--diff_files $file1 $file2 +--remove_file $file1 +--remove_file $file2 + +--disable_query_log +--eval select hex(weight_string(c2)) INTO OUTFILE '$file1' from t order by c2 +--eval select hex(weight_string(c2)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c2 +--enable_query_log + +--diff_files $file1 $file2 +--remove_file $file1 +--remove_file $file2 + +truncate t; + +# Test handling of spaces at the end of fields. +insert into t (c1, c2) values ('Asdf ', 'Asdf '); +select char_length(c1), char_length(c2), c1, c2 from t; + +drop table t; + +create table t (id int not null auto_increment, + c2 char(255) CHARACTER SET latin1 COLLATE latin1_general_ci, + primary key (id), + unique key sk2 (c2)); + +insert into t (c2) values ('Asdf'); +--error ER_DUP_ENTRY +insert into t (c2) values ('asdf '); + +drop table t; + +create table t (id int not null auto_increment, + c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci, + primary key (id), + unique key sk1 (c1)); + +insert into t (c1) values ('Asdf'); +--error ER_DUP_ENTRY +insert into t (c1) values ('asdf '); +--error ER_DUP_ENTRY +insert into t (c1) values ('asdf'); + +drop table t; + +create table t (id int not null auto_increment, + c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci, + primary key (id), + unique key sk1 (c1(1))); + +insert into t (c1) values ('Asdf'); +insert into t (c1) values ('bbbb '); +--error ER_DUP_ENTRY +insert into t (c1) values ('a '); + +--replace_column 9 # +explain select c1 from t; +select c1 from t; + +drop table t; + +# Test varchar keyparts with key prefix +set session rocksdb_verify_row_debug_checksums = on; +create table t (id int primary key, email varchar(100), KEY email_i (email(30))) engine=rocksdb default charset=latin1; +insert into t values (1, ' a'); +--replace_column 9 # +explain select 'email_i' as index_name, count(*) AS count from t force index(email_i); +select 'email_i' as index_name, count(*) AS count from t force index(email_i); +drop table t; + +# Test varchar with length greater than 255 +create table t (id int primary key, email varchar(767), KEY email_i (email)) engine=rocksdb default charset=latin1; +insert into t values (1, REPEAT('a', 700)); +select 'email_i' as index_name, count(*) AS count from t force index(email_i); +drop table t; |