1select ENGINE,COMMENT,TRANSACTIONS,XA,SAVEPOINTS from information_schema.engines where engine = 'rocksdb'; 2ENGINE COMMENT TRANSACTIONS XA SAVEPOINTS 3ROCKSDB RocksDB storage engine YES YES YES 4SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK; 5SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1; 6# 7# Issue #1: Don't update indexes if index values have not changed 8# 9create table t1 ( 10pk int primary key, 11a int, 12b int, 13key(a) 14) engine=rocksdb; 15insert into t1 values 16(1,1,1), (2,2,2), (3,3,3), (4,4,4); 17set @var1=(select variable_value 18from performance_schema.global_status 19where variable_name='rocksdb_number_keys_written'); 20# Do an update that doesn't change the key 'a'. 21update t1 set b=3334341 where a=2; 22set @var2=(select variable_value 23from performance_schema.global_status 24where variable_name='rocksdb_number_keys_written'); 25# The following should produce 1 26select @var2 - @var1; 27@var2 - @var1 281 29# Do an update that sets the key to the same value 30update t1 set a=pk where a=3; 31set @var3=(select variable_value 32from performance_schema.global_status 33where variable_name='rocksdb_number_keys_written'); 34# We have 'updated' column to the same value, so the following must return 0: 35select @var3 - @var2; 36@var3 - @var2 370 38drop table t1; 39create table t0 (a int primary key) engine=rocksdb; 40show create table t0; 41Table Create Table 42t0 CREATE TABLE `t0` ( 43 `a` int(11) NOT NULL, 44 PRIMARY KEY (`a`) 45) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 46drop table t0; 47create table t1 (a int primary key, b int) engine=rocksdb; 48insert into t1 values (1,1); 49insert into t1 values (2,2); 50select * from t1; 51a b 521 1 532 2 54# Check that we can create another table and insert there 55create table t2 (a varchar(10) primary key, b varchar(10)) engine=rocksdb; 56insert into t2 value ('abc','def'); 57insert into t2 value ('hijkl','mnopq'); 58select * from t2; 59a b 60abc def 61hijkl mnopq 62# Select again from t1 to see that records from different tables dont mix 63select * from t1; 64a b 651 1 662 2 67explain select * from t2 where a='no-such-key'; 68id select_type table partitions type possible_keys key key_len ref rows filtered Extra 691 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table 70Warnings: 71Note 1003 /* select#1 */ select NULL AS `a`,NULL AS `b` from `test`.`t2` where multiple equal('no-such-key', NULL) 72explain select * from t2 where a='abc'; 73id select_type table partitions type possible_keys key key_len ref rows filtered Extra 741 SIMPLE t2 NULL const PRIMARY PRIMARY 12 const # 100.00 NULL 75Warnings: 76Note 1003 /* select#1 */ select 'abc' AS `a`,'def' AS `b` from `test`.`t2` where 1 77select * from t2 where a='abc'; 78a b 79abc def 80# Try a composite PK 81create table t3 ( 82pk1 int, 83pk2 varchar(10), 84col1 varchar(10), 85primary key(pk1, pk2) 86) engine=rocksdb; 87insert into t3 values (2,'two', 'row#2'); 88insert into t3 values (3,'three', 'row#3'); 89insert into t3 values (1,'one', 'row#1'); 90select * from t3; 91pk1 pk2 col1 921 one row#1 932 two row#2 943 three row#3 95select * from t3 where pk1=3 and pk2='three'; 96pk1 pk2 col1 973 three row#3 98drop table t1, t2, t3; 99# 100# Test blob values 101# 102create table t4 (a int primary key, b blob) engine=rocksdb; 103insert into t4 values (1, repeat('quux-quux', 60)); 104insert into t4 values (10, repeat('foo-bar', 43)); 105insert into t4 values (5, repeat('foo-bar', 200)); 106insert into t4 values (2, NULL); 107select 108a, 109(case a 110when 1 then b=repeat('quux-quux', 60) 111when 10 then b=repeat('foo-bar', 43) 112when 5 then b=repeat('foo-bar', 200) 113when 2 then b is null 114else 'IMPOSSIBLE!' end) as CMP 115from t4; 116a CMP 1171 1 1182 1 1195 1 12010 1 121drop table t4; 122# 123# Test blobs of various sizes 124# 125# TINYBLOB 126create table t5 (a int primary key, b tinyblob) engine=rocksdb; 127insert into t5 values (1, repeat('quux-quux', 6)); 128insert into t5 values (10, repeat('foo-bar', 4)); 129insert into t5 values (5, repeat('foo-bar', 2)); 130select 131a, 132(case a 133when 1 then b=repeat('quux-quux', 6) 134when 10 then b=repeat('foo-bar', 4) 135when 5 then b=repeat('foo-bar', 2) 136else 'IMPOSSIBLE!' end) as CMP 137from t5; 138a CMP 1391 1 1405 1 14110 1 142drop table t5; 143# MEDIUMBLOB 144create table t6 (a int primary key, b mediumblob) engine=rocksdb; 145insert into t6 values (1, repeat('AB', 65000)); 146insert into t6 values (10, repeat('bbb', 40000)); 147insert into t6 values (5, repeat('foo-bar', 2)); 148select 149a, 150(case a 151when 1 then b=repeat('AB', 65000) 152when 10 then b=repeat('bbb', 40000) 153when 5 then b=repeat('foo-bar', 2) 154else 'IMPOSSIBLE!' end) as CMP 155from t6; 156a CMP 1571 1 1585 1 15910 1 160drop table t6; 161# LONGBLOB 162create table t7 (a int primary key, b longblob) engine=rocksdb; 163insert into t7 values (1, repeat('AB', 65000)); 164insert into t7 values (10, repeat('bbb', 40000)); 165insert into t7 values (5, repeat('foo-bar', 2)); 166select 167a, 168(case a 169when 1 then b=repeat('AB', 65000) 170when 10 then b=repeat('bbb', 40000) 171when 5 then b=repeat('foo-bar', 2) 172else 'IMPOSSIBLE!' end) as CMP 173from t7; 174a CMP 1751 1 1765 1 17710 1 178drop table t7; 179# 180# Check if DELETEs work 181# 182create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb; 183insert into t8 values 184('one', 'eins'), 185('two', 'zwei'), 186('three', 'drei'), 187('four', 'vier'), 188('five', 'funf'); 189# Delete by PK 190explain delete from t8 where a='three'; 191id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1921 DELETE t8 NULL range PRIMARY PRIMARY 12 const # 100.00 Using where 193delete from t8 where a='three'; 194select * from t8; 195a col1 196five funf 197four vier 198one eins 199two zwei 200# Delete while doing a full table scan 201delete from t8 where col1='eins' or col1='vier'; 202select * from t8; 203a col1 204five funf 205two zwei 206# delete w/o WHERE: 207delete from t8; 208select * from t8; 209a col1 210# 211# Test UPDATEs 212# 213insert into t8 values 214('one', 'eins'), 215('two', 'zwei'), 216('three', 'drei'), 217('four', 'vier'), 218('five', 'funf'); 219update t8 set col1='dva' where a='two'; 220update t8 set a='fourAAA' where col1='vier'; 221select * from t8; 222a col1 223five funf 224fourAAA vier 225one eins 226three drei 227two dva 228delete from t8; 229# 230# Basic transactions tests 231# 232begin; 233insert into t8 values ('trx1-val1', 'data'); 234insert into t8 values ('trx1-val2', 'data'); 235rollback; 236select * from t8; 237a col1 238begin; 239insert into t8 values ('trx1-val1', 'data'); 240insert into t8 values ('trx1-val2', 'data'); 241commit; 242select * from t8; 243a col1 244trx1-val1 data 245trx1-val2 data 246drop table t8; 247# 248# Check if DROP TABLE works 249# 250create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb; 251select * from t8; 252a col1 253insert into t8 values ('foo','foo'); 254drop table t8; 255create table t8 (a varchar(10) primary key, col1 varchar(12)) engine=rocksdb; 256select * from t8; 257a col1 258drop table t8; 259# 260# MDEV-3961: Assertion ... on creating a TEMPORARY RocksDB table 261# 262CREATE TEMPORARY TABLE t10 (pk INT PRIMARY KEY) ENGINE=RocksDB; 263ERROR HY000: Table storage engine 'ROCKSDB' does not support the create option 'TEMPORARY' 264# 265# MDEV-3963: JOIN or WHERE conditions involving keys on RocksDB tables don't work 266# 267CREATE TABLE t10 (i INT PRIMARY KEY) ENGINE=RocksDB; 268INSERT INTO t10 VALUES (1),(3); 269CREATE TABLE t11 (j INT PRIMARY KEY) ENGINE=RocksDB; 270INSERT INTO t11 VALUES (1),(4); 271select * from t10; 272i 2731 2743 275select * from t11; 276j 2771 2784 279EXPLAIN 280SELECT * FROM t10, t11 WHERE i=j; 281id select_type table partitions type possible_keys key key_len ref rows filtered Extra 2821 SIMPLE t10 NULL index PRIMARY PRIMARY 4 NULL # 100.00 Using index 2831 SIMPLE t11 NULL eq_ref PRIMARY PRIMARY 4 test.t10.i # 100.00 Using index 284Warnings: 285Note 1003 /* select#1 */ select `test`.`t10`.`i` AS `i`,`test`.`t11`.`j` AS `j` from `test`.`t10` join `test`.`t11` where (`test`.`t11`.`j` = `test`.`t10`.`i`) 286SELECT * FROM t10, t11 WHERE i=j; 287i j 2881 1 289DROP TABLE t10,t11; 290# 291# MDEV-3962: SELECT with ORDER BY causes "ERROR 1030 (HY000): Got error 122 292# 293CREATE TABLE t12 (pk INT PRIMARY KEY) ENGINE=RocksDB; 294INSERT INTO t12 VALUES (2),(1); 295SELECT * FROM t12 ORDER BY pk; 296pk 2971 2982 299DROP TABLE t12; 300# 301# MDEV-3964: Assertion `!pk_descr' fails in ha_rocksdb::open on adding partitions ... 302# 303create table t14 (pk int primary key) engine=RocksDB partition by hash(pk) partitions 2; 304Warnings: 305Warning 1287 The partition engine, used by table 'test.t14', is deprecated and will be removed in a future release. Please use native partitioning instead. 306drop table t14; 307# 308# MDEV-3960: Server crashes on running DISCARD TABLESPACE on a RocksDB table 309# 310create table t9 (i int primary key) engine=rocksdb; 311alter table t9 discard tablespace; 312ERROR HY000: Table storage engine for 't9' doesn't have this option 313drop table t9; 314# 315# MDEV-3959: Assertion `slice->size() == table->s->reclength' fails ... 316# on accessing a table after ALTER 317# 318CREATE TABLE t15 (a INT, rocksdb_pk INT PRIMARY KEY) ENGINE=RocksDB; 319INSERT INTO t15 VALUES (1,1),(5,2); 320ALTER TABLE t15 DROP COLUMN a; 321DROP TABLE t15; 322# 323# MDEV-3968: UPDATE produces a wrong result while modifying a PK on a RocksDB table 324# 325create table t16 (pk int primary key, a char(8)) engine=RocksDB; 326insert into t16 values (1,'a'),(2,'b'),(3,'c'),(4,'d'); 327update t16 set pk=100, a = 'updated' where a in ('b','c'); 328ERROR 23000: Duplicate entry '100' for key 'PRIMARY' 329select * from t16; 330pk a 3311 a 3322 b 3333 c 3344 d 335drop table t16; 336# 337# MDEV-3970: A set of assorted crashes on inserting a row into a RocksDB table 338# 339drop table if exists t_very_long_table_name; 340CREATE TABLE `t_very_long_table_name` ( 341`c` char(1) NOT NULL, 342`c0` char(0) NOT NULL, 343`c1` char(1) NOT NULL, 344`c20` char(20) NOT NULL, 345`c255` char(255) NOT NULL, 346PRIMARY KEY (`c255`) 347) ENGINE=RocksDB DEFAULT CHARSET=latin1; 348INSERT INTO t_very_long_table_name VALUES ('a', '', 'c', REPEAT('a',20), REPEAT('x',255)); 349drop table t_very_long_table_name; 350# 351# Test table locking and read-before-write checks. 352# 353create table t17 (pk varchar(12) primary key, col1 varchar(12)) engine=rocksdb; 354insert into t17 values ('row1', 'val1'); 355insert into t17 values ('row1', 'val1-try2'); 356ERROR 23000: Duplicate entry 'row1' for key 'PRIMARY' 357insert into t17 values ('ROW1', 'val1-try2'); 358ERROR 23000: Duplicate entry 'ROW1' for key 'PRIMARY' 359insert into t17 values ('row2', 'val2'); 360insert into t17 values ('row3', 'val3'); 361# This is ok 362update t17 set pk='row4' where pk='row1'; 363# This will try to overwrite another row: 364update t17 set pk='row3' where pk='row2'; 365ERROR 23000: Duplicate entry 'row3' for key 'PRIMARY' 366select * from t17; 367pk col1 368row2 val2 369row3 val3 370row4 val1 371# 372# Locking tests 373# 374# First, make sure there's no locking when transactions update different rows 375set autocommit=0; 376update t17 set col1='UPD1' where pk='row2'; 377update t17 set col1='UPD2' where pk='row3'; 378commit; 379select * from t17; 380pk col1 381row2 UPD1 382row3 UPD2 383row4 val1 384# Check the variable 385show variables like 'rocksdb_lock_wait_timeout'; 386Variable_name Value 387rocksdb_lock_wait_timeout 1 388set rocksdb_lock_wait_timeout=2; 389show variables like 'rocksdb_lock_wait_timeout'; 390Variable_name Value 391rocksdb_lock_wait_timeout 2 392# Try updating the same row from two transactions 393begin; 394update t17 set col1='UPD2-AA' where pk='row2'; 395update t17 set col1='UPD2-BB' where pk='row2'; 396ERROR HY000: Lock wait timeout exceeded; try restarting transaction 397set rocksdb_lock_wait_timeout=1000; 398update t17 set col1='UPD2-CC' where pk='row2'; 399rollback; 400select * from t17 where pk='row2'; 401pk col1 402row2 UPD2-CC 403drop table t17; 404# 405# MDEV-4035: RocksDB: SELECT produces different results inside a transaction (read is not repeatable) 406# 407create table t18 (pk int primary key, i int) engine=RocksDB; 408begin; 409select * from t18; 410pk i 411select * from t18 where pk = 1; 412pk i 413connect con1,localhost,root,,; 414insert into t18 values (1,100); 415connection default; 416select * from t18; 417pk i 418select * from t18 where pk = 1; 419pk i 420commit; 421drop table t18; 422# 423# MDEV-4036: RocksDB: INSERT .. ON DUPLICATE KEY UPDATE does not work, produces ER_DUP_KEY 424# 425create table t19 (pk int primary key, i int) engine=RocksDB; 426insert into t19 values (1,1); 427insert into t19 values (1,100) on duplicate key update i = 102; 428select * from t19; 429pk i 4301 102 431drop table t19; 432# MDEV-4037: RocksDB: REPLACE doesn't work, produces ER_DUP_KEY 433create table t20 (pk int primary key, i int) engine=RocksDB; 434insert into t20 values (1,1); 435replace into t20 values (1,100); 436select * from t20; 437pk i 4381 100 439drop table t20; 440# 441# MDEV-4041: Server crashes in Primary_key_comparator::get_hashnr on INSERT 442# 443create table t21 (v varbinary(16) primary key, i int) engine=RocksDB; 444insert into t21 values ('a',1); 445select * from t21; 446v i 447a 1 448drop table t21; 449# 450# MDEV-4047: RocksDB: Assertion `0' fails in Protocol::end_statement() on multi-table INSERT IGNORE 451# 452CREATE TABLE t22 (a int primary key) ENGINE=RocksDB; 453INSERT INTO t22 VALUES (1),(2); 454CREATE TABLE t23 (b int primary key) ENGINE=RocksDB; 455set @orig_tx_iso=@@session.transaction_isolation; 456set session transaction_isolation='READ-COMMITTED'; 457INSERT INTO t23 SELECT * FROM t22; 458DELETE IGNORE t22.*, t23.* FROM t22, t23 WHERE b < a; 459set session transaction_isolation=@orig_tx_iso; 460DROP TABLE t22,t23; 461# 462# MDEV-4046: RocksDB: Multi-table DELETE locks itself and ends with ER_LOCK_WAIT_TIMEOUT 463# 464CREATE TABLE t24 (pk int primary key) ENGINE=RocksDB; 465INSERT INTO t24 VALUES (1),(2); 466CREATE TABLE t25 LIKE t24; 467set @orig_tx_iso=@@session.transaction_isolation; 468set session transaction_isolation='READ-COMMITTED'; 469INSERT INTO t25 SELECT * FROM t24; 470DELETE t25.* FROM t24, t25; 471set session transaction_isolation=@orig_tx_iso; 472DROP TABLE t24,t25; 473# 474# MDEV-4044: RocksDB: UPDATE or DELETE with ORDER BY locks itself 475# 476create table t26 (pk int primary key, c char(1)) engine=RocksDB; 477insert into t26 values (1,'a'),(2,'b'); 478update t26 set c = 'x' order by pk limit 1; 479delete from t26 order by pk limit 1; 480select * from t26; 481pk c 4822 b 483drop table t26; 484# 485# Test whether SELECT ... FOR UPDATE puts locks 486# 487create table t27(pk varchar(10) primary key, col1 varchar(20)) engine=RocksDB; 488insert into t27 values 489('row1', 'row1data'), 490('row2', 'row2data'), 491('row3', 'row3data'); 492connection con1; 493begin; 494select * from t27 where pk='row3' for update; 495pk col1 496row3 row3data 497connection default; 498set rocksdb_lock_wait_timeout=1; 499update t27 set col1='row2-modified' where pk='row3'; 500ERROR HY000: Lock wait timeout exceeded; try restarting transaction 501connection con1; 502rollback; 503connection default; 504disconnect con1; 505drop table t27; 506# 507# MDEV-4060: RocksDB: Assertion `! trx->batch' fails in 508# 509create table t28 (pk int primary key, a int) engine=RocksDB; 510insert into t28 values (1,10),(2,20); 511begin; 512update t28 set a = 100 where pk = 3; 513rollback; 514select * from t28; 515pk a 5161 10 5172 20 518drop table t28; 519# 520# Secondary indexes 521# 522create table t30 ( 523pk varchar(16) not null primary key, 524key1 varchar(16) not null, 525col1 varchar(16) not null, 526key(key1) 527) engine=rocksdb; 528insert into t30 values ('row1', 'row1-key', 'row1-data'); 529insert into t30 values ('row2', 'row2-key', 'row2-data'); 530insert into t30 values ('row3', 'row3-key', 'row3-data'); 531explain 532select * from t30 where key1='row2-key'; 533id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5341 SIMPLE t30 NULL ref key1 key1 18 const # 100.00 NULL 535Warnings: 536Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`key1` = 'row2-key') 537select * from t30 where key1='row2-key'; 538pk key1 col1 539row2 row2-key row2-data 540explain 541select * from t30 where key1='row1'; 542id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5431 SIMPLE t30 NULL ref key1 key1 18 const # 100.00 NULL 544Warnings: 545Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`key1` = 'row1') 546# This will produce nothing: 547select * from t30 where key1='row1'; 548pk key1 col1 549explain 550select key1 from t30; 551id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5521 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 Using index 553Warnings: 554Note 1003 /* select#1 */ select `test`.`t30`.`key1` AS `key1` from `test`.`t30` 555select key1 from t30; 556key1 557row1-key 558row2-key 559row3-key 560# Create a duplicate record 561insert into t30 values ('row2a', 'row2-key', 'row2a-data'); 562# Can we see it? 563select * from t30 where key1='row2-key'; 564pk key1 col1 565row2 row2-key row2-data 566row2a row2-key row2a-data 567delete from t30 where pk='row2'; 568select * from t30 where key1='row2-key'; 569pk key1 col1 570row2a row2-key row2a-data 571# 572# Range scans on secondary index 573# 574delete from t30; 575insert into t30 values 576('row1', 'row1-key', 'row1-data'), 577('row2', 'row2-key', 'row2-data'), 578('row3', 'row3-key', 'row3-data'), 579('row4', 'row4-key', 'row4-data'), 580('row5', 'row5-key', 'row5-data'); 581explain 582select * from t30 where key1 <='row3-key'; 583id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5841 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 585Warnings: 586Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`key1` <= 'row3-key') 587select * from t30 where key1 <='row3-key'; 588pk key1 col1 589row1 row1-key row1-data 590row2 row2-key row2-data 591row3 row3-key row3-data 592explain 593select * from t30 where key1 between 'row2-key' and 'row4-key'; 594id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5951 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 596Warnings: 597Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`key1` between 'row2-key' and 'row4-key') 598select * from t30 where key1 between 'row2-key' and 'row4-key'; 599pk key1 col1 600row2 row2-key row2-data 601row3 row3-key row3-data 602row4 row4-key row4-data 603explain 604select * from t30 where key1 in ('row2-key','row4-key'); 605id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6061 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 607Warnings: 608Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`key1` in ('row2-key','row4-key')) 609select * from t30 where key1 in ('row2-key','row4-key'); 610pk key1 col1 611row2 row2-key row2-data 612row4 row4-key row4-data 613explain 614select key1 from t30 where key1 in ('row2-key','row4-key'); 615id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6161 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using where; Using index 617Warnings: 618Note 1003 /* select#1 */ select `test`.`t30`.`key1` AS `key1` from `test`.`t30` where (`test`.`t30`.`key1` in ('row2-key','row4-key')) 619select key1 from t30 where key1 in ('row2-key','row4-key'); 620key1 621row2-key 622row4-key 623explain 624select * from t30 where key1 > 'row1-key' and key1 < 'row4-key'; 625id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6261 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 627Warnings: 628Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where ((`test`.`t30`.`key1` > 'row1-key') and (`test`.`t30`.`key1` < 'row4-key')) 629select * from t30 where key1 > 'row1-key' and key1 < 'row4-key'; 630pk key1 col1 631row2 row2-key row2-data 632row3 row3-key row3-data 633explain 634select * from t30 order by key1 limit 3; 635id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6361 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 NULL 637Warnings: 638Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` order by `test`.`t30`.`key1` limit 3 639select * from t30 order by key1 limit 3; 640pk key1 col1 641row1 row1-key row1-data 642row2 row2-key row2-data 643row3 row3-key row3-data 644explain 645select * from t30 order by key1 desc limit 3; 646id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6471 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 NULL 648Warnings: 649Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` order by `test`.`t30`.`key1` desc limit 3 650select * from t30 order by key1 desc limit 3; 651pk key1 col1 652row5 row5-key row5-data 653row4 row4-key row4-data 654row3 row3-key row3-data 655# 656# Range scans on primary key 657# 658explain 659select * from t30 where pk <='row3'; 660id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6611 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 662Warnings: 663Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`pk` <= 'row3') 664select * from t30 where pk <='row3'; 665pk key1 col1 666row1 row1-key row1-data 667row2 row2-key row2-data 668row3 row3-key row3-data 669explain 670select * from t30 where pk between 'row2' and 'row4'; 671id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6721 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 673Warnings: 674Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`pk` between 'row2' and 'row4') 675select * from t30 where pk between 'row2' and 'row4'; 676pk key1 col1 677row2 row2-key row2-data 678row3 row3-key row3-data 679row4 row4-key row4-data 680explain 681select * from t30 where pk in ('row2','row4'); 682id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6831 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 684Warnings: 685Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` where (`test`.`t30`.`pk` in ('row2','row4')) 686select * from t30 where pk in ('row2','row4'); 687pk key1 col1 688row2 row2-key row2-data 689row4 row4-key row4-data 690explain 691select * from t30 order by pk limit 3; 692id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6931 SIMPLE t30 NULL index NULL PRIMARY 18 NULL # 100.00 NULL 694Warnings: 695Note 1003 /* select#1 */ select `test`.`t30`.`pk` AS `pk`,`test`.`t30`.`key1` AS `key1`,`test`.`t30`.`col1` AS `col1` from `test`.`t30` order by `test`.`t30`.`pk` limit 3 696select * from t30 order by pk limit 3; 697pk key1 col1 698row1 row1-key row1-data 699row2 row2-key row2-data 700row3 row3-key row3-data 701drop table t30; 702# 703# MDEV-3841: RocksDB: Reading by PK prefix does not work 704# 705create table t31 (i int, j int, k int, primary key(i,j,k)) engine=RocksDB; 706insert into t31 values (1,10,100),(2,20,200); 707select * from t31 where i = 1; 708i j k 7091 10 100 710select * from t31 where j = 10; 711i j k 7121 10 100 713select * from t31 where k = 100; 714i j k 7151 10 100 716select * from t31 where i = 1 and j = 10; 717i j k 7181 10 100 719select * from t31 where i = 1 and k = 100; 720i j k 7211 10 100 722select * from t31 where j = 10 and k = 100; 723i j k 7241 10 100 725select * from t31 where i = 1 and j = 10 and k = 100; 726i j k 7271 10 100 728drop table t31; 729# 730# MDEV-4055: RocksDB: UPDATE/DELETE by a multi-part PK does not work 731# 732create table t32 (i int, j int, k int, primary key(i,j,k), a varchar(8)) engine=RocksDB; 733insert into t32 values 734(1,10,100,''), 735(2,20,200,''); 736select * from t32 where i = 1 and j = 10 and k = 100; 737i j k a 7381 10 100 739update t32 set a = 'updated' where i = 1 and j = 10 and k = 100; 740select * from t32; 741i j k a 7421 10 100 updated 7432 20 200 744drop table t32; 745# 746# MDEV-3841: RocksDB: Assertion `0' fails in ha_rocksdb::index_read_map on range select with ORDER BY .. DESC 747# 748CREATE TABLE t33 (pk INT PRIMARY KEY, a CHAR(1)) ENGINE=RocksDB; 749INSERT INTO t33 VALUES (1,'a'),(2,'b'); 750SELECT * FROM t33 WHERE pk <= 10 ORDER BY pk DESC; 751pk a 7522 b 7531 a 754DROP TABLE t33; 755# 756# MDEV-4081: RocksDB throws error 122 on an attempt to create a table with unique index 757# 758# Unique indexes can be created, but uniqueness won't be enforced 759create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB; 760drop table t33; 761# 762# MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 763# 764CREATE TABLE t34 (pk INT PRIMARY KEY) ENGINE=RocksDB; 765INSERT INTO t34 VALUES (10),(11); 766SELECT pk FROM t34 WHERE pk > 5 AND pk < 15; 767pk 76810 76911 770SELECT pk FROM t34 WHERE pk BETWEEN 5 AND 15; 771pk 77210 77311 774SELECT pk FROM t34 WHERE pk > 5; 775pk 77610 77711 778SELECT pk FROM t34 WHERE pk < 15; 779pk 78010 78111 782drop table t34; 783# 784# MDEV-4086: RocksDB does not allow a query with multi-part pk and index and ORDER BY .. DEC 785# 786create table t35 (a int, b int, c int, d int, e int, primary key (a,b,c), key (a,c,d,e)) engine=RocksDB; 787insert into t35 values (1,1,1,1,1),(2,2,2,2,2); 788select * from t35 where a = 1 and c = 1 and d = 1 order by e desc; 789a b c d e 7901 1 1 1 1 791drop table t35; 792# 793# MDEV-4084: RocksDB: Wrong result on IN subquery with index 794# 795CREATE TABLE t36 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB; 796INSERT INTO t36 VALUES (1,10),(2,20); 797SELECT 3 IN ( SELECT a FROM t36 ); 7983 IN ( SELECT a FROM t36 ) 7990 800drop table t36; 801# 802# MDEV-4084: RocksDB: Wrong result on IN subquery with index 803# 804CREATE TABLE t37 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a), KEY(a,b)) 805ENGINE=RocksDB; 806INSERT INTO t37 VALUES (1,10,'x'), (2,20,'y'); 807SELECT MAX(a) FROM t37 WHERE a < 100; 808MAX(a) 80920 810DROP TABLE t37; 811# 812# MDEV-4090: RocksDB: Wrong result (duplicate rows) on range access with secondary key and ORDER BY DESC 813# 814CREATE TABLE t38 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB; 815INSERT INTO t38 VALUES (1,10), (2,20); 816SELECT i FROM t38 WHERE i NOT IN (8) ORDER BY i DESC; 817i 81820 81910 820drop table t38; 821# 822# MDEV-4092: RocksDB: Assertion `in_table(pa, a_len)' fails in Rdb_key_def::cmp_full_keys 823# with a multi-part key and ORDER BY .. DESC 824# 825CREATE TABLE t40 (pk1 INT PRIMARY KEY, a INT, b VARCHAR(1), KEY(b,a)) ENGINE=RocksDB; 826INSERT INTO t40 VALUES (1, 7,'x'),(2,8,'y'); 827CREATE TABLE t41 (pk2 INT PRIMARY KEY) ENGINE=RocksDB; 828INSERT INTO t41 VALUES (1),(2); 829SELECT * FROM t40, t41 WHERE pk1 = pk2 AND b = 'o' ORDER BY a DESC; 830pk1 a b pk2 831DROP TABLE t40,t41; 832# 833# MDEV-4093: RocksDB: IN subquery by secondary key with NULL among values returns true instead of NULL 834# 835CREATE TABLE t42 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB; 836INSERT INTO t42 VALUES (1, NULL),(2, 8); 837SELECT ( 3 ) NOT IN ( SELECT a FROM t42 ); 838( 3 ) NOT IN ( SELECT a FROM t42 ) 839NULL 840DROP TABLE t42; 841# 842# MDEV-4094: RocksDB: Wrong result on SELECT and ER_KEY_NOT_FOUND on 843# DELETE with search by NULL-able secondary key ... 844# 845CREATE TABLE t43 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a)) ENGINE=RocksDB; 846INSERT INTO t43 VALUES (1,8,'g'),(2,9,'x'); 847UPDATE t43 SET pk = 10 WHERE a = 8; 848REPLACE INTO t43 ( pk, a ) VALUES ( 1, 8 ); 849REPLACE INTO t43 ( pk, b ) VALUES ( 3, 'y' ); 850SELECT * FROM t43 WHERE a = 8; 851pk a b 8521 8 NULL 85310 8 g 854DELETE FROM t43 WHERE a = 8; 855DROP TABLE t43; 856# 857# Basic AUTO_INCREMENT tests 858# 859create table t44(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb; 860insert into t44 (col1) values ('row1'); 861insert into t44 (col1) values ('row2'); 862insert into t44 (col1) values ('row3'); 863select * from t44; 864pk col1 8651 row1 8662 row2 8673 row3 868drop table t44; 869# 870# ALTER TABLE tests 871# 872create table t45 (pk int primary key, col1 varchar(12)) engine=rocksdb; 873insert into t45 values (1, 'row1'); 874insert into t45 values (2, 'row2'); 875alter table t45 rename t46; 876select * from t46; 877pk col1 8781 row1 8792 row2 880drop table t46; 881drop table t45; 882ERROR 42S02: Unknown table 'test.t45' 883# 884# Check Bulk loading 885# Bulk loading used to overwrite existing data 886# Now it fails if there is data overlap with what 887# already exists 888# 889show variables where variable_name like 'rocksdb%' and variable_name not like 'rocksdb_max_open_files'; 890Variable_name Value 891rocksdb_access_hint_on_compaction_start 1 892rocksdb_advise_random_on_open ON 893rocksdb_allow_concurrent_memtable_write OFF 894rocksdb_allow_mmap_reads OFF 895rocksdb_allow_mmap_writes OFF 896rocksdb_allow_to_start_after_corruption OFF 897rocksdb_alter_column_default_inplace ON 898rocksdb_blind_delete_primary_key OFF 899rocksdb_block_cache_size 536870912 900rocksdb_block_restart_interval 16 901rocksdb_block_size 4096 902rocksdb_block_size_deviation 10 903rocksdb_bulk_load OFF 904rocksdb_bulk_load_allow_sk OFF 905rocksdb_bulk_load_allow_unsorted OFF 906rocksdb_bulk_load_size 1000 907rocksdb_bytes_per_sync 0 908rocksdb_cache_dump ON 909rocksdb_cache_high_pri_pool_ratio 0.000000 910rocksdb_cache_index_and_filter_blocks ON 911rocksdb_cache_index_and_filter_with_high_priority ON 912rocksdb_checksums_pct 100 913rocksdb_collect_sst_properties ON 914rocksdb_commit_in_the_middle OFF 915rocksdb_commit_time_batch_for_recovery OFF 916rocksdb_compact_cf 917rocksdb_compaction_readahead_size 0 918rocksdb_compaction_sequential_deletes 0 919rocksdb_compaction_sequential_deletes_count_sd OFF 920rocksdb_compaction_sequential_deletes_file_size 0 921rocksdb_compaction_sequential_deletes_window 0 922rocksdb_concurrent_prepare ON 923rocksdb_create_checkpoint 924rocksdb_create_if_missing ON 925rocksdb_create_missing_column_families OFF 926rocksdb_datadir ./.rocksdb 927rocksdb_db_write_buffer_size 0 928rocksdb_deadlock_detect OFF 929rocksdb_deadlock_detect_depth 50 930rocksdb_debug_manual_compaction_delay 0 931rocksdb_debug_optimizer_no_zero_cardinality ON 932rocksdb_debug_ttl_ignore_pk OFF 933rocksdb_debug_ttl_read_filter_ts 0 934rocksdb_debug_ttl_rec_ts 0 935rocksdb_debug_ttl_snapshot_ts 0 936rocksdb_default_cf_options compression=kLZ4Compression;bottommost_compression=kLZ4Compression 937rocksdb_delayed_write_rate 0 938rocksdb_delete_cf 939rocksdb_delete_obsolete_files_period_micros 21600000000 940rocksdb_enable_bulk_load_api ON 941rocksdb_enable_insert_with_update_caching ON 942rocksdb_enable_iterate_bounds ON 943rocksdb_enable_native_partition OFF 944rocksdb_enable_pipelined_write OFF 945rocksdb_enable_remove_orphaned_dropped_cfs ON 946rocksdb_enable_thread_tracking ON 947rocksdb_enable_ttl ON 948rocksdb_enable_ttl_read_filtering ON 949rocksdb_enable_write_thread_adaptive_yield OFF 950rocksdb_error_if_exists OFF 951rocksdb_error_on_suboptimal_collation OFF 952rocksdb_flush_log_at_trx_commit 1 953rocksdb_force_compute_memtable_stats ON 954rocksdb_force_compute_memtable_stats_cachetime 0 955rocksdb_force_flush_memtable_and_lzero_now OFF 956rocksdb_force_flush_memtable_now OFF 957rocksdb_force_index_records_in_range 0 958rocksdb_hash_index_allow_collision ON 959rocksdb_ignore_unknown_options ON 960rocksdb_index_type kBinarySearch 961rocksdb_info_log_level error_level 962rocksdb_is_fd_close_on_exec ON 963rocksdb_keep_log_file_num 1000 964rocksdb_large_prefix OFF 965rocksdb_lock_scanned_rows OFF 966rocksdb_lock_wait_timeout 1 967rocksdb_log_file_time_to_roll 0 968rocksdb_manifest_preallocation_size 4194304 969rocksdb_manual_compaction_bottommost_level kForceOptimized 970rocksdb_manual_compaction_threads 0 971rocksdb_manual_wal_flush ON 972rocksdb_master_skip_tx_api OFF 973rocksdb_max_background_compactions -1 974rocksdb_max_background_flushes -1 975rocksdb_max_background_jobs 2 976rocksdb_max_bottom_pri_background_compactions 0 977rocksdb_max_latest_deadlocks 5 978rocksdb_max_log_file_size 0 979rocksdb_max_manifest_file_size 1073741824 980rocksdb_max_manual_compactions 10 981rocksdb_max_row_locks 1048576 982rocksdb_max_subcompactions 1 983rocksdb_max_total_wal_size 0 984rocksdb_merge_buf_size 67108864 985rocksdb_merge_combine_read_size 1073741824 986rocksdb_merge_tmp_file_removal_delay_ms 0 987rocksdb_new_table_reader_for_compaction_inputs OFF 988rocksdb_no_block_cache OFF 989rocksdb_no_create_column_family OFF 990rocksdb_override_cf_options 991rocksdb_paranoid_checks ON 992rocksdb_pause_background_work ON 993rocksdb_perf_context_level 0 994rocksdb_persistent_cache_path 995rocksdb_persistent_cache_size_mb 0 996rocksdb_pin_l0_filter_and_index_blocks_in_cache ON 997rocksdb_print_snapshot_conflict_queries OFF 998rocksdb_rate_limiter_bytes_per_sec 0 999rocksdb_read_free_rpl OFF 1000rocksdb_read_free_rpl_tables .* 1001rocksdb_records_in_range 50 1002rocksdb_reset_stats OFF 1003rocksdb_rollback_on_timeout OFF 1004rocksdb_rpl_skip_tx_api OFF 1005rocksdb_seconds_between_stat_computes 3600 1006rocksdb_signal_drop_index_thread OFF 1007rocksdb_sim_cache_size 0 1008rocksdb_skip_bloom_filter_on_read OFF 1009rocksdb_skip_fill_cache OFF 1010rocksdb_skip_locks_if_skip_unique_check OFF 1011rocksdb_sst_mgr_rate_bytes_per_sec 0 1012rocksdb_stats_dump_period_sec 600 1013rocksdb_stats_level 1 1014rocksdb_stats_recalc_rate 0 1015rocksdb_store_row_debug_checksums OFF 1016rocksdb_strict_collation_check OFF 1017rocksdb_strict_collation_exceptions 1018rocksdb_table_cache_numshardbits 6 1019rocksdb_table_stats_background_thread_nice_value 19 1020rocksdb_table_stats_max_num_rows_scanned 0 1021rocksdb_table_stats_recalc_threshold_count 100 1022rocksdb_table_stats_recalc_threshold_pct 10 1023rocksdb_table_stats_sampling_pct 10 1024rocksdb_table_stats_use_table_scan OFF 1025rocksdb_tmpdir 1026rocksdb_trace_block_cache_access 1027rocksdb_trace_queries 1028rocksdb_trace_sst_api OFF 1029rocksdb_track_and_verify_wals_in_manifest ON 1030rocksdb_two_write_queues ON 1031rocksdb_unsafe_for_binlog OFF 1032rocksdb_update_cf_options 1033rocksdb_use_adaptive_mutex OFF 1034rocksdb_use_default_sk_cf OFF 1035rocksdb_use_direct_io_for_flush_and_compaction OFF 1036rocksdb_use_direct_reads OFF 1037rocksdb_use_fsync OFF 1038rocksdb_validate_tables 1 1039rocksdb_verify_row_debug_checksums OFF 1040rocksdb_wal_bytes_per_sync 0 1041rocksdb_wal_dir 1042rocksdb_wal_recovery_mode 2 1043rocksdb_wal_size_limit_mb 0 1044rocksdb_wal_ttl_seconds 0 1045rocksdb_whole_key_filtering ON 1046rocksdb_write_batch_flush_threshold 0 1047rocksdb_write_batch_max_bytes 0 1048rocksdb_write_disable_wal OFF 1049rocksdb_write_ignore_missing_column_families OFF 1050rocksdb_write_policy write_committed 1051create table t47 (pk int primary key, col1 varchar(12)) engine=rocksdb; 1052insert into t47 values (1, 'row1'); 1053insert into t47 values (2, 'row2'); 1054set rocksdb_bulk_load=1; 1055insert into t47 values (3, 'row3'),(4, 'row4'); 1056set rocksdb_bulk_load=0; 1057connect con1,localhost,root,,; 1058set rocksdb_bulk_load=1; 1059insert into t47 values (10, 'row10'),(11, 'row11'); 1060connection default; 1061set rocksdb_bulk_load=1; 1062insert into t47 values (100, 'row100'),(101, 'row101'); 1063disconnect con1; 1064connection default; 1065set rocksdb_bulk_load=0; 1066select * from t47; 1067pk col1 10681 row1 10692 row2 10703 row3 10714 row4 107210 row10 107311 row11 1074100 row100 1075101 row101 1076drop table t47; 1077# 1078# Fix TRUNCATE over empty table (transaction is committed when it wasn't 1079# started) 1080# 1081create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb; 1082set autocommit=0; 1083truncate table t48; 1084set autocommit=1; 1085drop table t48; 1086# 1087# MDEV-4059: RocksDB: query waiting for a lock cannot be killed until query timeout exceeded 1088# 1089create table t49 (pk int primary key, a int) engine=RocksDB; 1090insert into t49 values (1,10),(2,20); 1091begin; 1092update t49 set a = 100 where pk = 1; 1093connect con1,localhost,root,,; 1094set rocksdb_lock_wait_timeout=60; 1095set @var1= to_seconds(now()); 1096update t49 set a = 1000 where pk = 1; 1097connect con2,localhost,root,,; 1098kill query $con1_id; 1099connection con1; 1100ERROR 70100: Query execution was interrupted 1101set @var2= to_seconds(now()); 1102select if ((@var2 - @var1) < 60, "passed", (@var2 - @var1)) as 'result'; 1103result 1104passed 1105connection default; 1106disconnect con1; 1107disconnect con2; 1108commit; 1109drop table t49; 1110# 1111# Index-only tests for INT-based columns 1112# 1113create table t1 (pk int primary key, key1 int, col1 int, key(key1)) engine=rocksdb; 1114insert into t1 values (1,1,1); 1115insert into t1 values (2,2,2); 1116insert into t1 values (-5,-5,-5); 1117# INT column uses index-only: 1118explain 1119select key1 from t1 where key1=2; 1120id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11211 SIMPLE t1 NULL ref key1 key1 5 const # 100.00 Using index 1122Warnings: 1123Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1` from `test`.`t1` where (`test`.`t1`.`key1` = 2) 1124select key1 from t1 where key1=2; 1125key1 11262 1127select key1 from t1 where key1=-5; 1128key1 1129-5 1130drop table t1; 1131create table t2 (pk int primary key, key1 int unsigned, col1 int, key(key1)) engine=rocksdb; 1132insert into t2 values (1,1,1), (2,2,2); 1133# INT UNSIGNED column uses index-only: 1134explain 1135select key1 from t2 where key1=2; 1136id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11371 SIMPLE t2 NULL ref key1 key1 5 const # 100.00 Using index 1138Warnings: 1139Note 1003 /* select#1 */ select `test`.`t2`.`key1` AS `key1` from `test`.`t2` where (`test`.`t2`.`key1` = 2) 1140select key1 from t2 where key1=2; 1141key1 11422 1143drop table t2; 1144create table t3 (pk bigint primary key, key1 bigint, col1 int, key(key1)) engine=rocksdb; 1145insert into t3 values (1,1,1), (2,2,2); 1146# BIGINT uses index-only: 1147explain 1148select key1 from t3 where key1=2; 1149id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11501 SIMPLE t3 NULL ref key1 key1 9 const # 100.00 Using index 1151Warnings: 1152Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1` from `test`.`t3` where (`test`.`t3`.`key1` = 2) 1153select key1 from t3 where key1=2; 1154key1 11552 1156drop table t3; 1157# 1158# Index-only reads for string columns 1159# 1160create table t1 ( 1161pk int primary key, 1162key1 char(10) character set binary, 1163col1 int, 1164key (key1) 1165) engine=rocksdb; 1166insert into t1 values(1, 'one',11), (2,'two',22); 1167explain 1168select key1 from t1 where key1='one'; 1169id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11701 SIMPLE t1 NULL ref key1 key1 11 const # 100.00 Using where; Using index 1171Warnings: 1172Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1` from `test`.`t1` where (`test`.`t1`.`key1` = 'one') 1173# The following will produce no rows. This looks like a bug, 1174# but it is actually correct behavior. Binary strings are end-padded 1175# with \0 character (and not space). Comparison does not ignore 1176# the tail of \0. 1177select key1 from t1 where key1='one'; 1178key1 1179explain 1180select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0'; 1181id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11821 SIMPLE t1 NULL ref key1 key1 11 const # 100.00 Using where; Using index 1183Warnings: 1184Note 1003 /* select#1 */ select hex(`test`.`t1`.`key1`) AS `hex(key1)` from `test`.`t1` where (`test`.`t1`.`key1` = 'one\0\0\0\0\0\0\0') 1185select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0'; 1186hex(key1) 11876F6E6500000000000000 1188drop table t1; 1189create table t2 ( 1190pk int primary key, 1191key1 char(10) collate latin1_bin, 1192col1 int, 1193key (key1) 1194) engine=rocksdb; 1195insert into t2 values(1, 'one',11), (2,'two',22); 1196explain 1197select key1 from t2 where key1='one'; 1198id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11991 SIMPLE t2 NULL ref key1 key1 11 const # 100.00 Using index 1200Warnings: 1201Note 1003 /* select#1 */ select `test`.`t2`.`key1` AS `key1` from `test`.`t2` where (`test`.`t2`.`key1` = 'one') 1202select key1 from t2 where key1='one'; 1203key1 1204one 1205drop table t2; 1206create table t3 ( 1207pk int primary key, 1208key1 char(10) collate utf8_bin, 1209col1 int, 1210key (key1) 1211) engine=rocksdb; 1212insert into t3 values(1, 'one',11), (2,'two',22); 1213explain 1214select key1 from t3 where key1='one'; 1215id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12161 SIMPLE t3 NULL ref key1 key1 31 const # 100.00 Using index 1217Warnings: 1218Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1` from `test`.`t3` where (`test`.`t3`.`key1` = 'one') 1219select key1 from t3 where key1='one'; 1220key1 1221one 1222drop table t3; 1223# a VARCHAR column 1224create table t4 ( 1225pk int primary key, 1226key1 varchar(10) collate latin1_bin, 1227key(key1) 1228) engine=rocksdb; 1229insert into t4 values(1, 'one'), (2,'two'),(3,'threee'),(55,'fifty-five'); 1230explain 1231select key1 from t4 where key1='two'; 1232id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12331 SIMPLE t4 NULL ref key1 key1 13 const # 100.00 Using index 1234Warnings: 1235Note 1003 /* select#1 */ select `test`.`t4`.`key1` AS `key1` from `test`.`t4` where (`test`.`t4`.`key1` = 'two') 1236select key1 from t4 where key1='two'; 1237key1 1238two 1239select key1 from t4 where key1='fifty-five'; 1240key1 1241fifty-five 1242explain 1243select key1 from t4 where key1 between 's' and 'u'; 1244id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12451 SIMPLE t4 NULL range key1 key1 13 NULL # 100.00 Using where; Using index 1246Warnings: 1247Note 1003 /* select#1 */ select `test`.`t4`.`key1` AS `key1` from `test`.`t4` where (`test`.`t4`.`key1` between 's' and 'u') 1248select key1 from t4 where key1 between 's' and 'u'; 1249key1 1250threee 1251two 1252drop table t4; 1253# 1254# MDEV-4305: RocksDB: Assertion `((keypart_map + 1) & keypart_map) == 0' fails in calculate_key_len 1255# 1256CREATE TABLE t1 (pk1 INT, pk2 CHAR(32), i INT, PRIMARY KEY(pk1,pk2), KEY(i)) ENGINE=RocksDB; 1257INSERT INTO t1 VALUES (1,'test1',6),(2,'test2',8); 1258SELECT * FROM t1 WHERE i != 3 OR pk1 > 9; 1259pk1 pk2 i 12601 test1 6 12612 test2 8 1262DROP TABLE t1; 1263# 1264# MDEV-4298: RocksDB: Assertion `thd->is_error() || kill_errno' fails in ha_rows filesort 1265# 1266CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB; 1267INSERT INTO t1 VALUES (1,1),(2,2); 1268set @orig_tx_iso=@@session.transaction_isolation; 1269set session transaction_isolation='READ-COMMITTED'; 1270BEGIN; 1271UPDATE t1 SET i = 100; 1272connect con1,localhost,root,,test; 1273DELETE IGNORE FROM t1 ORDER BY i; 1274ERROR HY000: Lock wait timeout exceeded; try restarting transaction 1275disconnect con1; 1276connection default; 1277COMMIT; 1278set session transaction_isolation=@orig_tx_iso; 1279DROP TABLE t1; 1280# 1281# MDEV-4324: RocksDB: Valgrind "Use of uninitialised value" warnings on inserting value into varchar field 1282# (testcase only) 1283# 1284CREATE TABLE t1 (pk INT PRIMARY KEY, c VARCHAR(4)) ENGINE=RocksDB; 1285INSERT INTO t1 VALUES (1,'foo'), (2,'bar'); 1286DROP TABLE t1; 1287# 1288# MDEV-4304: RocksDB: Index-only scan by a field with utf8_bin collation returns garbage symbols 1289# 1290CREATE TABLE t1 (pk INT PRIMARY KEY, c1 CHAR(1), c2 CHAR(1), KEY(c1)) ENGINE=RocksDB CHARSET utf8 COLLATE utf8_bin; 1291INSERT INTO t1 VALUES (1,'h','h'); 1292SELECT * FROM t1; 1293pk c1 c2 12941 h h 1295SELECT c1 FROM t1; 1296c1 1297h 1298DROP TABLE t1; 1299# 1300# MDEV-4300: RocksDB: Server crashes in inline_mysql_mutex_lock on SELECT .. FOR UPDATE 1301# 1302CREATE TABLE t2 (pk INT PRIMARY KEY, i INT, KEY (i)) ENGINE=RocksDB; 1303INSERT INTO t2 VALUES (1,4),(2,5); 1304SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE; 13051 1306DROP TABLE t2; 1307# 1308# MDEV-4301: RocksDB: Assertion `pack_info != __null' fails in Rdb_key_def::unpack_record 1309# 1310CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, c CHAR(1), KEY(c,i)) ENGINE=RocksDB; 1311INSERT INTO t1 VALUES (1,4,'d'),(2,8,'e'); 1312SELECT MAX( pk ) FROM t1 WHERE i = 105 AND c = 'h'; 1313MAX( pk ) 1314NULL 1315DROP TABLE t1; 1316# 1317# MDEV-4337: RocksDB: Inconsistent results comparing a char field with an int field 1318# 1319create table t1 (c char(1), i int, primary key(c), key(i)) engine=RocksDB; 1320insert into t1 values ('2',2),('6',6); 1321select * from t1 where c = i; 1322c i 13232 2 13246 6 1325select * from t1 ignore index (i) where c = i; 1326c i 13272 2 13286 6 1329drop table t1; 1330# 1331# Test statement rollback inside a transaction 1332# 1333create table t1 (pk varchar(12) primary key) engine=rocksdb; 1334insert into t1 values ('old-val1'),('old-val2'); 1335create table t2 (pk varchar(12) primary key) engine=rocksdb; 1336insert into t2 values ('new-val2'),('old-val1'); 1337set @orig_tx_iso=@@session.transaction_isolation; 1338set session transaction_isolation='READ-COMMITTED'; 1339begin; 1340insert into t1 values ('new-val1'); 1341insert into t1 select * from t2; 1342ERROR 23000: Duplicate entry 'old-val1' for key 'PRIMARY' 1343commit; 1344set session transaction_isolation=@orig_tx_iso; 1345select * from t1; 1346pk 1347new-val1 1348old-val1 1349old-val2 1350drop table t1, t2; 1351# 1352# MDEV-4383: RocksDB: Wrong result of DELETE .. ORDER BY .. LIMIT: 1353# rows that should be deleted remain in the table 1354# 1355CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB; 1356CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB; 1357INSERT INTO t1 (pk) VALUES (NULL),(NULL); 1358set @orig_tx_iso=@@session.transaction_isolation; 1359set session transaction_isolation='READ-COMMITTED'; 1360BEGIN; 1361INSERT INTO t2 (pk) VALUES (NULL),(NULL); 1362INSERT INTO t1 (pk) VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); 1363SELECT * FROM t1 ORDER BY pk LIMIT 9; 1364pk 13651 13662 13673 13684 13695 13706 13717 13728 1373affected rows: 8 1374DELETE FROM t1 ORDER BY pk LIMIT 9; 1375affected rows: 8 1376SELECT * FROM t1 ORDER BY pk LIMIT 9; 1377pk 1378affected rows: 0 1379COMMIT; 1380DROP TABLE t1,t2; 1381set session transaction_isolation=@orig_tx_iso; 1382# 1383# MDEV-4374: RocksDB: Valgrind warnings 'Use of uninitialised value' on 1384# inserting into a varchar column 1385# 1386CREATE TABLE t1 (pk INT PRIMARY KEY, a VARCHAR(32)) ENGINE=ROCKSDB; 1387INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); 1388DROP TABLE t1; 1389# 1390# MDEV-4061: RocksDB: Changes from an interrupted query are still applied 1391# 1392create table t1 (pk int primary key, a int) engine=rocksdb; 1393insert into t1 values (1,10),(2,20); 1394set autocommit = 1; 1395update t1 set a = sleep(300) where pk = 1;; 1396connect con1,localhost,root,,; 1397kill query $con_id; 1398connection default; 1399ERROR 70100: Query execution was interrupted 1400select * from t1; 1401pk a 14021 10 14032 20 1404disconnect con1; 1405drop table t1; 1406# 1407# MDEV-4099: RocksDB: Wrong results with index and range access after INSERT IGNORE or REPLACE 1408# 1409CREATE TABLE t1 (pk INT PRIMARY KEY, a SMALLINT, b INT, KEY (a)) ENGINE=RocksDB; 1410INSERT IGNORE INTO t1 VALUES (1, 157, 0), (2, 1898, -504403), (1, -14659, 0); 1411Warnings: 1412Warning 1062 Duplicate entry '1' for key 'PRIMARY' 1413SELECT * FROM t1; 1414pk a b 14151 157 0 14162 1898 -504403 1417SELECT pk FROM t1; 1418pk 14191 14202 1421SELECT * FROM t1 WHERE a != 97; 1422pk a b 14231 157 0 14242 1898 -504403 1425DROP TABLE t1; 1426# 1427# Test @@rocksdb_max_row_locks 1428# 1429CREATE TABLE t1 (pk INT PRIMARY KEY, a int) ENGINE=RocksDB; 1430set @a=-1; 1431insert into t1 select (@a:=@a+1), 1234 from performance_schema.session_variables limit 100; 1432set @tmp1= @@rocksdb_max_row_locks; 1433set GLOBAL rocksdb_max_row_locks= 20; 1434update t1 set a=a+10; 1435ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB 1436set @@global.rocksdb_max_row_locks = @tmp1; 1437DROP TABLE t1; 1438# 1439# Test AUTO_INCREMENT behavior problem, 1440# "explicit insert into an auto-inc column is not noticed by RocksDB" 1441# 1442create table t1 (i int primary key auto_increment) engine=RocksDB; 1443insert into t1 values (null); 1444insert into t1 values (null); 1445select * from t1; 1446i 14471 14482 1449drop table t1; 1450create table t2 (i int primary key auto_increment) engine=RocksDB; 1451insert into t2 values (1); 1452select * from t2; 1453i 14541 1455# this fails (ie. used to fail), RocksDB engine did not notice use of '1' above 1456insert into t2 values (null); 1457select * from t2; 1458i 14591 14602 1461# but then this succeeds, so previous statement must have incremented next number counter 1462insert into t2 values (null); 1463select * from t2; 1464i 14651 14662 14673 1468drop table t2; 1469# 1470# Fix Issue#2: AUTO_INCREMENT value doesn't survive server shutdown 1471# 1472create table t1 (i int primary key auto_increment) engine=RocksDB; 1473insert into t1 values (null); 1474insert into t1 values (null); 1475SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; 1476# restart 1477SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK; 1478SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1; 1479insert into t1 values (null); 1480select * from t1; 1481i 14821 14832 14843 1485drop table t1; 1486# 1487# Fix Issue #3: SHOW TABLE STATUS shows Auto_increment=0 1488# 1489create table t1 (i int primary key auto_increment) engine=RocksDB; 1490insert into t1 values (null),(null); 1491show table status like 't1'; 1492Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment 1493t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL 1494drop table t1; 1495# 1496# Fix Issue #4: Crash when using pseudo-unique keys 1497# 1498CREATE TABLE t1 ( 1499i INT, 1500t TINYINT, 1501s SMALLINT, 1502m MEDIUMINT, 1503b BIGINT, 1504pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY, 1505UNIQUE KEY b_t (b,t) 1506) ENGINE=rocksdb; 1507INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16); 1508SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t; 1509b+t 15109 151111 151225 151327 151429 1515207 151610107 1517100000000000000100 15181000000000000000100 1519DROP TABLE t1; 1520# 1521# Fix issue #5: Transaction rollback doesn't undo all changes. 1522# 1523create table t0 (a int) engine=myisam; 1524insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1525create table t1 (id int auto_increment primary key, value int) engine=rocksdb; 1526set autocommit=0; 1527begin; 1528set @a:=0; 1529insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1530insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1531insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1532rollback; 1533select count(*) from t1; 1534count(*) 15350 1536set autocommit=1; 1537drop table t0, t1; 1538# 1539# Check status variables 1540# NOTE: We exclude rocksdb_num_get_for_update_calls because it's a debug only status var 1541# 1542show status where variable_name like 'rocksdb%' and variable_name not like '%num_get_for_update%'; 1543Variable_name Value 1544rocksdb_rows_deleted # 1545rocksdb_rows_deleted_blind # 1546rocksdb_rows_inserted # 1547rocksdb_rows_read # 1548rocksdb_rows_updated # 1549rocksdb_rows_expired # 1550rocksdb_rows_filtered # 1551rocksdb_system_rows_deleted # 1552rocksdb_system_rows_inserted # 1553rocksdb_system_rows_read # 1554rocksdb_system_rows_updated # 1555rocksdb_memtable_total # 1556rocksdb_memtable_unflushed # 1557rocksdb_queries_point # 1558rocksdb_queries_range # 1559rocksdb_table_index_stats_success # 1560rocksdb_table_index_stats_failure # 1561rocksdb_table_index_stats_req_queue_length # 1562rocksdb_covered_secondary_key_lookups # 1563rocksdb_additional_compaction_triggers # 1564rocksdb_block_cache_add # 1565rocksdb_block_cache_add_failures # 1566rocksdb_block_cache_bytes_read # 1567rocksdb_block_cache_bytes_write # 1568rocksdb_block_cache_compressed_hit # 1569rocksdb_block_cache_compressed_miss # 1570rocksdb_block_cache_data_add # 1571rocksdb_block_cache_data_bytes_insert # 1572rocksdb_block_cache_data_hit # 1573rocksdb_block_cache_data_miss # 1574rocksdb_block_cache_filter_add # 1575rocksdb_block_cache_filter_bytes_evict # 1576rocksdb_block_cache_filter_bytes_insert # 1577rocksdb_block_cache_filter_hit # 1578rocksdb_block_cache_filter_miss # 1579rocksdb_block_cache_hit # 1580rocksdb_block_cache_index_add # 1581rocksdb_block_cache_index_bytes_evict # 1582rocksdb_block_cache_index_bytes_insert # 1583rocksdb_block_cache_index_hit # 1584rocksdb_block_cache_index_miss # 1585rocksdb_block_cache_miss # 1586rocksdb_bloom_filter_full_positive # 1587rocksdb_bloom_filter_full_true_positive # 1588rocksdb_bloom_filter_prefix_checked # 1589rocksdb_bloom_filter_prefix_useful # 1590rocksdb_bloom_filter_useful # 1591rocksdb_bytes_read # 1592rocksdb_bytes_written # 1593rocksdb_compact_read_bytes # 1594rocksdb_compact_write_bytes # 1595rocksdb_compaction_key_drop_new # 1596rocksdb_compaction_key_drop_obsolete # 1597rocksdb_compaction_key_drop_user # 1598rocksdb_flush_write_bytes # 1599rocksdb_get_hit_l0 # 1600rocksdb_get_hit_l1 # 1601rocksdb_get_hit_l2_and_up # 1602rocksdb_get_updates_since_calls # 1603rocksdb_iter_bytes_read # 1604rocksdb_manual_compactions_processed # 1605rocksdb_manual_compactions_running # 1606rocksdb_memtable_hit # 1607rocksdb_memtable_miss # 1608rocksdb_no_file_closes # 1609rocksdb_no_file_errors # 1610rocksdb_no_file_opens # 1611rocksdb_num_iterators # 1612rocksdb_number_block_not_compressed # 1613rocksdb_number_db_next # 1614rocksdb_number_db_next_found # 1615rocksdb_number_db_prev # 1616rocksdb_number_db_prev_found # 1617rocksdb_number_db_seek # 1618rocksdb_number_db_seek_found # 1619rocksdb_number_deletes_filtered # 1620rocksdb_number_keys_read # 1621rocksdb_number_keys_updated # 1622rocksdb_number_keys_written # 1623rocksdb_number_merge_failures # 1624rocksdb_number_multiget_bytes_read # 1625rocksdb_number_multiget_get # 1626rocksdb_number_multiget_keys_read # 1627rocksdb_number_reseeks_iteration # 1628rocksdb_number_sst_entry_delete # 1629rocksdb_number_sst_entry_merge # 1630rocksdb_number_sst_entry_other # 1631rocksdb_number_sst_entry_put # 1632rocksdb_number_sst_entry_singledelete # 1633rocksdb_number_superversion_acquires # 1634rocksdb_number_superversion_cleanups # 1635rocksdb_number_superversion_releases # 1636rocksdb_row_lock_deadlocks # 1637rocksdb_row_lock_wait_timeouts # 1638rocksdb_snapshot_conflict_errors # 1639rocksdb_stall_l0_file_count_limit_slowdowns # 1640rocksdb_stall_locked_l0_file_count_limit_slowdowns # 1641rocksdb_stall_l0_file_count_limit_stops # 1642rocksdb_stall_locked_l0_file_count_limit_stops # 1643rocksdb_stall_pending_compaction_limit_stops # 1644rocksdb_stall_pending_compaction_limit_slowdowns # 1645rocksdb_stall_memtable_limit_stops # 1646rocksdb_stall_memtable_limit_slowdowns # 1647rocksdb_stall_total_stops # 1648rocksdb_stall_total_slowdowns # 1649rocksdb_stall_micros # 1650rocksdb_wal_bytes # 1651rocksdb_wal_group_syncs # 1652rocksdb_wal_synced # 1653rocksdb_write_other # 1654rocksdb_write_self # 1655rocksdb_write_timedout # 1656rocksdb_write_wal # 1657select VARIABLE_NAME from performance_schema.global_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%'; 1658VARIABLE_NAME 1659rocksdb_rows_deleted 1660rocksdb_rows_deleted_blind 1661rocksdb_rows_inserted 1662rocksdb_rows_read 1663rocksdb_rows_updated 1664rocksdb_rows_expired 1665rocksdb_rows_filtered 1666rocksdb_system_rows_deleted 1667rocksdb_system_rows_inserted 1668rocksdb_system_rows_read 1669rocksdb_system_rows_updated 1670rocksdb_memtable_total 1671rocksdb_memtable_unflushed 1672rocksdb_queries_point 1673rocksdb_queries_range 1674rocksdb_table_index_stats_success 1675rocksdb_table_index_stats_failure 1676rocksdb_table_index_stats_req_queue_length 1677rocksdb_covered_secondary_key_lookups 1678rocksdb_additional_compaction_triggers 1679rocksdb_block_cache_add 1680rocksdb_block_cache_add_failures 1681rocksdb_block_cache_bytes_read 1682rocksdb_block_cache_bytes_write 1683rocksdb_block_cache_compressed_hit 1684rocksdb_block_cache_compressed_miss 1685rocksdb_block_cache_data_add 1686rocksdb_block_cache_data_bytes_insert 1687rocksdb_block_cache_data_hit 1688rocksdb_block_cache_data_miss 1689rocksdb_block_cache_filter_add 1690rocksdb_block_cache_filter_bytes_evict 1691rocksdb_block_cache_filter_bytes_insert 1692rocksdb_block_cache_filter_hit 1693rocksdb_block_cache_filter_miss 1694rocksdb_block_cache_hit 1695rocksdb_block_cache_index_add 1696rocksdb_block_cache_index_bytes_evict 1697rocksdb_block_cache_index_bytes_insert 1698rocksdb_block_cache_index_hit 1699rocksdb_block_cache_index_miss 1700rocksdb_block_cache_miss 1701rocksdb_bloom_filter_full_positive 1702rocksdb_bloom_filter_full_true_positive 1703rocksdb_bloom_filter_prefix_checked 1704rocksdb_bloom_filter_prefix_useful 1705rocksdb_bloom_filter_useful 1706rocksdb_bytes_read 1707rocksdb_bytes_written 1708rocksdb_compact_read_bytes 1709rocksdb_compact_write_bytes 1710rocksdb_compaction_key_drop_new 1711rocksdb_compaction_key_drop_obsolete 1712rocksdb_compaction_key_drop_user 1713rocksdb_flush_write_bytes 1714rocksdb_get_hit_l0 1715rocksdb_get_hit_l1 1716rocksdb_get_hit_l2_and_up 1717rocksdb_get_updates_since_calls 1718rocksdb_iter_bytes_read 1719rocksdb_manual_compactions_processed 1720rocksdb_manual_compactions_running 1721rocksdb_memtable_hit 1722rocksdb_memtable_miss 1723rocksdb_no_file_closes 1724rocksdb_no_file_errors 1725rocksdb_no_file_opens 1726rocksdb_num_iterators 1727rocksdb_number_block_not_compressed 1728rocksdb_number_db_next 1729rocksdb_number_db_next_found 1730rocksdb_number_db_prev 1731rocksdb_number_db_prev_found 1732rocksdb_number_db_seek 1733rocksdb_number_db_seek_found 1734rocksdb_number_deletes_filtered 1735rocksdb_number_keys_read 1736rocksdb_number_keys_updated 1737rocksdb_number_keys_written 1738rocksdb_number_merge_failures 1739rocksdb_number_multiget_bytes_read 1740rocksdb_number_multiget_get 1741rocksdb_number_multiget_keys_read 1742rocksdb_number_reseeks_iteration 1743rocksdb_number_sst_entry_delete 1744rocksdb_number_sst_entry_merge 1745rocksdb_number_sst_entry_other 1746rocksdb_number_sst_entry_put 1747rocksdb_number_sst_entry_singledelete 1748rocksdb_number_superversion_acquires 1749rocksdb_number_superversion_cleanups 1750rocksdb_number_superversion_releases 1751rocksdb_row_lock_deadlocks 1752rocksdb_row_lock_wait_timeouts 1753rocksdb_snapshot_conflict_errors 1754rocksdb_stall_l0_file_count_limit_slowdowns 1755rocksdb_stall_locked_l0_file_count_limit_slowdowns 1756rocksdb_stall_l0_file_count_limit_stops 1757rocksdb_stall_locked_l0_file_count_limit_stops 1758rocksdb_stall_pending_compaction_limit_stops 1759rocksdb_stall_pending_compaction_limit_slowdowns 1760rocksdb_stall_memtable_limit_stops 1761rocksdb_stall_memtable_limit_slowdowns 1762rocksdb_stall_total_stops 1763rocksdb_stall_total_slowdowns 1764rocksdb_stall_micros 1765rocksdb_wal_bytes 1766rocksdb_wal_group_syncs 1767rocksdb_wal_synced 1768rocksdb_write_other 1769rocksdb_write_self 1770rocksdb_write_timedout 1771rocksdb_write_wal 1772# RocksDB-SE's status variables are global internally 1773# but they are shown as both session and global, like InnoDB's status vars. 1774select VARIABLE_NAME from performance_schema.session_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%'; 1775VARIABLE_NAME 1776rocksdb_rows_deleted 1777rocksdb_rows_deleted_blind 1778rocksdb_rows_inserted 1779rocksdb_rows_read 1780rocksdb_rows_updated 1781rocksdb_rows_expired 1782rocksdb_rows_filtered 1783rocksdb_system_rows_deleted 1784rocksdb_system_rows_inserted 1785rocksdb_system_rows_read 1786rocksdb_system_rows_updated 1787rocksdb_memtable_total 1788rocksdb_memtable_unflushed 1789rocksdb_queries_point 1790rocksdb_queries_range 1791rocksdb_table_index_stats_success 1792rocksdb_table_index_stats_failure 1793rocksdb_table_index_stats_req_queue_length 1794rocksdb_covered_secondary_key_lookups 1795rocksdb_additional_compaction_triggers 1796rocksdb_block_cache_add 1797rocksdb_block_cache_add_failures 1798rocksdb_block_cache_bytes_read 1799rocksdb_block_cache_bytes_write 1800rocksdb_block_cache_compressed_hit 1801rocksdb_block_cache_compressed_miss 1802rocksdb_block_cache_data_add 1803rocksdb_block_cache_data_bytes_insert 1804rocksdb_block_cache_data_hit 1805rocksdb_block_cache_data_miss 1806rocksdb_block_cache_filter_add 1807rocksdb_block_cache_filter_bytes_evict 1808rocksdb_block_cache_filter_bytes_insert 1809rocksdb_block_cache_filter_hit 1810rocksdb_block_cache_filter_miss 1811rocksdb_block_cache_hit 1812rocksdb_block_cache_index_add 1813rocksdb_block_cache_index_bytes_evict 1814rocksdb_block_cache_index_bytes_insert 1815rocksdb_block_cache_index_hit 1816rocksdb_block_cache_index_miss 1817rocksdb_block_cache_miss 1818rocksdb_bloom_filter_full_positive 1819rocksdb_bloom_filter_full_true_positive 1820rocksdb_bloom_filter_prefix_checked 1821rocksdb_bloom_filter_prefix_useful 1822rocksdb_bloom_filter_useful 1823rocksdb_bytes_read 1824rocksdb_bytes_written 1825rocksdb_compact_read_bytes 1826rocksdb_compact_write_bytes 1827rocksdb_compaction_key_drop_new 1828rocksdb_compaction_key_drop_obsolete 1829rocksdb_compaction_key_drop_user 1830rocksdb_flush_write_bytes 1831rocksdb_get_hit_l0 1832rocksdb_get_hit_l1 1833rocksdb_get_hit_l2_and_up 1834rocksdb_get_updates_since_calls 1835rocksdb_iter_bytes_read 1836rocksdb_manual_compactions_processed 1837rocksdb_manual_compactions_running 1838rocksdb_memtable_hit 1839rocksdb_memtable_miss 1840rocksdb_no_file_closes 1841rocksdb_no_file_errors 1842rocksdb_no_file_opens 1843rocksdb_num_iterators 1844rocksdb_number_block_not_compressed 1845rocksdb_number_db_next 1846rocksdb_number_db_next_found 1847rocksdb_number_db_prev 1848rocksdb_number_db_prev_found 1849rocksdb_number_db_seek 1850rocksdb_number_db_seek_found 1851rocksdb_number_deletes_filtered 1852rocksdb_number_keys_read 1853rocksdb_number_keys_updated 1854rocksdb_number_keys_written 1855rocksdb_number_merge_failures 1856rocksdb_number_multiget_bytes_read 1857rocksdb_number_multiget_get 1858rocksdb_number_multiget_keys_read 1859rocksdb_number_reseeks_iteration 1860rocksdb_number_sst_entry_delete 1861rocksdb_number_sst_entry_merge 1862rocksdb_number_sst_entry_other 1863rocksdb_number_sst_entry_put 1864rocksdb_number_sst_entry_singledelete 1865rocksdb_number_superversion_acquires 1866rocksdb_number_superversion_cleanups 1867rocksdb_number_superversion_releases 1868rocksdb_row_lock_deadlocks 1869rocksdb_row_lock_wait_timeouts 1870rocksdb_snapshot_conflict_errors 1871rocksdb_stall_l0_file_count_limit_slowdowns 1872rocksdb_stall_locked_l0_file_count_limit_slowdowns 1873rocksdb_stall_l0_file_count_limit_stops 1874rocksdb_stall_locked_l0_file_count_limit_stops 1875rocksdb_stall_pending_compaction_limit_stops 1876rocksdb_stall_pending_compaction_limit_slowdowns 1877rocksdb_stall_memtable_limit_stops 1878rocksdb_stall_memtable_limit_slowdowns 1879rocksdb_stall_total_stops 1880rocksdb_stall_total_slowdowns 1881rocksdb_stall_micros 1882rocksdb_wal_bytes 1883rocksdb_wal_group_syncs 1884rocksdb_wal_synced 1885rocksdb_write_other 1886rocksdb_write_self 1887rocksdb_write_timedout 1888rocksdb_write_wal 1889# 1890# Fix issue #9: HA_ERR_INTERNAL_ERROR when running linkbench 1891# 1892create table t0 (a int) engine=myisam; 1893insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1894create table t1 ( 1895pk int primary key, 1896col1 varchar(255), 1897key(col1) 1898) engine=rocksdb; 1899insert into t1 select a, repeat('123456789ABCDEF-', 15) from t0; 1900select * from t1 where pk=3; 1901pk col1 19023 123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF- 1903drop table t0, t1; 1904# 1905# Fix issue #10: Segfault in Rdb_key_def::get_primary_key_tuple 1906# 1907create table t0 (a int) engine=myisam; 1908insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1909CREATE TABLE t1 ( 1910id1 bigint(20) unsigned NOT NULL DEFAULT '0', 1911id2 bigint(20) unsigned NOT NULL DEFAULT '0', 1912link_type bigint(20) unsigned NOT NULL DEFAULT '0', 1913visibility tinyint(3) NOT NULL DEFAULT '0', 1914data varchar(255) NOT NULL DEFAULT '', 1915time bigint(20) unsigned NOT NULL DEFAULT '0', 1916version int(11) unsigned NOT NULL DEFAULT '0', 1917PRIMARY KEY (link_type,id1,id2) 1918) engine=rocksdb; 1919insert into t1 select a,a,a,1,a,a,a from t0; 1920alter table t1 add index id1_type (id1,link_type,visibility,time,version,data); 1921select * from t1 where id1 = 3; 1922id1 id2 link_type visibility data time version 19233 3 3 1 3 3 3 1924drop table t0,t1; 1925# 1926# Test column families 1927# 1928create table t1 ( 1929pk int primary key, 1930col1 int, 1931col2 int, 1932key(col1) comment 'cf3', 1933key(col2) comment 'cf4' 1934) engine=rocksdb; 1935insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); 1936explain 1937select * from t1 where col1=2; 1938id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19391 SIMPLE t1 NULL ref col1 col1 5 const # 100.00 NULL 1940Warnings: 1941Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` = 2) 1942select * from t1 where col1=2; 1943pk col1 col2 19442 2 2 1945explain 1946select * from t1 where col2=3; 1947id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19481 SIMPLE t1 NULL ref col2 col2 5 const # 100.00 NULL 1949Warnings: 1950Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col2` = 3) 1951select * from t1 where col2=3; 1952pk col1 col2 19533 3 3 1954select * from t1 where pk=4; 1955pk col1 col2 19564 4 4 1957drop table t1; 1958# 1959# Try primary key in a non-default CF: 1960# 1961create table t1 ( 1962pk int, 1963col1 int, 1964col2 int, 1965key(col1) comment 'cf3', 1966key(col2) comment 'cf4', 1967primary key (pk) comment 'cf5' 1968) engine=rocksdb; 1969insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); 1970explain 1971select * from t1 where col1=2; 1972id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19731 SIMPLE t1 NULL ref col1 col1 5 const # 100.00 NULL 1974Warnings: 1975Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`col1` AS `col1`,`test`.`t1`.`col2` AS `col2` from `test`.`t1` where (`test`.`t1`.`col1` = 2) 1976select * from t1 where col1=2; 1977pk col1 col2 19782 2 2 1979select * from t1 where pk=4; 1980pk col1 col2 19814 4 4 1982drop table t1; 1983# 1984# Issue #15: SIGSEGV from reading in blob data 1985# 1986CREATE TABLE t1 ( 1987id int not null, 1988blob_col text, 1989PRIMARY KEY (id) 1990) ENGINE=ROCKSDB CHARSET=latin1; 1991INSERT INTO t1 SET id=123, blob_col=repeat('z',64000) ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col); 1992INSERT INTO t1 SET id=123, blob_col='' ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col); 1993DROP TABLE t1; 1994# 1995# Issue #17: Automatic per-index column families 1996# (Now deprecated) 1997# 1998create table t1 ( 1999id int not null, 2000key1 int, 2001PRIMARY KEY (id), 2002index (key1) comment '$per_index_cf' 2003) engine=rocksdb; 2004ERROR HY000: The per-index column family option has been deprecated. 2005# 2006# Issue #22: SELECT ... FOR UPDATE takes a long time 2007# 2008create table t0 (a int) engine=myisam; 2009insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2010create table t1 ( 2011id1 int, 2012id2 int, 2013value1 int, 2014value2 int, 2015primary key(id1, id2) COMMENT 'new_column_family', 2016key(id2) 2017) engine=rocksdb default charset=latin1 collate=latin1_bin; 2018insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B; 2019explain 2020select * from t1 where id1=30 and value1=30 for update; 2021id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20221 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 const # 10.00 Using where 2023Warnings: 2024Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`id2` AS `id2`,`test`.`t1`.`value1` AS `value1`,`test`.`t1`.`value2` AS `value2` from `test`.`t1` where ((`test`.`t1`.`value1` = 30) and (`test`.`t1`.`id1` = 30)) 2025set @var1=(select variable_value 2026from performance_schema.global_status 2027where variable_name='rocksdb_number_keys_read'); 2028select * from t1 where id1=3 and value1=3 for update; 2029id1 id2 value1 value2 2030set @var2=(select variable_value 2031from performance_schema.global_status 2032where variable_name='rocksdb_number_keys_read'); 2033# The following must return true (before the fix, the difference was 70): 2034select if((@var2 - @var1) < 30, 1, @var2-@var1); 2035if((@var2 - @var1) < 30, 1, @var2-@var1) 20361 2037drop table t0,t1; 2038# 2039# Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting 2040# 2041create table t1 (id int primary key, value int) engine=rocksdb; 2042insert into t1 values (1,1),(2,2),(3,3); 2043# The following must not use 'Using filesort': 2044explain select * from t1 ORDER BY id; 2045id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20461 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 NULL 2047Warnings: 2048Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`value` AS `value` from `test`.`t1` order by `test`.`t1`.`id` 2049drop table t1; 2050# 2051# Issue #26: Index-only scans for DATETIME and TIMESTAMP 2052# 2053create table t0 (a int) engine=myisam; 2054insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2055# Try a DATETIME column: 2056create table t1 ( 2057pk int auto_increment primary key, 2058kp1 datetime, 2059kp2 int, 2060col1 int, 2061key(kp1, kp2) 2062) engine=rocksdb; 2063insert into t1 (kp1,kp2) 2064select date_add('2015-01-01 12:34:56', interval a day), a from t0; 2065select * from t1; 2066pk kp1 kp2 col1 20671 2015-01-01 12:34:56 0 NULL 20682 2015-01-02 12:34:56 1 NULL 20693 2015-01-03 12:34:56 2 NULL 20704 2015-01-04 12:34:56 3 NULL 20715 2015-01-05 12:34:56 4 NULL 20726 2015-01-06 12:34:56 5 NULL 20737 2015-01-07 12:34:56 6 NULL 20748 2015-01-08 12:34:56 7 NULL 20759 2015-01-09 12:34:56 8 NULL 207610 2015-01-10 12:34:56 9 NULL 2077# This must show 'Using index' 2078explain 2079select kp1,kp2 from t1 force index (kp1) 2080where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2081id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20821 SIMPLE t1 NULL range kp1 kp1 6 NULL # 100.00 Using where; Using index 2083Warnings: 2084Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,`test`.`t1`.`kp2` AS `kp2` from `test`.`t1` FORCE INDEX (`kp1`) where (`test`.`t1`.`kp1` between '2015-01-01 00:00:00' and '2015-01-05 23:59:59') 2085select kp1,kp2 from t1 force index (kp1) 2086where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2087kp1 kp2 20882015-01-01 12:34:56 0 20892015-01-02 12:34:56 1 20902015-01-03 12:34:56 2 20912015-01-04 12:34:56 3 20922015-01-05 12:34:56 4 2093# Now, the same with NOT NULL column 2094create table t2 ( 2095pk int auto_increment primary key, 2096kp1 datetime not null, 2097kp2 int, 2098col1 int, 2099key(kp1, kp2) 2100) engine=rocksdb; 2101set @orig_tx_iso=@@session.transaction_isolation; 2102set session transaction_isolation='READ-COMMITTED'; 2103insert into t2 select * from t1; 2104set session transaction_isolation=@orig_tx_iso; 2105# This must show 'Using index' 2106explain 2107select kp1,kp2 from t2 force index (kp1) 2108where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2109id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21101 SIMPLE t2 NULL range kp1 kp1 5 NULL # 100.00 Using where; Using index 2111Warnings: 2112Note 1003 /* select#1 */ select `test`.`t2`.`kp1` AS `kp1`,`test`.`t2`.`kp2` AS `kp2` from `test`.`t2` FORCE INDEX (`kp1`) where (`test`.`t2`.`kp1` between '2015-01-01 00:00:00' and '2015-01-05 23:59:59') 2113select kp1,kp2 from t2 force index (kp1) 2114where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2115kp1 kp2 21162015-01-01 12:34:56 0 21172015-01-02 12:34:56 1 21182015-01-03 12:34:56 2 21192015-01-04 12:34:56 3 21202015-01-05 12:34:56 4 2121drop table t1,t2; 2122# Try a DATE column: 2123create table t1 ( 2124pk int auto_increment primary key, 2125kp1 date, 2126kp2 int, 2127col1 int, 2128key(kp1, kp2) 2129) engine=rocksdb; 2130insert into t1 (kp1,kp2) 2131select date_add('2015-01-01', interval a day), a from t0; 2132select * from t1; 2133pk kp1 kp2 col1 21341 2015-01-01 0 NULL 21352 2015-01-02 1 NULL 21363 2015-01-03 2 NULL 21374 2015-01-04 3 NULL 21385 2015-01-05 4 NULL 21396 2015-01-06 5 NULL 21407 2015-01-07 6 NULL 21418 2015-01-08 7 NULL 21429 2015-01-09 8 NULL 214310 2015-01-10 9 NULL 2144# This must show 'Using index' 2145explain 2146select kp1,kp2 from t1 force index (kp1) 2147where kp1 between '2015-01-01' and '2015-01-05'; 2148id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21491 SIMPLE t1 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2150Warnings: 2151Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,`test`.`t1`.`kp2` AS `kp2` from `test`.`t1` FORCE INDEX (`kp1`) where (`test`.`t1`.`kp1` between '2015-01-01' and '2015-01-05') 2152select kp1,kp2 from t1 force index (kp1) 2153where kp1 between '2015-01-01' and '2015-01-05'; 2154kp1 kp2 21552015-01-01 0 21562015-01-02 1 21572015-01-03 2 21582015-01-04 3 21592015-01-05 4 2160# Now, the same with NOT NULL column 2161create table t2 ( 2162pk int auto_increment primary key, 2163kp1 date not null, 2164kp2 int, 2165col1 int, 2166key(kp1, kp2) 2167) engine=rocksdb; 2168set @orig_tx_iso=@@session.transaction_isolation; 2169set session transaction_isolation='READ-COMMITTED'; 2170insert into t2 select * from t1; 2171set session transaction_isolation=@orig_tx_iso; 2172# This must show 'Using index' 2173explain 2174select kp1,kp2 from t2 force index (kp1) 2175where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2176id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21771 SIMPLE t2 NULL range kp1 kp1 3 NULL # 100.00 Using where; Using index 2178Warnings: 2179Note 1003 /* select#1 */ select `test`.`t2`.`kp1` AS `kp1`,`test`.`t2`.`kp2` AS `kp2` from `test`.`t2` FORCE INDEX (`kp1`) where (`test`.`t2`.`kp1` between '2015-01-01 00:00:00' and '2015-01-05 23:59:59') 2180select kp1,kp2 from t2 force index (kp1) 2181where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2182kp1 kp2 21832015-01-01 0 21842015-01-02 1 21852015-01-03 2 21862015-01-04 3 21872015-01-05 4 2188drop table t1,t2; 2189# 2190# Try a TIMESTAMP column: 2191# 2192create table t1 ( 2193pk int auto_increment primary key, 2194kp1 timestamp, 2195kp2 int, 2196col1 int, 2197key(kp1, kp2) 2198) engine=rocksdb; 2199insert into t1 (kp1,kp2) 2200select date_add('2015-01-01 12:34:56', interval a day), a from t0; 2201select * from t1; 2202pk kp1 kp2 col1 22031 2015-01-01 12:34:56 0 NULL 22042 2015-01-02 12:34:56 1 NULL 22053 2015-01-03 12:34:56 2 NULL 22064 2015-01-04 12:34:56 3 NULL 22075 2015-01-05 12:34:56 4 NULL 22086 2015-01-06 12:34:56 5 NULL 22097 2015-01-07 12:34:56 6 NULL 22108 2015-01-08 12:34:56 7 NULL 22119 2015-01-09 12:34:56 8 NULL 221210 2015-01-10 12:34:56 9 NULL 2213# This must show 'Using index' 2214explain 2215select kp1,kp2 from t1 force index (kp1) 2216where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2217id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22181 SIMPLE t1 NULL range kp1 kp1 5 NULL # 100.00 Using where; Using index 2219Warnings: 2220Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,`test`.`t1`.`kp2` AS `kp2` from `test`.`t1` FORCE INDEX (`kp1`) where (`test`.`t1`.`kp1` between '2015-01-01 00:00:00' and '2015-01-05 23:59:59') 2221select kp1,kp2 from t1 force index (kp1) 2222where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2223kp1 kp2 22242015-01-01 12:34:56 0 22252015-01-02 12:34:56 1 22262015-01-03 12:34:56 2 22272015-01-04 12:34:56 3 22282015-01-05 12:34:56 4 2229# Now, the same with NOT NULL column 2230create table t2 ( 2231pk int auto_increment primary key, 2232kp1 timestamp not null, 2233kp2 int, 2234col1 int, 2235key(kp1, kp2) 2236) engine=rocksdb; 2237set @orig_tx_iso=@@session.transaction_isolation; 2238set session transaction_isolation='READ-COMMITTED'; 2239insert into t2 select * from t1; 2240set session transaction_isolation=@orig_tx_iso; 2241# This must show 'Using index' 2242explain 2243select kp1,kp2 from t2 force index (kp1) 2244where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2245id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22461 SIMPLE t2 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2247Warnings: 2248Note 1003 /* select#1 */ select `test`.`t2`.`kp1` AS `kp1`,`test`.`t2`.`kp2` AS `kp2` from `test`.`t2` FORCE INDEX (`kp1`) where (`test`.`t2`.`kp1` between '2015-01-01 00:00:00' and '2015-01-05 23:59:59') 2249select kp1,kp2 from t2 force index (kp1) 2250where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2251kp1 kp2 22522015-01-01 12:34:56 0 22532015-01-02 12:34:56 1 22542015-01-03 12:34:56 2 22552015-01-04 12:34:56 3 22562015-01-05 12:34:56 4 2257drop table t1,t2; 2258# 2259# Try a TIME column: 2260# 2261create table t1 ( 2262pk int auto_increment primary key, 2263kp1 time, 2264kp2 int, 2265col1 int, 2266key(kp1, kp2) 2267) engine=rocksdb; 2268insert into t1 (kp1,kp2) 2269select date_add('2015-01-01 09:00:00', interval a minute), a from t0; 2270select * from t1; 2271pk kp1 kp2 col1 22721 09:00:00 0 NULL 22732 09:01:00 1 NULL 22743 09:02:00 2 NULL 22754 09:03:00 3 NULL 22765 09:04:00 4 NULL 22776 09:05:00 5 NULL 22787 09:06:00 6 NULL 22798 09:07:00 7 NULL 22809 09:08:00 8 NULL 228110 09:09:00 9 NULL 2282# This must show 'Using index' 2283explain 2284select kp1,kp2 from t1 force index (kp1) 2285where kp1 between '09:01:00' and '09:05:00'; 2286id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22871 SIMPLE t1 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2288Warnings: 2289Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,`test`.`t1`.`kp2` AS `kp2` from `test`.`t1` FORCE INDEX (`kp1`) where (`test`.`t1`.`kp1` between '09:01:00' and '09:05:00') 2290select kp1,kp2 from t1 force index (kp1) 2291where kp1 between '09:01:00' and '09:05:00'; 2292kp1 kp2 229309:01:00 1 229409:02:00 2 229509:03:00 3 229609:04:00 4 229709:05:00 5 2298# Now, the same with NOT NULL column 2299create table t2 ( 2300pk int auto_increment primary key, 2301kp1 time not null, 2302kp2 int, 2303col1 int, 2304key(kp1, kp2) 2305) engine=rocksdb; 2306set @orig_tx_iso=@@session.transaction_isolation; 2307set session transaction_isolation='READ-COMMITTED'; 2308insert into t2 select * from t1; 2309set session transaction_isolation=@orig_tx_iso; 2310# This must show 'Using index' 2311explain 2312select kp1,kp2 from t2 force index (kp1) 2313where kp1 between '09:01:00' and '09:05:00'; 2314id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23151 SIMPLE t2 NULL range kp1 kp1 3 NULL # 100.00 Using where; Using index 2316Warnings: 2317Note 1003 /* select#1 */ select `test`.`t2`.`kp1` AS `kp1`,`test`.`t2`.`kp2` AS `kp2` from `test`.`t2` FORCE INDEX (`kp1`) where (`test`.`t2`.`kp1` between '09:01:00' and '09:05:00') 2318select kp1,kp2 from t2 force index (kp1) 2319where kp1 between '09:01:00' and '09:05:00'; 2320kp1 kp2 232109:01:00 1 232209:02:00 2 232309:03:00 3 232409:04:00 4 232509:05:00 5 2326drop table t1,t2; 2327# 2328# Try a YEAR column: 2329# 2330create table t1 ( 2331pk int auto_increment primary key, 2332kp1 year, 2333kp2 int, 2334col1 int, 2335key(kp1, kp2) 2336) engine=rocksdb; 2337insert into t1 (kp1,kp2) select 2015+a, a from t0; 2338select * from t1; 2339pk kp1 kp2 col1 23401 2015 0 NULL 23412 2016 1 NULL 23423 2017 2 NULL 23434 2018 3 NULL 23445 2019 4 NULL 23456 2020 5 NULL 23467 2021 6 NULL 23478 2022 7 NULL 23489 2023 8 NULL 234910 2024 9 NULL 2350# This must show 'Using index' 2351explain 2352select kp1,kp2 from t1 force index (kp1) 2353where kp1 between '2016' and '2020'; 2354id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23551 SIMPLE t1 NULL range kp1 kp1 2 NULL # 100.00 Using where; Using index 2356Warnings: 2357Note 1003 /* select#1 */ select `test`.`t1`.`kp1` AS `kp1`,`test`.`t1`.`kp2` AS `kp2` from `test`.`t1` FORCE INDEX (`kp1`) where (`test`.`t1`.`kp1` between 2016 and 2020) 2358select kp1,kp2 from t1 force index (kp1) 2359where kp1 between '2016' and '2020'; 2360kp1 kp2 23612016 1 23622017 2 23632018 3 23642019 4 23652020 5 2366# Now, the same with NOT NULL column 2367create table t2 ( 2368pk int auto_increment primary key, 2369kp1 year not null, 2370kp2 int, 2371col1 int, 2372key(kp1, kp2) 2373) engine=rocksdb; 2374set @orig_tx_iso=@@session.transaction_isolation; 2375set session transaction_isolation='READ-COMMITTED'; 2376insert into t2 select * from t1; 2377set session transaction_isolation=@orig_tx_iso; 2378# This must show 'Using index' 2379explain 2380select kp1,kp2 from t2 force index (kp1) 2381where kp1 between '2016' and '2020'; 2382id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23831 SIMPLE t2 NULL range kp1 kp1 1 NULL # 100.00 Using where; Using index 2384Warnings: 2385Note 1003 /* select#1 */ select `test`.`t2`.`kp1` AS `kp1`,`test`.`t2`.`kp2` AS `kp2` from `test`.`t2` FORCE INDEX (`kp1`) where (`test`.`t2`.`kp1` between 2016 and 2020) 2386select kp1,kp2 from t2 force index (kp1) 2387where kp1 between '2016' and '2020'; 2388kp1 kp2 23892016 1 23902017 2 23912018 3 23922019 4 23932020 5 2394drop table t1,t2; 2395# 2396# Issue #57: Release row locks on statement errors 2397# 2398create table t1 (id int primary key) engine=rocksdb; 2399insert into t1 values (1), (2), (3); 2400begin; 2401insert into t1 values (4), (5), (6); 2402insert into t1 values (7), (8), (2), (9); 2403ERROR 23000: Duplicate entry '2' for key 'PRIMARY' 2404select * from t1; 2405id 24061 24072 24083 24094 24105 24116 2412begin; 2413select * from t1 where id=4 for update; 2414ERROR HY000: Lock wait timeout exceeded; try restarting transaction 2415select * from t1 where id=7 for update; 2416id 2417select * from t1 where id=9 for update; 2418id 2419drop table t1; 2420#Index on blob column 2421SET @old_mode = @@sql_mode; 2422SET sql_mode = 'strict_all_tables'; 2423Warnings: 2424Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2425Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2426create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(c, b(255))) engine=rocksdb; 2427drop table t1; 2428set @orig_rocksdb_large_prefix=@@global.rocksdb_large_prefix; 2429set @@global.rocksdb_large_prefix=1; 2430create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(1255))) engine=rocksdb; 2431set @@global.rocksdb_large_prefix=@orig_rocksdb_large_prefix; 2432insert into t1 values (1, '1abcde', '1abcde'), (2, '2abcde', '2abcde'), (3, '3abcde', '3abcde'); 2433select * from t1; 2434a b c 24351 1abcde 1abcde 24362 2abcde 2abcde 24373 3abcde 3abcde 2438explain select * from t1 where b like '1%'; 2439id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24401 SIMPLE t1 NULL range b b 1258 NULL # 100.00 Using where 2441Warnings: 2442Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where (`test`.`t1`.`b` like '1%') 2443explain select b, a from t1 where b like '1%'; 2444id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24451 SIMPLE t1 NULL range b b 1258 NULL # 100.00 Using where 2446Warnings: 2447Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` like '1%') 2448update t1 set b= '12345' where b = '2abcde'; 2449select * from t1; 2450a b c 24511 1abcde 1abcde 24522 12345 2abcde 24533 3abcde 3abcde 2454drop table t1; 2455create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(2255))) engine=rocksdb; 2456ERROR 42000: Specified key was too long; max key length is 767 bytes 2457SET sql_mode = @old_mode; 2458Warnings: 2459Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2460drop table t0; 2461# 2462# Fix assertion failure (attempt to overrun the key buffer) for prefix indexes 2463# 2464create table t1 ( 2465pk int primary key, 2466col1 varchar(100), 2467key (col1(10)) 2468) engine=rocksdb; 2469insert into t1 values (1, repeat('0123456789', 9)); 2470drop table t1; 2471# 2472# Issue #76: Assertion `buf == table->record[0]' fails in virtual int ha_rocksdb::delete_row(const uchar*) 2473# 2474CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB; 2475CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB; 2476CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW DELETE FROM t2 WHERE pk = old.pk; 2477INSERT INTO t1 VALUES (1,1); 2478REPLACE INTO t1 VALUES (1,2); 2479SELECT * FROM t1; 2480pk f1 24811 2 2482DROP TABLE t1, t2; 2483# 2484# Issue #99: UPDATE for table with VARCHAR pk gives "Can't find record" error 2485# 2486create table t1(a int primary key) engine=rocksdb; 2487insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2488create table t2 ( 2489a varchar(32) primary key, 2490col1 int 2491) engine=rocksdb; 2492set @orig_tx_iso=@@session.transaction_isolation; 2493set session transaction_isolation='READ-COMMITTED'; 2494insert into t2 2495select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B; 2496update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004'; 2497set session transaction_isolation=@orig_tx_iso; 2498drop table t1,t2; 2499# 2500# Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed 2501# 2502CREATE TABLE t2(c1 INTEGER UNSIGNED NOT NULL, c2 INTEGER NULL, c3 TINYINT, c4 SMALLINT , c5 MEDIUMINT, c6 INT, c7 BIGINT, PRIMARY KEY(c1,c6)) ENGINE=RocksDB; 2503INSERT INTO t2 VALUES (1,1,1,1,1,1,1); 2504SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; 2505c1 c2 c3 c4 c5 c6 c7 2506EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; 2507id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25081 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 50 100.00 Using where 2509Warnings: 2510Note 1003 /* select#1 */ select `test`.`t2`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t2`.`c3` AS `c3`,`test`.`t2`.`c4` AS `c4`,`test`.`t2`.`c5` AS `c5`,`test`.`t2`.`c6` AS `c6`,`test`.`t2`.`c7` AS `c7` from `test`.`t2` where (`test`.`t2`.`c1` > 4294967295) order by `test`.`t2`.`c1`,`test`.`t2`.`c6` 2511drop table t2; 2512# 2513# Issue #135: register transaction was not being called for statement 2514# 2515CREATE DATABASE test_db; 2516CREATE TABLE test_db.t1(c1 INT PRIMARY KEY) ENGINE=ROCKSDB; 2517INSERT INTO test_db.t1(c1) VALUES(0), (1), (2), (3); 2518LOCK TABLES test_db.t1 READ; 2519SET AUTOCOMMIT=0; 2520SELECT c1 FROM test_db.t1 WHERE c1=2; 2521c1 25222 2523START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY; 2524DROP DATABASE test_db; 2525COMMIT; 2526SET AUTOCOMMIT=1; 2527# 2528# Issue #143: Split rocksdb_bulk_load option into two 2529# 2530CREATE TABLE t1 (id int primary key, value int) engine=RocksDB; 2531SET unique_checks=0; 2532INSERT INTO t1 VALUES(1, 1); 2533INSERT INTO t1 VALUES(1, 2); 2534INSERT INTO t1 VALUES(1, 3); 2535SELECT * FROM t1; 2536id value 25371 3 2538REPLACE INTO t1 VALUES(4, 4); 2539ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: REPLACE INTO t1 VALUES(4, 4) 2540INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1; 2541ERROR HY000: When unique checking is disabled in MyRocks, INSERT,UPDATE,LOAD statements with clauses that update or replace the key (i.e. INSERT ON DUPLICATE KEY UPDATE, REPLACE) are not allowed. Query: INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1 2542TRUNCATE TABLE t1; 2543SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size; 2544SET unique_checks=1; 2545SET rocksdb_commit_in_the_middle=1; 2546SET rocksdb_bulk_load_size=10; 2547BEGIN; 2548INSERT INTO t1 (id) VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10), 2549(11),(12),(13),(14),(15),(16),(17),(18),(19); 2550ROLLBACK; 2551SELECT * FROM t1; 2552id value 25531 NULL 25542 NULL 25553 NULL 25564 NULL 25575 NULL 25586 NULL 25597 NULL 25608 NULL 25619 NULL 256210 NULL 2563INSERT INTO t1 (id) VALUES (11),(12),(13),(14),(15); 2564set @orig_tx_iso=@@session.transaction_isolation; 2565set session transaction_isolation='READ-COMMITTED'; 2566BEGIN; 2567UPDATE t1 SET value=100; 2568ROLLBACK; 2569SELECT * FROM t1; 2570id value 25711 100 25722 100 25733 100 25744 100 25755 100 25766 100 25777 100 25788 100 25799 100 258010 100 258111 NULL 258212 NULL 258313 NULL 258414 NULL 258515 NULL 2586BEGIN; 2587DELETE FROM t1; 2588ROLLBACK; 2589SELECT * FROM t1; 2590id value 259111 NULL 259212 NULL 259313 NULL 259414 NULL 259515 NULL 2596set session transaction_isolation=@orig_tx_iso; 2597SET rocksdb_commit_in_the_middle=0; 2598SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size; 2599DROP TABLE t1; 2600# 2601# Issue #185 Assertion `BaseValid()' failed in void rocksdb::BaseDeltaIterator::Advance() 2602# 2603CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MEMORY; 2604INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar"); 2605Warnings: 2606Warning 1366 Incorrect integer value: 'long varchar' for column 'data' at row 2 2607Warning 1366 Incorrect integer value: 'varchar' for column 'data' at row 3 2608Warning 1366 Incorrect integer value: 'long long long varchar' for column 'data' at row 4 2609CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a,b)) ENGINE=ROCKSDB; 2610INSERT INTO t1 VALUES (1,1); 2611SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); 2612a 26131 26141 26151 26161 2617DROP TABLE t1, t2; 2618# 2619# Issue #189 ha_rocksdb::load_auto_incr_value() creates implicit snapshot and doesn't release 2620# 2621create table r1 (id int auto_increment primary key, value int) engine=rocksdb; 2622insert into r1 (id) values (null), (null), (null), (null), (null); 2623create table r2 like r1; 2624show create table r2; 2625Table Create Table 2626r2 CREATE TABLE `r2` ( 2627 `id` int(11) NOT NULL AUTO_INCREMENT, 2628 `value` int(11) DEFAULT NULL, 2629 PRIMARY KEY (`id`) 2630) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 2631begin; 2632insert into r1 values (10, 1); 2633commit; 2634begin; 2635select * from r1; 2636id value 26371 NULL 26382 NULL 26393 NULL 26404 NULL 26415 NULL 264210 1 2643commit; 2644drop table r1, r2; 2645create table r1 (id int auto_increment, value int, index i(id)) engine=rocksdb; 2646insert into r1 (id) values (null), (null), (null), (null), (null); 2647create table r2 like r1; 2648show create table r2; 2649Table Create Table 2650r2 CREATE TABLE `r2` ( 2651 `id` int(11) NOT NULL AUTO_INCREMENT, 2652 `value` int(11) DEFAULT NULL, 2653 KEY `i` (`id`) 2654) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 2655begin; 2656insert into r1 values (10, 1); 2657commit; 2658begin; 2659select * from r1; 2660id value 26611 NULL 26622 NULL 26633 NULL 26644 NULL 26655 NULL 266610 1 2667commit; 2668drop table r1, r2; 2669# 2670# Issue#211 Crash on LOCK TABLES + START TRANSACTION WITH CONSISTENT SNAPSHOT 2671# 2672CREATE TABLE t1(c1 INT) ENGINE=ROCKSDB; 2673lock TABLE t1 read local; 2674SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND()FROM''); 26751 2676set AUTOCOMMIT=0; 2677start transaction with consistent snapshot; 2678SELECT * FROM t1; 2679c1 2680COMMIT; 2681UNLOCK TABLES; 2682DROP TABLE t1; 2683set AUTOCOMMIT=1; 2684# 2685# Issue#213 Crash on LOCK TABLES + partitions 2686# 2687CREATE TABLE t1(a INT,b INT,KEY (b)) engine=rocksdb PARTITION BY HASH(a) PARTITIONS 2; 2688Warnings: 2689Warning 1287 The partition engine, used by table 'test.t1', is deprecated and will be removed in a future release. Please use native partitioning instead. 2690INSERT INTO t1(a)VALUES (20010101101010.999949); 2691ERROR 22003: Out of range value for column 'a' at row 1 2692set @orig_sql_mode=@@session.sql_mode; 2693set session sql_mode=""; 2694Warnings: 2695Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2696INSERT INTO t1(a)VALUES (20010101101010.999949); 2697Warnings: 2698Warning 1264 Out of range value for column 'a' at row 1 2699set session sql_mode=@orig_sql_mode; 2700Warnings: 2701Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2702lock tables t1 write,t1 as t0 write,t1 as t2 write; 2703set @orig_tx_iso=@@session.transaction_isolation; 2704set session transaction_isolation='READ-COMMITTED'; 2705SELECT a FROM t1 ORDER BY a; 2706a 27072147483647 2708set session transaction_isolation=@orig_tx_iso; 2709truncate t1; 2710INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020'); 2711ERROR 22003: Out of range value for column 'a' at row 1 2712set @orig_sql_mode=@@session.sql_mode; 2713set session sql_mode=""; 2714Warnings: 2715Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2716INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020'); 2717Warnings: 2718Warning 1264 Out of range value for column 'a' at row 1 2719Warning 1264 Out of range value for column 'b' at row 1 2720Warning 1264 Out of range value for column 'a' at row 2 2721Warning 1264 Out of range value for column 'b' at row 2 2722set session sql_mode=@orig_sql_mode; 2723Warnings: 2724Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2725UNLOCK TABLES; 2726DROP TABLE t1; 2727# 2728# Issue#250: MyRocks/Innodb different output from query with order by on table with index and decimal type 2729# (the test was changed to use VARCHAR, because DECIMAL now supports index-only, and this issue 2730# needs a datype that doesn't support index-inly) 2731# 2732CREATE TABLE t1( 2733c1 varchar(10) character set utf8 collate utf8_general_ci NOT NULL, 2734c2 varchar(10) character set utf8 collate utf8_general_ci, 2735c3 INT, 2736INDEX idx(c1,c2) 2737) ENGINE=ROCKSDB; 2738INSERT INTO t1 VALUES ('c1-val1','c2-val1',5); 2739INSERT INTO t1 VALUES ('c1-val2','c2-val3',6); 2740INSERT INTO t1 VALUES ('c1-val3','c2-val3',7); 2741SELECT * FROM t1 force index(idx) WHERE c1 <> 'c1-val2' ORDER BY c1 DESC; 2742c1 c2 c3 2743c1-val3 c2-val3 7 2744c1-val1 c2-val1 5 2745explain SELECT * FROM t1 force index(idx) WHERE c1 <> '1' ORDER BY c1 DESC; 2746id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27471 SIMPLE t1 NULL range idx idx 32 NULL # 100.00 Using where 2748Warnings: 2749Note 1003 /* select#1 */ select `test`.`t1`.`c1` AS `c1`,`test`.`t1`.`c2` AS `c2`,`test`.`t1`.`c3` AS `c3` from `test`.`t1` FORCE INDEX (`idx`) where (`test`.`t1`.`c1` <> '1') order by `test`.`t1`.`c1` desc 2750drop table t1; 2751# 2752# Issue#267: MyRocks issue with no matching min/max row and count(*) 2753# 2754CREATE TABLE t1(c1 INT UNSIGNED, c2 INT SIGNED, INDEX idx2(c2)) ENGINE=ROCKSDB; 2755INSERT INTO t1 VALUES(1,null); 2756INSERT INTO t1 VALUES(2,null); 2757SELECT count(*) as total_rows, min(c2) as min_value FROM t1; 2758total_rows min_value 27592 NULL 2760DROP TABLE t1; 2761# 2762# Issue#263: MyRocks auto_increment skips values if you insert a negative value 2763# 2764CREATE TABLE t1(a INT AUTO_INCREMENT KEY) ENGINE=ROCKSDB; 2765INSERT INTO t1 VALUES(0),(-1),(0); 2766SHOW TABLE STATUS LIKE 't1'; 2767Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment 2768t1 ROCKSDB 10 Fixed 1000 # # # # # 3 # # NULL latin1_swedish_ci NULL 2769SELECT * FROM t1; 2770a 2771-1 27721 27732 2774DROP TABLE t1; 2775CREATE TABLE t1(a INT AUTO_INCREMENT KEY) ENGINE=ROCKSDB; 2776INSERT INTO t1 VALUES(0),(10),(0); 2777SHOW TABLE STATUS LIKE 't1'; 2778Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment 2779t1 ROCKSDB 10 Fixed 1000 # # # # # 12 # # NULL latin1_swedish_ci NULL 2780SELECT * FROM t1; 2781a 27821 278310 278411 2785DROP TABLE t1; 2786# 2787# Issue #411: Setting rocksdb_commit_in_the_middle commits transaction 2788# without releasing iterator 2789# 2790CREATE TABLE t1 (id1 bigint(20), 2791id2 bigint(20), 2792id3 bigint(20), 2793PRIMARY KEY (id1, id2, id3)) 2794ENGINE=ROCKSDB 2795DEFAULT CHARSET=latin1; 2796CREATE TABLE t2 (id1 bigint(20), 2797id2 bigint(20), 2798PRIMARY KEY (id1, id2)) 2799ENGINE=ROCKSDB 2800DEFAULT CHARSET=latin1; 2801set rocksdb_commit_in_the_middle=1; 2802SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size; 2803set rocksdb_bulk_load_size = 100; 2804set @orig_tx_iso=@@session.transaction_isolation; 2805set session transaction_isolation='READ-COMMITTED'; 2806DELETE t2, t1 FROM t2 LEFT JOIN t1 ON t2.id2 = t1.id2 AND t2.id1 = t1.id1 WHERE t2.id1 = 0; 2807set session transaction_isolation=@orig_tx_iso; 2808SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size; 2809SET rocksdb_commit_in_the_middle=0; 2810DROP TABLE t1, t2; 2811SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; 2812# 2813# Issue #728: Assertion `covers_key(b)' failed in int 2814# myrocks::Rdb_key_def::cmp_full_keys(const rocks db::Slice&, 2815# const rocksdb::Slice&) 2816# 2817CREATE TABLE t2(c1 TINYINT SIGNED KEY,c2 TINYINT UNSIGNED,c3 INT) ENGINE=ROCKSDB; 2818INSERT INTO t2(c1)VALUES(0); 2819SELECT * FROM t2 WHERE c1<=127 ORDER BY c1 DESC; 2820c1 c2 c3 28210 NULL NULL 2822DROP TABLE t2; 2823