-
Sergei Petrunia authored
The code inside Item_subselect::fix_fields() could fail to check that left expression had an Item_row, like this: (('x', 1.0) ,1) IN (SELECT 'x', 1.23 FROM ... UNION ...) In order to hit the failure, the first SELECT of the subquery had to be a degenerate no-tables select. In this case, execution will not enter into Item_in_subselect::create_row_in_to_exists_cond() and will not check if left_expr is composed of scalars. But the subquery is a UNION so as a whole it is not degenerate. We try to create an expression cache for the subquery. We create a temp.table from left_expr columns. No field is created for the Item_row. Then, we crash when trying to add an index over a non-existent field. Fixed by moving the left_expr cardinality check to a point in check_and_do_in_subquery_rewrites() which gets executed for all cases. It's better to make the check early so we don't have to care about subquery rewrite code hitting Item_row in left_expr.
c8866892