[MDEV-6054] ER_BAD_FIELD_ERROR (Unknown column in where clause) on the 2nd execution of PS Created: 2014-04-09 Updated: 2023-11-28 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Prepared Statements |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Dmitry Shulga |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The problem was introduced in 5.5 tree with the following revision:
|
| Comments |
| Comment by Michael Widenius [ 2014-09-09 ] |
|
simplified prepare (easier to debug): PREPARE stmt FROM 'SELECT 1 FROM ( SELECT DISTINCT * FROM t1 ) AS sq WHERE a IN ( SELECT 1 FROM t2 WHERE sq.b <= c)'; The problem is that during the first execute, we call, as part of sub query optimization: void Item_field::fix_after_pullout(st_select_lex *new_parent, Item **ref) This sets ctx->outer_contex = NULL for the new context. This causes setup_without_group-> setup_conds for the second execution to not find the outer ref field sq.b. One can't use the old outer_context for the new context as in fix_outer_field we do: Item_subselect *prev_subselect_item= Which is 0 for the new context that was created. |
| Comment by Elena Stepanova [ 2022-12-20 ] |
|
Still reproducible on all existing versions. |