Skip to content
  • Ole John Aske's avatar
    83728bfe
    Backport to mysql-5.1-telco-7.0: · 83728bfe
    Ole John Aske authored
    Fix for bug#58422: Incorrect result when OUTER JOIN'ing with an empty table
          
    Fixed incorrect checks in join_read_const_table() for when to 
    accept a non-existing, or empty const-row as a part of the
    const'ified set of tables.
          
    Intention of this test is to only accept NULL-rows if this table
    is outer joined into the resultset. (In case of an inner-join
    we can conclude at this point thatresultset will be empty,
    and we want to return 'error' to signal this.)
          
    Initially 'maybe_null' is set to the same value as 'outer_join'
    in setup_table_map(), mysql_priv.h ~line 2424. Later
    simplify_joins() will attemp to replace outer joins by inner 
    join whenever possible.
    
    This will cause 'outer_join' to be updated. However, 'maybe_null'
    is *not* updated to reflect this rewrite as this field is used 
    to currectly set the 'nullability' property for the columns 
    in the resultset.
          
    We should therefore change join_read_const_table() to check the
    'outer_join' property instead of 'maybe_null', as this correctly
    reflect the nullability of the partial *execution plan* (not *resultset*).
    83728bfe
    Backport to mysql-5.1-telco-7.0:
    Ole John Aske authored
    Fix for bug#58422: Incorrect result when OUTER JOIN'ing with an empty table
          
    Fixed incorrect checks in join_read_const_table() for when to 
    accept a non-existing, or empty const-row as a part of the
    const'ified set of tables.
          
    Intention of this test is to only accept NULL-rows if this table
    is outer joined into the resultset. (In case of an inner-join
    we can conclude at this point thatresultset will be empty,
    and we want to return 'error' to signal this.)
          
    Initially 'maybe_null' is set to the same value as 'outer_join'
    in setup_table_map(), mysql_priv.h ~line 2424. Later
    simplify_joins() will attemp to replace outer joins by inner 
    join whenever possible.
    
    This will cause 'outer_join' to be updated. However, 'maybe_null'
    is *not* updated to reflect this rewrite as this field is used 
    to currectly set the 'nullability' property for the columns 
    in the resultset.
          
    We should therefore change join_read_const_table() to check the
    'outer_join' property instead of 'maybe_null', as this correctly
    reflect the nullability of the partial *execution plan* (not *resultset*).
Loading