1
drop table if exists t1, t2;
2
create table t1 (id int primary key, a int, b int) engine = blitzdb;
5
insert into t1 values (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4);
6
insert into t1 values (5, 5, 5), (6, 6, 6), (7, 7, 7), (8, 8, 8);
7
insert into t1 values (9, 9, 9), (10, 10, 10), (11, 11, 11), (12, 12, 12);
8
insert into t1 values (13, 13, 13), (14, 14, 14), (15, 15, 15), (16, 16, 16);
9
explain select count (*) from t1;
10
id select_type table type possible_keys key key_len ref rows Extra
11
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
12
insert into t1 values (2147483648, 1, 1);
13
ERROR 22003: Out of range value for column 'id' at row 1
14
insert into t1 values (1, 0, 0);
15
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
16
insert into t1 values (2, 0, 0);
17
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
18
insert into t1 values (3, 0, 0);
19
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
20
insert into t1 values (4, 0, 0);
21
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
22
select * from t1 where id = 2;
25
select * from t1 where id = 4;
28
select * from t1 where id = 6;
31
update t1 set a = 70 where id = 7;
32
update t1 set a = 80 where id = 8;
33
select * from t1 order by id;
51
update t1 set id = 2 where id = 1;
52
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
53
update t1 set id = 17 where id = 1;
54
update t1 set id = 18 where id = 2;
55
update t1 set id = 19 where id = 3;
56
update t1 set id = 20 where id = 4;
57
update t1 set id = 21 where id = 5;
58
update t1 set id = 22 where id = 6;
59
update t1 set id = 23 where id = 7;
60
update t1 set id = 20 where id = 8;
61
ERROR 23000: Duplicate entry '20' for key 'PRIMARY'
62
select * from t1 order by id;
80
select count (*) from t1;
83
delete from t1 where id = 8;
84
select count (*) from t1;
87
delete from t1 where id = 9;
88
select count (*) from t1;
91
delete from t1 where id = 18;
92
select count (*) from t1;
95
delete from t1 where id = 19;
96
select count (*) from t1;
99
select count (id) from t1;
102
select count (a) from t1;
105
select count (b) from t1;
108
select * from t1 order by id;
122
delete from t1 where id > 10 and id < 14;
123
select * from t1 order by id;
134
select count (*) from t1;
137
delete from t1 where id >= 20 and id <= 23;
138
select * from t1 order by id;
145
select count (*) from t1;
148
delete from t1 where a > 20;
149
select count(*) from t1;
153
create table t1 (id bigint primary key, a int) engine = blitzdb;
154
insert into t1 values (2147483647, 1);
155
insert into t1 values (1.8e+18, 2);
156
insert into t1 values (1.8e+19, 3);
157
ERROR 22003: Out of range value for column 'id' at row 1
158
insert into t1 values (1,1), (2,2), (3,3), (4,4);
159
update t1 set id = 4 where id = 1;
160
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
161
update t1 set id = 10 where id = 1;
162
update t1 set id = 20 where id = 2;
163
update t1 set id = 30 where id = 3;
164
update t1 set id = 40 where id = 4;
165
select count(*) from t1 where id < 10;
168
explain select id from t1 where id in (10, 20, 30, 40);
169
id select_type table type possible_keys key key_len ref rows Extra
170
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 4 Using where; Using index
171
select id from t1 where id in (10, 20, 30, 40);
180
1800000000000000000 2
185
delete from t1 where id = 10;
186
delete from t1 where id = 20;
187
delete from t1 where id in (30, 40);
191
1800000000000000000 2
193
create table t1 (id int primary key auto_increment, num int) engine = blitzdb;
194
insert into t1 (num) values (1);
198
insert into t1 (num) values (1);
199
insert into t1 (num) values (1);
200
insert into t1 (num) values (1);
201
select count(*) from t1;
205
select count(*) from t1;
208
insert into t1 (num) values (1);
209
insert into t1 (num) values (1);
210
insert into t1 (num) values (1);
211
insert into t1 (num) values (1);
212
select count(*) from t1;
215
select count(num) from t1;
229
create table t1 (id int primary key auto_increment) engine = blitzdb;
230
insert into t1 values (1), (2), (3), (4);
231
insert into t1 values (8), (9), (10), (11);
232
insert into t1 values (5), (7);
245
insert into t1 values (), (), ();
262
create table t1 (id int primary key auto_increment) engine = blitzdb;
263
insert into t1 values ();
264
insert into t1 values ();
265
insert into t1 values ();
266
insert into t1 values ();
267
select count(*) from t1;
270
delete from t1 where id = 1;
271
delete from t1 where id = 2;
272
select count(*) from t1;
275
insert into t1 values ();
276
insert into t1 values ();
277
select count(*) from t1;
281
create table t1 (id double primary key, a int) engine = blitzdb;
282
insert into t1 values (1.1, 1);
283
insert into t1 values (1.11, 2);
284
insert into t1 values (1.111, 3);
285
insert into t1 values (1.1111, 4);
286
insert into t1 values (2.2, 5);
287
insert into t1 values (2.22, 6);
288
insert into t1 values (2.222, 7);
289
insert into t1 values (2.2222, 8);
300
update t1 set id = 1.11 where id = 1.1;
301
ERROR 23000: Duplicate entry '1.11' for key 'PRIMARY'
302
update t1 set id = 2.22 where id = 2.2;
303
ERROR 23000: Duplicate entry '2.22' for key 'PRIMARY'
304
update t1 set id = 3.3 where id = 1.1;
305
update t1 set id = 3.33 where id = 1.11;
306
update t1 set id = 3.333 where id = 1.111;
307
update t1 set id = 3.3333 where id = 1.1111;
308
select * from t1 order by id;
318
update t1 set id = 2.2 where id = 3.3;
319
ERROR 23000: Duplicate entry '2.2' for key 'PRIMARY'
320
delete from t1 where id = 3.3;
321
delete from t1 where id = 3.33;
322
select * from t1 order by id;
331
create table t1 (id varchar(64) primary key, country varchar(64)) engine = blitzdb;
332
insert into t1 values ('amsterdam', 'netherlands');
333
insert into t1 values ('budapest', 'hungary');
334
insert into t1 values ('copenhagen', 'denmark');
335
insert into t1 values ('dublin', 'ireland');
336
insert into t1 values ('edinburgh', 'scotland');
337
insert into t1 values ('fukuoka', 'japan');
338
insert into t1 values ('geneva', 'switzerland');
339
select * from t1 order by id;
341
amsterdam netherlands
348
select country from t1 where id = 'dublin';
351
select country from t1 where id = 'geneva';
354
select country from t1 where id = 'amsterdam';
357
select country from t1 where id = 'non existent key';
359
select country from t1 where id = 'edinburgh';
362
select country from t1 where id = 'copenhagen';
365
select country from t1 where id = 'fukuoka';
368
select country from t1 where id = 'budapest';
371
select count (id) from t1;
374
update t1 set id = 'dublin' where id = 'geneva';
375
ERROR 23000: Duplicate entry 'dublin' for key 'PRIMARY'
376
update t1 set id = 'berlin', country = 'germany' where id = 'budapest';
377
update t1 set id = 'london', country = 'england' where id = 'copenhagen';
378
update t1 set id = 'paris', country = 'france' where id = 'dublin';
379
explain select * from t1 where id = 'berlin';
380
id select_type table type possible_keys key key_len ref rows Extra
381
1 SIMPLE t1 const PRIMARY PRIMARY 258 const 1
382
select * from t1 where id = 'berlin';
385
select * from t1 where id = 'london';
388
select * from t1 where id = 'paris';
391
delete from t1 where id = 'geneva';
392
delete from t1 where id = 'fukuoka';
393
select count (id) from t1;
396
select count (*) from t1;
399
select * from t1 order by id;
401
amsterdam netherlands
406
delete from t1 where id < 'london';
407
select count (*) from t1;
410
select * from t1 order by id;
415
create table t1 (a varchar(10) primary key, b int) engine = blitzdb;
416
insert into t1 values ('aaa', 1), ('bbb', 2), ('ccc', 3), ('ddd', 4);
417
insert into t1 values ('eee', 5), ('fff', 6), ('ggg', 7), ('hhh', 8);
418
select * from t1 where a = 'aaa';
421
select * from t1 where a = 'bbb';
424
select * from t1 where a = 'ccc';
427
select * from t1 where a = 'ddd';
440
delete from t1 where a = 'ggg';
441
delete from t1 where a = 'hhh';
450
update t1 set a = 'ddd' where a = 'aaa';
451
ERROR 23000: Duplicate entry 'ddd' for key 'PRIMARY'
452
update t1 set a = 'ccc' where a = 'bbb';
453
ERROR 23000: Duplicate entry 'ccc' for key 'PRIMARY'
454
update t1 set a = 'zzz' where a = 'fff';
455
select count(*) from t1 where a = 'fff';
458
select * from t1 where a = 'zzz';
470
create table t1 (a date primary key, b int, c varchar(32)) engine = blitzdb;
471
insert into t1 values ('1984-09-22', 22, 'twenty two');
472
insert into t1 values ('1984-09-23', 23, 'twenty three');
473
insert into t1 values ('1984-09-24', 24, 'twenty four');
474
insert into t1 values ('1984-09-25', 23, 'twenty five');
477
1984-09-22 22 twenty two
478
1984-09-23 23 twenty three
479
1984-09-24 24 twenty four
480
1984-09-25 23 twenty five
481
explain select * from t1 where a = '1984-09-22';
482
id select_type table type possible_keys key key_len ref rows Extra
483
1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
484
select * from t1 where a = '1984-09-22';
486
1984-09-22 22 twenty two
487
select * from t1 where a = '1984-09-23';
489
1984-09-23 23 twenty three
490
select * from t1 where a = '1984-09-24';
492
1984-09-24 24 twenty four
493
select * from t1 where a = '1984-09-25';
495
1984-09-25 23 twenty five
496
update t1 set a = '1984-09-22' where a = '1984-09-25';
497
ERROR 23000: Duplicate entry '1984-09-22' for key 'PRIMARY'
498
update t1 set a = '19840922' where a = '1984-09-25';
499
ERROR 23000: Duplicate entry '1984-09-22' for key 'PRIMARY'
500
update t1 set a = '2010-03-10' where a = '1984-09-22';
501
update t1 set a = '2010-03-11', b = 777, c = 'triple seven' where a = '1984-09-23';
502
select * from t1 order by a;
504
1984-09-24 24 twenty four
505
1984-09-25 23 twenty five
506
2010-03-10 22 twenty two
507
2010-03-11 777 triple seven
509
create table t1 (a int primary key) engine = blitzdb;
510
insert into t1 values (1), (2), (3), (4), (5), (6);
511
explain select * from t1 order by a desc;
512
id select_type table type possible_keys key key_len ref rows Extra
513
1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index
522
explain select * from t1 order by a desc;
523
id select_type table type possible_keys key key_len ref rows Extra
524
1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index
525
select * from t1 order by a desc;
534
insert into t1 values (6), (1), (5), (3), (2), (4);
535
explain select * from t1;
536
id select_type table type possible_keys key key_len ref rows Extra
537
1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index
546
explain select * from t1 order by a desc;
547
id select_type table type possible_keys key key_len ref rows Extra
548
1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index
549
select * from t1 order by a desc;
557
explain select max(a) from t1;
558
id select_type table type possible_keys key key_len ref rows Extra
559
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
560
select max(a) from t1;
563
explain select min(a) from t1;
564
id select_type table type possible_keys key key_len ref rows Extra
565
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
566
select min(a) from t1;
569
explain select sum(a) from t1;
570
id select_type table type possible_keys key key_len ref rows Extra
571
1 SIMPLE t1 index NULL PRIMARY 4 NULL 6 Using index
572
select sum(a) from t1;
576
create table t1 (a bigint primary key) engine = blitzdb;
577
insert into t1 values (10), (20), (30), (40), (50), (60);
578
explain select * from t1;
579
id select_type table type possible_keys key key_len ref rows Extra
580
1 SIMPLE t1 index NULL PRIMARY 8 NULL 6 Using index
589
select * from t1 order by a desc;
598
insert into t1 values (60), (10), (50), (30), (20), (40);
607
select * from t1 order by a desc;
616
create table t1 (a varchar(10) primary key) engine = blitzdb;
617
insert into t1 values ('a'), ('b'), ('c'), ('d'), ('e');
625
explain select * from t1 order by a desc;
626
id select_type table type possible_keys key key_len ref rows Extra
627
1 SIMPLE t1 index NULL PRIMARY 42 NULL 5 Using index
628
select * from t1 order by a desc;
636
insert into t1 values ('c'), ('a'), ('e'), ('b'), ('d');
645
insert into t1 values ('ć'), ('ć'), ('ć'), ('ć'), ('ć');
646
insert into t1 values ('ć'), ('ć'), ('ć'), ('ć'), ('ć');
647
explain select * from t1;
648
id select_type table type possible_keys key key_len ref rows Extra
649
1 SIMPLE t1 index NULL PRIMARY 42 NULL 10 Using index
662
explain select * from t1 order by a desc;
663
id select_type table type possible_keys key key_len ref rows Extra
664
1 SIMPLE t1 index NULL PRIMARY 42 NULL 10 Using index
665
select * from t1 order by a desc;
678
create table t1 (a varchar(255) primary key) engine = blitzdb;
679
insert into t1 values ('a'), ('b'), ('c'), ('d'), ('e');
680
explain select * from t1;
681
id select_type table type possible_keys key key_len ref rows Extra
682
1 SIMPLE t1 index NULL PRIMARY 1022 NULL 5 Using index
690
select * from t1 order by a desc;
698
insert into t1 values ('c'), ('a'), ('e'), ('b'), ('d');
708
create table t1 (a int, unique index(a)) engine = blitzdb;
709
insert into t1 values (1), (2);
710
insert into t1 values (1);
711
ERROR 23000: Duplicate entry '1' for key 'a'
712
insert into t1 values (2);
713
ERROR 23000: Duplicate entry '2' for key 'a'
714
insert into t1 values (NULL);
715
insert into t1 values (3);
716
insert into t1 values (4);
724
select * from t1 where a = 1;
727
select * from t1 where a = 2;
730
select * from t1 where a = 3;
733
select * from t1 where a = 4;
736
select * from t1 where a is NULL;
740
create table t1 (a varchar(32), unique index(a)) engine = blitzdb;
741
insert into t1 values ('a'), ('b'), ('c');
742
insert into t1 values ('a');
743
ERROR 23000: Duplicate entry 'a' for key 'a'
744
insert into t1 values ('b');
745
ERROR 23000: Duplicate entry 'b' for key 'a'
746
insert into t1 values ('c');
747
ERROR 23000: Duplicate entry 'c' for key 'a'
748
insert into t1 values ('f'), ('e'), ('d');
757
select count(*) from t1;
760
explain select * from t1 where a = 'a';
761
id select_type table type possible_keys key key_len ref rows Extra
762
1 SIMPLE t1 const a a 131 const 1 Using index
763
select * from t1 where a = 'a';
766
select * from t1 where a = 'b';
769
select * from t1 where a = 'c';
772
select * from t1 where a = 'd';
775
select * from t1 where a = 'e';
778
select * from t1 where a = 'f';
781
delete from t1 where a = 'a';
782
delete from t1 where a = 'b';
783
select count(*) from t1;
792
delete from t1 where a = 'c';
793
delete from t1 where a = 'd';
794
delete from t1 where a = 'e';
795
delete from t1 where a = 'f';
796
select count(*) from t1;
802
create table t1 (a int, index(a)) engine = blitzdb;
803
insert into t1 values (1), (2), (3), (4);
804
insert into t1 values (1), (2), (3), (4);
815
insert into t1 values (NULL), (NULL);
816
insert into t1 values (NULL), (NULL);
831
select count(*) from t1 where a is NULL;
834
select * from t1 where a is NULL;
840
select * from t1 where a is not NULL;
850
explain select * from t1 where a = 1;
851
id select_type table type possible_keys key key_len ref rows Extra
852
1 SIMPLE t1 ref a a 5 const 4 Using where; Using index
853
select * from t1 where a = 1;
857
select * from t1 where a = 2;
861
select * from t1 where a = 3;
865
select * from t1 where a = 4;
869
delete from t1 where a = 3;
870
select * from t1 where a = 3;
872
delete from t1 where a = 1;
873
select * from t1 where a = 1;
885
delete from t1 where a is NULL;
886
select * from t1 where a is NULL;
888
delete from t1 where a = 2;
889
select * from t1 where a = 2;
891
delete from t1 where a = 4;
892
select * from t1 where a = 4;
894
select count(*) from t1;
898
create table t1 (a varchar(32), index(a)) engine = blitzdb;
899
insert into t1 values ('ccc'), ('bbb'), ('aaa');
900
insert into t1 values ('eee'), ('ddd'), ('fff');
909
select * from t1 where a = 'aaa';
912
select * from t1 where a = 'bbb';
915
select * from t1 where a = 'ccc';
918
select * from t1 where a = 'ddd';
921
select * from t1 where a = 'eee';
924
delete from t1 where a = 'ddd';
925
delete from t1 where a = 'eee';
932
select count(*) from t1;
936
create table t1 (a int, b int, unique index(a)) engine = blitzdb;
937
insert into t1 values (NULL, 1), (NULL, 2), (NULL, 3), (NULL, 4);
944
select * from t1 where a is NULL;
950
insert into t1 values (1, 5), (2, 6);
951
insert into t1 values (1, 7), (1, 8);
952
ERROR 23000: Duplicate entry '1' for key 'a'
953
select * from t1 where a is not NULL;
957
delete from t1 where a is NULL;
962
select count(*) from t1;
968
lastname varchar(64),
969
description varchar(255),
973
insert into t1 values (1, "Schwartz", "Flight", 1500);
974
insert into t1 values (2, "Hayes", "Computer Equipment", 400);
975
insert into t1 values (3, "Lawrence", "Text Books", 220);
976
insert into t1 values (4, "Smith", "Weaponry", 45500);
977
insert into t1 values (5, "Yamada", "Dinner", 120);
978
insert into t1 values (6, "Smith", "Lunch", 30);
979
insert into t1 values (7, "Hayes", "Lunch", 30);
980
insert into t1 values (8, "Kinoshita", "Computer Equipment", 3740);
982
id lastname description price
983
1 Schwartz Flight 1500
984
2 Hayes Computer Equipment 400
985
3 Lawrence Text Books 220
986
4 Smith Weaponry 45500
990
8 Kinoshita Computer Equipment 3740
991
select sum(price) from t1;
994
select lastname, sum(price) from t1 group by lastname;
1003
create table t1 (a int, b int, c int, d int, primary key(a, b)) engine = blitzdb;
1004
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1005
create table t1 (a int, b int, c int, d int, primary key(a, b, c)) engine = blitzdb;
1006
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1007
create table t1 (a int, b int, c int, d int, index(a, b)) engine = blitzdb;
1008
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1009
create table t1 (a int, b int, c int, d int, index(a, b, c)) engine = blitzdb;
1010
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1011
create table t1 (a int, b int, c int, d int, unique(a, b)) engine = blitzdb;
1012
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1013
create table t1 (a int, b int, c int, d int, unique(a, b, c)) engine = blitzdb;
1014
ERROR HY000: Can't create table 'test.t1' (errno: 138)
1016
`col_varchar_10_key` varchar(10),
1018
`col_varchar_1024_key` varchar(1024),
1019
pk integer auto_increment,
1020
`col_varchar_10` varchar(10),
1022
`col_varchar_1024` varchar(1024),
1023
key (`col_varchar_10_key`),
1024
key (`col_int_key`),
1025
key (`col_varchar_1024_key`),
1029
Warning 1071 Specified key was too long; max key length is 1024 bytes
1030
insert /*! IGNORE */ into t1 values ('x', NULL, 'keyone', NULL, 'could', 1322188800, 'I\'m');
1031
insert /*! IGNORE */ into t1 values ('y', NULL, 'keytwo', NULL, 'could', 1322188800, 'I\'m');
1032
insert /*! IGNORE */ into t1 values ('z', NULL, 'keythree', NULL, 'could', 1322188800, 'I\'m');
1034
col_varchar_10_key col_int_key col_varchar_1024_key pk col_varchar_10 col_int col_varchar_1024
1035
x NULL keyone 1 could 1322188800 I'm
1036
y NULL keytwo 2 could 1322188800 I'm
1037
z NULL keythree 3 could 1322188800 I'm