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; 304drop table t14; 305# 306# MDEV-3960: Server crashes on running DISCARD TABLESPACE on a RocksDB table 307# 308create table t9 (i int primary key) engine=rocksdb; 309alter table t9 discard tablespace; 310ERROR HY000: Table storage engine for 't9' doesn't have this option 311drop table t9; 312# 313# MDEV-3959: Assertion `slice->size() == table->s->reclength' fails ... 314# on accessing a table after ALTER 315# 316CREATE TABLE t15 (a INT, rocksdb_pk INT PRIMARY KEY) ENGINE=RocksDB; 317INSERT INTO t15 VALUES (1,1),(5,2); 318ALTER TABLE t15 DROP COLUMN a; 319DROP TABLE t15; 320# 321# MDEV-3968: UPDATE produces a wrong result while modifying a PK on a RocksDB table 322# 323create table t16 (pk int primary key, a char(8)) engine=RocksDB; 324insert into t16 values (1,'a'),(2,'b'),(3,'c'),(4,'d'); 325update t16 set pk=100, a = 'updated' where a in ('b','c'); 326ERROR 23000: Duplicate entry '100' for key 'PRIMARY' 327select * from t16; 328pk a 3291 a 3302 b 3313 c 3324 d 333drop table t16; 334# 335# MDEV-3970: A set of assorted crashes on inserting a row into a RocksDB table 336# 337drop table if exists t_very_long_table_name; 338CREATE TABLE `t_very_long_table_name` ( 339`c` char(1) NOT NULL, 340`c0` char(0) NOT NULL, 341`c1` char(1) NOT NULL, 342`c20` char(20) NOT NULL, 343`c255` char(255) NOT NULL, 344PRIMARY KEY (`c255`) 345) ENGINE=RocksDB DEFAULT CHARSET=latin1; 346INSERT INTO t_very_long_table_name VALUES ('a', '', 'c', REPEAT('a',20), REPEAT('x',255)); 347drop table t_very_long_table_name; 348# 349# Test table locking and read-before-write checks. 350# 351create table t17 (pk varchar(12) primary key, col1 varchar(12)) engine=rocksdb; 352insert into t17 values ('row1', 'val1'); 353insert into t17 values ('row1', 'val1-try2'); 354ERROR 23000: Duplicate entry 'row1' for key 'PRIMARY' 355insert into t17 values ('ROW1', 'val1-try2'); 356ERROR 23000: Duplicate entry 'ROW1' for key 'PRIMARY' 357insert into t17 values ('row2', 'val2'); 358insert into t17 values ('row3', 'val3'); 359# This is ok 360update t17 set pk='row4' where pk='row1'; 361# This will try to overwrite another row: 362update t17 set pk='row3' where pk='row2'; 363ERROR 23000: Duplicate entry 'row3' for key 'PRIMARY' 364select * from t17; 365pk col1 366row2 val2 367row3 val3 368row4 val1 369# 370# Locking tests 371# 372# First, make sure there's no locking when transactions update different rows 373set autocommit=0; 374update t17 set col1='UPD1' where pk='row2'; 375update t17 set col1='UPD2' where pk='row3'; 376commit; 377select * from t17; 378pk col1 379row2 UPD1 380row3 UPD2 381row4 val1 382# Check the variable 383show variables like 'rocksdb_lock_wait_timeout'; 384Variable_name Value 385rocksdb_lock_wait_timeout 1 386set rocksdb_lock_wait_timeout=2; 387show variables like 'rocksdb_lock_wait_timeout'; 388Variable_name Value 389rocksdb_lock_wait_timeout 2 390# Try updating the same row from two transactions 391begin; 392update t17 set col1='UPD2-AA' where pk='row2'; 393update t17 set col1='UPD2-BB' where pk='row2'; 394ERROR HY000: Lock wait timeout exceeded; try restarting transaction 395set rocksdb_lock_wait_timeout=1000; 396update t17 set col1='UPD2-CC' where pk='row2'; 397rollback; 398select * from t17 where pk='row2'; 399pk col1 400row2 UPD2-CC 401drop table t17; 402# 403# MDEV-4035: RocksDB: SELECT produces different results inside a transaction (read is not repeatable) 404# 405create table t18 (pk int primary key, i int) engine=RocksDB; 406begin; 407select * from t18; 408pk i 409select * from t18 where pk = 1; 410pk i 411connect con1,localhost,root,,; 412insert into t18 values (1,100); 413connection default; 414select * from t18; 415pk i 416select * from t18 where pk = 1; 417pk i 418commit; 419drop table t18; 420# 421# MDEV-4036: RocksDB: INSERT .. ON DUPLICATE KEY UPDATE does not work, produces ER_DUP_KEY 422# 423create table t19 (pk int primary key, i int) engine=RocksDB; 424insert into t19 values (1,1); 425insert into t19 values (1,100) on duplicate key update i = 102; 426select * from t19; 427pk i 4281 102 429drop table t19; 430# MDEV-4037: RocksDB: REPLACE doesn't work, produces ER_DUP_KEY 431create table t20 (pk int primary key, i int) engine=RocksDB; 432insert into t20 values (1,1); 433replace into t20 values (1,100); 434select * from t20; 435pk i 4361 100 437drop table t20; 438# 439# MDEV-4041: Server crashes in Primary_key_comparator::get_hashnr on INSERT 440# 441create table t21 (v varbinary(16) primary key, i int) engine=RocksDB; 442insert into t21 values ('a',1); 443select * from t21; 444v i 445a 1 446drop table t21; 447# 448# MDEV-4047: RocksDB: Assertion `0' fails in Protocol::end_statement() on multi-table INSERT IGNORE 449# 450CREATE TABLE t22 (a int primary key) ENGINE=RocksDB; 451INSERT INTO t22 VALUES (1),(2); 452CREATE TABLE t23 (b int primary key) ENGINE=RocksDB; 453set @orig_tx_iso=@@session.transaction_isolation; 454set session transaction_isolation='READ-COMMITTED'; 455INSERT INTO t23 SELECT * FROM t22; 456DELETE IGNORE t22.*, t23.* FROM t22, t23 WHERE b < a; 457set session transaction_isolation=@orig_tx_iso; 458DROP TABLE t22,t23; 459# 460# MDEV-4046: RocksDB: Multi-table DELETE locks itself and ends with ER_LOCK_WAIT_TIMEOUT 461# 462CREATE TABLE t24 (pk int primary key) ENGINE=RocksDB; 463INSERT INTO t24 VALUES (1),(2); 464CREATE TABLE t25 LIKE t24; 465set @orig_tx_iso=@@session.transaction_isolation; 466set session transaction_isolation='READ-COMMITTED'; 467INSERT INTO t25 SELECT * FROM t24; 468DELETE t25.* FROM t24, t25; 469set session transaction_isolation=@orig_tx_iso; 470DROP TABLE t24,t25; 471# 472# MDEV-4044: RocksDB: UPDATE or DELETE with ORDER BY locks itself 473# 474create table t26 (pk int primary key, c char(1)) engine=RocksDB; 475insert into t26 values (1,'a'),(2,'b'); 476update t26 set c = 'x' order by pk limit 1; 477delete from t26 order by pk limit 1; 478select * from t26; 479pk c 4802 b 481drop table t26; 482# 483# Test whether SELECT ... FOR UPDATE puts locks 484# 485create table t27(pk varchar(10) primary key, col1 varchar(20)) engine=RocksDB; 486insert into t27 values 487('row1', 'row1data'), 488('row2', 'row2data'), 489('row3', 'row3data'); 490connection con1; 491begin; 492select * from t27 where pk='row3' for update; 493pk col1 494row3 row3data 495connection default; 496set rocksdb_lock_wait_timeout=1; 497update t27 set col1='row2-modified' where pk='row3'; 498ERROR HY000: Lock wait timeout exceeded; try restarting transaction 499connection con1; 500rollback; 501connection default; 502disconnect con1; 503drop table t27; 504# 505# MDEV-4060: RocksDB: Assertion `! trx->batch' fails in 506# 507create table t28 (pk int primary key, a int) engine=RocksDB; 508insert into t28 values (1,10),(2,20); 509begin; 510update t28 set a = 100 where pk = 3; 511rollback; 512select * from t28; 513pk a 5141 10 5152 20 516drop table t28; 517# 518# Secondary indexes 519# 520create table t30 ( 521pk varchar(16) not null primary key, 522key1 varchar(16) not null, 523col1 varchar(16) not null, 524key(key1) 525) engine=rocksdb; 526insert into t30 values ('row1', 'row1-key', 'row1-data'); 527insert into t30 values ('row2', 'row2-key', 'row2-data'); 528insert into t30 values ('row3', 'row3-key', 'row3-data'); 529explain 530select * from t30 where key1='row2-key'; 531id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5321 SIMPLE t30 NULL ref key1 key1 18 const # 100.00 NULL 533Warnings: 534Note 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') 535select * from t30 where key1='row2-key'; 536pk key1 col1 537row2 row2-key row2-data 538explain 539select * from t30 where key1='row1'; 540id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5411 SIMPLE t30 NULL ref key1 key1 18 const # 100.00 NULL 542Warnings: 543Note 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') 544# This will produce nothing: 545select * from t30 where key1='row1'; 546pk key1 col1 547explain 548select key1 from t30; 549id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5501 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 Using index 551Warnings: 552Note 1003 /* select#1 */ select `test`.`t30`.`key1` AS `key1` from `test`.`t30` 553select key1 from t30; 554key1 555row1-key 556row2-key 557row3-key 558# Create a duplicate record 559insert into t30 values ('row2a', 'row2-key', 'row2a-data'); 560# Can we see it? 561select * from t30 where key1='row2-key'; 562pk key1 col1 563row2 row2-key row2-data 564row2a row2-key row2a-data 565delete from t30 where pk='row2'; 566select * from t30 where key1='row2-key'; 567pk key1 col1 568row2a row2-key row2a-data 569# 570# Range scans on secondary index 571# 572delete from t30; 573insert into t30 values 574('row1', 'row1-key', 'row1-data'), 575('row2', 'row2-key', 'row2-data'), 576('row3', 'row3-key', 'row3-data'), 577('row4', 'row4-key', 'row4-data'), 578('row5', 'row5-key', 'row5-data'); 579explain 580select * from t30 where key1 <='row3-key'; 581id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5821 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 583Warnings: 584Note 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') 585select * from t30 where key1 <='row3-key'; 586pk key1 col1 587row1 row1-key row1-data 588row2 row2-key row2-data 589row3 row3-key row3-data 590explain 591select * from t30 where key1 between 'row2-key' and 'row4-key'; 592id select_type table partitions type possible_keys key key_len ref rows filtered Extra 5931 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 594Warnings: 595Note 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') 596select * from t30 where key1 between 'row2-key' and 'row4-key'; 597pk key1 col1 598row2 row2-key row2-data 599row3 row3-key row3-data 600row4 row4-key row4-data 601explain 602select * from t30 where key1 in ('row2-key','row4-key'); 603id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6041 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 605Warnings: 606Note 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')) 607select * from t30 where key1 in ('row2-key','row4-key'); 608pk key1 col1 609row2 row2-key row2-data 610row4 row4-key row4-data 611explain 612select key1 from t30 where key1 in ('row2-key','row4-key'); 613id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6141 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using where; Using index 615Warnings: 616Note 1003 /* select#1 */ select `test`.`t30`.`key1` AS `key1` from `test`.`t30` where (`test`.`t30`.`key1` in ('row2-key','row4-key')) 617select key1 from t30 where key1 in ('row2-key','row4-key'); 618key1 619row2-key 620row4-key 621explain 622select * from t30 where key1 > 'row1-key' and key1 < 'row4-key'; 623id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6241 SIMPLE t30 NULL range key1 key1 18 NULL # 100.00 Using index condition 625Warnings: 626Note 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')) 627select * from t30 where key1 > 'row1-key' and key1 < 'row4-key'; 628pk key1 col1 629row2 row2-key row2-data 630row3 row3-key row3-data 631explain 632select * from t30 order by key1 limit 3; 633id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6341 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 NULL 635Warnings: 636Note 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 637select * from t30 order by key1 limit 3; 638pk key1 col1 639row1 row1-key row1-data 640row2 row2-key row2-data 641row3 row3-key row3-data 642explain 643select * from t30 order by key1 desc limit 3; 644id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6451 SIMPLE t30 NULL index NULL key1 18 NULL # 100.00 NULL 646Warnings: 647Note 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 648select * from t30 order by key1 desc limit 3; 649pk key1 col1 650row5 row5-key row5-data 651row4 row4-key row4-data 652row3 row3-key row3-data 653# 654# Range scans on primary key 655# 656explain 657select * from t30 where pk <='row3'; 658id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6591 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 660Warnings: 661Note 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') 662select * from t30 where pk <='row3'; 663pk key1 col1 664row1 row1-key row1-data 665row2 row2-key row2-data 666row3 row3-key row3-data 667explain 668select * from t30 where pk between 'row2' and 'row4'; 669id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6701 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 671Warnings: 672Note 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') 673select * from t30 where pk between 'row2' and 'row4'; 674pk key1 col1 675row2 row2-key row2-data 676row3 row3-key row3-data 677row4 row4-key row4-data 678explain 679select * from t30 where pk in ('row2','row4'); 680id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6811 SIMPLE t30 NULL range PRIMARY PRIMARY 18 NULL # 100.00 Using where 682Warnings: 683Note 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')) 684select * from t30 where pk in ('row2','row4'); 685pk key1 col1 686row2 row2-key row2-data 687row4 row4-key row4-data 688explain 689select * from t30 order by pk limit 3; 690id select_type table partitions type possible_keys key key_len ref rows filtered Extra 6911 SIMPLE t30 NULL index NULL PRIMARY 18 NULL # 100.00 NULL 692Warnings: 693Note 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 694select * from t30 order by pk limit 3; 695pk key1 col1 696row1 row1-key row1-data 697row2 row2-key row2-data 698row3 row3-key row3-data 699drop table t30; 700# 701# MDEV-3841: RocksDB: Reading by PK prefix does not work 702# 703create table t31 (i int, j int, k int, primary key(i,j,k)) engine=RocksDB; 704insert into t31 values (1,10,100),(2,20,200); 705select * from t31 where i = 1; 706i j k 7071 10 100 708select * from t31 where j = 10; 709i j k 7101 10 100 711select * from t31 where k = 100; 712i j k 7131 10 100 714select * from t31 where i = 1 and j = 10; 715i j k 7161 10 100 717select * from t31 where i = 1 and k = 100; 718i j k 7191 10 100 720select * from t31 where j = 10 and k = 100; 721i j k 7221 10 100 723select * from t31 where i = 1 and j = 10 and k = 100; 724i j k 7251 10 100 726drop table t31; 727# 728# MDEV-4055: RocksDB: UPDATE/DELETE by a multi-part PK does not work 729# 730create table t32 (i int, j int, k int, primary key(i,j,k), a varchar(8)) engine=RocksDB; 731insert into t32 values 732(1,10,100,''), 733(2,20,200,''); 734select * from t32 where i = 1 and j = 10 and k = 100; 735i j k a 7361 10 100 737update t32 set a = 'updated' where i = 1 and j = 10 and k = 100; 738select * from t32; 739i j k a 7401 10 100 updated 7412 20 200 742drop table t32; 743# 744# MDEV-3841: RocksDB: Assertion `0' fails in ha_rocksdb::index_read_map on range select with ORDER BY .. DESC 745# 746CREATE TABLE t33 (pk INT PRIMARY KEY, a CHAR(1)) ENGINE=RocksDB; 747INSERT INTO t33 VALUES (1,'a'),(2,'b'); 748SELECT * FROM t33 WHERE pk <= 10 ORDER BY pk DESC; 749pk a 7502 b 7511 a 752DROP TABLE t33; 753# 754# MDEV-4081: RocksDB throws error 122 on an attempt to create a table with unique index 755# 756# Unique indexes can be created, but uniqueness won't be enforced 757create table t33 (pk int primary key, u int, unique index(u)) engine=RocksDB; 758drop table t33; 759# 760# MDEV-4077: RocksDB: Wrong result (duplicate row) on select with range 761# 762CREATE TABLE t34 (pk INT PRIMARY KEY) ENGINE=RocksDB; 763INSERT INTO t34 VALUES (10),(11); 764SELECT pk FROM t34 WHERE pk > 5 AND pk < 15; 765pk 76610 76711 768SELECT pk FROM t34 WHERE pk BETWEEN 5 AND 15; 769pk 77010 77111 772SELECT pk FROM t34 WHERE pk > 5; 773pk 77410 77511 776SELECT pk FROM t34 WHERE pk < 15; 777pk 77810 77911 780drop table t34; 781# 782# MDEV-4086: RocksDB does not allow a query with multi-part pk and index and ORDER BY .. DEC 783# 784create table t35 (a int, b int, c int, d int, e int, primary key (a,b,c), key (a,c,d,e)) engine=RocksDB; 785insert into t35 values (1,1,1,1,1),(2,2,2,2,2); 786select * from t35 where a = 1 and c = 1 and d = 1 order by e desc; 787a b c d e 7881 1 1 1 1 789drop table t35; 790# 791# MDEV-4084: RocksDB: Wrong result on IN subquery with index 792# 793CREATE TABLE t36 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB; 794INSERT INTO t36 VALUES (1,10),(2,20); 795SELECT 3 IN ( SELECT a FROM t36 ); 7963 IN ( SELECT a FROM t36 ) 7970 798drop table t36; 799# 800# MDEV-4084: RocksDB: Wrong result on IN subquery with index 801# 802CREATE TABLE t37 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a), KEY(a,b)) 803ENGINE=RocksDB; 804INSERT INTO t37 VALUES (1,10,'x'), (2,20,'y'); 805SELECT MAX(a) FROM t37 WHERE a < 100; 806MAX(a) 80720 808DROP TABLE t37; 809# 810# MDEV-4090: RocksDB: Wrong result (duplicate rows) on range access with secondary key and ORDER BY DESC 811# 812CREATE TABLE t38 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB; 813INSERT INTO t38 VALUES (1,10), (2,20); 814SELECT i FROM t38 WHERE i NOT IN (8) ORDER BY i DESC; 815i 81620 81710 818drop table t38; 819# 820# MDEV-4092: RocksDB: Assertion `in_table(pa, a_len)' fails in Rdb_key_def::cmp_full_keys 821# with a multi-part key and ORDER BY .. DESC 822# 823CREATE TABLE t40 (pk1 INT PRIMARY KEY, a INT, b VARCHAR(1), KEY(b,a)) ENGINE=RocksDB; 824INSERT INTO t40 VALUES (1, 7,'x'),(2,8,'y'); 825CREATE TABLE t41 (pk2 INT PRIMARY KEY) ENGINE=RocksDB; 826INSERT INTO t41 VALUES (1),(2); 827SELECT * FROM t40, t41 WHERE pk1 = pk2 AND b = 'o' ORDER BY a DESC; 828pk1 a b pk2 829DROP TABLE t40,t41; 830# 831# MDEV-4093: RocksDB: IN subquery by secondary key with NULL among values returns true instead of NULL 832# 833CREATE TABLE t42 (pk INT PRIMARY KEY, a INT, KEY(a)) ENGINE=RocksDB; 834INSERT INTO t42 VALUES (1, NULL),(2, 8); 835SELECT ( 3 ) NOT IN ( SELECT a FROM t42 ); 836( 3 ) NOT IN ( SELECT a FROM t42 ) 837NULL 838DROP TABLE t42; 839# 840# MDEV-4094: RocksDB: Wrong result on SELECT and ER_KEY_NOT_FOUND on 841# DELETE with search by NULL-able secondary key ... 842# 843CREATE TABLE t43 (pk INT PRIMARY KEY, a INT, b CHAR(1), KEY(a)) ENGINE=RocksDB; 844INSERT INTO t43 VALUES (1,8,'g'),(2,9,'x'); 845UPDATE t43 SET pk = 10 WHERE a = 8; 846REPLACE INTO t43 ( pk, a ) VALUES ( 1, 8 ); 847REPLACE INTO t43 ( pk, b ) VALUES ( 3, 'y' ); 848SELECT * FROM t43 WHERE a = 8; 849pk a b 8501 8 NULL 85110 8 g 852DELETE FROM t43 WHERE a = 8; 853DROP TABLE t43; 854# 855# Basic AUTO_INCREMENT tests 856# 857create table t44(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb; 858insert into t44 (col1) values ('row1'); 859insert into t44 (col1) values ('row2'); 860insert into t44 (col1) values ('row3'); 861select * from t44; 862pk col1 8631 row1 8642 row2 8653 row3 866drop table t44; 867# 868# ALTER TABLE tests 869# 870create table t45 (pk int primary key, col1 varchar(12)) engine=rocksdb; 871insert into t45 values (1, 'row1'); 872insert into t45 values (2, 'row2'); 873alter table t45 rename t46; 874select * from t46; 875pk col1 8761 row1 8772 row2 878drop table t46; 879drop table t45; 880ERROR 42S02: Unknown table 'test.t45' 881# 882# Check Bulk loading 883# Bulk loading used to overwrite existing data 884# Now it fails if there is data overlap with what 885# already exists 886# 887show variables where variable_name like 'rocksdb%' and variable_name not like 'rocksdb_max_open_files'; 888Variable_name Value 889rocksdb_access_hint_on_compaction_start 1 890rocksdb_advise_random_on_open ON 891rocksdb_allow_concurrent_memtable_write OFF 892rocksdb_allow_mmap_reads OFF 893rocksdb_allow_mmap_writes OFF 894rocksdb_allow_to_start_after_corruption OFF 895rocksdb_alter_column_default_inplace ON 896rocksdb_blind_delete_primary_key OFF 897rocksdb_block_cache_size 536870912 898rocksdb_block_restart_interval 16 899rocksdb_block_size 4096 900rocksdb_block_size_deviation 10 901rocksdb_bulk_load OFF 902rocksdb_bulk_load_allow_sk OFF 903rocksdb_bulk_load_allow_unsorted OFF 904rocksdb_bulk_load_size 1000 905rocksdb_bytes_per_sync 0 906rocksdb_cache_dump ON 907rocksdb_cache_high_pri_pool_ratio 0.000000 908rocksdb_cache_index_and_filter_blocks ON 909rocksdb_cache_index_and_filter_with_high_priority ON 910rocksdb_checksums_pct 100 911rocksdb_collect_sst_properties ON 912rocksdb_commit_in_the_middle OFF 913rocksdb_commit_time_batch_for_recovery OFF 914rocksdb_compact_cf 915rocksdb_compaction_readahead_size 0 916rocksdb_compaction_sequential_deletes 0 917rocksdb_compaction_sequential_deletes_count_sd OFF 918rocksdb_compaction_sequential_deletes_file_size 0 919rocksdb_compaction_sequential_deletes_window 0 920rocksdb_concurrent_prepare ON 921rocksdb_create_checkpoint 922rocksdb_create_if_missing ON 923rocksdb_create_missing_column_families OFF 924rocksdb_datadir ./.rocksdb 925rocksdb_db_write_buffer_size 0 926rocksdb_deadlock_detect OFF 927rocksdb_deadlock_detect_depth 50 928rocksdb_debug_manual_compaction_delay 0 929rocksdb_debug_optimizer_no_zero_cardinality ON 930rocksdb_debug_ttl_ignore_pk OFF 931rocksdb_debug_ttl_read_filter_ts 0 932rocksdb_debug_ttl_rec_ts 0 933rocksdb_debug_ttl_snapshot_ts 0 934rocksdb_default_cf_options compression=kLZ4Compression;bottommost_compression=kLZ4Compression 935rocksdb_delayed_write_rate 0 936rocksdb_delete_cf 937rocksdb_delete_obsolete_files_period_micros 21600000000 938rocksdb_enable_bulk_load_api ON 939rocksdb_enable_insert_with_update_caching ON 940rocksdb_enable_iterate_bounds ON 941rocksdb_enable_native_partition ON 942rocksdb_enable_pipelined_write OFF 943rocksdb_enable_remove_orphaned_dropped_cfs ON 944rocksdb_enable_thread_tracking ON 945rocksdb_enable_ttl ON 946rocksdb_enable_ttl_read_filtering ON 947rocksdb_enable_write_thread_adaptive_yield OFF 948rocksdb_error_if_exists OFF 949rocksdb_error_on_suboptimal_collation OFF 950rocksdb_flush_log_at_trx_commit 1 951rocksdb_force_compute_memtable_stats ON 952rocksdb_force_compute_memtable_stats_cachetime 0 953rocksdb_force_flush_memtable_and_lzero_now OFF 954rocksdb_force_flush_memtable_now OFF 955rocksdb_force_index_records_in_range 0 956rocksdb_hash_index_allow_collision ON 957rocksdb_ignore_unknown_options ON 958rocksdb_index_type kBinarySearch 959rocksdb_info_log_level error_level 960rocksdb_is_fd_close_on_exec ON 961rocksdb_keep_log_file_num 1000 962rocksdb_large_prefix OFF 963rocksdb_lock_scanned_rows OFF 964rocksdb_lock_wait_timeout 1 965rocksdb_log_file_time_to_roll 0 966rocksdb_manifest_preallocation_size 4194304 967rocksdb_manual_compaction_bottommost_level kForceOptimized 968rocksdb_manual_compaction_threads 0 969rocksdb_manual_wal_flush ON 970rocksdb_master_skip_tx_api OFF 971rocksdb_max_background_compactions -1 972rocksdb_max_background_flushes -1 973rocksdb_max_background_jobs 2 974rocksdb_max_bottom_pri_background_compactions 0 975rocksdb_max_latest_deadlocks 5 976rocksdb_max_log_file_size 0 977rocksdb_max_manifest_file_size 1073741824 978rocksdb_max_manual_compactions 10 979rocksdb_max_row_locks 1048576 980rocksdb_max_subcompactions 1 981rocksdb_max_total_wal_size 0 982rocksdb_merge_buf_size 67108864 983rocksdb_merge_combine_read_size 1073741824 984rocksdb_merge_tmp_file_removal_delay_ms 0 985rocksdb_new_table_reader_for_compaction_inputs OFF 986rocksdb_no_block_cache OFF 987rocksdb_no_create_column_family OFF 988rocksdb_override_cf_options 989rocksdb_paranoid_checks ON 990rocksdb_pause_background_work ON 991rocksdb_perf_context_level 0 992rocksdb_persistent_cache_path 993rocksdb_persistent_cache_size_mb 0 994rocksdb_pin_l0_filter_and_index_blocks_in_cache ON 995rocksdb_print_snapshot_conflict_queries OFF 996rocksdb_rate_limiter_bytes_per_sec 0 997rocksdb_read_free_rpl OFF 998rocksdb_read_free_rpl_tables .* 999rocksdb_records_in_range 50 1000rocksdb_reset_stats OFF 1001rocksdb_rollback_on_timeout OFF 1002rocksdb_rpl_skip_tx_api OFF 1003rocksdb_seconds_between_stat_computes 3600 1004rocksdb_signal_drop_index_thread OFF 1005rocksdb_sim_cache_size 0 1006rocksdb_skip_bloom_filter_on_read OFF 1007rocksdb_skip_fill_cache OFF 1008rocksdb_skip_locks_if_skip_unique_check OFF 1009rocksdb_sst_mgr_rate_bytes_per_sec 0 1010rocksdb_stats_dump_period_sec 600 1011rocksdb_stats_level 1 1012rocksdb_stats_recalc_rate 0 1013rocksdb_store_row_debug_checksums OFF 1014rocksdb_strict_collation_check OFF 1015rocksdb_strict_collation_exceptions 1016rocksdb_table_cache_numshardbits 6 1017rocksdb_table_stats_background_thread_nice_value 19 1018rocksdb_table_stats_max_num_rows_scanned 0 1019rocksdb_table_stats_recalc_threshold_count 100 1020rocksdb_table_stats_recalc_threshold_pct 10 1021rocksdb_table_stats_sampling_pct 10 1022rocksdb_table_stats_use_table_scan OFF 1023rocksdb_tmpdir 1024rocksdb_trace_block_cache_access 1025rocksdb_trace_queries 1026rocksdb_trace_sst_api OFF 1027rocksdb_track_and_verify_wals_in_manifest ON 1028rocksdb_two_write_queues ON 1029rocksdb_unsafe_for_binlog OFF 1030rocksdb_update_cf_options 1031rocksdb_use_adaptive_mutex OFF 1032rocksdb_use_default_sk_cf OFF 1033rocksdb_use_direct_io_for_flush_and_compaction OFF 1034rocksdb_use_direct_reads OFF 1035rocksdb_use_fsync OFF 1036rocksdb_validate_tables 1 1037rocksdb_verify_row_debug_checksums OFF 1038rocksdb_wal_bytes_per_sync 0 1039rocksdb_wal_dir 1040rocksdb_wal_recovery_mode 2 1041rocksdb_wal_size_limit_mb 0 1042rocksdb_wal_ttl_seconds 0 1043rocksdb_whole_key_filtering ON 1044rocksdb_write_batch_flush_threshold 0 1045rocksdb_write_batch_max_bytes 0 1046rocksdb_write_disable_wal OFF 1047rocksdb_write_ignore_missing_column_families OFF 1048rocksdb_write_policy write_committed 1049create table t47 (pk int primary key, col1 varchar(12)) engine=rocksdb; 1050insert into t47 values (1, 'row1'); 1051insert into t47 values (2, 'row2'); 1052set rocksdb_bulk_load=1; 1053insert into t47 values (3, 'row3'),(4, 'row4'); 1054set rocksdb_bulk_load=0; 1055connect con1,localhost,root,,; 1056set rocksdb_bulk_load=1; 1057insert into t47 values (10, 'row10'),(11, 'row11'); 1058connection default; 1059set rocksdb_bulk_load=1; 1060insert into t47 values (100, 'row100'),(101, 'row101'); 1061disconnect con1; 1062connection default; 1063set rocksdb_bulk_load=0; 1064select * from t47; 1065pk col1 10661 row1 10672 row2 10683 row3 10694 row4 107010 row10 107111 row11 1072100 row100 1073101 row101 1074drop table t47; 1075# 1076# Fix TRUNCATE over empty table (transaction is committed when it wasn't 1077# started) 1078# 1079create table t48(pk int primary key auto_increment, col1 varchar(12)) engine=rocksdb; 1080set autocommit=0; 1081truncate table t48; 1082set autocommit=1; 1083drop table t48; 1084# 1085# MDEV-4059: RocksDB: query waiting for a lock cannot be killed until query timeout exceeded 1086# 1087create table t49 (pk int primary key, a int) engine=RocksDB; 1088insert into t49 values (1,10),(2,20); 1089begin; 1090update t49 set a = 100 where pk = 1; 1091connect con1,localhost,root,,; 1092set rocksdb_lock_wait_timeout=60; 1093set @var1= to_seconds(now()); 1094update t49 set a = 1000 where pk = 1; 1095connect con2,localhost,root,,; 1096kill query $con1_id; 1097connection con1; 1098ERROR 70100: Query execution was interrupted 1099set @var2= to_seconds(now()); 1100select if ((@var2 - @var1) < 60, "passed", (@var2 - @var1)) as 'result'; 1101result 1102passed 1103connection default; 1104disconnect con1; 1105disconnect con2; 1106commit; 1107drop table t49; 1108# 1109# Index-only tests for INT-based columns 1110# 1111create table t1 (pk int primary key, key1 int, col1 int, key(key1)) engine=rocksdb; 1112insert into t1 values (1,1,1); 1113insert into t1 values (2,2,2); 1114insert into t1 values (-5,-5,-5); 1115# INT column uses index-only: 1116explain 1117select key1 from t1 where key1=2; 1118id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11191 SIMPLE t1 NULL ref key1 key1 5 const # 100.00 Using index 1120Warnings: 1121Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1` from `test`.`t1` where (`test`.`t1`.`key1` = 2) 1122select key1 from t1 where key1=2; 1123key1 11242 1125select key1 from t1 where key1=-5; 1126key1 1127-5 1128drop table t1; 1129create table t2 (pk int primary key, key1 int unsigned, col1 int, key(key1)) engine=rocksdb; 1130insert into t2 values (1,1,1), (2,2,2); 1131# INT UNSIGNED column uses index-only: 1132explain 1133select key1 from t2 where key1=2; 1134id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11351 SIMPLE t2 NULL ref key1 key1 5 const # 100.00 Using index 1136Warnings: 1137Note 1003 /* select#1 */ select `test`.`t2`.`key1` AS `key1` from `test`.`t2` where (`test`.`t2`.`key1` = 2) 1138select key1 from t2 where key1=2; 1139key1 11402 1141drop table t2; 1142create table t3 (pk bigint primary key, key1 bigint, col1 int, key(key1)) engine=rocksdb; 1143insert into t3 values (1,1,1), (2,2,2); 1144# BIGINT uses index-only: 1145explain 1146select key1 from t3 where key1=2; 1147id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11481 SIMPLE t3 NULL ref key1 key1 9 const # 100.00 Using index 1149Warnings: 1150Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1` from `test`.`t3` where (`test`.`t3`.`key1` = 2) 1151select key1 from t3 where key1=2; 1152key1 11532 1154drop table t3; 1155# 1156# Index-only reads for string columns 1157# 1158create table t1 ( 1159pk int primary key, 1160key1 char(10) character set binary, 1161col1 int, 1162key (key1) 1163) engine=rocksdb; 1164insert into t1 values(1, 'one',11), (2,'two',22); 1165explain 1166select key1 from t1 where key1='one'; 1167id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11681 SIMPLE t1 NULL ref key1 key1 11 const # 100.00 Using where; Using index 1169Warnings: 1170Note 1003 /* select#1 */ select `test`.`t1`.`key1` AS `key1` from `test`.`t1` where (`test`.`t1`.`key1` = 'one') 1171# The following will produce no rows. This looks like a bug, 1172# but it is actually correct behavior. Binary strings are end-padded 1173# with \0 character (and not space). Comparison does not ignore 1174# the tail of \0. 1175select key1 from t1 where key1='one'; 1176key1 1177explain 1178select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0'; 1179id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11801 SIMPLE t1 NULL ref key1 key1 11 const # 100.00 Using where; Using index 1181Warnings: 1182Note 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') 1183select hex(key1) from t1 where key1='one\0\0\0\0\0\0\0'; 1184hex(key1) 11856F6E6500000000000000 1186drop table t1; 1187create table t2 ( 1188pk int primary key, 1189key1 char(10) collate latin1_bin, 1190col1 int, 1191key (key1) 1192) engine=rocksdb; 1193insert into t2 values(1, 'one',11), (2,'two',22); 1194explain 1195select key1 from t2 where key1='one'; 1196id select_type table partitions type possible_keys key key_len ref rows filtered Extra 11971 SIMPLE t2 NULL ref key1 key1 11 const # 100.00 Using index 1198Warnings: 1199Note 1003 /* select#1 */ select `test`.`t2`.`key1` AS `key1` from `test`.`t2` where (`test`.`t2`.`key1` = 'one') 1200select key1 from t2 where key1='one'; 1201key1 1202one 1203drop table t2; 1204create table t3 ( 1205pk int primary key, 1206key1 char(10) collate utf8_bin, 1207col1 int, 1208key (key1) 1209) engine=rocksdb; 1210insert into t3 values(1, 'one',11), (2,'two',22); 1211explain 1212select key1 from t3 where key1='one'; 1213id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12141 SIMPLE t3 NULL ref key1 key1 31 const # 100.00 Using index 1215Warnings: 1216Note 1003 /* select#1 */ select `test`.`t3`.`key1` AS `key1` from `test`.`t3` where (`test`.`t3`.`key1` = 'one') 1217select key1 from t3 where key1='one'; 1218key1 1219one 1220drop table t3; 1221# a VARCHAR column 1222create table t4 ( 1223pk int primary key, 1224key1 varchar(10) collate latin1_bin, 1225key(key1) 1226) engine=rocksdb; 1227insert into t4 values(1, 'one'), (2,'two'),(3,'threee'),(55,'fifty-five'); 1228explain 1229select key1 from t4 where key1='two'; 1230id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12311 SIMPLE t4 NULL ref key1 key1 13 const # 100.00 Using index 1232Warnings: 1233Note 1003 /* select#1 */ select `test`.`t4`.`key1` AS `key1` from `test`.`t4` where (`test`.`t4`.`key1` = 'two') 1234select key1 from t4 where key1='two'; 1235key1 1236two 1237select key1 from t4 where key1='fifty-five'; 1238key1 1239fifty-five 1240explain 1241select key1 from t4 where key1 between 's' and 'u'; 1242id select_type table partitions type possible_keys key key_len ref rows filtered Extra 12431 SIMPLE t4 NULL range key1 key1 13 NULL # 100.00 Using where; Using index 1244Warnings: 1245Note 1003 /* select#1 */ select `test`.`t4`.`key1` AS `key1` from `test`.`t4` where (`test`.`t4`.`key1` between 's' and 'u') 1246select key1 from t4 where key1 between 's' and 'u'; 1247key1 1248threee 1249two 1250drop table t4; 1251# 1252# MDEV-4305: RocksDB: Assertion `((keypart_map + 1) & keypart_map) == 0' fails in calculate_key_len 1253# 1254CREATE TABLE t1 (pk1 INT, pk2 CHAR(32), i INT, PRIMARY KEY(pk1,pk2), KEY(i)) ENGINE=RocksDB; 1255INSERT INTO t1 VALUES (1,'test1',6),(2,'test2',8); 1256SELECT * FROM t1 WHERE i != 3 OR pk1 > 9; 1257pk1 pk2 i 12581 test1 6 12592 test2 8 1260DROP TABLE t1; 1261# 1262# MDEV-4298: RocksDB: Assertion `thd->is_error() || kill_errno' fails in ha_rows filesort 1263# 1264CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, KEY(i)) ENGINE=RocksDB; 1265INSERT INTO t1 VALUES (1,1),(2,2); 1266set @orig_tx_iso=@@session.transaction_isolation; 1267set session transaction_isolation='READ-COMMITTED'; 1268BEGIN; 1269UPDATE t1 SET i = 100; 1270connect con1,localhost,root,,test; 1271DELETE IGNORE FROM t1 ORDER BY i; 1272ERROR HY000: Lock wait timeout exceeded; try restarting transaction 1273disconnect con1; 1274connection default; 1275COMMIT; 1276set session transaction_isolation=@orig_tx_iso; 1277DROP TABLE t1; 1278# 1279# MDEV-4324: RocksDB: Valgrind "Use of uninitialised value" warnings on inserting value into varchar field 1280# (testcase only) 1281# 1282CREATE TABLE t1 (pk INT PRIMARY KEY, c VARCHAR(4)) ENGINE=RocksDB; 1283INSERT INTO t1 VALUES (1,'foo'), (2,'bar'); 1284DROP TABLE t1; 1285# 1286# MDEV-4304: RocksDB: Index-only scan by a field with utf8_bin collation returns garbage symbols 1287# 1288CREATE TABLE t1 (pk INT PRIMARY KEY, c1 CHAR(1), c2 CHAR(1), KEY(c1)) ENGINE=RocksDB CHARSET utf8 COLLATE utf8_bin; 1289INSERT INTO t1 VALUES (1,'h','h'); 1290SELECT * FROM t1; 1291pk c1 c2 12921 h h 1293SELECT c1 FROM t1; 1294c1 1295h 1296DROP TABLE t1; 1297# 1298# MDEV-4300: RocksDB: Server crashes in inline_mysql_mutex_lock on SELECT .. FOR UPDATE 1299# 1300CREATE TABLE t2 (pk INT PRIMARY KEY, i INT, KEY (i)) ENGINE=RocksDB; 1301INSERT INTO t2 VALUES (1,4),(2,5); 1302SELECT 1 FROM t2 WHERE i < 0 FOR UPDATE; 13031 1304DROP TABLE t2; 1305# 1306# MDEV-4301: RocksDB: Assertion `pack_info != __null' fails in Rdb_key_def::unpack_record 1307# 1308CREATE TABLE t1 (pk INT PRIMARY KEY, i INT, c CHAR(1), KEY(c,i)) ENGINE=RocksDB; 1309INSERT INTO t1 VALUES (1,4,'d'),(2,8,'e'); 1310SELECT MAX( pk ) FROM t1 WHERE i = 105 AND c = 'h'; 1311MAX( pk ) 1312NULL 1313DROP TABLE t1; 1314# 1315# MDEV-4337: RocksDB: Inconsistent results comparing a char field with an int field 1316# 1317create table t1 (c char(1), i int, primary key(c), key(i)) engine=RocksDB; 1318insert into t1 values ('2',2),('6',6); 1319select * from t1 where c = i; 1320c i 13212 2 13226 6 1323select * from t1 ignore index (i) where c = i; 1324c i 13252 2 13266 6 1327drop table t1; 1328# 1329# Test statement rollback inside a transaction 1330# 1331create table t1 (pk varchar(12) primary key) engine=rocksdb; 1332insert into t1 values ('old-val1'),('old-val2'); 1333create table t2 (pk varchar(12) primary key) engine=rocksdb; 1334insert into t2 values ('new-val2'),('old-val1'); 1335set @orig_tx_iso=@@session.transaction_isolation; 1336set session transaction_isolation='READ-COMMITTED'; 1337begin; 1338insert into t1 values ('new-val1'); 1339insert into t1 select * from t2; 1340ERROR 23000: Duplicate entry 'old-val1' for key 'PRIMARY' 1341commit; 1342set session transaction_isolation=@orig_tx_iso; 1343select * from t1; 1344pk 1345new-val1 1346old-val1 1347old-val2 1348drop table t1, t2; 1349# 1350# MDEV-4383: RocksDB: Wrong result of DELETE .. ORDER BY .. LIMIT: 1351# rows that should be deleted remain in the table 1352# 1353CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB; 1354CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=RocksDB; 1355INSERT INTO t1 (pk) VALUES (NULL),(NULL); 1356set @orig_tx_iso=@@session.transaction_isolation; 1357set session transaction_isolation='READ-COMMITTED'; 1358BEGIN; 1359INSERT INTO t2 (pk) VALUES (NULL),(NULL); 1360INSERT INTO t1 (pk) VALUES (NULL),(NULL),(NULL),(NULL),(NULL),(NULL); 1361SELECT * FROM t1 ORDER BY pk LIMIT 9; 1362pk 13631 13642 13653 13664 13675 13686 13697 13708 1371affected rows: 8 1372DELETE FROM t1 ORDER BY pk LIMIT 9; 1373affected rows: 8 1374SELECT * FROM t1 ORDER BY pk LIMIT 9; 1375pk 1376affected rows: 0 1377COMMIT; 1378DROP TABLE t1,t2; 1379set session transaction_isolation=@orig_tx_iso; 1380# 1381# MDEV-4374: RocksDB: Valgrind warnings 'Use of uninitialised value' on 1382# inserting into a varchar column 1383# 1384CREATE TABLE t1 (pk INT PRIMARY KEY, a VARCHAR(32)) ENGINE=ROCKSDB; 1385INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); 1386DROP TABLE t1; 1387# 1388# MDEV-4061: RocksDB: Changes from an interrupted query are still applied 1389# 1390create table t1 (pk int primary key, a int) engine=rocksdb; 1391insert into t1 values (1,10),(2,20); 1392set autocommit = 1; 1393update t1 set a = sleep(300) where pk = 1;; 1394connect con1,localhost,root,,; 1395kill query $con_id; 1396connection default; 1397ERROR 70100: Query execution was interrupted 1398select * from t1; 1399pk a 14001 10 14012 20 1402disconnect con1; 1403drop table t1; 1404# 1405# MDEV-4099: RocksDB: Wrong results with index and range access after INSERT IGNORE or REPLACE 1406# 1407CREATE TABLE t1 (pk INT PRIMARY KEY, a SMALLINT, b INT, KEY (a)) ENGINE=RocksDB; 1408INSERT IGNORE INTO t1 VALUES (1, 157, 0), (2, 1898, -504403), (1, -14659, 0); 1409Warnings: 1410Warning 1062 Duplicate entry '1' for key 'PRIMARY' 1411SELECT * FROM t1; 1412pk a b 14131 157 0 14142 1898 -504403 1415SELECT pk FROM t1; 1416pk 14171 14182 1419SELECT * FROM t1 WHERE a != 97; 1420pk a b 14211 157 0 14222 1898 -504403 1423DROP TABLE t1; 1424# 1425# Test @@rocksdb_max_row_locks 1426# 1427CREATE TABLE t1 (pk INT PRIMARY KEY, a int) ENGINE=RocksDB; 1428set @a=-1; 1429insert into t1 select (@a:=@a+1), 1234 from performance_schema.session_variables limit 100; 1430set @tmp1= @@rocksdb_max_row_locks; 1431set GLOBAL rocksdb_max_row_locks= 20; 1432update t1 set a=a+10; 1433ERROR HY000: Got error 10 'Operation aborted: Failed to acquire lock due to rocksdb_max_row_locks limit' from ROCKSDB 1434set @@global.rocksdb_max_row_locks = @tmp1; 1435DROP TABLE t1; 1436# 1437# Test AUTO_INCREMENT behavior problem, 1438# "explicit insert into an auto-inc column is not noticed by RocksDB" 1439# 1440create table t1 (i int primary key auto_increment) engine=RocksDB; 1441insert into t1 values (null); 1442insert into t1 values (null); 1443select * from t1; 1444i 14451 14462 1447drop table t1; 1448create table t2 (i int primary key auto_increment) engine=RocksDB; 1449insert into t2 values (1); 1450select * from t2; 1451i 14521 1453# this fails (ie. used to fail), RocksDB engine did not notice use of '1' above 1454insert into t2 values (null); 1455select * from t2; 1456i 14571 14582 1459# but then this succeeds, so previous statement must have incremented next number counter 1460insert into t2 values (null); 1461select * from t2; 1462i 14631 14642 14653 1466drop table t2; 1467# 1468# Fix Issue#2: AUTO_INCREMENT value doesn't survive server shutdown 1469# 1470create table t1 (i int primary key auto_increment) engine=RocksDB; 1471insert into t1 values (null); 1472insert into t1 values (null); 1473SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; 1474# restart 1475SET @ORIG_PAUSE_BACKGROUND_WORK = @@ROCKSDB_PAUSE_BACKGROUND_WORK; 1476SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = 1; 1477insert into t1 values (null); 1478select * from t1; 1479i 14801 14812 14823 1483drop table t1; 1484# 1485# Fix Issue #3: SHOW TABLE STATUS shows Auto_increment=0 1486# 1487create table t1 (i int primary key auto_increment) engine=RocksDB; 1488insert into t1 values (null),(null); 1489show table status like 't1'; 1490Name 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 1491t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL 1492drop table t1; 1493# 1494# Fix Issue #4: Crash when using pseudo-unique keys 1495# 1496CREATE TABLE t1 ( 1497i INT, 1498t TINYINT, 1499s SMALLINT, 1500m MEDIUMINT, 1501b BIGINT, 1502pk MEDIUMINT AUTO_INCREMENT PRIMARY KEY, 1503UNIQUE KEY b_t (b,t) 1504) ENGINE=rocksdb; 1505INSERT 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); 1506SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t; 1507b+t 15089 150911 151025 151127 151229 1513207 151410107 1515100000000000000100 15161000000000000000100 1517DROP TABLE t1; 1518# 1519# Fix issue #5: Transaction rollback doesn't undo all changes. 1520# 1521create table t0 (a int) engine=myisam; 1522insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1523create table t1 (id int auto_increment primary key, value int) engine=rocksdb; 1524set autocommit=0; 1525begin; 1526set @a:=0; 1527insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1528insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1529insert into t1 select @a:=@a+1, @a from t0 A, t0 B, t0 C, t0 D where D.a<4; 1530rollback; 1531select count(*) from t1; 1532count(*) 15330 1534set autocommit=1; 1535drop table t0, t1; 1536# 1537# Check status variables 1538# NOTE: We exclude rocksdb_num_get_for_update_calls because it's a debug only status var 1539# 1540show status where variable_name like 'rocksdb%' and variable_name not like '%num_get_for_update%'; 1541Variable_name Value 1542rocksdb_rows_deleted # 1543rocksdb_rows_deleted_blind # 1544rocksdb_rows_inserted # 1545rocksdb_rows_read # 1546rocksdb_rows_updated # 1547rocksdb_rows_expired # 1548rocksdb_rows_filtered # 1549rocksdb_system_rows_deleted # 1550rocksdb_system_rows_inserted # 1551rocksdb_system_rows_read # 1552rocksdb_system_rows_updated # 1553rocksdb_memtable_total # 1554rocksdb_memtable_unflushed # 1555rocksdb_queries_point # 1556rocksdb_queries_range # 1557rocksdb_table_index_stats_success # 1558rocksdb_table_index_stats_failure # 1559rocksdb_table_index_stats_req_queue_length # 1560rocksdb_covered_secondary_key_lookups # 1561rocksdb_additional_compaction_triggers # 1562rocksdb_block_cache_add # 1563rocksdb_block_cache_add_failures # 1564rocksdb_block_cache_bytes_read # 1565rocksdb_block_cache_bytes_write # 1566rocksdb_block_cache_compressed_hit # 1567rocksdb_block_cache_compressed_miss # 1568rocksdb_block_cache_data_add # 1569rocksdb_block_cache_data_bytes_insert # 1570rocksdb_block_cache_data_hit # 1571rocksdb_block_cache_data_miss # 1572rocksdb_block_cache_filter_add # 1573rocksdb_block_cache_filter_bytes_evict # 1574rocksdb_block_cache_filter_bytes_insert # 1575rocksdb_block_cache_filter_hit # 1576rocksdb_block_cache_filter_miss # 1577rocksdb_block_cache_hit # 1578rocksdb_block_cache_index_add # 1579rocksdb_block_cache_index_bytes_evict # 1580rocksdb_block_cache_index_bytes_insert # 1581rocksdb_block_cache_index_hit # 1582rocksdb_block_cache_index_miss # 1583rocksdb_block_cache_miss # 1584rocksdb_bloom_filter_full_positive # 1585rocksdb_bloom_filter_full_true_positive # 1586rocksdb_bloom_filter_prefix_checked # 1587rocksdb_bloom_filter_prefix_useful # 1588rocksdb_bloom_filter_useful # 1589rocksdb_bytes_read # 1590rocksdb_bytes_written # 1591rocksdb_compact_read_bytes # 1592rocksdb_compact_write_bytes # 1593rocksdb_compaction_key_drop_new # 1594rocksdb_compaction_key_drop_obsolete # 1595rocksdb_compaction_key_drop_user # 1596rocksdb_flush_write_bytes # 1597rocksdb_get_hit_l0 # 1598rocksdb_get_hit_l1 # 1599rocksdb_get_hit_l2_and_up # 1600rocksdb_get_updates_since_calls # 1601rocksdb_iter_bytes_read # 1602rocksdb_manual_compactions_processed # 1603rocksdb_manual_compactions_running # 1604rocksdb_memtable_hit # 1605rocksdb_memtable_miss # 1606rocksdb_no_file_closes # 1607rocksdb_no_file_errors # 1608rocksdb_no_file_opens # 1609rocksdb_num_iterators # 1610rocksdb_number_block_not_compressed # 1611rocksdb_number_db_next # 1612rocksdb_number_db_next_found # 1613rocksdb_number_db_prev # 1614rocksdb_number_db_prev_found # 1615rocksdb_number_db_seek # 1616rocksdb_number_db_seek_found # 1617rocksdb_number_deletes_filtered # 1618rocksdb_number_keys_read # 1619rocksdb_number_keys_updated # 1620rocksdb_number_keys_written # 1621rocksdb_number_merge_failures # 1622rocksdb_number_multiget_bytes_read # 1623rocksdb_number_multiget_get # 1624rocksdb_number_multiget_keys_read # 1625rocksdb_number_reseeks_iteration # 1626rocksdb_number_sst_entry_delete # 1627rocksdb_number_sst_entry_merge # 1628rocksdb_number_sst_entry_other # 1629rocksdb_number_sst_entry_put # 1630rocksdb_number_sst_entry_singledelete # 1631rocksdb_number_superversion_acquires # 1632rocksdb_number_superversion_cleanups # 1633rocksdb_number_superversion_releases # 1634rocksdb_row_lock_deadlocks # 1635rocksdb_row_lock_wait_timeouts # 1636rocksdb_snapshot_conflict_errors # 1637rocksdb_stall_l0_file_count_limit_slowdowns # 1638rocksdb_stall_locked_l0_file_count_limit_slowdowns # 1639rocksdb_stall_l0_file_count_limit_stops # 1640rocksdb_stall_locked_l0_file_count_limit_stops # 1641rocksdb_stall_pending_compaction_limit_stops # 1642rocksdb_stall_pending_compaction_limit_slowdowns # 1643rocksdb_stall_memtable_limit_stops # 1644rocksdb_stall_memtable_limit_slowdowns # 1645rocksdb_stall_total_stops # 1646rocksdb_stall_total_slowdowns # 1647rocksdb_stall_micros # 1648rocksdb_wal_bytes # 1649rocksdb_wal_group_syncs # 1650rocksdb_wal_synced # 1651rocksdb_write_other # 1652rocksdb_write_self # 1653rocksdb_write_timedout # 1654rocksdb_write_wal # 1655select VARIABLE_NAME from performance_schema.global_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%'; 1656VARIABLE_NAME 1657rocksdb_rows_deleted 1658rocksdb_rows_deleted_blind 1659rocksdb_rows_inserted 1660rocksdb_rows_read 1661rocksdb_rows_updated 1662rocksdb_rows_expired 1663rocksdb_rows_filtered 1664rocksdb_system_rows_deleted 1665rocksdb_system_rows_inserted 1666rocksdb_system_rows_read 1667rocksdb_system_rows_updated 1668rocksdb_memtable_total 1669rocksdb_memtable_unflushed 1670rocksdb_queries_point 1671rocksdb_queries_range 1672rocksdb_table_index_stats_success 1673rocksdb_table_index_stats_failure 1674rocksdb_table_index_stats_req_queue_length 1675rocksdb_covered_secondary_key_lookups 1676rocksdb_additional_compaction_triggers 1677rocksdb_block_cache_add 1678rocksdb_block_cache_add_failures 1679rocksdb_block_cache_bytes_read 1680rocksdb_block_cache_bytes_write 1681rocksdb_block_cache_compressed_hit 1682rocksdb_block_cache_compressed_miss 1683rocksdb_block_cache_data_add 1684rocksdb_block_cache_data_bytes_insert 1685rocksdb_block_cache_data_hit 1686rocksdb_block_cache_data_miss 1687rocksdb_block_cache_filter_add 1688rocksdb_block_cache_filter_bytes_evict 1689rocksdb_block_cache_filter_bytes_insert 1690rocksdb_block_cache_filter_hit 1691rocksdb_block_cache_filter_miss 1692rocksdb_block_cache_hit 1693rocksdb_block_cache_index_add 1694rocksdb_block_cache_index_bytes_evict 1695rocksdb_block_cache_index_bytes_insert 1696rocksdb_block_cache_index_hit 1697rocksdb_block_cache_index_miss 1698rocksdb_block_cache_miss 1699rocksdb_bloom_filter_full_positive 1700rocksdb_bloom_filter_full_true_positive 1701rocksdb_bloom_filter_prefix_checked 1702rocksdb_bloom_filter_prefix_useful 1703rocksdb_bloom_filter_useful 1704rocksdb_bytes_read 1705rocksdb_bytes_written 1706rocksdb_compact_read_bytes 1707rocksdb_compact_write_bytes 1708rocksdb_compaction_key_drop_new 1709rocksdb_compaction_key_drop_obsolete 1710rocksdb_compaction_key_drop_user 1711rocksdb_flush_write_bytes 1712rocksdb_get_hit_l0 1713rocksdb_get_hit_l1 1714rocksdb_get_hit_l2_and_up 1715rocksdb_get_updates_since_calls 1716rocksdb_iter_bytes_read 1717rocksdb_manual_compactions_processed 1718rocksdb_manual_compactions_running 1719rocksdb_memtable_hit 1720rocksdb_memtable_miss 1721rocksdb_no_file_closes 1722rocksdb_no_file_errors 1723rocksdb_no_file_opens 1724rocksdb_num_iterators 1725rocksdb_number_block_not_compressed 1726rocksdb_number_db_next 1727rocksdb_number_db_next_found 1728rocksdb_number_db_prev 1729rocksdb_number_db_prev_found 1730rocksdb_number_db_seek 1731rocksdb_number_db_seek_found 1732rocksdb_number_deletes_filtered 1733rocksdb_number_keys_read 1734rocksdb_number_keys_updated 1735rocksdb_number_keys_written 1736rocksdb_number_merge_failures 1737rocksdb_number_multiget_bytes_read 1738rocksdb_number_multiget_get 1739rocksdb_number_multiget_keys_read 1740rocksdb_number_reseeks_iteration 1741rocksdb_number_sst_entry_delete 1742rocksdb_number_sst_entry_merge 1743rocksdb_number_sst_entry_other 1744rocksdb_number_sst_entry_put 1745rocksdb_number_sst_entry_singledelete 1746rocksdb_number_superversion_acquires 1747rocksdb_number_superversion_cleanups 1748rocksdb_number_superversion_releases 1749rocksdb_row_lock_deadlocks 1750rocksdb_row_lock_wait_timeouts 1751rocksdb_snapshot_conflict_errors 1752rocksdb_stall_l0_file_count_limit_slowdowns 1753rocksdb_stall_locked_l0_file_count_limit_slowdowns 1754rocksdb_stall_l0_file_count_limit_stops 1755rocksdb_stall_locked_l0_file_count_limit_stops 1756rocksdb_stall_pending_compaction_limit_stops 1757rocksdb_stall_pending_compaction_limit_slowdowns 1758rocksdb_stall_memtable_limit_stops 1759rocksdb_stall_memtable_limit_slowdowns 1760rocksdb_stall_total_stops 1761rocksdb_stall_total_slowdowns 1762rocksdb_stall_micros 1763rocksdb_wal_bytes 1764rocksdb_wal_group_syncs 1765rocksdb_wal_synced 1766rocksdb_write_other 1767rocksdb_write_self 1768rocksdb_write_timedout 1769rocksdb_write_wal 1770# RocksDB-SE's status variables are global internally 1771# but they are shown as both session and global, like InnoDB's status vars. 1772select VARIABLE_NAME from performance_schema.session_status where VARIABLE_NAME LIKE 'rocksdb%' and VARIABLE_NAME NOT LIKE '%num_get_for_update%'; 1773VARIABLE_NAME 1774rocksdb_rows_deleted 1775rocksdb_rows_deleted_blind 1776rocksdb_rows_inserted 1777rocksdb_rows_read 1778rocksdb_rows_updated 1779rocksdb_rows_expired 1780rocksdb_rows_filtered 1781rocksdb_system_rows_deleted 1782rocksdb_system_rows_inserted 1783rocksdb_system_rows_read 1784rocksdb_system_rows_updated 1785rocksdb_memtable_total 1786rocksdb_memtable_unflushed 1787rocksdb_queries_point 1788rocksdb_queries_range 1789rocksdb_table_index_stats_success 1790rocksdb_table_index_stats_failure 1791rocksdb_table_index_stats_req_queue_length 1792rocksdb_covered_secondary_key_lookups 1793rocksdb_additional_compaction_triggers 1794rocksdb_block_cache_add 1795rocksdb_block_cache_add_failures 1796rocksdb_block_cache_bytes_read 1797rocksdb_block_cache_bytes_write 1798rocksdb_block_cache_compressed_hit 1799rocksdb_block_cache_compressed_miss 1800rocksdb_block_cache_data_add 1801rocksdb_block_cache_data_bytes_insert 1802rocksdb_block_cache_data_hit 1803rocksdb_block_cache_data_miss 1804rocksdb_block_cache_filter_add 1805rocksdb_block_cache_filter_bytes_evict 1806rocksdb_block_cache_filter_bytes_insert 1807rocksdb_block_cache_filter_hit 1808rocksdb_block_cache_filter_miss 1809rocksdb_block_cache_hit 1810rocksdb_block_cache_index_add 1811rocksdb_block_cache_index_bytes_evict 1812rocksdb_block_cache_index_bytes_insert 1813rocksdb_block_cache_index_hit 1814rocksdb_block_cache_index_miss 1815rocksdb_block_cache_miss 1816rocksdb_bloom_filter_full_positive 1817rocksdb_bloom_filter_full_true_positive 1818rocksdb_bloom_filter_prefix_checked 1819rocksdb_bloom_filter_prefix_useful 1820rocksdb_bloom_filter_useful 1821rocksdb_bytes_read 1822rocksdb_bytes_written 1823rocksdb_compact_read_bytes 1824rocksdb_compact_write_bytes 1825rocksdb_compaction_key_drop_new 1826rocksdb_compaction_key_drop_obsolete 1827rocksdb_compaction_key_drop_user 1828rocksdb_flush_write_bytes 1829rocksdb_get_hit_l0 1830rocksdb_get_hit_l1 1831rocksdb_get_hit_l2_and_up 1832rocksdb_get_updates_since_calls 1833rocksdb_iter_bytes_read 1834rocksdb_manual_compactions_processed 1835rocksdb_manual_compactions_running 1836rocksdb_memtable_hit 1837rocksdb_memtable_miss 1838rocksdb_no_file_closes 1839rocksdb_no_file_errors 1840rocksdb_no_file_opens 1841rocksdb_num_iterators 1842rocksdb_number_block_not_compressed 1843rocksdb_number_db_next 1844rocksdb_number_db_next_found 1845rocksdb_number_db_prev 1846rocksdb_number_db_prev_found 1847rocksdb_number_db_seek 1848rocksdb_number_db_seek_found 1849rocksdb_number_deletes_filtered 1850rocksdb_number_keys_read 1851rocksdb_number_keys_updated 1852rocksdb_number_keys_written 1853rocksdb_number_merge_failures 1854rocksdb_number_multiget_bytes_read 1855rocksdb_number_multiget_get 1856rocksdb_number_multiget_keys_read 1857rocksdb_number_reseeks_iteration 1858rocksdb_number_sst_entry_delete 1859rocksdb_number_sst_entry_merge 1860rocksdb_number_sst_entry_other 1861rocksdb_number_sst_entry_put 1862rocksdb_number_sst_entry_singledelete 1863rocksdb_number_superversion_acquires 1864rocksdb_number_superversion_cleanups 1865rocksdb_number_superversion_releases 1866rocksdb_row_lock_deadlocks 1867rocksdb_row_lock_wait_timeouts 1868rocksdb_snapshot_conflict_errors 1869rocksdb_stall_l0_file_count_limit_slowdowns 1870rocksdb_stall_locked_l0_file_count_limit_slowdowns 1871rocksdb_stall_l0_file_count_limit_stops 1872rocksdb_stall_locked_l0_file_count_limit_stops 1873rocksdb_stall_pending_compaction_limit_stops 1874rocksdb_stall_pending_compaction_limit_slowdowns 1875rocksdb_stall_memtable_limit_stops 1876rocksdb_stall_memtable_limit_slowdowns 1877rocksdb_stall_total_stops 1878rocksdb_stall_total_slowdowns 1879rocksdb_stall_micros 1880rocksdb_wal_bytes 1881rocksdb_wal_group_syncs 1882rocksdb_wal_synced 1883rocksdb_write_other 1884rocksdb_write_self 1885rocksdb_write_timedout 1886rocksdb_write_wal 1887# 1888# Fix issue #9: HA_ERR_INTERNAL_ERROR when running linkbench 1889# 1890create table t0 (a int) engine=myisam; 1891insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1892create table t1 ( 1893pk int primary key, 1894col1 varchar(255), 1895key(col1) 1896) engine=rocksdb; 1897insert into t1 select a, repeat('123456789ABCDEF-', 15) from t0; 1898select * from t1 where pk=3; 1899pk col1 19003 123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF-123456789ABCDEF- 1901drop table t0, t1; 1902# 1903# Fix issue #10: Segfault in Rdb_key_def::get_primary_key_tuple 1904# 1905create table t0 (a int) engine=myisam; 1906insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 1907CREATE TABLE t1 ( 1908id1 bigint(20) unsigned NOT NULL DEFAULT '0', 1909id2 bigint(20) unsigned NOT NULL DEFAULT '0', 1910link_type bigint(20) unsigned NOT NULL DEFAULT '0', 1911visibility tinyint(3) NOT NULL DEFAULT '0', 1912data varchar(255) NOT NULL DEFAULT '', 1913time bigint(20) unsigned NOT NULL DEFAULT '0', 1914version int(11) unsigned NOT NULL DEFAULT '0', 1915PRIMARY KEY (link_type,id1,id2) 1916) engine=rocksdb; 1917insert into t1 select a,a,a,1,a,a,a from t0; 1918alter table t1 add index id1_type (id1,link_type,visibility,time,version,data); 1919select * from t1 where id1 = 3; 1920id1 id2 link_type visibility data time version 19213 3 3 1 3 3 3 1922drop table t0,t1; 1923# 1924# Test column families 1925# 1926create table t1 ( 1927pk int primary key, 1928col1 int, 1929col2 int, 1930key(col1) comment 'cf3', 1931key(col2) comment 'cf4' 1932) engine=rocksdb; 1933insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); 1934explain 1935select * from t1 where col1=2; 1936id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19371 SIMPLE t1 NULL ref col1 col1 5 const # 100.00 NULL 1938Warnings: 1939Note 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) 1940select * from t1 where col1=2; 1941pk col1 col2 19422 2 2 1943explain 1944select * from t1 where col2=3; 1945id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19461 SIMPLE t1 NULL ref col2 col2 5 const # 100.00 NULL 1947Warnings: 1948Note 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) 1949select * from t1 where col2=3; 1950pk col1 col2 19513 3 3 1952select * from t1 where pk=4; 1953pk col1 col2 19544 4 4 1955drop table t1; 1956# 1957# Try primary key in a non-default CF: 1958# 1959create table t1 ( 1960pk int, 1961col1 int, 1962col2 int, 1963key(col1) comment 'cf3', 1964key(col2) comment 'cf4', 1965primary key (pk) comment 'cf5' 1966) engine=rocksdb; 1967insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5); 1968explain 1969select * from t1 where col1=2; 1970id select_type table partitions type possible_keys key key_len ref rows filtered Extra 19711 SIMPLE t1 NULL ref col1 col1 5 const # 100.00 NULL 1972Warnings: 1973Note 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) 1974select * from t1 where col1=2; 1975pk col1 col2 19762 2 2 1977select * from t1 where pk=4; 1978pk col1 col2 19794 4 4 1980drop table t1; 1981# 1982# Issue #15: SIGSEGV from reading in blob data 1983# 1984CREATE TABLE t1 ( 1985id int not null, 1986blob_col text, 1987PRIMARY KEY (id) 1988) ENGINE=ROCKSDB CHARSET=latin1; 1989INSERT INTO t1 SET id=123, blob_col=repeat('z',64000) ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col); 1990INSERT INTO t1 SET id=123, blob_col='' ON DUPLICATE KEY UPDATE blob_col=VALUES(blob_col); 1991DROP TABLE t1; 1992# 1993# Issue #17: Automatic per-index column families 1994# (Now deprecated) 1995# 1996create table t1 ( 1997id int not null, 1998key1 int, 1999PRIMARY KEY (id), 2000index (key1) comment '$per_index_cf' 2001) engine=rocksdb; 2002ERROR HY000: The per-index column family option has been deprecated. 2003# 2004# Issue #22: SELECT ... FOR UPDATE takes a long time 2005# 2006create table t0 (a int) engine=myisam; 2007insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2008create table t1 ( 2009id1 int, 2010id2 int, 2011value1 int, 2012value2 int, 2013primary key(id1, id2) COMMENT 'new_column_family', 2014key(id2) 2015) engine=rocksdb default charset=latin1 collate=latin1_bin; 2016insert into t1 select A.a, B.a, 31, 1234 from t0 A, t0 B; 2017explain 2018select * from t1 where id1=30 and value1=30 for update; 2019id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20201 SIMPLE t1 NULL ref PRIMARY PRIMARY 4 const # 10.00 Using where 2021Warnings: 2022Note 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)) 2023set @var1=(select variable_value 2024from performance_schema.global_status 2025where variable_name='rocksdb_number_keys_read'); 2026select * from t1 where id1=3 and value1=3 for update; 2027id1 id2 value1 value2 2028set @var2=(select variable_value 2029from performance_schema.global_status 2030where variable_name='rocksdb_number_keys_read'); 2031# The following must return true (before the fix, the difference was 70): 2032select if((@var2 - @var1) < 30, 1, @var2-@var1); 2033if((@var2 - @var1) < 30, 1, @var2-@var1) 20341 2035drop table t0,t1; 2036# 2037# Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting 2038# 2039create table t1 (id int primary key, value int) engine=rocksdb; 2040insert into t1 values (1,1),(2,2),(3,3); 2041# The following must not use 'Using filesort': 2042explain select * from t1 ORDER BY id; 2043id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20441 SIMPLE t1 NULL index NULL PRIMARY 4 NULL # 100.00 NULL 2045Warnings: 2046Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`test`.`t1`.`value` AS `value` from `test`.`t1` order by `test`.`t1`.`id` 2047drop table t1; 2048# 2049# Issue #26: Index-only scans for DATETIME and TIMESTAMP 2050# 2051create table t0 (a int) engine=myisam; 2052insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2053# Try a DATETIME column: 2054create table t1 ( 2055pk int auto_increment primary key, 2056kp1 datetime, 2057kp2 int, 2058col1 int, 2059key(kp1, kp2) 2060) engine=rocksdb; 2061insert into t1 (kp1,kp2) 2062select date_add('2015-01-01 12:34:56', interval a day), a from t0; 2063select * from t1; 2064pk kp1 kp2 col1 20651 2015-01-01 12:34:56 0 NULL 20662 2015-01-02 12:34:56 1 NULL 20673 2015-01-03 12:34:56 2 NULL 20684 2015-01-04 12:34:56 3 NULL 20695 2015-01-05 12:34:56 4 NULL 20706 2015-01-06 12:34:56 5 NULL 20717 2015-01-07 12:34:56 6 NULL 20728 2015-01-08 12:34:56 7 NULL 20739 2015-01-09 12:34:56 8 NULL 207410 2015-01-10 12:34:56 9 NULL 2075# This must show 'Using index' 2076explain 2077select kp1,kp2 from t1 force index (kp1) 2078where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2079id select_type table partitions type possible_keys key key_len ref rows filtered Extra 20801 SIMPLE t1 NULL range kp1 kp1 6 NULL # 100.00 Using where; Using index 2081Warnings: 2082Note 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') 2083select kp1,kp2 from t1 force index (kp1) 2084where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2085kp1 kp2 20862015-01-01 12:34:56 0 20872015-01-02 12:34:56 1 20882015-01-03 12:34:56 2 20892015-01-04 12:34:56 3 20902015-01-05 12:34:56 4 2091# Now, the same with NOT NULL column 2092create table t2 ( 2093pk int auto_increment primary key, 2094kp1 datetime not null, 2095kp2 int, 2096col1 int, 2097key(kp1, kp2) 2098) engine=rocksdb; 2099set @orig_tx_iso=@@session.transaction_isolation; 2100set session transaction_isolation='READ-COMMITTED'; 2101insert into t2 select * from t1; 2102set session transaction_isolation=@orig_tx_iso; 2103# This must show 'Using index' 2104explain 2105select kp1,kp2 from t2 force index (kp1) 2106where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2107id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21081 SIMPLE t2 NULL range kp1 kp1 5 NULL # 100.00 Using where; Using index 2109Warnings: 2110Note 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') 2111select kp1,kp2 from t2 force index (kp1) 2112where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2113kp1 kp2 21142015-01-01 12:34:56 0 21152015-01-02 12:34:56 1 21162015-01-03 12:34:56 2 21172015-01-04 12:34:56 3 21182015-01-05 12:34:56 4 2119drop table t1,t2; 2120# Try a DATE column: 2121create table t1 ( 2122pk int auto_increment primary key, 2123kp1 date, 2124kp2 int, 2125col1 int, 2126key(kp1, kp2) 2127) engine=rocksdb; 2128insert into t1 (kp1,kp2) 2129select date_add('2015-01-01', interval a day), a from t0; 2130select * from t1; 2131pk kp1 kp2 col1 21321 2015-01-01 0 NULL 21332 2015-01-02 1 NULL 21343 2015-01-03 2 NULL 21354 2015-01-04 3 NULL 21365 2015-01-05 4 NULL 21376 2015-01-06 5 NULL 21387 2015-01-07 6 NULL 21398 2015-01-08 7 NULL 21409 2015-01-09 8 NULL 214110 2015-01-10 9 NULL 2142# This must show 'Using index' 2143explain 2144select kp1,kp2 from t1 force index (kp1) 2145where kp1 between '2015-01-01' and '2015-01-05'; 2146id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21471 SIMPLE t1 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2148Warnings: 2149Note 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') 2150select kp1,kp2 from t1 force index (kp1) 2151where kp1 between '2015-01-01' and '2015-01-05'; 2152kp1 kp2 21532015-01-01 0 21542015-01-02 1 21552015-01-03 2 21562015-01-04 3 21572015-01-05 4 2158# Now, the same with NOT NULL column 2159create table t2 ( 2160pk int auto_increment primary key, 2161kp1 date not null, 2162kp2 int, 2163col1 int, 2164key(kp1, kp2) 2165) engine=rocksdb; 2166set @orig_tx_iso=@@session.transaction_isolation; 2167set session transaction_isolation='READ-COMMITTED'; 2168insert into t2 select * from t1; 2169set session transaction_isolation=@orig_tx_iso; 2170# This must show 'Using index' 2171explain 2172select kp1,kp2 from t2 force index (kp1) 2173where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2174id select_type table partitions type possible_keys key key_len ref rows filtered Extra 21751 SIMPLE t2 NULL range kp1 kp1 3 NULL # 100.00 Using where; Using index 2176Warnings: 2177Note 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') 2178select kp1,kp2 from t2 force index (kp1) 2179where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2180kp1 kp2 21812015-01-01 0 21822015-01-02 1 21832015-01-03 2 21842015-01-04 3 21852015-01-05 4 2186drop table t1,t2; 2187# 2188# Try a TIMESTAMP column: 2189# 2190create table t1 ( 2191pk int auto_increment primary key, 2192kp1 timestamp, 2193kp2 int, 2194col1 int, 2195key(kp1, kp2) 2196) engine=rocksdb; 2197insert into t1 (kp1,kp2) 2198select date_add('2015-01-01 12:34:56', interval a day), a from t0; 2199select * from t1; 2200pk kp1 kp2 col1 22011 2015-01-01 12:34:56 0 NULL 22022 2015-01-02 12:34:56 1 NULL 22033 2015-01-03 12:34:56 2 NULL 22044 2015-01-04 12:34:56 3 NULL 22055 2015-01-05 12:34:56 4 NULL 22066 2015-01-06 12:34:56 5 NULL 22077 2015-01-07 12:34:56 6 NULL 22088 2015-01-08 12:34:56 7 NULL 22099 2015-01-09 12:34:56 8 NULL 221010 2015-01-10 12:34:56 9 NULL 2211# This must show 'Using index' 2212explain 2213select kp1,kp2 from t1 force index (kp1) 2214where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2215id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22161 SIMPLE t1 NULL range kp1 kp1 5 NULL # 100.00 Using where; Using index 2217Warnings: 2218Note 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') 2219select kp1,kp2 from t1 force index (kp1) 2220where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2221kp1 kp2 22222015-01-01 12:34:56 0 22232015-01-02 12:34:56 1 22242015-01-03 12:34:56 2 22252015-01-04 12:34:56 3 22262015-01-05 12:34:56 4 2227# Now, the same with NOT NULL column 2228create table t2 ( 2229pk int auto_increment primary key, 2230kp1 timestamp not null, 2231kp2 int, 2232col1 int, 2233key(kp1, kp2) 2234) engine=rocksdb; 2235set @orig_tx_iso=@@session.transaction_isolation; 2236set session transaction_isolation='READ-COMMITTED'; 2237insert into t2 select * from t1; 2238set session transaction_isolation=@orig_tx_iso; 2239# This must show 'Using index' 2240explain 2241select kp1,kp2 from t2 force index (kp1) 2242where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2243id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22441 SIMPLE t2 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2245Warnings: 2246Note 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') 2247select kp1,kp2 from t2 force index (kp1) 2248where kp1 between '2015-01-01 00:00:00' and '2015-01-05 23:59:59'; 2249kp1 kp2 22502015-01-01 12:34:56 0 22512015-01-02 12:34:56 1 22522015-01-03 12:34:56 2 22532015-01-04 12:34:56 3 22542015-01-05 12:34:56 4 2255drop table t1,t2; 2256# 2257# Try a TIME column: 2258# 2259create table t1 ( 2260pk int auto_increment primary key, 2261kp1 time, 2262kp2 int, 2263col1 int, 2264key(kp1, kp2) 2265) engine=rocksdb; 2266insert into t1 (kp1,kp2) 2267select date_add('2015-01-01 09:00:00', interval a minute), a from t0; 2268select * from t1; 2269pk kp1 kp2 col1 22701 09:00:00 0 NULL 22712 09:01:00 1 NULL 22723 09:02:00 2 NULL 22734 09:03:00 3 NULL 22745 09:04:00 4 NULL 22756 09:05:00 5 NULL 22767 09:06:00 6 NULL 22778 09:07:00 7 NULL 22789 09:08:00 8 NULL 227910 09:09:00 9 NULL 2280# This must show 'Using index' 2281explain 2282select kp1,kp2 from t1 force index (kp1) 2283where kp1 between '09:01:00' and '09:05:00'; 2284id select_type table partitions type possible_keys key key_len ref rows filtered Extra 22851 SIMPLE t1 NULL range kp1 kp1 4 NULL # 100.00 Using where; Using index 2286Warnings: 2287Note 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') 2288select kp1,kp2 from t1 force index (kp1) 2289where kp1 between '09:01:00' and '09:05:00'; 2290kp1 kp2 229109:01:00 1 229209:02:00 2 229309:03:00 3 229409:04:00 4 229509:05:00 5 2296# Now, the same with NOT NULL column 2297create table t2 ( 2298pk int auto_increment primary key, 2299kp1 time not null, 2300kp2 int, 2301col1 int, 2302key(kp1, kp2) 2303) engine=rocksdb; 2304set @orig_tx_iso=@@session.transaction_isolation; 2305set session transaction_isolation='READ-COMMITTED'; 2306insert into t2 select * from t1; 2307set session transaction_isolation=@orig_tx_iso; 2308# This must show 'Using index' 2309explain 2310select kp1,kp2 from t2 force index (kp1) 2311where kp1 between '09:01:00' and '09:05:00'; 2312id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23131 SIMPLE t2 NULL range kp1 kp1 3 NULL # 100.00 Using where; Using index 2314Warnings: 2315Note 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') 2316select kp1,kp2 from t2 force index (kp1) 2317where kp1 between '09:01:00' and '09:05:00'; 2318kp1 kp2 231909:01:00 1 232009:02:00 2 232109:03:00 3 232209:04:00 4 232309:05:00 5 2324drop table t1,t2; 2325# 2326# Try a YEAR column: 2327# 2328create table t1 ( 2329pk int auto_increment primary key, 2330kp1 year, 2331kp2 int, 2332col1 int, 2333key(kp1, kp2) 2334) engine=rocksdb; 2335insert into t1 (kp1,kp2) select 2015+a, a from t0; 2336select * from t1; 2337pk kp1 kp2 col1 23381 2015 0 NULL 23392 2016 1 NULL 23403 2017 2 NULL 23414 2018 3 NULL 23425 2019 4 NULL 23436 2020 5 NULL 23447 2021 6 NULL 23458 2022 7 NULL 23469 2023 8 NULL 234710 2024 9 NULL 2348# This must show 'Using index' 2349explain 2350select kp1,kp2 from t1 force index (kp1) 2351where kp1 between '2016' and '2020'; 2352id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23531 SIMPLE t1 NULL range kp1 kp1 2 NULL # 100.00 Using where; Using index 2354Warnings: 2355Note 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) 2356select kp1,kp2 from t1 force index (kp1) 2357where kp1 between '2016' and '2020'; 2358kp1 kp2 23592016 1 23602017 2 23612018 3 23622019 4 23632020 5 2364# Now, the same with NOT NULL column 2365create table t2 ( 2366pk int auto_increment primary key, 2367kp1 year not null, 2368kp2 int, 2369col1 int, 2370key(kp1, kp2) 2371) engine=rocksdb; 2372set @orig_tx_iso=@@session.transaction_isolation; 2373set session transaction_isolation='READ-COMMITTED'; 2374insert into t2 select * from t1; 2375set session transaction_isolation=@orig_tx_iso; 2376# This must show 'Using index' 2377explain 2378select kp1,kp2 from t2 force index (kp1) 2379where kp1 between '2016' and '2020'; 2380id select_type table partitions type possible_keys key key_len ref rows filtered Extra 23811 SIMPLE t2 NULL range kp1 kp1 1 NULL # 100.00 Using where; Using index 2382Warnings: 2383Note 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) 2384select kp1,kp2 from t2 force index (kp1) 2385where kp1 between '2016' and '2020'; 2386kp1 kp2 23872016 1 23882017 2 23892018 3 23902019 4 23912020 5 2392drop table t1,t2; 2393# 2394# Issue #57: Release row locks on statement errors 2395# 2396create table t1 (id int primary key) engine=rocksdb; 2397insert into t1 values (1), (2), (3); 2398begin; 2399insert into t1 values (4), (5), (6); 2400insert into t1 values (7), (8), (2), (9); 2401ERROR 23000: Duplicate entry '2' for key 'PRIMARY' 2402select * from t1; 2403id 24041 24052 24063 24074 24085 24096 2410begin; 2411select * from t1 where id=4 for update; 2412ERROR HY000: Lock wait timeout exceeded; try restarting transaction 2413select * from t1 where id=7 for update; 2414id 2415select * from t1 where id=9 for update; 2416id 2417drop table t1; 2418#Index on blob column 2419SET @old_mode = @@sql_mode; 2420SET sql_mode = 'strict_all_tables'; 2421Warnings: 2422Warning 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. 2423Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2424create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(c, b(255))) engine=rocksdb; 2425drop table t1; 2426set @orig_rocksdb_large_prefix=@@global.rocksdb_large_prefix; 2427set @@global.rocksdb_large_prefix=1; 2428create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(1255))) engine=rocksdb; 2429set @@global.rocksdb_large_prefix=@orig_rocksdb_large_prefix; 2430insert into t1 values (1, '1abcde', '1abcde'), (2, '2abcde', '2abcde'), (3, '3abcde', '3abcde'); 2431select * from t1; 2432a b c 24331 1abcde 1abcde 24342 2abcde 2abcde 24353 3abcde 3abcde 2436explain select * from t1 where b like '1%'; 2437id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24381 SIMPLE t1 NULL range b b 1258 NULL # 100.00 Using where 2439Warnings: 2440Note 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%') 2441explain select b, a from t1 where b like '1%'; 2442id select_type table partitions type possible_keys key key_len ref rows filtered Extra 24431 SIMPLE t1 NULL range b b 1258 NULL # 100.00 Using where 2444Warnings: 2445Note 1003 /* select#1 */ select `test`.`t1`.`b` AS `b`,`test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`b` like '1%') 2446update t1 set b= '12345' where b = '2abcde'; 2447select * from t1; 2448a b c 24491 1abcde 1abcde 24502 12345 2abcde 24513 3abcde 3abcde 2452drop table t1; 2453create table t1 (a int, b text, c varchar(400), Primary Key(a), Key(b(2255))) engine=rocksdb; 2454ERROR 42000: Specified key was too long; max key length is 767 bytes 2455SET sql_mode = @old_mode; 2456Warnings: 2457Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2458drop table t0; 2459# 2460# Fix assertion failure (attempt to overrun the key buffer) for prefix indexes 2461# 2462create table t1 ( 2463pk int primary key, 2464col1 varchar(100), 2465key (col1(10)) 2466) engine=rocksdb; 2467insert into t1 values (1, repeat('0123456789', 9)); 2468drop table t1; 2469# 2470# Issue #76: Assertion `buf == table->record[0]' fails in virtual int ha_rocksdb::delete_row(const uchar*) 2471# 2472CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB; 2473CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT) ENGINE=RocksDB; 2474CREATE TRIGGER tr AFTER DELETE ON t1 FOR EACH ROW DELETE FROM t2 WHERE pk = old.pk; 2475INSERT INTO t1 VALUES (1,1); 2476REPLACE INTO t1 VALUES (1,2); 2477SELECT * FROM t1; 2478pk f1 24791 2 2480DROP TABLE t1, t2; 2481# 2482# Issue #99: UPDATE for table with VARCHAR pk gives "Can't find record" error 2483# 2484create table t1(a int primary key) engine=rocksdb; 2485insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 2486create table t2 ( 2487a varchar(32) primary key, 2488col1 int 2489) engine=rocksdb; 2490set @orig_tx_iso=@@session.transaction_isolation; 2491set session transaction_isolation='READ-COMMITTED'; 2492insert into t2 2493select concat('v-', 100 + A.a*100 + B.a), 12345 from t1 A, t1 B; 2494update t2 set a=concat('x-', a) where a between 'v-1002' and 'v-1004'; 2495set session transaction_isolation=@orig_tx_iso; 2496drop table t1,t2; 2497# 2498# Issue #131: Assertion `v->cfd_->internal_comparator().Compare(start, end) <= 0' failed 2499# 2500CREATE 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; 2501INSERT INTO t2 VALUES (1,1,1,1,1,1,1); 2502SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; 2503c1 c2 c3 c4 c5 c6 c7 2504EXPLAIN SELECT * FROM t2 WHERE c1 > 4294967295 ORDER BY c1,c6; 2505id select_type table partitions type possible_keys key key_len ref rows filtered Extra 25061 SIMPLE t2 NULL range PRIMARY PRIMARY 4 NULL 50 100.00 Using where 2507Warnings: 2508Note 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` 2509drop table t2; 2510# 2511# Issue #135: register transaction was not being called for statement 2512# 2513CREATE DATABASE test_db; 2514CREATE TABLE test_db.t1(c1 INT PRIMARY KEY) ENGINE=ROCKSDB; 2515INSERT INTO test_db.t1(c1) VALUES(0), (1), (2), (3); 2516LOCK TABLES test_db.t1 READ; 2517SET AUTOCOMMIT=0; 2518SELECT c1 FROM test_db.t1 WHERE c1=2; 2519c1 25202 2521START TRANSACTION WITH CONSISTENT SNAPSHOT, READ ONLY; 2522DROP DATABASE test_db; 2523COMMIT; 2524SET AUTOCOMMIT=1; 2525# 2526# Issue #143: Split rocksdb_bulk_load option into two 2527# 2528CREATE TABLE t1 (id int primary key, value int) engine=RocksDB; 2529SET unique_checks=0; 2530INSERT INTO t1 VALUES(1, 1); 2531INSERT INTO t1 VALUES(1, 2); 2532INSERT INTO t1 VALUES(1, 3); 2533SELECT * FROM t1; 2534id value 25351 3 2536REPLACE INTO t1 VALUES(4, 4); 2537ERROR 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) 2538INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1; 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: INSERT INTO t1 VALUES(5, 5) ON DUPLICATE KEY UPDATE value=value+1 2540TRUNCATE TABLE t1; 2541SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size; 2542SET unique_checks=1; 2543SET rocksdb_commit_in_the_middle=1; 2544SET rocksdb_bulk_load_size=10; 2545BEGIN; 2546INSERT INTO t1 (id) VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),(10), 2547(11),(12),(13),(14),(15),(16),(17),(18),(19); 2548ROLLBACK; 2549SELECT * FROM t1; 2550id value 25511 NULL 25522 NULL 25533 NULL 25544 NULL 25555 NULL 25566 NULL 25577 NULL 25588 NULL 25599 NULL 256010 NULL 2561INSERT INTO t1 (id) VALUES (11),(12),(13),(14),(15); 2562set @orig_tx_iso=@@session.transaction_isolation; 2563set session transaction_isolation='READ-COMMITTED'; 2564BEGIN; 2565UPDATE t1 SET value=100; 2566ROLLBACK; 2567SELECT * FROM t1; 2568id value 25691 100 25702 100 25713 100 25724 100 25735 100 25746 100 25757 100 25768 100 25779 100 257810 100 257911 NULL 258012 NULL 258113 NULL 258214 NULL 258315 NULL 2584BEGIN; 2585DELETE FROM t1; 2586ROLLBACK; 2587SELECT * FROM t1; 2588id value 258911 NULL 259012 NULL 259113 NULL 259214 NULL 259315 NULL 2594set session transaction_isolation=@orig_tx_iso; 2595SET rocksdb_commit_in_the_middle=0; 2596SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size; 2597DROP TABLE t1; 2598# 2599# Issue #185 Assertion `BaseValid()' failed in void rocksdb::BaseDeltaIterator::Advance() 2600# 2601CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MEMORY; 2602INSERT INTO t2 VALUES (100,NULL),(150,"long varchar"),(200,"varchar"),(250,"long long long varchar"); 2603Warnings: 2604Warning 1366 Incorrect integer value: 'long varchar' for column 'data' at row 2 2605Warning 1366 Incorrect integer value: 'varchar' for column 'data' at row 3 2606Warning 1366 Incorrect integer value: 'long long long varchar' for column 'data' at row 4 2607CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY(a,b)) ENGINE=ROCKSDB; 2608INSERT INTO t1 VALUES (1,1); 2609SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); 2610a 26111 26121 26131 26141 2615DROP TABLE t1, t2; 2616# 2617# Issue #189 ha_rocksdb::load_auto_incr_value() creates implicit snapshot and doesn't release 2618# 2619create table r1 (id int auto_increment primary key, value int) engine=rocksdb; 2620insert into r1 (id) values (null), (null), (null), (null), (null); 2621create table r2 like r1; 2622show create table r2; 2623Table Create Table 2624r2 CREATE TABLE `r2` ( 2625 `id` int(11) NOT NULL AUTO_INCREMENT, 2626 `value` int(11) DEFAULT NULL, 2627 PRIMARY KEY (`id`) 2628) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 2629begin; 2630insert into r1 values (10, 1); 2631commit; 2632begin; 2633select * from r1; 2634id value 26351 NULL 26362 NULL 26373 NULL 26384 NULL 26395 NULL 264010 1 2641commit; 2642drop table r1, r2; 2643create table r1 (id int auto_increment, value int, index i(id)) engine=rocksdb; 2644insert into r1 (id) values (null), (null), (null), (null), (null); 2645create table r2 like r1; 2646show create table r2; 2647Table Create Table 2648r2 CREATE TABLE `r2` ( 2649 `id` int(11) NOT NULL AUTO_INCREMENT, 2650 `value` int(11) DEFAULT NULL, 2651 KEY `i` (`id`) 2652) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 2653begin; 2654insert into r1 values (10, 1); 2655commit; 2656begin; 2657select * from r1; 2658id value 26591 NULL 26602 NULL 26613 NULL 26624 NULL 26635 NULL 266410 1 2665commit; 2666drop table r1, r2; 2667# 2668# Issue#211 Crash on LOCK TABLES + START TRANSACTION WITH CONSISTENT SNAPSHOT 2669# 2670CREATE TABLE t1(c1 INT) ENGINE=ROCKSDB; 2671lock TABLE t1 read local; 2672SELECT 1 FROM t1 GROUP BY TRIM(LEADING RAND()FROM''); 26731 2674set AUTOCOMMIT=0; 2675start transaction with consistent snapshot; 2676SELECT * FROM t1; 2677c1 2678COMMIT; 2679UNLOCK TABLES; 2680DROP TABLE t1; 2681set AUTOCOMMIT=1; 2682# 2683# Issue#213 Crash on LOCK TABLES + partitions 2684# 2685CREATE TABLE t1(a INT,b INT,KEY (b)) engine=rocksdb PARTITION BY HASH(a) PARTITIONS 2; 2686INSERT INTO t1(a)VALUES (20010101101010.999949); 2687ERROR 22003: Out of range value for column 'a' at row 1 2688set @orig_sql_mode=@@session.sql_mode; 2689set session sql_mode=""; 2690Warnings: 2691Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2692INSERT INTO t1(a)VALUES (20010101101010.999949); 2693Warnings: 2694Warning 1264 Out of range value for column 'a' at row 1 2695set session sql_mode=@orig_sql_mode; 2696Warnings: 2697Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2698lock tables t1 write,t1 as t0 write,t1 as t2 write; 2699set @orig_tx_iso=@@session.transaction_isolation; 2700set session transaction_isolation='READ-COMMITTED'; 2701SELECT a FROM t1 ORDER BY a; 2702a 27032147483647 2704set session transaction_isolation=@orig_tx_iso; 2705truncate t1; 2706INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020'); 2707ERROR 22003: Out of range value for column 'a' at row 1 2708set @orig_sql_mode=@@session.sql_mode; 2709set session sql_mode=""; 2710Warnings: 2711Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2712INSERT INTO t1 VALUES(X'042000200020',X'042000200020'),(X'200400200020',X'200400200020'); 2713Warnings: 2714Warning 1264 Out of range value for column 'a' at row 1 2715Warning 1264 Out of range value for column 'b' at row 1 2716Warning 1264 Out of range value for column 'a' at row 2 2717Warning 1264 Out of range value for column 'b' at row 2 2718set session sql_mode=@orig_sql_mode; 2719Warnings: 2720Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release. 2721UNLOCK TABLES; 2722DROP TABLE t1; 2723# 2724# Issue#250: MyRocks/Innodb different output from query with order by on table with index and decimal type 2725# (the test was changed to use VARCHAR, because DECIMAL now supports index-only, and this issue 2726# needs a datype that doesn't support index-inly) 2727# 2728CREATE TABLE t1( 2729c1 varchar(10) character set utf8 collate utf8_general_ci NOT NULL, 2730c2 varchar(10) character set utf8 collate utf8_general_ci, 2731c3 INT, 2732INDEX idx(c1,c2) 2733) ENGINE=ROCKSDB; 2734INSERT INTO t1 VALUES ('c1-val1','c2-val1',5); 2735INSERT INTO t1 VALUES ('c1-val2','c2-val3',6); 2736INSERT INTO t1 VALUES ('c1-val3','c2-val3',7); 2737SELECT * FROM t1 force index(idx) WHERE c1 <> 'c1-val2' ORDER BY c1 DESC; 2738c1 c2 c3 2739c1-val3 c2-val3 7 2740c1-val1 c2-val1 5 2741explain SELECT * FROM t1 force index(idx) WHERE c1 <> '1' ORDER BY c1 DESC; 2742id select_type table partitions type possible_keys key key_len ref rows filtered Extra 27431 SIMPLE t1 NULL range idx idx 32 NULL # 100.00 Using where 2744Warnings: 2745Note 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 2746drop table t1; 2747# 2748# Issue#267: MyRocks issue with no matching min/max row and count(*) 2749# 2750CREATE TABLE t1(c1 INT UNSIGNED, c2 INT SIGNED, INDEX idx2(c2)) ENGINE=ROCKSDB; 2751INSERT INTO t1 VALUES(1,null); 2752INSERT INTO t1 VALUES(2,null); 2753SELECT count(*) as total_rows, min(c2) as min_value FROM t1; 2754total_rows min_value 27552 NULL 2756DROP TABLE t1; 2757# 2758# Issue#263: MyRocks auto_increment skips values if you insert a negative value 2759# 2760CREATE TABLE t1(a INT AUTO_INCREMENT KEY) ENGINE=ROCKSDB; 2761INSERT INTO t1 VALUES(0),(-1),(0); 2762SHOW TABLE STATUS LIKE 't1'; 2763Name 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 2764t1 ROCKSDB 10 Fixed 1000 # # # # # 3 # # NULL latin1_swedish_ci NULL 2765SELECT * FROM t1; 2766a 2767-1 27681 27692 2770DROP TABLE t1; 2771CREATE TABLE t1(a INT AUTO_INCREMENT KEY) ENGINE=ROCKSDB; 2772INSERT INTO t1 VALUES(0),(10),(0); 2773SHOW TABLE STATUS LIKE 't1'; 2774Name 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 2775t1 ROCKSDB 10 Fixed 1000 # # # # # 12 # # NULL latin1_swedish_ci NULL 2776SELECT * FROM t1; 2777a 27781 277910 278011 2781DROP TABLE t1; 2782# 2783# Issue #411: Setting rocksdb_commit_in_the_middle commits transaction 2784# without releasing iterator 2785# 2786CREATE TABLE t1 (id1 bigint(20), 2787id2 bigint(20), 2788id3 bigint(20), 2789PRIMARY KEY (id1, id2, id3)) 2790ENGINE=ROCKSDB 2791DEFAULT CHARSET=latin1; 2792CREATE TABLE t2 (id1 bigint(20), 2793id2 bigint(20), 2794PRIMARY KEY (id1, id2)) 2795ENGINE=ROCKSDB 2796DEFAULT CHARSET=latin1; 2797set rocksdb_commit_in_the_middle=1; 2798SET @save_rocksdb_bulk_load_size= @@rocksdb_bulk_load_size; 2799set rocksdb_bulk_load_size = 100; 2800set @orig_tx_iso=@@session.transaction_isolation; 2801set session transaction_isolation='READ-COMMITTED'; 2802DELETE t2, t1 FROM t2 LEFT JOIN t1 ON t2.id2 = t1.id2 AND t2.id1 = t1.id1 WHERE t2.id1 = 0; 2803set session transaction_isolation=@orig_tx_iso; 2804SET rocksdb_bulk_load_size= @save_rocksdb_bulk_load_size; 2805SET rocksdb_commit_in_the_middle=0; 2806DROP TABLE t1, t2; 2807SET GLOBAL ROCKSDB_PAUSE_BACKGROUND_WORK = @ORIG_PAUSE_BACKGROUND_WORK; 2808# 2809# Issue #728: Assertion `covers_key(b)' failed in int 2810# myrocks::Rdb_key_def::cmp_full_keys(const rocks db::Slice&, 2811# const rocksdb::Slice&) 2812# 2813CREATE TABLE t2(c1 TINYINT SIGNED KEY,c2 TINYINT UNSIGNED,c3 INT) ENGINE=ROCKSDB; 2814INSERT INTO t2(c1)VALUES(0); 2815SELECT * FROM t2 WHERE c1<=127 ORDER BY c1 DESC; 2816c1 c2 c3 28170 NULL NULL 2818DROP TABLE t2; 2819