~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/blitzdb/tests/r/index.result

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
drop table if exists t1, t2;
2
 
create table t1 (id int primary key, a int, b int) engine = blitzdb;
3
 
select * from t1;
4
 
id      a       b
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;
23
 
id      a       b
24
 
2       2       2
25
 
select * from t1 where id = 4;
26
 
id      a       b
27
 
4       4       4
28
 
select * from t1 where id = 6;
29
 
id      a       b
30
 
6       6       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;
34
 
id      a       b
35
 
1       1       1
36
 
2       2       2
37
 
3       3       3
38
 
4       4       4
39
 
5       5       5
40
 
6       6       6
41
 
7       70      7
42
 
8       80      8
43
 
9       9       9
44
 
10      10      10
45
 
11      11      11
46
 
12      12      12
47
 
13      13      13
48
 
14      14      14
49
 
15      15      15
50
 
16      16      16
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;
63
 
id      a       b
64
 
8       80      8
65
 
9       9       9
66
 
10      10      10
67
 
11      11      11
68
 
12      12      12
69
 
13      13      13
70
 
14      14      14
71
 
15      15      15
72
 
16      16      16
73
 
17      1       1
74
 
18      2       2
75
 
19      3       3
76
 
20      4       4
77
 
21      5       5
78
 
22      6       6
79
 
23      70      7
80
 
select count (*) from t1;
81
 
count (*)
82
 
16
83
 
delete from t1 where id = 8;
84
 
select count (*) from t1;
85
 
count (*)
86
 
15
87
 
delete from t1 where id = 9;
88
 
select count (*) from t1;
89
 
count (*)
90
 
14
91
 
delete from t1 where id = 18;
92
 
select count (*) from t1;
93
 
count (*)
94
 
13
95
 
delete from t1 where id = 19;
96
 
select count (*) from t1;
97
 
count (*)
98
 
12
99
 
select count (id) from t1;
100
 
count (id)
101
 
12
102
 
select count (a) from t1;
103
 
count (a)
104
 
12
105
 
select count (b) from t1;
106
 
count (b)
107
 
12
108
 
select * from t1 order by id;
109
 
id      a       b
110
 
10      10      10
111
 
11      11      11
112
 
12      12      12
113
 
13      13      13
114
 
14      14      14
115
 
15      15      15
116
 
16      16      16
117
 
17      1       1
118
 
20      4       4
119
 
21      5       5
120
 
22      6       6
121
 
23      70      7
122
 
delete from t1 where id > 10 and id < 14;
123
 
select * from t1 order by id;
124
 
id      a       b
125
 
10      10      10
126
 
14      14      14
127
 
15      15      15
128
 
16      16      16
129
 
17      1       1
130
 
20      4       4
131
 
21      5       5
132
 
22      6       6
133
 
23      70      7
134
 
select count (*) from t1;
135
 
count (*)
136
 
9
137
 
delete from t1 where id >= 20 and id <= 23;
138
 
select * from t1 order by id;
139
 
id      a       b
140
 
10      10      10
141
 
14      14      14
142
 
15      15      15
143
 
16      16      16
144
 
17      1       1
145
 
select count (*) from t1;
146
 
count (*)
147
 
5
148
 
delete from t1 where a > 20;
149
 
select count(*) from t1;
150
 
count(*)
151
 
5
152
 
drop table 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;
166
 
count(*)
167
 
0
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);
172
 
id
173
 
10
174
 
20
175
 
30
176
 
40
177
 
select * from t1;
178
 
id      a
179
 
2147483647      1
180
 
1800000000000000000     2
181
 
10      1
182
 
20      2
183
 
30      3
184
 
40      4
185
 
delete from t1 where id = 10;
186
 
delete from t1 where id = 20;
187
 
delete from t1 where id in (30, 40);
188
 
select * from t1;
189
 
id      a
190
 
2147483647      1
191
 
1800000000000000000     2
192
 
drop table t1;
193
 
create table t1 (id int primary key auto_increment, num int) engine = blitzdb;
194
 
insert into t1 (num) values (1);
195
 
select * from t1;
196
 
id      num
197
 
1       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;
202
 
count(*)
203
 
4
204
 
flush table t1;
205
 
select count(*) from t1;
206
 
count(*)
207
 
4
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;
213
 
count(*)
214
 
8
215
 
select count(num) from t1;
216
 
count(num)
217
 
8
218
 
select * from t1;
219
 
id      num
220
 
1       1
221
 
2       1
222
 
3       1
223
 
4       1
224
 
5       1
225
 
6       1
226
 
7       1
227
 
8       1
228
 
drop table 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);
233
 
select * from t1;
234
 
id
235
 
1
236
 
2
237
 
3
238
 
4
239
 
5
240
 
7
241
 
8
242
 
9
243
 
10
244
 
11
245
 
insert into t1 values (), (), ();
246
 
select * from t1;
247
 
id
248
 
1
249
 
2
250
 
3
251
 
4
252
 
5
253
 
7
254
 
8
255
 
9
256
 
10
257
 
11
258
 
12
259
 
13
260
 
14
261
 
drop table t1;
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;
268
 
count(*)
269
 
4
270
 
delete from t1 where id = 1;
271
 
delete from t1 where id = 2;
272
 
select count(*) from t1;
273
 
count(*)
274
 
2
275
 
insert into t1 values ();
276
 
insert into t1 values ();
277
 
select count(*) from t1;
278
 
count(*)
279
 
4
280
 
drop table 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);
290
 
select * from t1;
291
 
id      a
292
 
1.1     1
293
 
1.11    2
294
 
1.111   3
295
 
1.1111  4
296
 
2.2     5
297
 
2.22    6
298
 
2.222   7
299
 
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;
309
 
id      a
310
 
2.2     5
311
 
2.22    6
312
 
2.222   7
313
 
2.2222  8
314
 
3.3     1
315
 
3.33    2
316
 
3.333   3
317
 
3.3333  4
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;
323
 
id      a
324
 
2.2     5
325
 
2.22    6
326
 
2.222   7
327
 
2.2222  8
328
 
3.333   3
329
 
3.3333  4
330
 
drop table t1;
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;
340
 
id      country
341
 
amsterdam       netherlands
342
 
budapest        hungary
343
 
copenhagen      denmark
344
 
dublin  ireland
345
 
edinburgh       scotland
346
 
fukuoka japan
347
 
geneva  switzerland
348
 
select country from t1 where id = 'dublin';
349
 
country
350
 
ireland
351
 
select country from t1 where id = 'geneva';
352
 
country
353
 
switzerland
354
 
select country from t1 where id = 'amsterdam';
355
 
country
356
 
netherlands
357
 
select country from t1 where id = 'non existent key';
358
 
country
359
 
select country from t1 where id = 'edinburgh';
360
 
country
361
 
scotland
362
 
select country from t1 where id = 'copenhagen';
363
 
country
364
 
denmark
365
 
select country from t1 where id = 'fukuoka';
366
 
country
367
 
japan
368
 
select country from t1 where id = 'budapest';
369
 
country
370
 
hungary
371
 
select count (id) from t1;
372
 
count (id)
373
 
7
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';
383
 
id      country
384
 
berlin  germany
385
 
select * from t1 where id = 'london';
386
 
id      country
387
 
london  england
388
 
select * from t1 where id = 'paris';
389
 
id      country
390
 
paris   france
391
 
delete from t1 where id = 'geneva';
392
 
delete from t1 where id = 'fukuoka';
393
 
select count (id) from t1;
394
 
count (id)
395
 
5
396
 
select count (*) from t1;
397
 
count (*)
398
 
5
399
 
select * from t1 order by id;
400
 
id      country
401
 
amsterdam       netherlands
402
 
berlin  germany
403
 
edinburgh       scotland
404
 
london  england
405
 
paris   france
406
 
delete from t1 where id < 'london';
407
 
select count (*) from t1;
408
 
count (*)
409
 
2
410
 
select * from t1 order by id;
411
 
id      country
412
 
london  england
413
 
paris   france
414
 
drop table t1;
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';
419
 
a       b
420
 
aaa     1
421
 
select * from t1 where a = 'bbb';
422
 
a       b
423
 
bbb     2
424
 
select * from t1 where a = 'ccc';
425
 
a       b
426
 
ccc     3
427
 
select * from t1 where a = 'ddd';
428
 
a       b
429
 
ddd     4
430
 
select * from t1;
431
 
a       b
432
 
aaa     1
433
 
bbb     2
434
 
ccc     3
435
 
ddd     4
436
 
eee     5
437
 
fff     6
438
 
ggg     7
439
 
hhh     8
440
 
delete from t1 where a = 'ggg';
441
 
delete from t1 where a = 'hhh';
442
 
select * from t1;
443
 
a       b
444
 
aaa     1
445
 
bbb     2
446
 
ccc     3
447
 
ddd     4
448
 
eee     5
449
 
fff     6
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';
456
 
count(*)
457
 
0
458
 
select * from t1 where a = 'zzz';
459
 
a       b
460
 
zzz     6
461
 
select * from t1;
462
 
a       b
463
 
aaa     1
464
 
bbb     2
465
 
ccc     3
466
 
ddd     4
467
 
eee     5
468
 
zzz     6
469
 
drop table t1;
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');
475
 
select * from t1;
476
 
a       b       c
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';
485
 
a       b       c
486
 
1984-09-22      22      twenty two
487
 
select * from t1 where a = '1984-09-23';
488
 
a       b       c
489
 
1984-09-23      23      twenty three
490
 
select * from t1 where a = '1984-09-24';
491
 
a       b       c
492
 
1984-09-24      24      twenty four
493
 
select * from t1 where a = '1984-09-25';
494
 
a       b       c
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;
503
 
a       b       c
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
508
 
drop table t1;
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
514
 
select * from t1;
515
 
a
516
 
1
517
 
2
518
 
3
519
 
4
520
 
5
521
 
6
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;
526
 
a
527
 
6
528
 
5
529
 
4
530
 
3
531
 
2
532
 
1
533
 
delete from t1;
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
538
 
select * from t1;
539
 
a
540
 
1
541
 
2
542
 
3
543
 
4
544
 
5
545
 
6
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;
550
 
a
551
 
6
552
 
5
553
 
4
554
 
3
555
 
2
556
 
1
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;
561
 
max(a)
562
 
6
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;
567
 
min(a)
568
 
1
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;
573
 
sum(a)
574
 
21
575
 
drop table 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
581
 
select * from t1;
582
 
a
583
 
10
584
 
20
585
 
30
586
 
40
587
 
50
588
 
60
589
 
select * from t1 order by a desc;
590
 
a
591
 
60
592
 
50
593
 
40
594
 
30
595
 
20
596
 
10
597
 
delete from t1;
598
 
insert into t1 values (60), (10), (50), (30), (20), (40);
599
 
select * from t1;
600
 
a
601
 
10
602
 
20
603
 
30
604
 
40
605
 
50
606
 
60
607
 
select * from t1 order by a desc;
608
 
a
609
 
60
610
 
50
611
 
40
612
 
30
613
 
20
614
 
10
615
 
drop table t1;
616
 
create table t1 (a varchar(10) primary key) engine = blitzdb;
617
 
insert into t1 values ('a'), ('b'), ('c'), ('d'), ('e');
618
 
select * from t1;
619
 
a
620
 
a
621
 
b
622
 
c
623
 
d
624
 
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;
629
 
a
630
 
e
631
 
d
632
 
c
633
 
b
634
 
a
635
 
delete from t1;
636
 
insert into t1 values ('c'), ('a'), ('e'), ('b'), ('d');
637
 
select * from t1;
638
 
a
639
 
a
640
 
b
641
 
c
642
 
d
643
 
e
644
 
delete from t1;
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
650
 
select * from t1;
651
 
a
652
 
恂
653
 
恄
654
 
恆
655
 
恈
656
 
恊
657
 
恋
658
 
恍
659
 
恏
660
 
恑
661
 
恓
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;
666
 
a
667
 
恓
668
 
恑
669
 
恏
670
 
恍
671
 
恋
672
 
恊
673
 
恈
674
 
恆
675
 
恄
676
 
恂
677
 
drop table t1;
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
683
 
select * from t1;
684
 
a
685
 
a
686
 
b
687
 
c
688
 
d
689
 
e
690
 
select * from t1 order by a desc;
691
 
a
692
 
e
693
 
d
694
 
c
695
 
b
696
 
a
697
 
delete from t1;
698
 
insert into t1 values ('c'), ('a'), ('e'), ('b'), ('d');
699
 
select * from t1;
700
 
a
701
 
a
702
 
b
703
 
c
704
 
d
705
 
e
706
 
delete from t1;
707
 
drop table t1;
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);
717
 
select * from t1;
718
 
a
719
 
NULL
720
 
1
721
 
2
722
 
3
723
 
4
724
 
select * from t1 where a = 1;
725
 
a
726
 
1
727
 
select * from t1 where a = 2;
728
 
a
729
 
2
730
 
select * from t1 where a = 3;
731
 
a
732
 
3
733
 
select * from t1 where a = 4;
734
 
a
735
 
4
736
 
select * from t1 where a is NULL;
737
 
a
738
 
NULL
739
 
drop table t1;
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');
749
 
select * from t1;
750
 
a
751
 
a
752
 
b
753
 
c
754
 
d
755
 
e
756
 
f
757
 
select count(*) from t1;
758
 
count(*)
759
 
6
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';
764
 
a
765
 
a
766
 
select * from t1 where a = 'b';
767
 
a
768
 
b
769
 
select * from t1 where a = 'c';
770
 
a
771
 
c
772
 
select * from t1 where a = 'd';
773
 
a
774
 
d
775
 
select * from t1 where a = 'e';
776
 
a
777
 
e
778
 
select * from t1 where a = 'f';
779
 
a
780
 
f
781
 
delete from t1 where a = 'a';
782
 
delete from t1 where a = 'b';
783
 
select count(*) from t1;
784
 
count(*)
785
 
4
786
 
select * from t1;
787
 
a
788
 
c
789
 
d
790
 
e
791
 
f
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;
797
 
count(*)
798
 
0
799
 
select * from t1;
800
 
a
801
 
drop table 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);
805
 
select * from t1;
806
 
a
807
 
1
808
 
1
809
 
2
810
 
2
811
 
3
812
 
3
813
 
4
814
 
4
815
 
insert into t1 values (NULL), (NULL);
816
 
insert into t1 values (NULL), (NULL);
817
 
select * from t1;
818
 
a
819
 
NULL
820
 
NULL
821
 
NULL
822
 
NULL
823
 
1
824
 
1
825
 
2
826
 
2
827
 
3
828
 
3
829
 
4
830
 
4
831
 
select count(*) from t1 where a is NULL;
832
 
count(*)
833
 
4
834
 
select * from t1 where a is NULL;
835
 
a
836
 
NULL
837
 
NULL
838
 
NULL
839
 
NULL
840
 
select * from t1 where a is not NULL;
841
 
a
842
 
1
843
 
1
844
 
2
845
 
2
846
 
3
847
 
3
848
 
4
849
 
4
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;
854
 
a
855
 
1
856
 
1
857
 
select * from t1 where a = 2;
858
 
a
859
 
2
860
 
2
861
 
select * from t1 where a = 3;
862
 
a
863
 
3
864
 
3
865
 
select * from t1 where a = 4;
866
 
a
867
 
4
868
 
4
869
 
delete from t1 where a = 3;
870
 
select * from t1 where a = 3;
871
 
a
872
 
delete from t1 where a = 1;
873
 
select * from t1 where a = 1;
874
 
a
875
 
select * from t1;
876
 
a
877
 
NULL
878
 
NULL
879
 
NULL
880
 
NULL
881
 
2
882
 
2
883
 
4
884
 
4
885
 
delete from t1 where a is NULL;
886
 
select * from t1 where a is NULL;
887
 
a
888
 
delete from t1 where a = 2;
889
 
select * from t1 where a = 2;
890
 
a
891
 
delete from t1 where a = 4;
892
 
select * from t1 where a = 4;
893
 
a
894
 
select count(*) from t1;
895
 
count(*)
896
 
0
897
 
drop table 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');
901
 
select * from t1;
902
 
a
903
 
aaa
904
 
bbb
905
 
ccc
906
 
ddd
907
 
eee
908
 
fff
909
 
select * from t1 where a = 'aaa';
910
 
a
911
 
aaa
912
 
select * from t1 where a = 'bbb';
913
 
a
914
 
bbb
915
 
select * from t1 where a = 'ccc';
916
 
a
917
 
ccc
918
 
select * from t1 where a = 'ddd';
919
 
a
920
 
ddd
921
 
select * from t1 where a = 'eee';
922
 
a
923
 
eee
924
 
delete from t1 where a = 'ddd';
925
 
delete from t1 where a = 'eee';
926
 
select * from t1;
927
 
a
928
 
aaa
929
 
bbb
930
 
ccc
931
 
fff
932
 
select count(*) from t1;
933
 
count(*)
934
 
4
935
 
drop table 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);
938
 
select * from t1;
939
 
a       b
940
 
NULL    1
941
 
NULL    2
942
 
NULL    3
943
 
NULL    4
944
 
select * from t1 where a is NULL;
945
 
a       b
946
 
NULL    1
947
 
NULL    2
948
 
NULL    3
949
 
NULL    4
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;
954
 
a       b
955
 
1       5
956
 
2       6
957
 
delete from t1 where a is NULL;
958
 
select * from t1;
959
 
a       b
960
 
1       5
961
 
2       6
962
 
select count(*) from t1;
963
 
count(*)
964
 
2
965
 
drop table t1;
966
 
create table t1 (
967
 
id int primary key,
968
 
lastname varchar(64),
969
 
description varchar(255), 
970
 
price int,
971
 
INDEX(price)
972
 
) engine = blitzdb;
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);
981
 
select * from t1;
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
987
 
5       Yamada  Dinner  120
988
 
6       Smith   Lunch   30
989
 
7       Hayes   Lunch   30
990
 
8       Kinoshita       Computer Equipment      3740
991
 
select sum(price) from t1;
992
 
sum(price)
993
 
51540
994
 
select lastname, sum(price) from t1 group by lastname;
995
 
lastname        sum(price)
996
 
Hayes   430
997
 
Kinoshita       3740
998
 
Lawrence        220
999
 
Schwartz        1500
1000
 
Smith   45530
1001
 
Yamada  120
1002
 
drop table t1;
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)
1015
 
create table `t1` (
1016
 
`col_varchar_10_key` varchar(10),
1017
 
`col_int_key` int,
1018
 
`col_varchar_1024_key` varchar(1024),
1019
 
pk integer auto_increment,
1020
 
`col_varchar_10` varchar(10),
1021
 
`col_int` int,
1022
 
`col_varchar_1024` varchar(1024),
1023
 
key (`col_varchar_10_key`),
1024
 
key (`col_int_key`),
1025
 
key (`col_varchar_1024_key`),
1026
 
primary key (pk)
1027
 
) engine = blitzdb;
1028
 
Warnings:
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');
1033
 
select * from t1;
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
1038
 
drop table t1;