~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/blitzdb/tests/t/blitzdb-index.test

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
insert into t1 values (9, 9, 9), (10, 10, 10), (11, 11, 11), (12, 12, 12);
15
15
insert into t1 values (13, 13, 13), (14, 14, 14), (15, 15, 15), (16, 16, 16);
16
16
 
17
 
# this statement should be 'optimized away'.
18
 
explain select count (*) from t1;
19
 
 
20
17
# overflow
21
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
18
--error 1264
22
19
insert into t1 values (2147483648, 1, 1);
23
20
 
24
21
# duplicates 
25
 
--error ER_DUP_ENTRY
 
22
--error 1062
26
23
insert into t1 values (1, 0, 0);
27
 
--error ER_DUP_ENTRY
 
24
--error 1062
28
25
insert into t1 values (2, 0, 0);
29
 
--error ER_DUP_ENTRY
 
26
--error 1062
30
27
insert into t1 values (3, 0, 0);
31
 
--error ER_DUP_ENTRY
 
28
--error 1062
32
29
insert into t1 values (4, 0, 0);
33
30
 
34
31
# needle in a haystack 
42
39
select * from t1 order by id;
43
40
 
44
41
# update the key
45
 
--error ER_DUP_ENTRY
 
42
--error 1062
46
43
update t1 set id = 2 where id = 1;
47
44
 
48
45
update t1 set id = 17 where id = 1;
53
50
update t1 set id = 22 where id = 6;
54
51
update t1 set id = 23 where id = 7;
55
52
 
56
 
--error ER_DUP_ENTRY
 
53
--error 1062
57
54
update t1 set id = 20 where id = 8;
58
55
 
59
56
# TODO: This is using filesort. Investigate why.
73
70
select count (a) from t1;
74
71
select count (b) from t1;
75
72
select * from t1 order by id;
76
 
 
77
 
# delete by pk range
78
 
delete from t1 where id > 10 and id < 14;
79
 
select * from t1 order by id;
80
 
select count (*) from t1;
81
 
delete from t1 where id >= 20 and id <= 23;
82
 
select * from t1 order by id;
83
 
select count (*) from t1;
84
 
 
85
 
# impossible range
86
 
delete from t1 where a > 20;
87
 
select count(*) from t1;
88
 
 
 
73
delete from t1;
 
74
select count (*) from t1;
89
75
drop table t1;
90
76
 
91
77
# +---------------------+
100
86
insert into t1 values (1.8e+18, 2);
101
87
 
102
88
# overflow
103
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
89
--error 1264
104
90
insert into t1 values (1.8e+19, 3);
105
91
 
106
92
insert into t1 values (1,1), (2,2), (3,3), (4,4);
107
93
 
108
 
--error ER_DUP_ENTRY
 
94
--error 1062
109
95
update t1 set id = 4 where id = 1;
110
96
 
111
97
update t1 set id = 10 where id = 1;
183
169
insert into t1 values (2.2222, 8);
184
170
select * from t1;
185
171
 
186
 
--error ER_DUP_ENTRY
 
172
--error 1062
187
173
update t1 set id = 1.11 where id = 1.1;
188
 
--error ER_DUP_ENTRY
 
174
--error 1062
189
175
update t1 set id = 2.22 where id = 2.2;
190
176
 
191
177
update t1 set id = 3.3 where id = 1.1;
194
180
update t1 set id = 3.3333 where id = 1.1111;
195
181
select * from t1 order by id;
196
182
 
197
 
--error ER_DUP_ENTRY
 
183
--error 1062
198
184
update t1 set id = 2.2 where id = 3.3;
199
185
 
200
186
delete from t1 where id = 3.3;
225
211
select country from t1 where id = 'budapest';
226
212
select count (id) from t1;
227
213
 
228
 
--error ER_DUP_ENTRY
 
214
--error 1062
229
215
update t1 set id = 'dublin' where id = 'geneva';
230
216
update t1 set id = 'berlin', country = 'germany' where id = 'budapest';
231
217
update t1 set id = 'london', country = 'england' where id = 'copenhagen';
241
227
select count (id) from t1;
242
228
select count (*) from t1;
243
229
select * from t1 order by id;
244
 
 
245
 
# Delete by Range
246
 
delete from t1 where id < 'london';
247
 
select count (*) from t1;
248
 
select * from t1 order by id;
249
230
drop table t1;
250
231
 
251
232
# Test HA_KEYTYPE_VARTEXT1 as a PRIMARY KEY
263
244
delete from t1 where a = 'hhh';
264
245
select * from t1;
265
246
 
266
 
--error ER_DUP_ENTRY
 
247
--error 1062
267
248
update t1 set a = 'ddd' where a = 'aaa';
268
 
--error ER_DUP_ENTRY
 
249
--error 1062
269
250
update t1 set a = 'ccc' where a = 'bbb';
270
251
 
271
252
update t1 set a = 'zzz' where a = 'fff';
289
270
select * from t1 where a = '1984-09-24';
290
271
select * from t1 where a = '1984-09-25';
291
272
 
292
 
--error ER_DUP_ENTRY
 
273
--error 1062
293
274
update t1 set a = '1984-09-22' where a = '1984-09-25';
294
 
--error ER_DUP_ENTRY
 
275
--error 1062
295
276
update t1 set a = '19840922' where a = '1984-09-25';
296
277
 
297
278
update t1 set a = '2010-03-10' where a = '1984-09-22';
384
365
create table t1 (a int, unique index(a)) engine = blitzdb;
385
366
insert into t1 values (1), (2);
386
367
 
387
 
--error ER_DUP_ENTRY
 
368
--error 1062
388
369
insert into t1 values (1);
389
 
--error ER_DUP_ENTRY
 
370
--error 1062
390
371
insert into t1 values (2);
391
372
 
392
373
insert into t1 values (NULL);
404
385
create table t1 (a varchar(32), unique index(a)) engine = blitzdb;
405
386
insert into t1 values ('a'), ('b'), ('c');
406
387
 
407
 
--error ER_DUP_ENTRY
 
388
--error 1062
408
389
insert into t1 values ('a');
409
 
--error ER_DUP_ENTRY
 
390
--error 1062
410
391
insert into t1 values ('b');
411
 
--error ER_DUP_ENTRY
 
392
--error 1062
412
393
insert into t1 values ('c');
413
394
 
414
395
insert into t1 values ('f'), ('e'), ('d');
476
457
select count(*) from t1;
477
458
drop table t1;
478
459
 
479
 
# +-----------------+
480
 
# | INDEX: VARTEXT1 |
481
 
# +-----------------+
482
 
create table t1 (a varchar(32), index(a)) engine = blitzdb;
483
 
insert into t1 values ('ccc'), ('bbb'), ('aaa');
484
 
insert into t1 values ('eee'), ('ddd'), ('fff');
485
 
--sorted_result
486
 
select * from t1;
487
 
select * from t1 where a = 'aaa';
488
 
select * from t1 where a = 'bbb';
489
 
select * from t1 where a = 'ccc';
490
 
select * from t1 where a = 'ddd';
491
 
select * from t1 where a = 'eee';
492
 
delete from t1 where a = 'ddd';
493
 
delete from t1 where a = 'eee';
494
 
select * from t1;
495
 
select count(*) from t1;
496
 
drop table t1;
497
 
 
498
460
# +------------------------------+
499
461
# | UNIQUE INDEX: DUPLICATE NULL |
500
462
# +------------------------------+
503
465
select * from t1;
504
466
select * from t1 where a is NULL;
505
467
insert into t1 values (1, 5), (2, 6);
506
 
--error ER_DUP_ENTRY
 
468
--error 1062
507
469
insert into t1 values (1, 7), (1, 8);
508
470
select * from t1 where a is not NULL;
509
471
delete from t1 where a is NULL;
541
503
# | COMPOSITE INDEX CHECK |
542
504
# +-----------------------+
543
505
 
544
 
--error ER_CANT_CREATE_TABLE
 
506
--error 1005
545
507
create table t1 (a int, b int, c int, d int, primary key(a, b)) engine = blitzdb;
546
 
--error ER_CANT_CREATE_TABLE
 
508
--error 1005
547
509
create table t1 (a int, b int, c int, d int, primary key(a, b, c)) engine = blitzdb;
548
 
--error ER_CANT_CREATE_TABLE
 
510
--error 1005
549
511
create table t1 (a int, b int, c int, d int, index(a, b)) engine = blitzdb;
550
 
--error ER_CANT_CREATE_TABLE
 
512
--error 1005
551
513
create table t1 (a int, b int, c int, d int, index(a, b, c)) engine = blitzdb;
552
 
--error ER_CANT_CREATE_TABLE
 
514
--error 1005
553
515
create table t1 (a int, b int, c int, d int, unique(a, b)) engine = blitzdb;
554
 
--error ER_CANT_CREATE_TABLE
 
516
--error 1005
555
517
create table t1 (a int, b int, c int, d int, unique(a, b, c)) engine = blitzdb;
556
 
 
557
 
# +------------------------------------------+
558
 
# | LARGE KEYS : Testcase from Patrick Crews |
559
 
# +------------------------------------------+
560
 
 
561
 
create table `t1` (
562
 
  `col_varchar_10_key` varchar(10),
563
 
  `col_int_key` int,
564
 
  `col_varchar_1024_key` varchar(1024),
565
 
  pk integer auto_increment,
566
 
  `col_varchar_10` varchar(10),
567
 
  `col_int` int,
568
 
  `col_varchar_1024` varchar(1024),
569
 
  key (`col_varchar_10_key`),
570
 
  key (`col_int_key`),
571
 
  key (`col_varchar_1024_key`),
572
 
  primary key (pk)
573
 
) engine = blitzdb;
574
 
 
575
 
insert /*! IGNORE */ into t1 values ('x', NULL, 'keyone', NULL, 'could', 1322188800, 'I\'m');
576
 
insert /*! IGNORE */ into t1 values ('y', NULL, 'keytwo', NULL, 'could', 1322188800, 'I\'m');
577
 
insert /*! IGNORE */ into t1 values ('z', NULL, 'keythree', NULL, 'could', 1322188800, 'I\'m');
578
 
select * from t1;
579
 
 
580
 
drop table t1;