Bug #85899 WL9603: bad column names in EXPLAIN
Submitted: 11 Apr 2017 10:14 Modified: 23 May 2017 6:50
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.1 OS:Any
Assigned to: CPU Architecture:Any

[11 Apr 2017 10:14] Guilhem Bichot
Description:
We can see it in result files:

cd mysql-test/r
grep -nH -e tmp_field *

window_functions_explain.result:3747:Note	1003	/* select#1 */ select (`tmp_field` * 2) AS `SUM(id) OVER w * 2`,avg(`test`.`t1`.`id`) OVER `w` AS `AVG(id) OVER w`,count(`test`.`t1`.`id`) OVER `w` AS `COUNT(id) OVER w` from `test`.`t1` window `w` AS (PARTITION BY `test`.`t1`.`sex` ) 
window_functions_explain.result:5392:Note	1003	/* select#1 */ select ((((`tmp_field` * 5) - 1) DIV `tmp_field`) + 1) AS `cnt` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` asc ) , `w2` AS () 
window_functions_explain.result:5456:Note	1003	/* select#1 */ select ((((`tmp_field` * 5) - 1) DIV `tmp_field`) + 1) AS `ntile_manually`,count(0) OVER `w3` AS `COUNT(*) OVER w3` from `test`.`t1` window `w1` AS (ORDER BY `test`.`t1`.`id` asc ) , `w2` AS () , `w3` AS () 
window_functions_explain.result:10039:Note	1003	/* select#1 */ select cast(`tmp_field` as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj`
window_functions_explain.result:10580:Note	1003	/* select#1 */ select `test`.`tj`.`j` AS `j`,cast(`tmp_field` as json) AS `CAST(SUM(j) OVER (PARTITION BY i) AS JSON)`,cast(`tmp_field` as json) AS `CAST(SUM(j) OVER () AS JSON)` from `test`.`tj`
window_functions_explain.result:10627:Note	1003	/* select#1 */ select `test`.`tj`.`j` AS `j`,cast(`tmp_field` as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)`,cast(`tmp_field` as json) AS `CAST(SUM(j) OVER (PARTITION BY i ROWS UNBOUNDED PRECEDING) AS JSON)` from `test`.`tj`
window_functions_explain.result:11880:Note	1003	/* select#1 */ select `test`.`t1`.`s1` AS `s1`,`test`.`t1`.`s2` AS `s2`,(abs(`ROW_NUMBER() OVER (ORDER BY s1,s2)`) - `tmp_field`) AS `X` from `test`.`t1`
window_functions_explain.result:12572:Note	1003	/* select#1 */ select `alias`.`sum1` AS `sum1`,`alias`.`a` AS `a` from (/* select#2 */ select (`tmp_field` + `tmp_field`) AS `sum1`,`test`.`t`.`a` AS `a` from `test`.`t`) `alias`

All these tmp_field don't exist in the query, should be expressions (window functions) instead.

How to repeat:
see above