1
1
--enable_prepare_warnings
2
-
2
+ --disable_view_protocol # Since optimizer hints are not supported inside views
3
3
SET NAMES utf8mb4;
4
4
5
5
--echo # Testing that index names in hints are accent sensitive case insensitive
6
6
CREATE TABLE t1 (a INT, ä INT, INDEX idx_a(a), INDEX idx_ä(ä));
7
7
INSERT INTO t1 VALUES (1,1),(2,2);
8
8
SELECT /*+ NO_MRR(t1 idx_a) */ a FROM t1;
9
9
SELECT /*+ NO_MRR(t1 idx_A) */ a FROM t1;
10
+
11
+ # Warnings "Unresolved table/index name..." are generated during both prepare
12
+ # and execution stages. So disable PS protocol to avoid duplication
13
+ --disable_ps_protocol
10
14
SELECT /*+ NO_MRR(t1 idx_å) */ a FROM t1;
11
15
SELECT /*+ NO_MRR(t1 idx_a, idx_å, idx_A) */ a FROM t1;
16
+ --enable_ps_protocol
12
17
DROP TABLE t1;
13
18
14
19
--echo # Testing that query block names are accent sensitive case insensitive
@@ -129,9 +134,13 @@ EXPLAIN EXTENDED SELECT /*+ NO_ICP(t5@блок1 x_idx) */ * FROM
129
134
130
135
131
136
--echo # Expected warning for z_idx key, unresolved name.
137
+ # Warnings "Unresolved table/index name..." are generated during both prepare
138
+ # and execution stages. So disable PS protocol to avoid duplication
139
+ --disable_ps_protocol
132
140
EXPLAIN EXTENDED SELECT * FROM
133
141
(SELECT /*+ NO_ICP(t5 y_idx, x_idx, z_idx) */ t4.x, t5.y FROM t4, t4 t5
134
142
WHERE t4.y = 8 AND t5.x BETWEEN 7 AND t4.y+0) AS TD;
143
+ --enable_ps_protocol
135
144
136
145
--echo # ICP should still be used
137
146
EXPLAIN EXTENDED SELECT * FROM
@@ -300,10 +309,14 @@ EXPLAIN EXTENDED SELECT /*+ BKA(tbl12, tbl13) */ * FROM t12 tbl12, t13 tbl13
300
309
WHERE tbl12.a=tbl13.a AND (tbl13.b+1 <= tbl13.b+1);
301
310
302
311
--echo # Print warnings for nonexistent names
312
+ # Warnings "Unresolved table/index name..." are generated during both prepare
313
+ # and execution stages. So disable PS protocol to avoid duplication
314
+ --disable_ps_protocol
303
315
EXPLAIN EXTENDED
304
316
SELECT /*+ BKA(t2) NO_BNL(t1) BKA(t3) NO_RANGE_OPTIMIZATION(t3 idx1) NO_RANGE_OPTIMIZATION(t3) */
305
317
t2.f1, t2.f2, t2.f3 FROM t1,t2 WHERE t1.f1=t2.f1 AND
306
318
t2.f2 BETWEEN t1.f1 AND t1.f2 AND t2.f2 + 1 >= t1.f1 + 1;
319
+ --enable_ps_protocol
307
320
308
321
--echo # Check illegal syntax
309
322
EXPLAIN EXTENDED SELECT /*+ BKA(qb1 t3@qb1) */ f2 FROM
@@ -319,8 +332,12 @@ EXPLAIN EXTENDED SELECT /*+ BKA(@qb1 t13) */ * FROM (SELECT /*+ QB_NAME(QB1) */
319
332
WHERE t12.a=t13.a AND (t13.b+1 <= t13.b+1)) AS s1;
320
333
321
334
--echo # Check that original table name is not recognized if alias is used.
335
+ # Warnings "Unresolved table/index name..." are generated during both prepare
336
+ # and execution stages. So disable PS protocol to avoid duplication
337
+ --disable_ps_protocol
322
338
EXPLAIN EXTENDED SELECT /*+ BKA(tbl2) */ * FROM t12 tbl12, t13 tbl13
323
339
WHERE tbl12.a=tbl13.a AND (tbl13.b+1 <= tbl13.b+1);
340
+ --enable_ps_protocol
324
341
325
342
--disable_ps2_protocol
326
343
--echo # Check that PS and conventional statements give the same result.
@@ -500,8 +517,41 @@ SELECT /*+ QB_NAME(q1) NO_ICP(@q1 t1 PRIMARY) NO_ICP(@q1 t1 PRIMARY) */ * FROM t
500
517
501
518
DROP TABLE t1;
502
519
503
- --echo # WL#8016 Parser for optimizer hints
520
+ --echo #
521
+ --echo # Hints inside views are not supported
522
+ --echo #
523
+ CREATE TABLE t1 (a INT, INDEX idx_a(a));
524
+ INSERT INTO t1 VALUES (1),(2);
525
+
526
+ CREATE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) */ a FROM t1;
527
+ SELECT * FROM v1;
528
+ --echo # Make sure hints are not present inside the view definition:
529
+ SHOW CREATE VIEW v1;
530
+ EXPLAIN EXTENDED SELECT * FROM v1;
531
+
532
+ CREATE OR REPLACE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) BKA(t1)*/ a FROM t1;
533
+ SHOW CREATE VIEW v1;
534
+
535
+ ALTER VIEW v1 AS SELECT /*+ QB_NAME(q1)*/ a FROM t1;
536
+ SHOW CREATE VIEW v1;
537
+ SELECT * FROM v1;
538
+
539
+ --echo # Wrong place for the hint, must be simply ignored:
540
+ CREATE OR REPLACE VIEW v1 AS SELECT a /*+ NO_ICP(t1 idx_a)*/ FROM t1;
541
+ SHOW CREATE VIEW v1;
504
542
543
+ --echo # Incorrect hint does not prevent view creation, only a warning generated:
544
+ CREATE VIEW v2 AS SELECT /*+ BAD HINT*/ a+10 FROM t1;
545
+ SELECT * FROM v2;
546
+ EXPLAIN EXTENDED SELECT * FROM v2;
547
+ SHOW CREATE VIEW v2;
548
+
549
+ DROP VIEW v1, v2;
550
+ DROP TABLE t1;
551
+
552
+ --echo #
553
+ --echo # Tests of parser for optimizer hints
554
+ --echo #
505
555
506
556
CREATE TABLE t1 (i INT, j INT);
507
557
CREATE INDEX i1 ON t1(i);
@@ -552,8 +602,12 @@ DELETE /*+ NO_ICP() */ FROM t1 WHERE 1;
552
602
553
603
SELECT /*+ BKA(a b) */ 1 FROM t1 a, t1 b;
554
604
605
+ # Warnings "Unresolved table/index name..." are generated during both prepare
606
+ # and execution stages. So disable PS protocol to avoid duplication
607
+ --disable_ps_protocol
555
608
SELECT /*+ NO_ICP(i1) */ 1 FROM t1;
556
609
SELECT /*+ NO_ICP(i1 i2) */ 1 FROM t1;
610
+ --enable_ps_protocol
557
611
SELECT /*+ NO_ICP(@qb ident) */ 1 FROM t1;
558
612
559
613
--echo
@@ -578,6 +632,10 @@ EXPLAIN EXTENDED DELETE /*+ test */ FROM t1 WHERE i = 10;
578
632
--echo
579
633
580
634
CREATE INDEX 3rd_index ON t1(i, j);
635
+
636
+ # Warnings "Unresolved table/index name..." are generated during both prepare
637
+ # and execution stages. So disable PS protocol to avoid duplication
638
+ --disable_ps_protocol
581
639
SELECT /*+ NO_ICP(3rd_index) */ 1 FROM t1;
582
640
583
641
CREATE INDEX $index ON t1(j, i);
@@ -605,6 +663,7 @@ SELECT /*+ BKA(" quoted name test") */ 1 FROM t1;
605
663
606
664
DROP TABLE ` quoted name test`;
607
665
DROP TABLE `test1``test2```;
666
+ --enable_ps_protocol
608
667
609
668
--echo # Valid hints, no warning:
610
669
EXPLAIN EXTENDED SELECT /*+ QB_NAME(`*`) */ 1;
@@ -622,6 +681,10 @@ EXPLAIN EXTENDED SELECT /*+ QB_NAME(`\BF``\BF`) */ 1;
622
681
CREATE TABLE tableТ (i INT);
623
682
624
683
--echo # invalid hints, should warn:
684
+
685
+ # Warnings "Unresolved table/index name..." are generated during both prepare
686
+ # and execution stages. So disable PS protocol to avoid duplication
687
+ --disable_ps_protocol
625
688
SELECT /*+ BKA(tableТ) */ 1 FROM t1;
626
689
SELECT /*+ BKA(test@tableТ) */ 1 FROM t1;
627
690
DROP TABLE tableТ;
@@ -635,6 +698,7 @@ SELECT /*+ BKA(test@таблица) */ 1 FROM t1;
635
698
SELECT /*+ NO_ICP(`\D1`) */ 1 FROM t1;
636
699
637
700
DROP TABLE таблица;
701
+ --enable_ps_protocol
638
702
639
703
--echo
640
704
--echo # derived tables and other subqueries:
@@ -649,7 +713,9 @@ SELECT 1 FROM DUAL WHERE 1 IN (SELECT /*+ DEBUG_HINT3 */ 1);
649
713
--echo
650
714
SELECT /*+ 10 */ 1;
651
715
SELECT /*+ NO_ICP() */ 1;
716
+ --disable_ps_protocol # to avoid warnings duplication, see details above
652
717
SELECT /*+ NO_ICP(10) */ 1;
718
+ --enable_ps_protocol
653
719
SELECT /*+ NO_ICP( */ 1;
654
720
SELECT /*+ NO_ICP) */ 1;
655
721
SELECT /*+ NO_ICP(t1 */ 1;
@@ -664,6 +730,7 @@ INSERT INTO t1 VALUES (1, 1), (2, 2);
664
730
665
731
SELECT 1 FROM /*+ regular commentary, not a hint! */ t1;
666
732
SELECT 1 FROM /*+ #1 */ t1 WHERE /*+ #2 */ 1 /*+ #3 */;
733
+ SELECT 1 FROM /*+ QB_NAME(q1) */ t1 /*+ NO_ICP() */WHERE /*+ NO_MRR(t1) */ 1 /*+ #3 */;
667
734
668
735
--echo # Warnings expected:
669
736
SELECT /*+ NO_ICP() */ 1
0 commit comments