~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Stewart Smith
  • Date: 2010-08-12 16:48:46 UTC
  • mto: This revision was merged to the branch mainline in revision 1707.
  • Revision ID: stewart@flamingspork.com-20100812164846-s9bhy47g60bvqs41
bug lp:611379 Equivalent queries with Impossible where return different results

The following two equivalent queries return different results in maria 5.2 and 5.3 (and identical results in mysql 5.5.5) :

SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ;

SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` );

MariaDB returns 0 on the second query and NULL on the first, whereas MySQL returns NULL on both. In MariaDB, both EXPLAIN plans agree that "Impossible WHERE noticed after reading const tables"



We have some slightly different output in drizzle:

main.bug_lp611379 [ fail ]
drizzletest: At line 9: query 'explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a)
as t' failed: 1048: Column 'sum(distinct t1.a)' cannot be null

but the fix gets us the correct query results, although with slightly different execution plans.



This fix is directly ported from MariaDB.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
explain select count (*) from t1;
19
19
 
20
20
# overflow
21
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
21
--error 1264
22
22
insert into t1 values (2147483648, 1, 1);
23
23
 
24
24
# duplicates 
25
 
--error ER_DUP_ENTRY
 
25
--error 1062
26
26
insert into t1 values (1, 0, 0);
27
 
--error ER_DUP_ENTRY
 
27
--error 1062
28
28
insert into t1 values (2, 0, 0);
29
 
--error ER_DUP_ENTRY
 
29
--error 1062
30
30
insert into t1 values (3, 0, 0);
31
 
--error ER_DUP_ENTRY
 
31
--error 1062
32
32
insert into t1 values (4, 0, 0);
33
33
 
34
34
# needle in a haystack 
42
42
select * from t1 order by id;
43
43
 
44
44
# update the key
45
 
--error ER_DUP_ENTRY
 
45
--error 1062
46
46
update t1 set id = 2 where id = 1;
47
47
 
48
48
update t1 set id = 17 where id = 1;
53
53
update t1 set id = 22 where id = 6;
54
54
update t1 set id = 23 where id = 7;
55
55
 
56
 
--error ER_DUP_ENTRY
 
56
--error 1062
57
57
update t1 set id = 20 where id = 8;
58
58
 
59
59
# TODO: This is using filesort. Investigate why.
100
100
insert into t1 values (1.8e+18, 2);
101
101
 
102
102
# overflow
103
 
--error ER_WARN_DATA_OUT_OF_RANGE
 
103
--error 1264
104
104
insert into t1 values (1.8e+19, 3);
105
105
 
106
106
insert into t1 values (1,1), (2,2), (3,3), (4,4);
107
107
 
108
 
--error ER_DUP_ENTRY
 
108
--error 1062
109
109
update t1 set id = 4 where id = 1;
110
110
 
111
111
update t1 set id = 10 where id = 1;
183
183
insert into t1 values (2.2222, 8);
184
184
select * from t1;
185
185
 
186
 
--error ER_DUP_ENTRY
 
186
--error 1062
187
187
update t1 set id = 1.11 where id = 1.1;
188
 
--error ER_DUP_ENTRY
 
188
--error 1062
189
189
update t1 set id = 2.22 where id = 2.2;
190
190
 
191
191
update t1 set id = 3.3 where id = 1.1;
194
194
update t1 set id = 3.3333 where id = 1.1111;
195
195
select * from t1 order by id;
196
196
 
197
 
--error ER_DUP_ENTRY
 
197
--error 1062
198
198
update t1 set id = 2.2 where id = 3.3;
199
199
 
200
200
delete from t1 where id = 3.3;
225
225
select country from t1 where id = 'budapest';
226
226
select count (id) from t1;
227
227
 
228
 
--error ER_DUP_ENTRY
 
228
--error 1062
229
229
update t1 set id = 'dublin' where id = 'geneva';
230
230
update t1 set id = 'berlin', country = 'germany' where id = 'budapest';
231
231
update t1 set id = 'london', country = 'england' where id = 'copenhagen';
263
263
delete from t1 where a = 'hhh';
264
264
select * from t1;
265
265
 
266
 
--error ER_DUP_ENTRY
 
266
--error 1062
267
267
update t1 set a = 'ddd' where a = 'aaa';
268
 
--error ER_DUP_ENTRY
 
268
--error 1062
269
269
update t1 set a = 'ccc' where a = 'bbb';
270
270
 
271
271
update t1 set a = 'zzz' where a = 'fff';
289
289
select * from t1 where a = '1984-09-24';
290
290
select * from t1 where a = '1984-09-25';
291
291
 
292
 
--error ER_DUP_ENTRY
 
292
--error 1062
293
293
update t1 set a = '1984-09-22' where a = '1984-09-25';
294
 
--error ER_DUP_ENTRY
 
294
--error 1062
295
295
update t1 set a = '19840922' where a = '1984-09-25';
296
296
 
297
297
update t1 set a = '2010-03-10' where a = '1984-09-22';
384
384
create table t1 (a int, unique index(a)) engine = blitzdb;
385
385
insert into t1 values (1), (2);
386
386
 
387
 
--error ER_DUP_ENTRY
 
387
--error 1062
388
388
insert into t1 values (1);
389
 
--error ER_DUP_ENTRY
 
389
--error 1062
390
390
insert into t1 values (2);
391
391
 
392
392
insert into t1 values (NULL);
404
404
create table t1 (a varchar(32), unique index(a)) engine = blitzdb;
405
405
insert into t1 values ('a'), ('b'), ('c');
406
406
 
407
 
--error ER_DUP_ENTRY
 
407
--error 1062
408
408
insert into t1 values ('a');
409
 
--error ER_DUP_ENTRY
 
409
--error 1062
410
410
insert into t1 values ('b');
411
 
--error ER_DUP_ENTRY
 
411
--error 1062
412
412
insert into t1 values ('c');
413
413
 
414
414
insert into t1 values ('f'), ('e'), ('d');
476
476
select count(*) from t1;
477
477
drop table t1;
478
478
 
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
479
# +------------------------------+
499
480
# | UNIQUE INDEX: DUPLICATE NULL |
500
481
# +------------------------------+
503
484
select * from t1;
504
485
select * from t1 where a is NULL;
505
486
insert into t1 values (1, 5), (2, 6);
506
 
--error ER_DUP_ENTRY
 
487
--error 1062
507
488
insert into t1 values (1, 7), (1, 8);
508
489
select * from t1 where a is not NULL;
509
490
delete from t1 where a is NULL;
541
522
# | COMPOSITE INDEX CHECK |
542
523
# +-----------------------+
543
524
 
544
 
--error ER_CANT_CREATE_TABLE
 
525
--error 1005
545
526
create table t1 (a int, b int, c int, d int, primary key(a, b)) engine = blitzdb;
546
 
--error ER_CANT_CREATE_TABLE
 
527
--error 1005
547
528
create table t1 (a int, b int, c int, d int, primary key(a, b, c)) engine = blitzdb;
548
 
--error ER_CANT_CREATE_TABLE
 
529
--error 1005
549
530
create table t1 (a int, b int, c int, d int, index(a, b)) engine = blitzdb;
550
 
--error ER_CANT_CREATE_TABLE
 
531
--error 1005
551
532
create table t1 (a int, b int, c int, d int, index(a, b, c)) engine = blitzdb;
552
 
--error ER_CANT_CREATE_TABLE
 
533
--error 1005
553
534
create table t1 (a int, b int, c int, d int, unique(a, b)) engine = blitzdb;
554
 
--error ER_CANT_CREATE_TABLE
 
535
--error 1005
555
536
create table t1 (a int, b int, c int, d int, unique(a, b, c)) engine = blitzdb;
556
537
 
557
538
# +------------------------------------------+