File: func_prefix_key.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (840 lines) | stat: -rw-r--r-- 52,304 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde');
ALTER TABLE t1 ADD KEY k2 (b(4));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	3	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%')
EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	k2	NULL	NULL	NULL	5	36.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a'))
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# 'Using index' method is not used  since 'b' field is used in select output.
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# Index k2 shouldn't be used.
EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%')
DROP TABLE t1;
CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB  DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde');
ALTER TABLE t1 ADD KEY k2 (b(4));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	7	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	3	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	7	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	7	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	7	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%')
EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	7	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	k2	NULL	NULL	NULL	5	36.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a'))
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# 'Using index' method is not used  since 'b' field is used in select output.
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	7	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# Index k2 shouldn't be used.
EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%')
DROP TABLE t1;
CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB  DEFAULT CHARSET=utf32;
INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde');
ALTER TABLE t1 ADD KEY k2 (b(4));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	3	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%')
EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a'))
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# 'Using index' method is not used  since 'b' field is used in select output.
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# Index k2 shouldn't be used.
EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%')
DROP TABLE t1;
CREATE TABLE t1(a int, b TEXT, PRIMARY KEY(a))ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde');
ALTER TABLE t1 ADD KEY k2 (b(4));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcd%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc\%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc\\%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%abc%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	3	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '____%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	k2	19	NULL	5	20.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '____%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\_\_\_\_%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\_\\_\\_\\_%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '\%\%\%\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '\\%\\%\\%\\%')
EXPLAIN SELECT b LIKE 'abcd' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcd') AS `b LIKE 'abcd'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abc%' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abc%') AS `b LIKE 'abc%'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaa\\\\%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaa\\\\%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a_';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	k2	k2	19	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a_')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like '%a')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%c';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	5	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'a%c')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	2	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abcde%')
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE 'abcde' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcde') AS `b LIKE 'abcde'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT b LIKE '%bc' FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like '%bc') AS `b LIKE '%bc'` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa\\';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa\\')
# 'Using index' method is not used  since wild string is not suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'a%' OR b like '%a';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	k2	NULL	NULL	NULL	5	36.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` like 'a%') or (`test`.`t1`.`b` like '%a'))
# 'Using index' method is used since wild string is suitable for the use with prefix key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# 'Using index' method is not used  since 'b' field is used in select output.
EXPLAIN SELECT b FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	4	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t1`.`b` AS `b` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
# Index k2 shouldn't be used.
EXPLAIN SELECT COUNT(*) FROM t1 IGNORE INDEX(k2) WHERE b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	5	20.00	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` IGNORE INDEX (`k2`) where (`test`.`t1`.`b` like 'a%')
DROP TABLE t1;
CREATE TABLE t1(a int, b VARCHAR(5), PRIMARY KEY(a))ENGINE=INNODB  DEFAULT CHARSET=utf32;
INSERT INTO t1 VALUES (1, 'a'), (2, 'ab'), (3, 'abc'), (4, 'abcd'), (5, 'abcde'), (6, 'abcdf');
ALTER TABLE t1 ADD KEY k2 (b(4));
ALTER TABLE t1 ADD KEY k3 (b(2));
ALTER TABLE t1 ADD KEY k4 (a, b(3));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# k2 index used since it's  covering.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2,k3	k2	19	NULL	4	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'abc%')
SELECT COUNT(*) FROM t1 WHERE b like 'abc%';
COUNT(*)
4
# k4 index used since it's  covering.
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
EXPLAIN SELECT /*+ INDEX(t1 k4) */ COUNT(*) FROM t1 WHERE a > 4 AND b like 'abc%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k4	k4	4	NULL	2	16.67	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select /*+ INDEX(`t1`@`select#1` `k4`) */ count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abc%'))
SELECT /*+ INDEX(t1 k4) */ COUNT(*) FROM t1 WHERE a > 4 AND b like 'abc%';
COUNT(*)
2
# k3 index is used since it's shorters key.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2,k3	k3	11	NULL	5	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'ab%')
SELECT COUNT(*) FROM t1 WHERE b like 'ab%';
COUNT(*)
5
# Index access is not used, no covering keys.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcde%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	PRIMARY,k2,k3,k4	PRIMARY	4	NULL	2	16.67	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcde%'))
SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcde%';
COUNT(*)
1
# k2 index used since it's  covering.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	PRIMARY,k2,k3,k4	k2	23	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcd%'))
SELECT COUNT(*) FROM t1 WHERE a > 4 AND b like 'abcd%';
COUNT(*)
2
# Index access is not used, no covering keys.
EXPLAIN SELECT b like 'abcdf%'  FROM t1 WHERE a > 4 AND b like 'abcd%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	PRIMARY,k2,k3,k4	PRIMARY	4	NULL	2	16.67	Using where
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'abcdf%') AS `b like 'abcdf%'` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'abcd%'))
SELECT b like 'abcdf%'  FROM t1 WHERE a > 4 AND b like 'abcd%';
b like 'abcdf%'
0
1
# Index access is used since k4 is covering.
EXPLAIN SELECT b like 'ab%'  FROM t1 WHERE a > 4 AND b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	PRIMARY,k2,k3,k4	k4	4	NULL	2	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'ab%') AS `b like 'ab%'` from `test`.`t1` where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'a%'))
SELECT b like 'ab%'  FROM t1 WHERE a > 4 AND b like 'a%';
b like 'ab%'
1
1
# Index access is used since k3 is forced and covering.
EXPLAIN SELECT b like 'ab%'  FROM t1 FORCE INDEX(k3) WHERE a > 4 AND b like 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k3	k3	15	NULL	1	33.33	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`b` like 'ab%') AS `b like 'ab%'` from `test`.`t1` FORCE INDEX (`k3`) where ((`test`.`t1`.`a` > 4) and (`test`.`t1`.`b` like 'a%'))
SELECT b like 'ab%'  FROM t1 FORCE INDEX(k3) WHERE a > 4 AND b like 'a%';
b like 'ab%'
1
1
# No index access is used since second argument is not const.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like a;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	6	16.67	Using where
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like `test`.`t1`.`a`)
SELECT COUNT(*) FROM t1 WHERE b like a;
COUNT(*)
0
DROP TABLE t1;
CREATE TABLE t1(a int, b TEXT, c TEXT, PRIMARY KEY(a))ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 'a', 'a'), (2, 'ab', 'ab'), (3, 'abc', 'abc'), (4, 'abcd', 'abcd'), (5, 'abcde', 'abcde');
ALTER TABLE t1 ADD KEY k2 (b(4), c(3));
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# Index access is used since key is covering.
EXPLAIN SELECT COUNT(*) FROM t1 WHERE b like 'aaaa';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	k2	k2	19	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select count(0) AS `COUNT(*)` from `test`.`t1` where (`test`.`t1`.`b` like 'aaaa')
DROP TABLE t1;
#
# Bug#27660560 RECENT REGRESSION: CRASH IN CHECK_COVERING_PREFIX_KEYS.
#
CREATE TABLE t1(f1 BLOB, KEY(f1(1))) ENGINE=INNODB;
INSERT INTO t1 VALUES ('ccc'), ('aa');
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
SELECT (f1 LIKE null) from t1;
(f1 LIKE null)
NULL
NULL
SELECT 1 FROM t1 WHERE f1 NOT LIKE json_merge('' ,'+' );
ERROR 22032: Invalid JSON text in argument 1 to function json_merge_preserve: "The document is empty." at position 0.
SELECT 1 FROM t1 WHERE f1 LIKE json_contains('key2' ,'key4' );
ERROR 22032: Invalid JSON text in argument 1 to function json_contains: "Invalid value." at position 0.
SELECT 1 FROM t1 WHERE f1 LIKE json_depth(null);
1
EXPLAIN SELECT (f1 LIKE null) from t1;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	index	NULL	f1	4	NULL	2	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`f1` like NULL) AS `(f1 LIKE null)` from `test`.`t1`
EXPLAIN SELECT (f1 LIKE null) from t1 WHERE f1 LIKE 'a%';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	range	f1	f1	4	NULL	1	100.00	Using where; Using index
Warnings:
Note	1003	/* select#1 */ select (`test`.`t1`.`f1` like NULL) AS `(f1 LIKE null)` from `test`.`t1` where (`test`.`t1`.`f1` like 'a%')
DROP TABLE t1;
#
# Bug#28934315 CASE STATEMENT USE IN CONDITIONAL WITH SUB_PART INDEX REGRESSION IN 8.0.
#
CREATE TABLE t1 (
id INT(11) NOT NULL AUTO_INCREMENT,
example VARCHAR(100) NOT NULL DEFAULT '',
PRIMARY KEY (id),
KEY example_key (example(9))
) ENGINE=InnoDB;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
CREATE TABLE t2 (
id INT(11) NOT NULL AUTO_INCREMENT,
example VARCHAR(100) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) ENGINE=InnoDB;
Warnings:
Warning	1681	Integer display width is deprecated and will be removed in a future release.
INSERT INTO t1 (example) VALUES ('1234567890');
INSERT INTO t2 (example) VALUES ('1234567890');
EXPLAIN SELECT t2.example, t2.id FROM t2, t1 WHERE t1.example = LOWER(t2.example);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	ALL	NULL	NULL	NULL	NULL	1	100.00	NULL
1	SIMPLE	t1	NULL	ref	example_key	example_key	38	func	1	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select `test`.`t2`.`example` AS `example`,`test`.`t2`.`id` AS `id` from `test`.`t2` join `test`.`t1` where (`test`.`t1`.`example` = lower(`test`.`t2`.`example`))
SELECT t2.example, t2.id FROM t2, t1 WHERE t1.example = LOWER(t2.example);
example	id
1234567890	1
DROP TABLE t1, t2;