1--source include/have_rocksdb.inc 2--source include/have_debug.inc 3 4# Test if unknown collation works. 5set session debug_dbug= "+d,myrocks_enable_unknown_collation_index_only_scans"; 6create table t (id int not null auto_increment primary key, 7 c varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci, 8 key sk (c)); 9insert into t (c) values ('☀'), ('ß'); 10--replace_column 9 # 11explain select c from t; 12select c from t; 13drop table t; 14set session debug_dbug= "-d,myrocks_enable_unknown_collation_index_only_scans"; 15 16# Testing if all characters in latin1 charset get restored correctly. This is 17# done by comparing results from a PK scan. 18create table t (id int not null auto_increment, 19 c1 varchar(1) CHARACTER SET latin1 COLLATE latin1_swedish_ci, 20 c2 char(1) CHARACTER SET latin1 COLLATE latin1_general_ci, 21 primary key (id), 22 key sk1 (c1), 23 key sk2 (c2)); 24 25let $i = 0; 26 27--disable_query_log 28while ($i < 256) 29{ 30 --eval insert into t (c1, c2) values (CHAR('$i'), CHAR('$i')) 31 inc $i; 32} 33--enable_query_log 34 35--replace_column 9 # 36explain select hex(c1) from t order by c1; 37--replace_column 9 # 38explain select hex(c1) from t IGNORE INDEX (sk1) order by c1; 39 40--replace_column 9 # 41explain select hex(c2) from t order by c2; 42--replace_column 9 # 43explain select hex(c2) from t IGNORE INDEX (sk1) order by c2; 44 45--let $file1=$MYSQLTEST_VARDIR/tmp/filesort_order 46--let $file2=$MYSQLTEST_VARDIR/tmp/sk_order 47--disable_query_log 48--eval select hex(weight_string(c1)) INTO OUTFILE '$file1' from t order by c1 49--eval select hex(weight_string(c1)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c1 50--enable_query_log 51 52--diff_files $file1 $file2 53--remove_file $file1 54--remove_file $file2 55 56--disable_query_log 57--eval select hex(weight_string(c2)) INTO OUTFILE '$file1' from t order by c2 58--eval select hex(weight_string(c2)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c2 59--enable_query_log 60 61--diff_files $file1 $file2 62--remove_file $file1 63--remove_file $file2 64 65truncate t; 66 67# Test handling of spaces at the end of fields. 68insert into t (c1, c2) values ('Asdf ', 'Asdf '); 69select char_length(c1), char_length(c2), c1, c2 from t; 70 71drop table t; 72 73create table t (id int not null auto_increment, 74 c2 char(255) CHARACTER SET latin1 COLLATE latin1_general_ci, 75 primary key (id), 76 unique key sk2 (c2)); 77 78insert into t (c2) values ('Asdf'); 79--error ER_DUP_ENTRY 80insert into t (c2) values ('asdf '); 81 82drop table t; 83 84create table t (id int not null auto_increment, 85 c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci, 86 primary key (id), 87 unique key sk1 (c1)); 88 89insert into t (c1) values ('Asdf'); 90--error ER_DUP_ENTRY 91insert into t (c1) values ('asdf '); 92--error ER_DUP_ENTRY 93insert into t (c1) values ('asdf'); 94 95drop table t; 96 97create table t (id int not null auto_increment, 98 c1 varchar(256) CHARACTER SET latin1 COLLATE latin1_swedish_ci, 99 primary key (id), 100 unique key sk1 (c1(1))); 101 102insert into t (c1) values ('Asdf'); 103insert into t (c1) values ('bbbb '); 104--error ER_DUP_ENTRY 105insert into t (c1) values ('a '); 106 107--replace_column 9 # 108explain select c1 from t; 109select c1 from t; 110 111drop table t; 112 113# Test varchar keyparts with key prefix 114set session rocksdb_verify_row_debug_checksums = on; 115create table t (id int primary key, email varchar(100), KEY email_i (email(30))) engine=rocksdb default charset=latin1; 116insert into t values (1, ' a'); 117--replace_column 9 # 118explain select 'email_i' as index_name, count(*) AS count from t force index(email_i); 119select 'email_i' as index_name, count(*) AS count from t force index(email_i); 120drop table t; 121 122# Test varchar with length greater than 255 123create table t (id int primary key, email varchar(767), KEY email_i (email)) engine=rocksdb default charset=latin1; 124insert into t values (1, REPEAT('a', 700)); 125select 'email_i' as index_name, count(*) AS count from t force index(email_i); 126drop table t; 127