Skip to content
  • Sreeharsha Ramanavarapu's avatar
    e7492152
    Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS · e7492152
    Sreeharsha Ramanavarapu authored
                   INCORRECT RESULTS IN 5.6
    
    Issue
    -----
    This issue occurs with a query of the form
    SQ1 IN (SQ2 IN (SQ3)). To handle the first IN, a semijoin
    is used and the subquery is materialized. The second IN
    is converted to EXISTS optimization.
    
    During IN-TO-EXISTS transform for SQ3,
    Item_in_subselect's used_tables_cache is set to 3 instead
    of 2. This is because <left expr> is a direct_ref to
    concat(a,''). It visits Item_ref::resolved_used_tables.
    The used_tables_cache of concat(a,'') is set to 1. This
    difference allows for the condition to be eliminated by
    make_cond_for_table_from_pred, since the table, represented
    by used_tables_cache, is not referenced.
    
    
    SOLUTION:
    ---------
    This is the same problem fixed in Bug#21139722.
    
    The issue is solved by creating a new used_tables_for_level
    for Item_field class. This will return the table number if
    the column is resolved in the current query block. If it is
    resolved in an outer query block, the appropriate value is
    returned.
    
    Since constant tables are not handled in
    Item_field::used_tables_for_level, Bug#21139402 is also
    backported.
    e7492152
    Bug #22305361: QUERY WITH MATERIALIZED TABLE RETURNS
    Sreeharsha Ramanavarapu authored
                   INCORRECT RESULTS IN 5.6
    
    Issue
    -----
    This issue occurs with a query of the form
    SQ1 IN (SQ2 IN (SQ3)). To handle the first IN, a semijoin
    is used and the subquery is materialized. The second IN
    is converted to EXISTS optimization.
    
    During IN-TO-EXISTS transform for SQ3,
    Item_in_subselect's used_tables_cache is set to 3 instead
    of 2. This is because <left expr> is a direct_ref to
    concat(a,''). It visits Item_ref::resolved_used_tables.
    The used_tables_cache of concat(a,'') is set to 1. This
    difference allows for the condition to be eliminated by
    make_cond_for_table_from_pred, since the table, represented
    by used_tables_cache, is not referenced.
    
    
    SOLUTION:
    ---------
    This is the same problem fixed in Bug#21139722.
    
    The issue is solved by creating a new used_tables_for_level
    for Item_field class. This will return the table number if
    the column is resolved in the current query block. If it is
    resolved in an outer query block, the appropriate value is
    returned.
    
    Since constant tables are not handled in
    Item_field::used_tables_for_level, Bug#21139402 is also
    backported.
Loading