MDEV-33281 Optimizer hints code cleanup:

- remove get_args_printer() from hints printing
 - add append_hint_arguments(THD *thd, opt_hints_enum hint, String *str)
 - add more comments
 - rename st_opt_hint_info::hint_name to hint_type
 - add pptimizer trace support for hints
 - add dbug_print_hints()
 - make print_warn() not be a template
 - introduce Printable_parser_rule interface, make grammar rules that
     emit warnings implement it  and print_warn invokes its function)
 - remove Parser::Hint::append_args() as it is not used anywhere
     (it used to be necessary call print_warn(... (Parser::Hint*)NULL);
This commit is contained in:
Sergei Petrunia 2024-12-08 22:03:01 +02:00 committed by Oleg Smirnov
parent 0e088b5d7e
commit c4fe794d22
10 changed files with 216 additions and 168 deletions

View File

@ -230,7 +230,7 @@ a
1 1
2 2
Warnings: Warnings:
Warning 4206 Hint BKA("A") is ignored as conflicting/duplicated Warning 4207 Hint BKA("A") is ignored as conflicting/duplicated
DROP TABLE t1; DROP TABLE t1;
# #
# End of 11.7 tests # End of 11.7 tests

View File

@ -49,7 +49,7 @@ SELECT /*+ MAX_EXECUTION_TIME(10) MAX_EXECUTION_TIME(100) */ count(*) FROM t1;
count(*) count(*)
512 512
Warnings: Warnings:
Warning 4206 Hint MAX_EXECUTION_TIME(100) is ignored as conflicting/duplicated Warning 4207 Hint MAX_EXECUTION_TIME(100) is ignored as conflicting/duplicated
# Wrong values # Wrong values
SELECT /*+ MAX_EXECUTION_TIME(0) */ count(*) FROM t1; SELECT /*+ MAX_EXECUTION_TIME(0) */ count(*) FROM t1;
count(*) count(*)
@ -102,7 +102,7 @@ SELECT /*+ MAX_EXECUTION_TIME(30) */ count(*) FROM t1;
count(*) count(*)
512 512
Warnings: Warnings:
Warning 4206 Hint MAX_EXECUTION_TIME(30) is ignored as conflicting/duplicated Warning 4207 Hint MAX_EXECUTION_TIME(30) is ignored as conflicting/duplicated
SELECT count(*) FROM t1 SELECT count(*) FROM t1
UNION UNION
SELECT /*+ MAX_EXECUTION_TIME(30) */ count(*) FROM t1; SELECT /*+ MAX_EXECUTION_TIME(30) */ count(*) FROM t1;

View File

@ -15,25 +15,25 @@ a
1 1
2 2
Warnings: Warnings:
Warning 4209 Unresolved index name `t1`@`select#1` `idx_å` for NO_MRR hint Warning 4210 Unresolved index name `t1`@`select#1` `idx_å` for NO_MRR hint
SELECT /*+ NO_MRR(t1 idx_a, idx_å, idx_A) */ a FROM t1; SELECT /*+ NO_MRR(t1 idx_a, idx_å, idx_A) */ a FROM t1;
a a
1 1
2 2
Warnings: Warnings:
Warning 4206 Hint NO_MRR(`t1` `idx_A`) is ignored as conflicting/duplicated Warning 4207 Hint NO_MRR(`t1` `idx_A`) is ignored as conflicting/duplicated
Warning 4209 Unresolved index name `t1`@`select#1` `idx_å` for NO_MRR hint Warning 4210 Unresolved index name `t1`@`select#1` `idx_å` for NO_MRR hint
DROP TABLE t1; DROP TABLE t1;
# Testing that query block names are accent sensitive case insensitive # Testing that query block names are accent sensitive case insensitive
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
SELECT /*+ QB_NAME(a) BKA(t1@a) BKA(t1@A) */ * FROM t1; SELECT /*+ QB_NAME(a) BKA(t1@a) BKA(t1@A) */ * FROM t1;
a a
Warnings: Warnings:
Warning 4206 Hint BKA(`t1`@`A`) is ignored as conflicting/duplicated Warning 4207 Hint BKA(`t1`@`A`) is ignored as conflicting/duplicated
SELECT /*+ QB_NAME(a) BKA(t1@a) BKA(t1@å) */ * FROM t1; SELECT /*+ QB_NAME(a) BKA(t1@a) BKA(t1@å) */ * FROM t1;
a a
Warnings: Warnings:
Warning 4207 Query block name `å` is not found for BKA hint Warning 4208 Query block name `å` is not found for BKA hint
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(f1 INT, f2 INT); CREATE TABLE t1(f1 INT, f2 INT);
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
@ -230,7 +230,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t4 ref y_idx y_idx 5 const 1 100.00 1 SIMPLE t4 ref y_idx y_idx 5 const 1 100.00
1 SIMPLE t5 range x_idx x_idx 5 NULL 2 100.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t5 range x_idx x_idx 5 NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Warning 4209 Unresolved index name `t5`@`select#2` `z_idx` for NO_ICP hint Warning 4210 Unresolved index name `t5`@`select#2` `z_idx` for NO_ICP hint
Note 1003 select /*+ NO_ICP(`t5`@`select#2` `y_idx`) NO_ICP(`t5`@`select#2` `x_idx`) */ `test`.`t4`.`x` AS `x`,`test`.`t5`.`y` AS `y` from `test`.`t4` join `test`.`t4` `t5` where `test`.`t4`.`y` = 8 and `test`.`t5`.`x` between 7 and <cache>(8 + 0) Note 1003 select /*+ NO_ICP(`t5`@`select#2` `y_idx`) NO_ICP(`t5`@`select#2` `x_idx`) */ `test`.`t4`.`x` AS `x`,`test`.`t5`.`y` AS `y` from `test`.`t4` join `test`.`t4` `t5` where `test`.`t4`.`y` = 8 and `test`.`t5`.`x` between 7 and <cache>(8 + 0)
# ICP should still be used # ICP should still be used
EXPLAIN EXTENDED SELECT * FROM EXPLAIN EXTENDED SELECT * FROM
@ -548,7 +548,7 @@ EXPLAIN EXTENDED SELECT /*+ QB_NAME(qb1) QB_NAME(qb1 ) */ * FROM t2;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 28 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 28 100.00
Warnings: Warnings:
Warning 4206 Hint QB_NAME(`qb1`) is ignored as conflicting/duplicated Warning 4207 Hint QB_NAME(`qb1`) is ignored as conflicting/duplicated
Note 1003 select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t2` Note 1003 select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t2`
# Should issue warning # Should issue warning
EXPLAIN EXTENDED SELECT /*+ BKA(@qb1) QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 EXPLAIN EXTENDED SELECT /*+ BKA(@qb1) QB_NAME(qb1) */ t2.f1, t2.f2, t2.f3 FROM t1,t2
@ -557,7 +557,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL f1 NULL NULL NULL 28 25.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL f1 NULL NULL NULL 28 25.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Warning 4207 Query block name `qb1` is not found for BKA hint Warning 4208 Query block name `qb1` is not found for BKA hint
Note 1003 select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`f1` = `test`.`t1`.`f1` and `test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2` and `test`.`t2`.`f2` + 1 >= `test`.`t1`.`f1` + 1 Note 1003 select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`f1` = `test`.`t1`.`f1` and `test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2` and `test`.`t2`.`f2` + 1 >= `test`.`t1`.`f1` + 1
# Should not crash # Should not crash
PREPARE stmt1 FROM "SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2 PREPARE stmt1 FROM "SELECT /*+ BKA(t2) */ t2.f1, t2.f2, t2.f3 FROM t1,t2
@ -601,9 +601,9 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
1 SIMPLE t2 ALL f1 NULL NULL NULL 28 25.00 Using where; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL f1 NULL NULL NULL 28 25.00 Using where; Using join buffer (flat, BNL join)
Warnings: Warnings:
Warning 4208 Unresolved table name `t3`@`select#1` for BKA hint Warning 4209 Unresolved table name `t3`@`select#1` for BKA hint
Warning 4208 Unresolved table name `t3`@`select#1` for NO_RANGE_OPTIMIZATION hint Warning 4209 Unresolved table name `t3`@`select#1` for NO_RANGE_OPTIMIZATION hint
Warning 4209 Unresolved index name `t3`@`select#1` `idx1` for NO_RANGE_OPTIMIZATION hint Warning 4210 Unresolved index name `t3`@`select#1` `idx1` for NO_RANGE_OPTIMIZATION hint
Note 1003 select /*+ BKA(`t2`@`select#1`) NO_BNL(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`f1` = `test`.`t1`.`f1` and `test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2` and `test`.`t2`.`f2` + 1 >= `test`.`t1`.`f1` + 1 Note 1003 select /*+ BKA(`t2`@`select#1`) NO_BNL(`t1`@`select#1`) */ `test`.`t2`.`f1` AS `f1`,`test`.`t2`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`f1` = `test`.`t1`.`f1` and `test`.`t2`.`f2` between `test`.`t1`.`f1` and `test`.`t1`.`f2` and `test`.`t2`.`f2` + 1 >= `test`.`t1`.`f1` + 1
# Check illegal syntax # Check illegal syntax
EXPLAIN EXTENDED SELECT /*+ BKA(qb1 t3@qb1) */ f2 FROM EXPLAIN EXTENDED SELECT /*+ BKA(qb1 t3@qb1) */ f2 FROM
@ -640,7 +640,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tbl12 ALL NULL NULL NULL NULL 10 100.00 Using where 1 SIMPLE tbl12 ALL NULL NULL NULL NULL 10 100.00 Using where
1 SIMPLE tbl13 hash_ALL a #hash#a 5 test.tbl12.a 1000 0.10 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE tbl13 hash_ALL a #hash#a 5 test.tbl12.a 1000 0.10 Using where; Using join buffer (flat, BNLH join)
Warnings: Warnings:
Warning 4208 Unresolved table name `tbl2`@`select#1` for BKA hint Warning 4209 Unresolved table name `tbl2`@`select#1` for BKA hint
Note 1003 select `test`.`tbl12`.`a` AS `a`,`test`.`tbl12`.`b` AS `b`,`test`.`tbl13`.`a` AS `a`,`test`.`tbl13`.`b` AS `b`,`test`.`tbl13`.`c` AS `c`,`test`.`tbl13`.`filler` AS `filler` from `test`.`t12` `tbl12` join `test`.`t13` `tbl13` where `test`.`tbl13`.`a` = `test`.`tbl12`.`a` and `test`.`tbl13`.`b` + 1 <= `test`.`tbl13`.`b` + 1 Note 1003 select `test`.`tbl12`.`a` AS `a`,`test`.`tbl12`.`b` AS `b`,`test`.`tbl13`.`a` AS `a`,`test`.`tbl13`.`b` AS `b`,`test`.`tbl13`.`c` AS `c`,`test`.`tbl13`.`filler` AS `filler` from `test`.`t12` `tbl12` join `test`.`t13` `tbl13` where `test`.`tbl13`.`a` = `test`.`tbl12`.`a` and `test`.`tbl13`.`b` + 1 <= `test`.`tbl13`.`b` + 1
# Check that PS and conventional statements give the same result. # Check that PS and conventional statements give the same result.
FLUSH STATUS; FLUSH STATUS;
@ -1476,19 +1476,19 @@ SELECT /*+ BKA() BKA() */ 1;
1 1
1 1
Warnings: Warnings:
Warning 4206 Hint BKA() is ignored as conflicting/duplicated Warning 4207 Hint BKA() is ignored as conflicting/duplicated
SELECT /*+ BKA(t1) BKA(t1) */ * FROM t1; SELECT /*+ BKA(t1) BKA(t1) */ * FROM t1;
i i
Warnings: Warnings:
Warning 4206 Hint BKA(`t1`) is ignored as conflicting/duplicated Warning 4207 Hint BKA(`t1`) is ignored as conflicting/duplicated
SELECT /*+ QB_NAME(q1) BKA(t1@q1) BKA(t1@q1) */ * FROM t1; SELECT /*+ QB_NAME(q1) BKA(t1@q1) BKA(t1@q1) */ * FROM t1;
i i
Warnings: Warnings:
Warning 4206 Hint BKA(`t1`@`q1`) is ignored as conflicting/duplicated Warning 4207 Hint BKA(`t1`@`q1`) is ignored as conflicting/duplicated
SELECT /*+ QB_NAME(q1) NO_ICP(@q1 t1 PRIMARY) NO_ICP(@q1 t1 PRIMARY) */ * FROM t1; SELECT /*+ QB_NAME(q1) NO_ICP(@q1 t1 PRIMARY) NO_ICP(@q1 t1 PRIMARY) */ * FROM t1;
i i
Warnings: Warnings:
Warning 4206 Hint NO_ICP(`t1`@`q1` `PRIMARY`) is ignored as conflicting/duplicated Warning 4207 Hint NO_ICP(`t1`@`q1` `PRIMARY`) is ignored as conflicting/duplicated
DROP TABLE t1; DROP TABLE t1;
# #
# Hints inside views are not supported # Hints inside views are not supported
@ -1497,7 +1497,7 @@ CREATE TABLE t1 (a INT, INDEX idx_a(a));
INSERT INTO t1 VALUES (1),(2); INSERT INTO t1 VALUES (1),(2);
CREATE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) */ a FROM t1; CREATE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) */ a FROM t1;
Warnings: Warnings:
Warning 4210 Optimizer hints are not supported inside view definitions Warning 4211 Optimizer hints are not supported inside view definitions
SELECT * FROM v1; SELECT * FROM v1;
a a
1 1
@ -1513,13 +1513,13 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1`
CREATE OR REPLACE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) BKA(t1)*/ a FROM t1; CREATE OR REPLACE VIEW v1 AS SELECT /*+ NO_MRR(t1 idx_a) BKA(t1)*/ a FROM t1;
Warnings: Warnings:
Warning 4210 Optimizer hints are not supported inside view definitions Warning 4211 Optimizer hints are not supported inside view definitions
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci
ALTER VIEW v1 AS SELECT /*+ QB_NAME(q1)*/ a FROM t1; ALTER VIEW v1 AS SELECT /*+ QB_NAME(q1)*/ a FROM t1;
Warnings: Warnings:
Warning 4210 Optimizer hints are not supported inside view definitions Warning 4211 Optimizer hints are not supported inside view definitions
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` utf8mb4 utf8mb4_uca1400_ai_ci
@ -1686,15 +1686,15 @@ Warning 1064 Optimizer hint syntax error near 'b) */ 1 FROM t1 a, t1 b' at lin
SELECT /*+ NO_ICP(i1) */ 1 FROM t1; SELECT /*+ NO_ICP(i1) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `i1`@`select#1` for NO_ICP hint Warning 4209 Unresolved table name `i1`@`select#1` for NO_ICP hint
SELECT /*+ NO_ICP(i1 i2) */ 1 FROM t1; SELECT /*+ NO_ICP(i1 i2) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4209 Unresolved index name `i1`@`select#1` `i2` for NO_ICP hint Warning 4210 Unresolved index name `i1`@`select#1` `i2` for NO_ICP hint
SELECT /*+ NO_ICP(@qb ident) */ 1 FROM t1; SELECT /*+ NO_ICP(@qb ident) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4207 Query block name `qb` is not found for NO_ICP hint Warning 4208 Query block name `qb` is not found for NO_ICP hint
# valid hint sequences, no warnings expected: # valid hint sequences, no warnings expected:
@ -1749,49 +1749,49 @@ CREATE INDEX 3rd_index ON t1(i, j);
SELECT /*+ NO_ICP(3rd_index) */ 1 FROM t1; SELECT /*+ NO_ICP(3rd_index) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `3rd_index`@`select#1` for NO_ICP hint Warning 4209 Unresolved table name `3rd_index`@`select#1` for NO_ICP hint
CREATE INDEX $index ON t1(j, i); CREATE INDEX $index ON t1(j, i);
SELECT /*+ NO_ICP($index) */ 1 FROM t1; SELECT /*+ NO_ICP($index) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `$index`@`select#1` for NO_ICP hint Warning 4209 Unresolved table name `$index`@`select#1` for NO_ICP hint
CREATE TABLE ` quoted name test` (i INT); CREATE TABLE ` quoted name test` (i INT);
SELECT /*+ BKA(` quoted name test`) */ 1 FROM t1; SELECT /*+ BKA(` quoted name test`) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name ` quoted name test`@`select#1` for BKA hint Warning 4209 Unresolved table name ` quoted name test`@`select#1` for BKA hint
SELECT /*+ BKA(` quoted name test`@`select#1`) */ 1 FROM t1; SELECT /*+ BKA(` quoted name test`@`select#1`) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4207 Query block name `select#1` is not found for BKA hint Warning 4208 Query block name `select#1` is not found for BKA hint
DROP TABLE ` quoted name test`; DROP TABLE ` quoted name test`;
SET SQL_MODE = 'ANSI_QUOTES'; SET SQL_MODE = 'ANSI_QUOTES';
CREATE TABLE " quoted name test" (i INT); CREATE TABLE " quoted name test" (i INT);
SELECT /*+ BKA(" quoted name test") */ 1 FROM t1; SELECT /*+ BKA(" quoted name test") */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name " quoted name test"@"select#1" for BKA hint Warning 4209 Unresolved table name " quoted name test"@"select#1" for BKA hint
SELECT /*+ BKA(" quoted name test"@"select#1") */ 1 FROM t1; SELECT /*+ BKA(" quoted name test"@"select#1") */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4207 Query block name "select#1" is not found for BKA hint Warning 4208 Query block name "select#1" is not found for BKA hint
CREATE TABLE `test1``test2``` (i INT); CREATE TABLE `test1``test2``` (i INT);
SELECT /*+ BKA(`test1``test2```) */ 1; SELECT /*+ BKA(`test1``test2```) */ 1;
1 1
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name "test1`test2`"@"select#1" for BKA hint Warning 4209 Unresolved table name "test1`test2`"@"select#1" for BKA hint
SELECT /*+ BKA("test1""test2""") */ 1; SELECT /*+ BKA("test1""test2""") */ 1;
1 1
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name "test1""test2"""@"select#1" for BKA hint Warning 4209 Unresolved table name "test1""test2"""@"select#1" for BKA hint
SET SQL_MODE = ''; SET SQL_MODE = '';
# should warn: # should warn:
SELECT /*+ BKA(" quoted name test") */ 1 FROM t1; SELECT /*+ BKA(" quoted name test") */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name ` quoted name test`@`select#1` for BKA hint Warning 4209 Unresolved table name ` quoted name test`@`select#1` for BKA hint
DROP TABLE ` quoted name test`; DROP TABLE ` quoted name test`;
DROP TABLE `test1``test2```; DROP TABLE `test1``test2```;
# Valid hints, no warning: # Valid hints, no warning:
@ -1843,29 +1843,29 @@ CREATE TABLE tableТ (i INT);
SELECT /*+ BKA(tableТ) */ 1 FROM t1; SELECT /*+ BKA(tableТ) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `tableТ`@`select#1` for BKA hint Warning 4209 Unresolved table name `tableТ`@`select#1` for BKA hint
SELECT /*+ BKA(test@tableТ) */ 1 FROM t1; SELECT /*+ BKA(test@tableТ) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4207 Query block name `tableТ` is not found for BKA hint Warning 4208 Query block name `tableТ` is not found for BKA hint
DROP TABLE tableТ; DROP TABLE tableТ;
CREATE TABLE таблица (i INT); CREATE TABLE таблица (i INT);
SELECT /*+ BKA(`таблица`) */ 1 FROM t1; SELECT /*+ BKA(`таблица`) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `таблица`@`select#1` for BKA hint Warning 4209 Unresolved table name `таблица`@`select#1` for BKA hint
SELECT /*+ BKA(таблица) */ 1 FROM t1; SELECT /*+ BKA(таблица) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `таблица`@`select#1` for BKA hint Warning 4209 Unresolved table name `таблица`@`select#1` for BKA hint
SELECT /*+ BKA(test@таблица) */ 1 FROM t1; SELECT /*+ BKA(test@таблица) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4207 Query block name `таблица` is not found for BKA hint Warning 4208 Query block name `таблица` is not found for BKA hint
SELECT /*+ NO_ICP(`\D1`) */ 1 FROM t1; SELECT /*+ NO_ICP(`\D1`) */ 1 FROM t1;
1 1
Warnings: Warnings:
Warning 4208 Unresolved table name `\D1`@`select#1` for NO_ICP hint Warning 4209 Unresolved table name `\D1`@`select#1` for NO_ICP hint
DROP TABLE таблица; DROP TABLE таблица;
# derived tables and other subqueries: # derived tables and other subqueries:
@ -1966,7 +1966,7 @@ NO_ICP(@qb ident)
1 1
1 1
Warnings: Warnings:
Warning 4207 Query block name `qb` is not found for NO_ICP hint Warning 4208 Query block name `qb` is not found for NO_ICP hint
SELECT /*+ SELECT /*+
? bad syntax ? bad syntax
*/ 1; */ 1;

View File

@ -158,7 +158,7 @@ a
3 3
4 4
Warnings: Warnings:
Warning 4207 Query block name `qb1` is not found for SUBQUERY hint Warning 4208 Query block name `qb1` is not found for SUBQUERY hint
SELECT /*+ SUBQUERY() */ a FROM t1; SELECT /*+ SUBQUERY() */ a FROM t1;
a a
1 1
@ -195,15 +195,15 @@ SELECT /*+ SEMIJOIN() SEMIJOIN(dupsweedout) NO_SEMIJOIN(firstmatch)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(DUPSWEEDOUT) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(DUPSWEEDOUT) is ignored as conflicting/duplicated
Warning 4206 Hint NO_SEMIJOIN(FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SEMIJOIN(@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN(loosescan,materialization) SEMIJOIN(dupsweedout)*/ a FROM t1; SELECT /*+ SEMIJOIN(loosescan,materialization) SEMIJOIN(dupsweedout)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(DUPSWEEDOUT) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(DUPSWEEDOUT) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`select#1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SEMIJOIN(@`select#1` LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ NO_SEMIJOIN(firstmatch,loosescan,materialization) SEMIJOIN() NO_SEMIJOIN()*/ a SELECT /*+ NO_SEMIJOIN(firstmatch,loosescan,materialization) SEMIJOIN() NO_SEMIJOIN()*/ a
@ -211,8 +211,8 @@ FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN() is ignored as conflicting/duplicated
Warning 4206 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated
Note 1003 select /*+ NO_SEMIJOIN(@`select#1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ NO_SEMIJOIN(@`select#1` FIRSTMATCH, LOOSESCAN, MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ QB_NAME(qb1) SEMIJOIN(@qb1) SEMIJOIN(loosescan) NO_SEMIJOIN(@qb1 dupsweedout)*/ a SELECT /*+ QB_NAME(qb1) SEMIJOIN(@qb1) SEMIJOIN(loosescan) NO_SEMIJOIN(@qb1 dupsweedout)*/ a
@ -220,36 +220,36 @@ FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(LOOSESCAN) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(LOOSESCAN) is ignored as conflicting/duplicated
Warning 4206 Hint NO_SEMIJOIN(@`qb1` DUPSWEEDOUT) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`qb1` DUPSWEEDOUT) is ignored as conflicting/duplicated
Note 1003 select /*+ QB_NAME(`qb1`) SEMIJOIN(@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ QB_NAME(`qb1`) SEMIJOIN(@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED SELECT /*+ SEMIJOIN(firstmatch) NO_SEMIJOIN()*/ a FROM t1; EXPLAIN EXTENDED SELECT /*+ SEMIJOIN(firstmatch) NO_SEMIJOIN()*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`select#1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SEMIJOIN(@`select#1` FIRSTMATCH) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN() SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ SEMIJOIN() SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SEMIJOIN(@`select#1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists) SUBQUERY(materialization)*/ a SELECT /*+ SUBQUERY(materialization) SUBQUERY(intoexists) SUBQUERY(materialization)*/ a
@ -257,32 +257,32 @@ FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Warning 4206 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated
Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SUBQUERY(materialization) SEMIJOIN(firstmatch) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ SUBQUERY(materialization) SEMIJOIN(firstmatch) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(FIRSTMATCH) is ignored as conflicting/duplicated
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ SUBQUERY(@`select#1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ QB_NAME(qb1) SEMIJOIN(@qb1) SUBQUERY(@qb1 materialization) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ QB_NAME(qb1) SEMIJOIN(@qb1) SUBQUERY(@qb1 materialization) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(@`qb1` MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(@`qb1` MATERIALIZATION) is ignored as conflicting/duplicated
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ QB_NAME(`qb1`) SEMIJOIN(@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ QB_NAME(`qb1`) SEMIJOIN(@`qb1`) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ QB_NAME(qb1) SUBQUERY(@qb1 materialization) SEMIJOIN(@qb1 firstmatch) SUBQUERY(intoexists)*/ a FROM t1; SELECT /*+ QB_NAME(qb1) SUBQUERY(@qb1 materialization) SEMIJOIN(@qb1 firstmatch) SUBQUERY(intoexists)*/ a FROM t1;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`qb1` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`qb1` FIRSTMATCH) is ignored as conflicting/duplicated
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 select /*+ QB_NAME(`qb1`) SUBQUERY(@`qb1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1` Note 1003 select /*+ QB_NAME(`qb1`) SUBQUERY(@`qb1` MATERIALIZATION) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN(@qb1) SEMIJOIN(loosescan) NO_SEMIJOIN(@qb1 dupsweedout)*/ a SELECT /*+ SEMIJOIN(@qb1) SEMIJOIN(loosescan) NO_SEMIJOIN(@qb1 dupsweedout)*/ a
@ -291,7 +291,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4 100.00
2 DERIVED t2 index NULL a 4 NULL 4 100.00 Using index 2 DERIVED t2 index NULL a 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN(@`qb1` DUPSWEEDOUT) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`qb1` DUPSWEEDOUT) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`qb1`) SEMIJOIN(@`select#1` LOOSESCAN) */ `tt`.`a` AS `a` from (/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`a` AS `a` from `test`.`t2`) `tt` Note 1003 /* select#1 */ select /*+ SEMIJOIN(@`qb1`) SEMIJOIN(@`select#1` LOOSESCAN) */ `tt`.`a` AS `a` from (/* select#2 */ select /*+ QB_NAME(`qb1`) */ `test`.`t2`.`a` AS `a` from `test`.`t2`) `tt`
DROP TABLE t1, t2 ,t3; DROP TABLE t1, t2 ,t3;
set optimizer_switch=default; set optimizer_switch=default;
@ -1434,7 +1434,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN() is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Try opposite order # Try opposite order
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1444,7 +1444,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index 1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN() is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` Note 1003 select /*+ SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a`
# Specify at different levels, hint inside block has effect # Specify at different levels, hint inside block has effect
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1454,7 +1454,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index 1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a`
# Specify at different levels, opposite order # Specify at different levels, opposite order
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1464,7 +1464,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Duplicate hints also gives warning, but hint has effect # Duplicate hints also gives warning, but hint has effect
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1474,7 +1474,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index 1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2 SELECT /*+ NO_SEMIJOIN(@subq) */ * FROM t2
@ -1483,7 +1483,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`subq` ) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Multiple subqueries with conflicting hints # Multiple subqueries with conflicting hints
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1495,8 +1495,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; Start temporary; End temporary 1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; Start temporary; End temporary
2 DEPENDENT SUBQUERY t3 index_subquery a a 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t3 index_subquery a a 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated
Warning 4206 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`b` and <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t3 on a)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq1`) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`a` = `test`.`t1`.`b` and <expr_cache><`test`.`t1`.`a`>(<in_optimizer>(`test`.`t1`.`a`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`a`) in t3 on a))))
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1 SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) SEMIJOIN(@subq2 FIRSTMATCH) */ * FROM t1
@ -1507,8 +1507,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) 1 PRIMARY t3 ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1)
1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; Start temporary; End temporary 1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; Start temporary; End temporary
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated
Warning 4206 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq2` FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b` Note 1003 select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) SEMIJOIN(@`subq2` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b`
# Conflicting hints in same hint comment # Conflicting hints in same hint comment
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1520,7 +1520,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 25.00 Using where 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 25.00 Using where
1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t1) 1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t1)
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t3`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b` Note 1003 select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t3`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 LOOSESCAN) */ * SELECT /*+ SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 LOOSESCAN) */ *
@ -1532,7 +1532,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 25.00 Using where 1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1 25.00 Using where
1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t1) 1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t1)
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`subq1` LOOSESCAN) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t3`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b` Note 1003 select /*+ SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t3`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 FIRSTMATCH) */ * SELECT /*+ NO_SEMIJOIN(@subq1 LOOSESCAN) NO_SEMIJOIN(@subq1 FIRSTMATCH) */ *
@ -1544,7 +1544,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t3 ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1) 1 PRIMARY t3 ref a a 4 test.t1.a 1 100.00 Using index; FirstMatch(t1)
1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t3) 1 PRIMARY t2 ref a a 4 test.t1.b 1 66.67 Using index; FirstMatch(t3)
Warnings: Warnings:
Warning 4206 Hint NO_SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint NO_SEMIJOIN(@`subq1` FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b` Note 1003 select /*+ NO_SEMIJOIN(@`subq1` LOOSESCAN) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join (`test`.`t3`) semi join (`test`.`t2`) where `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t1`.`b`
# Non-supported strategies should give warnings # Non-supported strategies should give warnings
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1770,7 +1770,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 MATERIALIZED t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 MATERIALIZED t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`))))
# Try opposite order # Try opposite order
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1781,7 +1781,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Specify at different levels, hint inside block has effect # Specify at different levels, hint inside block has effect
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1791,7 +1791,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Specify at different levels, opposite order # Specify at different levels, opposite order
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1801,7 +1801,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 MATERIALIZED t1 index NULL PRIMARY 4 NULL 4 100.00 Using index 2 MATERIALIZED t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` MATERIALIZATION) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,`test`.`t2`.`a` in ( <materialize> (/* select#2 */ select /*+ QB_NAME(`subq`) */ `test`.`t1`.`a` from `test`.`t1` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`a`))))
# Specifying combinations of SUBQUERY and SEMIJOIN/NO_SEMIJOIN # Specifying combinations of SUBQUERY and SEMIJOIN/NO_SEMIJOIN
# for same query block gives warning # for same query block gives warning
@ -1813,7 +1813,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN() is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN() is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`select#2` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Try opposite order # Try opposite order
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1823,7 +1823,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(MATERIALIZATION) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`select#2`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
# Specify at different levels, hint inside block has effect # Specify at different levels, hint inside block has effect
EXPLAIN EXTENDED EXPLAIN EXTENDED
@ -1833,7 +1833,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index 1 PRIMARY t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index
1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index 1 PRIMARY t2 ref a a 4 test.t1.a 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(@`subq` MATERIALIZATION) is ignored as conflicting/duplicated
Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a` Note 1003 select /*+ SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t2`.`a` = `test`.`t1`.`a`
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2 SELECT /*+ SUBQUERY(@subq INTOEXISTS) */ * FROM t2
@ -1842,7 +1842,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated Warning 4207 Hint SUBQUERY(@`subq` INTOEXISTS) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ NO_SEMIJOIN(@`subq`) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
EXPLAIN EXTENDED EXPLAIN EXTENDED
SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2 SELECT /*+ SEMIJOIN(@subq FIRSTMATCH) */ * FROM t2
@ -1851,6 +1851,6 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index 1 PRIMARY t2 index NULL a 4 NULL 6 100.00 Using where; Using index
2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings: Warnings:
Warning 4206 Hint SEMIJOIN(@`subq` FIRSTMATCH) is ignored as conflicting/duplicated Warning 4207 Hint SEMIJOIN(@`subq` FIRSTMATCH) is ignored as conflicting/duplicated
Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY)))) Note 1003 /* select#1 */ select /*+ SUBQUERY(@`subq` INTOEXISTS) */ `test`.`t2`.`a` AS `a` from `test`.`t2` where <expr_cache><`test`.`t2`.`a`>(<in_optimizer>(`test`.`t2`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t2`.`a`) in t1 on PRIMARY))))
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;

View File

@ -53,21 +53,20 @@ const LEX_CSTRING sys_qb_prefix= {"select#", 7};
static const Lex_ident_sys null_ident_sys; static const Lex_ident_sys null_ident_sys;
template<typename Hint_type>
static static
void print_warn(THD *thd, uint err_code, opt_hints_enum hint_type, void print_warn(THD *thd, uint err_code, opt_hints_enum hint_type,
bool hint_state, bool hint_state,
const Lex_ident_sys *qb_name_arg, const Lex_ident_sys *qb_name_arg,
const Lex_ident_sys *table_name_arg, const Lex_ident_sys *table_name_arg,
const Lex_ident_sys *key_name_arg, const Lex_ident_sys *key_name_arg,
Hint_type *hint) const Printable_parser_rule *hint)
{ {
String str; String str;
/* Append hint name */ /* Append hint name */
if (!hint_state) if (!hint_state)
str.append(STRING_WITH_LEN("NO_")); str.append(STRING_WITH_LEN("NO_"));
str.append(opt_hint_info[hint_type].hint_name); str.append(opt_hint_info[hint_type].hint_type);
/* ER_WARN_UNKNOWN_QB_NAME with two arguments */ /* ER_WARN_UNKNOWN_QB_NAME with two arguments */
if (err_code == ER_WARN_UNKNOWN_QB_NAME) if (err_code == ER_WARN_UNKNOWN_QB_NAME)
@ -212,7 +211,7 @@ static Opt_hints_qb *find_qb_hints(Parse_context *pc,
if (qb == NULL) if (qb == NULL)
{ {
print_warn(pc->thd, ER_WARN_UNKNOWN_QB_NAME, hint_type, hint_state, print_warn(pc->thd, ER_WARN_UNKNOWN_QB_NAME, hint_type, hint_state,
&qb_name, NULL, NULL, (Parser::Hint*) NULL); &qb_name, NULL, NULL, NULL);
} }
return qb; return qb;
} }
@ -274,9 +273,14 @@ Opt_hints* Opt_hints::find_by_name(const LEX_CSTRING &name_arg) const
void Opt_hints::print(THD *thd, String *str) void Opt_hints::print(THD *thd, String *str)
{ {
/* Do not print the hint if we couldn't attach it to its object */
if (!is_fixed())
return;
// Print the hints stored in the bitmap
for (uint i= 0; i < MAX_HINT_ENUM; i++) for (uint i= 0; i < MAX_HINT_ENUM; i++)
{ {
if (is_specified(static_cast<opt_hints_enum>(i)) && is_fixed()) if (is_specified(static_cast<opt_hints_enum>(i)))
{ {
append_hint_type(str, static_cast<opt_hints_enum>(i)); append_hint_type(str, static_cast<opt_hints_enum>(i));
str->append(STRING_WITH_LEN("(")); str->append(STRING_WITH_LEN("("));
@ -286,10 +290,7 @@ void Opt_hints::print(THD *thd, String *str)
if (len_after_name > len_before_name) if (len_after_name > len_before_name)
str->append(' '); str->append(' ');
if (opt_hint_info[i].has_arguments) if (opt_hint_info[i].has_arguments)
{ append_hint_arguments(thd, static_cast<opt_hints_enum>(i), str);
std::function<void(THD*, String*)> args_printer= get_args_printer();
args_printer(thd, str);
}
if (str->length() == len_after_name + 1) if (str->length() == len_after_name + 1)
{ {
// No additional arguments were printed, trim the space added before // No additional arguments were printed, trim the space added before
@ -304,11 +305,16 @@ void Opt_hints::print(THD *thd, String *str)
} }
/*
@brief
Append hint "type", for example, "NO_RANGE_OPTIMIZATION" or "BKA"
*/
void Opt_hints::append_hint_type(String *str, opt_hints_enum type) void Opt_hints::append_hint_type(String *str, opt_hints_enum type)
{ {
if(!hints_map.is_switched_on(type)) if(!hints_map.is_switched_on(type))
str->append(STRING_WITH_LEN("NO_")); str->append(STRING_WITH_LEN("NO_"));
str->append(opt_hint_info[type].hint_name); str->append(opt_hint_info[type].hint_type);
} }
@ -605,7 +611,7 @@ bool Parser::Table_level_hint::resolve(Parse_context *pc) const
if (qb->set_switch(hint_state, hint_type, false)) if (qb->set_switch(hint_state, hint_type, false))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&qb_name_sys, nullptr, nullptr, (Parser::Hint*) nullptr); &qb_name_sys, nullptr, nullptr, nullptr);
} }
return false; return false;
} }
@ -623,7 +629,7 @@ bool Parser::Table_level_hint::resolve(Parse_context *pc) const
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&qb_name_sys, &table_name_sys, nullptr, &qb_name_sys, &table_name_sys, nullptr,
(Parser::Hint*) nullptr); nullptr);
} }
} }
} }
@ -642,7 +648,7 @@ bool Parser::Table_level_hint::resolve(Parse_context *pc) const
if (qb->set_switch(hint_state, hint_type, false)) if (qb->set_switch(hint_state, hint_type, false))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&null_ident_sys, nullptr, nullptr, (Parser::Hint*) nullptr); &null_ident_sys, nullptr, nullptr, nullptr);
} }
return false; return false;
} }
@ -656,8 +662,7 @@ bool Parser::Table_level_hint::resolve(Parse_context *pc) const
if (tab->set_switch(hint_state, hint_type, true)) if (tab->set_switch(hint_state, hint_type, true))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&null_ident_sys, &table_name_sys, nullptr, &null_ident_sys, &table_name_sys, nullptr, nullptr);
(Parser::Hint*) nullptr);
} }
} }
@ -677,8 +682,7 @@ bool Parser::Table_level_hint::resolve(Parse_context *pc) const
if (tab->set_switch(hint_state, hint_type, true)) if (tab->set_switch(hint_state, hint_type, true))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&qb_name_sys, &table_name_sys, nullptr, &qb_name_sys, &table_name_sys, nullptr, nullptr);
(Parser::Hint*) nullptr);
} }
} }
} }
@ -741,8 +745,7 @@ bool Parser::Index_level_hint::resolve(Parse_context *pc) const
if (tab->set_switch(hint_state, hint_type, false)) if (tab->set_switch(hint_state, hint_type, false))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&qb_name_sys, &table_name_sys, nullptr, &qb_name_sys, &table_name_sys, nullptr, nullptr);
(Parser::Hint*) nullptr);
} }
return false; return false;
} }
@ -761,8 +764,7 @@ bool Parser::Index_level_hint::resolve(Parse_context *pc) const
if (idx->set_switch(hint_state, hint_type, true)) if (idx->set_switch(hint_state, hint_type, true))
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, hint_type, hint_state,
&qb_name_sys, &table_name_sys, &index_name_sys, &qb_name_sys, &table_name_sys, &index_name_sys, nullptr);
(Parser::Hint*) nullptr);
} }
} }
return false; return false;
@ -789,7 +791,7 @@ bool Parser::Qb_name_hint::resolve(Parse_context *pc) const
qb->get_parent()->find_by_name(qb_name_sys)) // Name is already used qb->get_parent()->find_by_name(qb_name_sys)) // Name is already used
{ {
print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, QB_NAME_HINT_ENUM, true, print_warn(pc->thd, ER_WARN_CONFLICTING_HINT, QB_NAME_HINT_ENUM, true,
&qb_name_sys, nullptr, nullptr, (Parser::Hint*) nullptr); &qb_name_sys, nullptr, nullptr, nullptr);
return false; return false;
} }
@ -1157,6 +1159,28 @@ bool Opt_hints_global::fix_hint(THD *thd)
} }
#ifndef DBUG_OFF
static char dbug_print_hint_buf[64];
const char *dbug_print_hints(Opt_hints_qb *hint)
{
char *buf= dbug_print_hint_buf;
THD *thd= current_thd;
String str(buf, sizeof(dbug_print_hint_buf), &my_charset_bin);
str.length(0);
if (!hint)
return "(Opt_hints_qb*)NULL";
hint->print(thd, &str);
if (str.c_ptr_safe() == buf)
return buf;
else
return "Couldn't fit into buffer";
}
#endif
bool Parser::Hint_list::resolve(Parse_context *pc) const bool Parser::Hint_list::resolve(Parse_context *pc) const
{ {
if (pc->thd->lex->create_view) if (pc->thd->lex->create_view)

View File

@ -84,6 +84,7 @@
#include "sql_show.h" #include "sql_show.h"
#include "mysqld_error.h" #include "mysqld_error.h"
#include "opt_hints_parser.h" #include "opt_hints_parser.h"
#include "opt_trace.h"
struct LEX; struct LEX;
@ -111,7 +112,7 @@ enum opt_hints_enum
struct st_opt_hint_info struct st_opt_hint_info
{ {
LEX_CSTRING hint_name; // Hint name. LEX_CSTRING hint_type; // Hint "type", like "BKA" or "MRR".
bool check_upper_lvl; // true if upper level hint check is needed (for hints bool check_upper_lvl; // true if upper level hint check is needed (for hints
// which can be specified on more than one level). // which can be specified on more than one level).
bool has_arguments; // true if hint has additional arguments. bool has_arguments; // true if hint has additional arguments.
@ -324,16 +325,16 @@ public:
@param thd Pointer to THD object @param thd Pointer to THD object
*/ */
void check_unfixed(THD *thd); void check_unfixed(THD *thd);
/*
Append the name of object(table, index, etc) that hints in this collection
are attached to.
*/
virtual void append_name(THD *thd, String *str)= 0; virtual void append_name(THD *thd, String *str)= 0;
/** virtual void append_hint_arguments(THD *thd, opt_hints_enum hint, String *str)
Get the function appending additional hint arguments to the printed string,
if the arguments exist. For example, SEMIJOIN and SUBQUERY hints may have
a list of strategies as additional arguments
*/
virtual std::function<void(THD*, String*)> get_args_printer() const
{ {
return [](THD*, String*) {}; DBUG_ASSERT(0);
} }
virtual ~Opt_hints() {} virtual ~Opt_hints() {}
@ -367,7 +368,7 @@ protected:
/** /**
Global level hints. Global level hints. Currently, it's only MAX_EXECUTION_TIME.
*/ */
class Opt_hints_global : public Opt_hints class Opt_hints_global : public Opt_hints
@ -386,14 +387,21 @@ public:
: Opt_hints(Lex_ident_sys(), NULL, mem_root_arg) : Opt_hints(Lex_ident_sys(), NULL, mem_root_arg)
{} {}
virtual void append_name(THD *thd, String *str) override {} virtual void append_name(THD *thd, String *str) override
virtual std::function<void(THD*, String*)> get_args_printer() const override
{ {
using std::placeholders::_1; /*
using std::placeholders::_2; Don't write anything: global hints are not attached to anything named
return std::bind(&Parser::Max_execution_time_hint::append_args, like a table/query block/etc
max_exec_time_hint, _1, _2); */
}
void append_hint_arguments(THD *thd, opt_hints_enum hint,
String *str) override
{
if (hint == MAX_EXEC_TIME_HINT_ENUM)
max_exec_time_hint->append_args(thd, str);
else
DBUG_ASSERT(0);
} }
bool fix_hint(THD *thd); bool fix_hint(THD *thd);
@ -403,7 +411,11 @@ public:
class Opt_hints_table; class Opt_hints_table;
/** /**
Query block level hints. Query block level hints. Currently, these can be:
- QB_NAME (this is interpreted in the parser and is not explicitly
present after that)
- [NO_]SEMIJOIN
- SUBQUERY
*/ */
class Opt_hints_qb : public Opt_hints class Opt_hints_qb : public Opt_hints
@ -422,12 +434,7 @@ public:
return name.str ? name : sys_name; return name.str ? name : sys_name;
} }
/**
Append query block hint.
@param thd pointer to THD object
@param str pointer to String object
*/
void append_qb_hint(THD *thd, String *str) void append_qb_hint(THD *thd, String *str)
{ {
if (name.str) if (name.str)
@ -437,34 +444,24 @@ public:
str->append(STRING_WITH_LEN(") ")); str->append(STRING_WITH_LEN(") "));
} }
} }
/**
Append query block name.
@param thd pointer to THD object
@param str pointer to String object
*/
virtual void append_name(THD *thd, String *str) override virtual void append_name(THD *thd, String *str) override
{ {
/* Append query block name. */
str->append(STRING_WITH_LEN("@")); str->append(STRING_WITH_LEN("@"));
const LEX_CSTRING print_name= get_print_name(); const LEX_CSTRING print_name= get_print_name();
append_identifier(thd, str, &print_name); append_identifier(thd, str, &print_name);
} }
std::function<void(THD*, String*)> get_args_printer() const override void append_hint_arguments(THD *thd, opt_hints_enum hint,
String *str) override
{ {
using std::placeholders::_1; if (hint == SUBQUERY_HINT_ENUM)
using std::placeholders::_2; subquery_hint->append_args(thd, str);
if (semijoin_hint) else if (hint == SEMIJOIN_HINT_ENUM)
{ semijoin_hint->append_args(thd, str);
return std::bind(&Parser::Semijoin_hint::append_args, semijoin_hint, else
_1, _2); DBUG_ASSERT(0);
}
else if (subquery_hint)
{
return std::bind(&Parser::Subquery_hint::append_args, subquery_hint,
_1, _2);
}
return [](THD*, String*) {};
} }
/** /**
@ -518,6 +515,19 @@ public:
const Parser::Subquery_hint *subquery_hint= nullptr; const Parser::Subquery_hint *subquery_hint= nullptr;
uint subquery_strategy= SUBS_NOT_TRANSFORMED; uint subquery_strategy= SUBS_NOT_TRANSFORMED;
void trace_hints(THD *thd)
{
if (unlikely(thd->trace_started()))
{
Json_writer_object obj(thd);
String str;
str.length(0);
print(thd, &str);
// Eventually we may want to print them as array.
obj.add("hints", str.c_ptr_safe());
}
}
}; };
@ -635,4 +645,9 @@ bool hint_key_state(const THD *thd, const TABLE *table,
*/ */
bool hint_table_state(const THD *thd, const TABLE *table, bool hint_table_state(const THD *thd, const TABLE *table,
opt_hints_enum type_arg, bool fallback_value); opt_hints_enum type_arg, bool fallback_value);
#ifndef DBUG_OFF
const char *dbug_print_hints(Opt_hints_qb *hint);
#endif
#endif /* OPT_HINTS_INCLUDED */ #endif /* OPT_HINTS_INCLUDED */

View File

@ -245,7 +245,7 @@ Optimizer_hint_parser::
Hint_list_container::add(Optimizer_hint_parser *p, Hint_list_container::add(Optimizer_hint_parser *p,
Hint &&elem) Hint &&elem)
{ {
Hint *pe= (Hint*) p->m_thd->alloc(sizeof(*pe)); Hint *pe= new (p->m_thd->mem_root) Hint;
if (!pe) if (!pe)
return true; return true;
*pe= std::move(elem); *pe= std::move(elem);

View File

@ -117,6 +117,14 @@ protected:
}; };
class Printable_parser_rule
{
public:
virtual void append_args(THD *thd, String *str) const = 0;
virtual ~Printable_parser_rule() {}
};
class Optimizer_hint_parser: public Optimizer_hint_tokenizer, class Optimizer_hint_parser: public Optimizer_hint_tokenizer,
public Parser_templates public Parser_templates
{ {
@ -605,13 +613,14 @@ public:
Keyword_MAX_EXECUTION_TIME, Keyword_MAX_EXECUTION_TIME,
LParen, LParen,
Unsigned_Number, Unsigned_Number,
RParen> RParen>,
public Printable_parser_rule
{ {
public: public:
using AND4::AND4; using AND4::AND4;
bool resolve(Parse_context *pc) const; bool resolve(Parse_context *pc) const;
void append_args(THD *thd, String *str) const; void append_args(THD *thd, String *str) const override;
ulonglong get_milliseconds() const; ulonglong get_milliseconds() const;
}; };
@ -717,13 +726,14 @@ public:
Semijoin_hint_type, Semijoin_hint_type,
LParen, LParen,
Semijoin_hint_body, Semijoin_hint_body,
RParen> RParen>,
public Printable_parser_rule
{ {
public: public:
using AND4::AND4; using AND4::AND4;
bool resolve(Parse_context *pc) const; bool resolve(Parse_context *pc) const;
void append_args(THD *thd, String *str) const; void append_args(THD *thd, String *str) const override;
private: private:
Opt_hints_qb* resolve_for_qb_name(Parse_context *pc, bool hint_state, Opt_hints_qb* resolve_for_qb_name(Parse_context *pc, bool hint_state,
@ -792,13 +802,14 @@ public:
Keyword_SUBQUERY, Keyword_SUBQUERY,
LParen, LParen,
Subquery_hint_body, Subquery_hint_body,
RParen> RParen>,
public Printable_parser_rule
{ {
public: public:
using AND4::AND4; using AND4::AND4;
bool resolve(Parse_context *pc) const; bool resolve(Parse_context *pc) const;
void append_args(THD *thd, String *str) const; void append_args(THD *thd, String *str) const override;
private: private:
void set_subquery_strategy(TokenID token_id, Opt_hints_qb *qb) const; void set_subquery_strategy(TokenID token_id, Opt_hints_qb *qb) const;
@ -825,16 +836,6 @@ public:
{ {
public: public:
using OR6::OR6; using OR6::OR6;
/**
Append additional hint arguments to the printed string.
Implement this method in Hint specifications if needed:
Table_level_hint, Semijoin_hint, etc
@param thd Pointer to THD object
@param str Pointer to String object
*/
void append_args(THD *thd, String *str) const {}
}; };
private: private:

View File

@ -1260,6 +1260,13 @@ public:
*/ */
table_map select_list_tables; table_map select_list_tables;
/*
Parse tree of optimizer hints that were specified in this SELECT. Note
that hints specified in one select can prescribe how to execute another.
*/
const Optimizer_hint_parser_output *parsed_optimizer_hints;
/* Optimizer hints that prescribe how to execute this SELECT */
Opt_hints_qb *opt_hints_qb; Opt_hints_qb *opt_hints_qb;
/* Set to 1 if any field in field list has ROWNUM() */ /* Set to 1 if any field in field list has ROWNUM() */
@ -1273,8 +1280,6 @@ public:
/* it is for correct printing SELECT options */ /* it is for correct printing SELECT options */
thr_lock_type lock_type; thr_lock_type lock_type;
const Optimizer_hint_parser_output *parsed_optimizer_hints;
/** System Versioning */ /** System Versioning */
int vers_setup_conds(THD *thd, TABLE_LIST *tables); int vers_setup_conds(THD *thd, TABLE_LIST *tables);
/* push new Item_field into item_list */ /* push new Item_field into item_list */

View File

@ -2194,6 +2194,9 @@ JOIN::optimize_inner()
trace_prepare.add_select_number(select_lex->select_number); trace_prepare.add_select_number(select_lex->select_number);
Json_writer_array trace_steps(thd, "steps"); Json_writer_array trace_steps(thd, "steps");
if (select_lex->opt_hints_qb)
select_lex->opt_hints_qb->trace_hints(thd);
/* /*
Needed in case optimizer short-cuts, Needed in case optimizer short-cuts,
set properly in make_aggr_tables_info() set properly in make_aggr_tables_info()