• Jorgen Loland's avatar
    Bug#48177 - SELECTs with NOT IN subqueries containing NULL · bec35067
    Jorgen Loland authored
                values return too many records
    
    WHERE clauses with "outer_value_list NOT IN subselect" were
    handled incorrectly if the outer value list contained multiple 
    items where at least one of these could be NULL. The first 
    outer record with NULL value was handled correctly, but if a 
    second record with NULL value existed, the optimizer would 
    choose to reuse the result it got on the last execution of the 
    subselect. This is incorrect if the outer value list has 
    multiple items.
         
    The fix is to make Item_in_optimizer::val_int (in 
    item_cmpfunc.cc) reuse the result of the latest execution
    for NULL values only if all values in the outer_value_list 
    are NULL.
    
    
    mysql-test/r/subselect3.result:
      Added test for BUG#48177
    mysql-test/t/subselect3.test:
      Added test for BUG#48177
    sql/item_cmpfunc.cc:
      Make Item_in_optimizer::val_int (in item_cmpfunc.cc) reuse the result of the latest execution for NULL values only if all values in the outer_value_list are NULL.
    bec35067
item_cmpfunc.cc 135 KB