oleg.smirnov we indeed produce warnings for the wrong_name example you gave above. But we don't include the wrong name hints in the Note message for the query. That's because the hints are stored by table name and when we fix the hints, we look them up only by the table alias, which must be known because it is associated with a TABLE instance. We don't find the wrong names at that point because they don't have TABLEs that exist, so they are not fixed. Later, during warning generation, we skip any unfixed hints (see Opt_hints::print).
MariaDB [test]> explain extended SELECT /*+ no_derived_condition_pushdown(wrong_name) */a, b FROM (SELECT i as a, j as b FROM (select i*10 as i, j*5 as j from v1) dt_in) AS dt_out WHERE a < 3 AND b > 8;
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 10 | 100.00 | Using where |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
1 row in set, 2 warnings (5.091 sec)
|
|
MariaDB [test]> show warnings\G
|
*************************** 1. row ***************************
|
Level: Warning
|
Code: 4209
|
Message: Unresolved table name `wrong_name`@`select#1` for NO_DERIVED_CONDITION_PUSHDOWN hint
|
*************************** 2. row ***************************
|
Level: Note
|
Code: 1003
|
Message: select `test`.`t1`.`i` * 10 AS `a`,`test`.`t1`.`j` * 5 AS `b` from `test`.`t1` where `test`.`t1`.`i` * 10 < 3 and `test`.`t1`.`j` * 5 > 8
|
2 rows in set (0.001 sec)
|
We can alter this behavior by removing this check from the start of Opt_hints::print:
/* Do not print the hint if we couldn't attach it to its object */
|
if (!is_fixed())
|
return;
|
If we do that, then we generate warnings like this:
MariaDB [test]> explain extended SELECT /*+ no_derived_condition_pushdown(wrong_name) */a, b FROM (SELECT i as a, j as b FROM (select i*10 as i, j*5 as j from v1) dt_in) AS dt_out WHERE a < 3 AND b > 8;
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
| 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 10 | 100.00 | Using where |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+
|
1 row in set, 2 warnings (0.010 sec)
|
|
MariaDB [test]> show warnings\G
|
*************************** 1. row ***************************
|
Level: Warning
|
Code: 4209
|
Message: Unresolved table name `wrong_name`@`select#1` for NO_DERIVED_CONDITION_PUSHDOWN hint
|
*************************** 2. row ***************************
|
Level: Note
|
Code: 1003
|
Message: select /*+ NO_DERIVED_CONDITION_PUSHDOWN(`wrong_name`@`select#1`) */ `test`.`t1`.`i` * 10 AS `a`,`test`.`t1`.`j` * 5 AS `b` from `test`.`t1` where `test`.`t1`.`i` * 10 < 3 and `test`.`t1`.`j` * 5 > 8
|
2 rows in set (0.001 sec)
|
Maybe, using something like this
would produce shorter and more readable output?
It shows original_condition from both selects without telling which is which (not perfect) but at least it doesn't show equality_propagation steps.