Skip to content
  • Norvald H. Ryeng's avatar
    ef5b21d6
    Bug#12888306 MISSING ROWS FOR SELECT >ALL (SUBQUERY WITHOUT ROWS) · ef5b21d6
    Norvald H. Ryeng authored
    Problem: Subqueries with implicit grouping may return incorrect
    results due to not evaluating the WHERE clause.
    
    Queries with ALL/ANY are rewritten to use MIN/MAX. The rewritten form
    of the query has no GROUP BY clause, so these queries fit the pattern
    for triggering this bug.
    
    JOIN::optimize() calls opt_sum_query() to replace aggregation
    functions with constant fields for implicitly grouped queries. If the
    aggregation function is MIN or MAX, it checks the argument to the
    aggregation function. If it is a constant, the constant is selected as
    the minimum/maximum value if the table has rows, and NULL if it
    doesn't. However, the WHERE clause is not checked, so the MIN/MAX may
    be evaluated to a constant when it should have been NULL.
    
    Fix: Don't replace MIN/MAX of constants if there is a WHERE clause.
    ef5b21d6
    Bug#12888306 MISSING ROWS FOR SELECT >ALL (SUBQUERY WITHOUT ROWS)
    Norvald H. Ryeng authored
    Problem: Subqueries with implicit grouping may return incorrect
    results due to not evaluating the WHERE clause.
    
    Queries with ALL/ANY are rewritten to use MIN/MAX. The rewritten form
    of the query has no GROUP BY clause, so these queries fit the pattern
    for triggering this bug.
    
    JOIN::optimize() calls opt_sum_query() to replace aggregation
    functions with constant fields for implicitly grouped queries. If the
    aggregation function is MIN or MAX, it checks the argument to the
    aggregation function. If it is a constant, the constant is selected as
    the minimum/maximum value if the table has rows, and NULL if it
    doesn't. However, the WHERE clause is not checked, so the MIN/MAX may
    be evaluated to a constant when it should have been NULL.
    
    Fix: Don't replace MIN/MAX of constants if there is a WHERE clause.
Loading