• unknown's avatar
    BUG#8804: wrong results for NULL IN (SELECT ...) · 48df3b96
    unknown authored
    Evaluate "NULL IN (SELECT ...)" in a special way: Disable pushed-down 
    conditions and their "consequences": 
     = Do full table scans instead of unique_[index_subquery] lookups.
     = Change appropriate "ref_or_null" accesses to full table scans in
       subquery's joins.
    Also cache value of NULL IN (SELECT ...) if the SELECT is not correlated 
    wrt any upper select.
    
    
    mysql-test/r/subselect.result:
      BUG#8804: wrong results for NULL IN (SELECT ...): 
       - Updated test results
    sql/item.h:
      BUG#8804: wrong results for NULL IN (SELECT ...): 
       - Added comments
    sql/item_cmpfunc.cc:
      BUG#8804: wrong results for NULL IN (SELECT ...): 
      Made Item_in_optimizer to:
      - cache the value of "NULL IN (uncorrelated select)"
      - Turn off pushed-down predicates when evaluating "NULL IN (SELECT ...)"
    sql/item_cmpfunc.h:
      BUG#8804: wrong results for NULL IN (SELECT ...): 
      - Made Item_in_optimizer cache the value of "NULL IN (uncorrelated select)"
      - Added comments
    sql/item_subselect.cc:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - When needed, wrap the predicates we push into subquery into an 
        Item_func_trig_cond so we're able to turn them off when evaluating 
        NULL IN (SELECT ...).
      - Added code to evaluate NULL IN (SELECT ...) in a special way:
        = In [unique_]index_subquery, do full table scan to see if there 
          are any rows.
        = For other subqueries, change ref[_or_null] to ALL if the
          ref[_or_null] was created from pushed-down predicate.
    sql/item_subselect.h:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Added Item_subselect::is_correlated
      - Added comments
    sql/records.cc:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Make rr_sequential() non-static
    sql/sql_lex.cc:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Added st_select_lex::is_correlated and Item_subselect::is_correlated.
    sql/sql_lex.h:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Added st_select_lex::is_correlated
    sql/sql_select.cc:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Added KEY_FIELD::outer_ref to keep track of which ref accesses are 
        created from predicates that were pushed down into the subquery.
    sql/sql_select.h:
      BUG#8804: wrong results for NULL IN (SELECT ...):
      - Added KEYUSE::outer_ref
    mysql-test/r/subselect3.result:
      New BitKeeper file ``mysql-test/r/subselect3.result''
    mysql-test/t/subselect3.test:
      New BitKeeper file ``mysql-test/t/subselect3.test''
    48df3b96
item_subselect.h 14.2 KB