1--source include/have_debug.inc 2--source include/have_rocksdb.inc 3 4# Create a table with a varbinary key with the current format and validate 5# that it sorts correctly 6CREATE TABLE t1( 7 vb VARBINARY(64) primary key 8) ENGINE=rocksdb; 9 10INSERT INTO t1 values(0x00); 11INSERT INTO t1 values(0x0000); 12INSERT INTO t1 values(0x0000000000000000); 13INSERT INTO t1 values(0x000000); 14INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000); 15INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000); 16INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000); 17INSERT INTO t1 values(0x00000000); 18INSERT INTO t1 values(0x0000000000); 19INSERT INTO t1 values(0x00000000000000000000); 20INSERT INTO t1 values(0x000000000000); 21INSERT INTO t1 values(0x00000000000000); 22INSERT INTO t1 values(0x000000000000000000); 23 24SELECT hex(vb) FROM t1; 25 26# Use the fact that the rocksdb_locks shows the keys as they are encoded to 27# validate that the keys were encoded as expected 28BEGIN; 29SELECT hex(vb) FROM t1 FOR UPDATE; 30SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key; 31ROLLBACK; 32 33DROP TABLE t1; 34 35# Now create the same table in the old format to show that they can be read 36# and handled correctly 37set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT'; 38CREATE TABLE t1( 39 vb VARBINARY(64) primary key 40) ENGINE=rocksdb; 41set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT'; 42 43INSERT INTO t1 values(0x00); 44INSERT INTO t1 values(0x0000); 45INSERT INTO t1 values(0x0000000000000000); 46INSERT INTO t1 values(0x000000); 47INSERT INTO t1 values(0x000000000000000000000000000000000000000000000000000000000000000000); 48INSERT INTO t1 values(0x00000000000000000000000000000000000000000000000000000000000000); 49INSERT INTO t1 values(0x0000000000000000000000000000000000000000000000000000000000000000); 50INSERT INTO t1 values(0x00000000); 51INSERT INTO t1 values(0x0000000000); 52INSERT INTO t1 values(0x00000000000000000000); 53INSERT INTO t1 values(0x000000000000); 54INSERT INTO t1 values(0x00000000000000); 55INSERT INTO t1 values(0x000000000000000000); 56 57SELECT hex(vb) FROM t1; 58 59# Use the fact that the rocksdb_locks shows the keys as they are encoded to 60# validate that the keys were encoded as expected 61BEGIN; 62SELECT hex(vb) FROM t1 FOR UPDATE; 63SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key; 64ROLLBACK; 65 66DROP TABLE t1; 67 68# Now create a table with a varchar key using a binary collation with the 69# current format and validate that it sorts correctly 70CREATE TABLE t1( 71 vc VARCHAR(64) collate 'binary' primary key 72) ENGINE=rocksdb; 73 74INSERT INTO t1 values('a'); 75INSERT INTO t1 values('aa'); 76INSERT INTO t1 values('aaaaaaaa'); 77INSERT INTO t1 values('aaa'); 78INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 79INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 80INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 81INSERT INTO t1 values('aaaa'); 82INSERT INTO t1 values('aaaaa'); 83INSERT INTO t1 values('aaaaaaaaaa'); 84INSERT INTO t1 values('aaaaaa'); 85INSERT INTO t1 values('aaaaaaa'); 86INSERT INTO t1 values('aaaaaaaaa'); 87 88SELECT * FROM t1; 89 90# Use the fact that the rocksdb_locks shows the keys as they are encoded to 91# validate that the keys were encoded as expected 92BEGIN; 93SELECT * FROM t1 FOR UPDATE; 94SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key; 95ROLLBACK; 96 97DROP TABLE t1; 98 99# Now create the same table in the old format to show that they can be read 100# and handled correctly 101set session debug_dbug= '+d,MYROCKS_LEGACY_VARBINARY_FORMAT'; 102CREATE TABLE t1( 103 vc VARCHAR(64) collate 'binary' primary key 104) ENGINE=rocksdb; 105set session debug_dbug= '-d,MYROCKS_LEGACY_VARBINARY_FORMAT'; 106 107INSERT INTO t1 values('a'); 108INSERT INTO t1 values('aa'); 109INSERT INTO t1 values('aaaaaaaa'); 110INSERT INTO t1 values('aaa'); 111INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 112INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 113INSERT INTO t1 values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); 114INSERT INTO t1 values('aaaa'); 115INSERT INTO t1 values('aaaaa'); 116INSERT INTO t1 values('aaaaaaaaaa'); 117INSERT INTO t1 values('aaaaaa'); 118INSERT INTO t1 values('aaaaaaa'); 119INSERT INTO t1 values('aaaaaaaaa'); 120 121SELECT * FROM t1; 122 123# Use the fact that the rocksdb_locks shows the keys as they are encoded to 124# validate that the keys were encoded as expected 125BEGIN; 126SELECT * FROM t1 FOR UPDATE; 127SELECT SUBSTRING(a.key,9) FROM information_schema.rocksdb_locks AS a ORDER BY a.key; 128ROLLBACK; 129 130DROP TABLE t1; 131 132