1# tests the basic functionality of rocksdb_strict_collation, 2# rocksdb_strict_collation_exceptions, and my_regex functionality behind 3# rocksdb_strict_collation_exceptions 4--source include/have_rocksdb.inc 5 6# ci non-indexed column is allowed 7CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8; 8DROP TABLE t1; 9 10# ci indexed column is not allowed 11--error ER_UNKNOWN_ERROR 12CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8; 13--error ER_UNKNOWN_ERROR 14CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8; 15# ci indexed column with rocksdb_strict_collation_check=OFF is allowed. 16SET GLOBAL rocksdb_strict_collation_check=0; 17CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8; 18DROP TABLE t1; 19SET GLOBAL rocksdb_strict_collation_check=1; 20 21# cs indexed column is allowed 22CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value2)) engine=rocksdb charset utf8; 23DROP TABLE t1; 24 25# cs latin1_bin is allowed 26CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset latin1 collate latin1_bin; 27DROP TABLE t1; 28 29# cs utf8_bin is allowed 30CREATE TABLE t1 (id varchar(20), value varchar(50), value2 varchar(50), value3 text, primary key (id), index(value, value2)) engine=rocksdb charset utf8 collate utf8_bin; 31DROP TABLE t1; 32 33# cs mixed latin1_bin and utf8_bin is allowed 34CREATE TABLE t1 (id varchar(20) collate latin1_bin, value varchar(50) collate utf8_bin, value2 varchar(50) collate latin1_bin, value3 text, primary key (id), index(value, value2)) engine=rocksdb; 35DROP TABLE t1; 36 37# ci indexed column is not allowed unless table name is in exception list 38SET GLOBAL rocksdb_strict_collation_exceptions=t1; 39CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 40DROP TABLE t1; 41--error ER_UNKNOWN_ERROR 42CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 43 44# test regex for exception list 45SET GLOBAL rocksdb_strict_collation_exceptions="t.*"; 46CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 47DROP TABLE t123; 48--error ER_UNKNOWN_ERROR 49CREATE TABLE s123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 50 51SET GLOBAL rocksdb_strict_collation_exceptions=".t.*"; 52CREATE TABLE xt123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 53DROP TABLE xt123; 54--error ER_UNKNOWN_ERROR 55CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 56 57# test multiple entries in the list with vertical bar 58SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*"; 59CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 60DROP TABLE s1; 61CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 62DROP TABLE t1; 63--error ER_UNKNOWN_ERROR 64CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; 65 66# test allowing alters to create temporary tables 67SET GLOBAL rocksdb_strict_collation_exceptions='t1'; 68CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb; 69ALTER TABLE t1 AUTO_INCREMENT=1; 70DROP TABLE t1; 71--error ER_UNKNOWN_ERROR 72CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb; 73CREATE TABLE t2 (id INT primary key, value varchar(50)) engine=rocksdb; 74--error ER_UNKNOWN_ERROR 75ALTER TABLE t2 ADD INDEX(value); 76DROP TABLE t2; 77 78--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/rocksdb.collation.err 79--let $restart_parameters="restart: --log-error=$SEARCH_FILE" 80--source include/restart_mysqld.inc 81 82# test invalid regex (missing end bracket) 83SET GLOBAL rocksdb_strict_collation_exceptions="[a-b"; 84--let SEARCH_PATTERN=RocksDB: Invalid pattern in strict_collation_exceptions: \[a-b 85--source include/search_pattern_in_file.inc 86 87--error ER_UNKNOWN_ERROR 88CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; 89SET GLOBAL rocksdb_strict_collation_exceptions="[a-b]"; 90CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; 91CREATE TABLE b (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; 92--error ER_UNKNOWN_ERROR 93CREATE TABLE c (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; 94DROP TABLE a, b; 95 96# test invalid regex (trailing escape) 97SET GLOBAL rocksdb_strict_collation_exceptions="abc\\"; 98--let SEARCH_PATTERN=Invalid pattern in strict_collation_exceptions: abc\\\\ 99--source include/search_pattern_in_file.inc 100 101# cleanup 102--let SEARCH_PATTERN= 103--let SEARCH_FILE= 104--let $restart_parameters= 105--source include/restart_mysqld.inc 106