1 # include/index_merge1.inc
6 # $engine_type -- storage engine to be tested
7 # $merge_table_support -- 1 storage engine supports merge tables
8 # -- 0 storage engine does not support merge tables
9 # have to be set before sourcing this script.
11 # Note: The comments/expectations refer to MyISAM.
12 # They might be not valid for other storage engines.
15 # 2006-08-02 ML test refactored
16 # old name was t/index_merge.test
17 # main code went into include/index_merge1.inc
20 --echo #---------------- Index merge
test 1 -------------------------------------------
22 eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
25 drop
table if exists t0, t1, t2, t3, t4;
28 # Create and fill a table with simple keys
50 insert into t0 values (1,1,1,1,1,1,1,1023),(2,2,2,2,2,2,2,1022);
56 eval insert into t0 select key1+@d, key2+@d, key3+@d, key4+@d, key5+@d,
57 key6+@d, key7+@d, key8-@d from t0;
66 explain select * from t0 where key1 < 3 or key1 > 1020;
70 select * from t0 where key1 < 3 or key2 > 1020;
71 select * from t0 where key1 < 3 or key2 > 1020;
73 if ($index_merge_random_rows_in_EXPLAIN)
77 explain select * from t0 where key1 < 2 or key2 <3;
79 if ($index_merge_random_rows_in_EXPLAIN)
84 select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
85 # Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
86 select * from t0 where (key1 > 30 and key1<35) or (key2 >32 and key2 < 40);
88 # 3. Check that index_merge doesn't break "ignore/force/use index"
89 if ($index_merge_random_rows_in_EXPLAIN)
93 explain select * from t0 ignore
index (i2) where key1 < 3 or key2 <4;
95 if ($index_merge_random_rows_in_EXPLAIN)
99 explain select * from t0 where (key1 < 3 or key2 <4) and key3 = 50;
101 if ($index_merge_random_rows_in_EXPLAIN)
105 explain select * from t0 use
index (i1,i2) where (key1 < 2 or key2 <3) and key3 = 50;
107 if ($index_merge_random_rows_in_EXPLAIN)
111 explain select * from t0 where (key1 > 1 or key2 > 2);
113 if ($index_merge_random_rows_in_EXPLAIN)
117 explain select * from t0 force
index (i1,i2) where (key1 > 1 or key2 > 2);
120 # 4. Check if conjuncts are grouped by keyuse
121 if ($index_merge_random_rows_in_EXPLAIN)
126 select * from t0 where key1<2 or key2<3 or (key1>5 and key1<7) or
127 (key1>10 and key1<12) or (key2>100 and key2<102);
129 # 5. Check index_merge with conjuncts that are always true/false
130 # verify fallback to "range" if there is only one non-confluent condition
131 if ($index_merge_random_rows_in_EXPLAIN)
135 explain select * from t0 where key2 = 45 or key1 <=> null;
137 if ($index_merge_random_rows_in_EXPLAIN)
141 explain select * from t0 where key2 = 45 or key1 is not null;
143 if ($index_merge_random_rows_in_EXPLAIN)
147 explain select * from t0 where key2 = 45 or key1 is null;
149 # the last conj. is always false and will be discarded
150 if ($index_merge_random_rows_in_EXPLAIN)
154 explain select * from t0 where key2=10 or key3=3 or key4 <=> null;
156 # the last conj. is always true and will cause 'all' scan
157 if ($index_merge_random_rows_in_EXPLAIN)
161 explain select * from t0 where key2=10 or key3=3 or key4 is null;
163 # some more complicated cases
165 if ($index_merge_random_rows_in_EXPLAIN)
169 explain select key1 from t0 where (key1 <=> null) or (key2 < 2) or
170 (key3=10) or (key4 <=> null);
172 if ($index_merge_random_rows_in_EXPLAIN)
176 explain select key1 from t0 where (key1 <=> null) or (key1 < 5) or
177 (key3=10) or (key4 <=> null);
179 # 6.Several ways to do index_merge, (ignored) index_merge vs. range
180 if ($index_merge_random_rows_in_EXPLAIN)
184 explain select * from t0 where
185 (key1 < 2 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 5 or key6 < 5);
187 if ($index_merge_random_rows_in_EXPLAIN)
192 select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
194 select * from t0 where (key1 < 2 or key2 < 4) and (key1 < 5 or key3 < 3);
197 if ($index_merge_random_rows_in_EXPLAIN)
201 explain select * from t0 where
202 (key1 < 3 or key2 < 2) and (key3 < 3 or key4 < 3) and (key5 < 2 or key6 < 2);
204 if ($index_merge_random_rows_in_EXPLAIN)
208 explain select * from t0 where
209 (key1 < 3 or key2 < 3) and (key3 < 70);
211 if ($index_merge_random_rows_in_EXPLAIN)
215 explain select * from t0 where
216 (key1 < 3 or key2 < 3) and (key3 < 1000);
220 # tree_or(List<SEL_IMERGE>, range SEL_TREE).
221 if ($index_merge_random_rows_in_EXPLAIN)
225 explain select * from t0 where
226 ((key1 < 3 or key2 < 3) and (key2 <4 or key3 < 3))
230 if ($index_merge_random_rows_in_EXPLAIN)
234 explain select * from t0 where
235 ((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
239 select * from t0 where
240 ((key1 < 4 or key2 < 4) and (key2 <4 or key3 < 3))
244 # tree_or(List<SEL_IMERGE>, List<SEL_IMERGE>).
245 if ($index_merge_random_rows_in_EXPLAIN)
249 explain select * from t0 where
250 ((key1 < 2 or key2 < 2) and (key3 <4 or key5 < 3))
252 ((key5 < 3 or key6 < 3) and (key7 <3 or key8 < 3));
254 if ($index_merge_random_rows_in_EXPLAIN)
258 explain select * from t0 where
259 ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
261 ((key7 <5 or key8 < 3) and (key5 < 4 or key6 < 4));
263 if ($index_merge_random_rows_in_EXPLAIN)
267 explain select * from t0 where
268 ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 4))
270 ((key3 <4 or key5 < 2) and (key5 < 5 or key6 < 3));
272 if ($index_merge_random_rows_in_EXPLAIN)
276 explain select * from t0 where
277 ((key3 <4 or key5 < 3) and (key1 < 3 or key2 < 3))
279 (((key3 <5 and key7 < 5) or key5 < 2) and (key5 < 4 or key6 < 4));
281 if ($index_merge_random_rows_in_EXPLAIN)
285 explain select * from t0 where
286 ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
288 ((key3 >5 or key5 < 2) and (key5 < 5 or key6 < 6));
290 if ($index_merge_random_rows_in_EXPLAIN)
294 explain select * from t0 force
index(i1, i2, i3, i4, i5, i6 ) where
295 ((key3 <3 or key5 < 4) and (key1 < 3 or key2 < 3))
297 ((key3 >4 or key5 < 2) and (key5 < 5 or key6 < 4));
299 # Can't merge any indexes here (predicate on key3 is always true)
300 if ($index_merge_random_rows_in_EXPLAIN)
304 explain select * from t0 force
index(i1, i2, i3, i4, i5, i6 ) where
305 ((key3 <5 or key5 < 4) and (key1 < 4 or key2 < 4))
307 ((key3 >=5 or key5 < 2) and (key5 < 5 or key6 < 6));
309 # 8. Verify that "order by" after index merge uses filesort
310 select * from t0 where key1 < 3 or key8 < 2 order by key1;
312 if ($index_merge_random_rows_in_EXPLAIN)
317 select * from t0 where key1 < 3 or key8 < 2 order by key1;
319 # 9. Check that index_merge cost is compared to 'index' where possible
320 create
table t2 like t0;
321 insert into t2 select * from t0;
327 alter
table t2 add
index i321(key3, key2, key1);
330 -- disable_result_log
335 # index_merge vs 'index', index_merge is better.
336 if ($index_merge_random_rows_in_EXPLAIN)
340 explain select key3 from t2 where key1 = 100 or key2 = 100;
342 # index_merge vs 'index', 'index' is better.
343 if ($index_merge_random_rows_in_EXPLAIN)
347 explain select key3 from t2 where key1 <100 or key2 < 100;
349 # index_merge vs 'all', index_merge is better.
350 if ($index_merge_random_rows_in_EXPLAIN)
354 explain select key7 from t2 where key1 <100 or key2 < 100;
356 # 10. Multipart keys.
364 index i1a (key1a, key1b),
365 index i1b (key1b, key1a),
366 index i2_1(key2, key2_1),
367 index i2_2(key2, key2_1)
370 insert into t4 select key1,key1,key1 div 10, key1 % 10, key1 % 10, key1 from t0;
373 -- disable_result_log
378 # the following will be handled by index_merge:
379 select * from t4 where key1a = 3 or key1b = 4;
380 explain select * from t4 where key1a = 3 or key1b = 4;
382 # and the following will not
383 explain select * from t4 where key2 = 1 and (key2_1 = 1 or key3 = 5);
385 explain select * from t4 where key2 = 1 and (key2_1 = 1 or key2_2 = 5);
387 if ($index_merge_random_rows_in_EXPLAIN)
391 explain select * from t4 where key2_1 = 1 or key2_2 = 5;
394 # 11. Multitable selects
395 create
table t1 like t0;
396 insert into t1 select * from t0;
399 -- disable_result_log
404 # index_merge on first table in join
405 explain select * from t0 left join t1 on (t0.key1=t1.key1)
406 where t0.key1=3 or t0.key2=4;
408 select * from t0 left join t1 on (t0.key1=t1.key1)
409 where t0.key1=3 or t0.key2=4;
412 select * from t0,t1 where (t0.key1=t1.key1) and ( t0.key1=3 or t0.key2=4);
414 # index_merge vs. ref
415 if (!$index_merge_random_rows_in_EXPLAIN)
417 #this plan varies too much for InnoDB
419 select * from t0,t1 where (t0.key1=t1.key1) and
420 (t0.key1=3 or t0.key2=4) and t1.key1<200;
423 # index_merge vs. ref
425 select * from t0,t1 where (t0.key1=t1.key1) and
426 (t0.key1=3 or t0.key2<4) and t1.key1=2;
428 # index_merge on second table in join
429 explain select * from t0,t1 where t0.key1 = 5 and
430 (t1.key1 = t0.key1 or t1.key8 = t0.key1);
433 if ($index_merge_random_rows_in_EXPLAIN)
437 explain select * from t0,t1 where t0.key1 < 3 and
438 (t1.key1 = t0.key1 or t1.key8 = t0.key1);
440 # index_merge inside union
441 explain select * from t1 where key1=3 or key2=4
442 union select * from t1 where key1<4 or key3=5;
444 # index merge in subselect
445 explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
447 # 12. check for long index_merges.
448 create
table t3 like t0;
449 insert into t3 select * from t0;
450 alter
table t3 add key9
int not null, add
index i9(key9);
451 alter
table t3 add keyA
int not null, add
index iA(keyA);
452 alter
table t3 add keyB
int not null, add
index iB(keyB);
453 alter
table t3 add keyC
int not null, add
index iC(keyC);
454 update t3
set key9=key1,keyA=key1,keyB=key1,keyC=key1;
457 -- disable_result_log
462 explain select * from t3 where
463 key1=1 or key2=2 or key3=3 or key4=4 or
464 key5=5 or key6=6 or key7=7 or key8=8 or
465 key9=9 or keyA=10 or keyB=11 or keyC=12;
467 select * from t3 where
468 key1=1 or key2=2 or key3=3 or key4=4 or
469 key5=5 or key6=6 or key7=7 or key8=8 or
470 key9=9 or keyA=10 or keyB=11 or keyC=12;
473 explain select * from t0 where key1 < 3 or key2 < 4;
474 # Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
475 select * from t0 where key1 < 3 or key2 < 4;
477 update t0
set key8=123 where key1 < 3 or key2 < 4;
480 -- disable_result_log
485 # Bug#21277: InnoDB, wrong result set, index_merge strategy, second index not evaluated
486 select * from t0 where key1 < 3 or key2 < 4;
488 delete from t0 where key1 < 3 or key2 < 4;
490 -- disable_result_log
495 select * from t0 where key1 < 3 or key2 < 4;
496 select count(*) from t0;
500 create
table t4 (a
int);
501 insert into t4 values (1),(4),(3);
503 -- disable_result_log
508 set @save_join_buffer_size=@@join_buffer_size;
509 set join_buffer_size= 4096;
511 if ($index_merge_random_rows_in_EXPLAIN)
515 explain select max(
A.key1 + B.key1 +
A.key2 + B.key2 +
A.key3 + B.key3 +
A.key4 + B.key4 +
A.key5 + B.key5)
516 from t0 as
A force
index(i1,i2), t0 as B force
index (i1,i2)
517 where (
A.key1 < 500000 or
A.key2 < 3)
518 and (B.key1 < 500000 or B.key2 < 3);
520 select max(
A.key1 + B.key1 +
A.key2 + B.key2 +
A.key3 + B.key3 +
A.key4 + B.key4 +
A.key5 + B.key5)
521 from t0 as
A force
index(i1,i2), t0 as B force
index (i1,i2)
522 where (
A.key1 < 500000 or
A.key2 < 3)
523 and (B.key1 < 500000 or B.key2 < 3);
525 update t0 set key1=1;
527 -- disable_result_log
532 if ($index_merge_random_rows_in_EXPLAIN)
536 explain select max(
A.key1 + B.key1 +
A.key2 + B.key2 +
A.key3 + B.key3 +
A.key4 + B.key4 +
A.key5 + B.key5)
537 from t0 as
A force
index(i1,i2), t0 as B force
index (i1,i2)
538 where (
A.key1 = 1 or
A.key2 = 1)
539 and (B.key1 = 1 or B.key2 = 1);
541 select max(
A.key1 + B.key1 +
A.key2 + B.key2 +
A.key3 + B.key3 +
A.key4 + B.key4 +
A.key5 + B.key5)
542 from t0 as
A force
index(i1,i2), t0 as B force
index (i1,i2)
543 where (
A.key1 = 1 or
A.key2 = 1)
544 and (B.key1 = 1 or B.key2 = 1);
546 alter
table t0 add filler1
char(200), add filler2
char(200), add filler3
char(200);
547 update t0 set key2=1, key3=1, key4=1, key5=1,key6=1,key7=1 where key7 < 500;
550 -- disable_result_log
555 # The next query will not use index i7 in intersection if the OS doesn't
556 # support file sizes > 2GB. (ha_myisam::ref_length depends on this and index
557 # scan cost estimates depend on ha_myisam::ref_length)
558 if (!$index_merge_random_rows_in_EXPLAIN)
560 # Too unstable for innodb
562 --replace_result
"4,4,4,4,4,4,4" X
"4,4,4,4,4,4" X
"i6,i7" "i6,i7?" "i6" "i6,i7?"
563 explain select max(
A.key1 + B.key1 +
A.key2 + B.key2 +
A.key3 + B.key3 +
A.key4 + B.key4 +
A.key5 + B.key5)
564 from t0 as
A, t0 as B
565 where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
566 and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
568 select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5)
569 from t0 as A, t0 as B
570 where (A.key1 = 1 and A.key2 = 1 and A.key3 = 1 and A.key4=1 and A.key5=1 and A.key6=1 and A.key7 = 1 or A.key8=1)
571 and (B.key1 = 1 and B.key2 = 1 and B.key3 = 1 and B.key4=1 and B.key5=1 and B.key6=1 and B.key7 = 1 or B.key8=1);
573 set join_buffer_size= @save_join_buffer_size;
574 # Test for BUG#4177 ends
576 drop
table t0, t1, t2, t3, t4;
580 cola
char(3) not null, colb
char(3) not null, filler
char(200),
583 INSERT INTO t1 VALUES (
'foo',
'bar',
'ZZ'),(
'fuz',
'baz',
'ZZ');
589 eval INSERT INTO t1 SELECT * from t1 WHERE cola =
'foo';
596 eval INSERT INTO t1 SELECT * from t1 WHERE cola <>
'foo';
603 select count(*) from t1;
606 -- disable_result_log
611 if ($index_merge_random_rows_in_EXPLAIN)
615 explain select * from t1 WHERE cola =
'foo' AND colb =
'bar';
617 if ($index_merge_random_rows_in_EXPLAIN)
621 explain select * from t1 force
index(cola,colb) WHERE cola = 'foo' AND colb = 'bar';
624 if ($merge_table_support)
627 # BUG#17314: Index_merge/intersection not choosen by the optimizer for MERGE tables
629 create
table t0 (a
int);
630 insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
633 filler1
char(200), filler2
char(200),
636 insert into t1 select @v:= A.a, @v,
't1',
'filler2' from t0 A, t0 B, t0 C;
637 create
table t2 like t1;
641 filler1
char(200), filler2
char(200),
643 ) engine=merge union=(t1,t2);
646 -- disable_result_log
655 explain select * from t1 where a=1 and b=1;
657 explain select * from t3 where a=1 and b=1;
660 drop
table t0, t1, t2;
664 # BUG#20256 - LOCK WRITE - MyISAM
666 CREATE
TABLE t1(a INT);
667 INSERT INTO t1 VALUES(1);
668 CREATE
TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT
'',
KEY(a),
KEY(b));
669 INSERT INTO t2(a,b) VALUES
670 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
671 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
672 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
673 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
674 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
675 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
676 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
677 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
678 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
679 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
680 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
681 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
682 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
683 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
684 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
685 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
686 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
687 (0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
689 LOCK TABLES t1 WRITE, t2 WRITE;
690 INSERT INTO t2(a,b) VALUES(1,2);
691 SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
696 # BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine
699 `a` int(11) DEFAULT NULL,
700 `filler`
char(200) DEFAULT NULL,
701 `b`
int(11) DEFAULT NULL,
704 ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
706 insert into t1 values
707 (0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3),
708 (4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7),
709 (8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1),
710 (2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5),
711 (6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9),
712 (10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13),
713 (14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17),
714 (18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0),
715 (4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4);
718 `a`
int(11) DEFAULT NULL,
719 `filler`
char(200) DEFAULT NULL,
720 `b`
int(11) DEFAULT NULL,
721 KEY USING BTREE (`a`),
722 KEY USING BTREE (`b`)
723 ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
724 insert into t2 select * from t1;
727 -- disable_result_log
733 --echo must use sort-union rather than union:
735 explain select * from t1 where a=4 or b=4;
737 select * from t1 where a=4 or b=4;
739 select * from t1 ignore
index(a,b) where a=4 or b=4;
741 --echo must use union, not sort-union:
743 explain select * from t2 where a=4 or b=4;
745 select * from t2 where a=4 or b=4;
750 # Bug #37943: Reproducible mysqld crash/sigsegv in sel_trees_can_be_ored
753 CREATE
TABLE t1 (a varchar(8), b
set(
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h'),
755 INSERT INTO t1 VALUES (
'y',
''), (
'z',
'');
758 SELECT b,a from t1 WHERE (b!=
'c' AND b!=
'f' && b!=
'h') OR
759 (a='pure-S') OR (a='DE80337a') OR (a='DE80799');
764 --echo # BUG#40974: Incorrect
query results when
using clause evaluated
using range check
766 create
table t0 (a
int);
767 insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
769 create
table t1 (a
int);
770 insert into t1 values (1),(2);
771 create
table t2(a
int, b
int);
772 insert into t2 values (1,1), (2, 1000);
773 create
table t3 (a
int, b
int, filler
char(100), key(a), key(b));
775 insert into t3 select 1000, 1000,
'filler' from t0 A, t0 B, t0 C;
776 insert into t3 values (1,1,
'data');
777 insert into t3 values (1,1,
'data');
778 -- echo The
plan should be ALL/ALL/ALL(Range checked
for each record (
index map: 0x3)
781 -- disable_result_log
789 if ($index_merge_random_rows_in_EXPLAIN)
793 explain select * from t1
794 where exists (select 1 from t2, t3
795 where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
798 where exists (select 1 from t2, t3
799 where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
801 drop
table t0, t1, t2, t3;
804 --echo # BUG#44810:
index merge and order by with low sort_buffer_size
805 --echo # crashes server!
807 CREATE
TABLE t1(a VARCHAR(128),b VARCHAR(128),
KEY(A),
KEY(B));
808 INSERT INTO t1 VALUES (REPEAT(
'a',128),REPEAT(
'b',128));
809 INSERT INTO t1 SELECT * FROM t1;
810 INSERT INTO t1 SELECT * FROM t1;
811 INSERT INTO t1 SELECT * FROM t1;
812 INSERT INTO t1 SELECT * FROM t1;
813 INSERT INTO t1 SELECT * FROM t1;
814 INSERT INTO t1 SELECT * FROM t1;
816 -- disable_result_log
821 SET SESSION sort_buffer_size=1;
823 if ($index_merge_random_rows_in_EXPLAIN)
828 SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
831 # we don't actually care about the result : we're checking if it crashes
833 SELECT * FROM t1 FORCE INDEX(a,b) WHERE a LIKE 'a%' OR b LIKE 'b%'
837 SET SESSION sort_buffer_size=DEFAULT;
841 --echo End of 5.0 tests