13.1.2 Row IN Subquery

To rewrite a row IN subquery, the method used is Item_in_subselect::row_value_transformer. It works in almost the same way as the scalar analog, but works with Item_cache_row for caching left expression and uses references for elements of Item_cache_row. To refer to the item list, it uses Item_ref_null_helper(ref_array+i).

A subquery with HAVING, SUM() function, or GROUP BY will transformed in the following way:

ROW(l1, l2, ... lN) IN (SELECT i1, i2, ... iN FROM t HAVING <having_expr>) 

will become:

(SELECT i1, i2, ... iN FROM t
   HAVING <having_expr> and      <cache_l0> = <Item_ref_null_helper(ref_array[0]> AND      <cache_l1> = <Item_ref_null_helper(ref_array[1])> AND
     <cache_lN-1> = <Item_ref_null_helper(ref_array[N-1]>) 

SELECT without FROM will be transformed in this way, too.

It will be the same for other subqueries, except for the WHERE clause.

User Comments
Sign Up Login You must be logged in to post a comment.