• unknown's avatar
    Fixed bug #24856: the result set of a ROLLUP query with DISTINCT could lack · dd34042e
    unknown authored
    some rollup rows (rows with NULLs for grouping attributes) if GROUP BY
    list contained constant expressions.
    
    This happened because the results of constant expressions were not put
    in the temporary table used for duplicate elimination. In fact a constant
    item from the GROUP BY list of a ROLLUP query can be replaced for an
    Item_null_result object when a rollup row is produced . 
    
    Now the JOIN::rollup_init function wraps any constant item referenced in
    the GROYP BY list of a ROLLUP query into an Item_func object of a special
    class that is never detected as constant item. This ensures creation of
    fields for such  constant items in temporary tables and guarantees right
    results when the result of the rollup operation first has to be written
    into a temporary table, e.g. in the cases when duplicate elimination is
    required.  
    
    
    mysql-test/r/olap.result:
      Added a test case for bug #24856.
    mysql-test/t/olap.test:
      Added a test case for bug #24856.
    sql/item_func.h:
      Fixed bug #24856: the result set of a ROLLUP query with DISTINCT could lack
      some rollup rows (rows with NULLs for grouping attributes) if GROUP BY
      list contained constant expressions.
      
      Itroduced class Item_func_rollup_const derived from Item_func. The object of
      this class are never detected as constant items.
      We use them for wrapping constant items from the GROUP BY list of any ROLLUP
      query. This wrapping allows us to ensure writing constant items into temporary
      tables whenever the result of the ROLLUP operation has to be written into a
      temporary table, e.g. when ROLLUP is used together with DISTINCT in the SELECT
      list.
    sql/sql_select.cc:
      Fixed bug #24856: the result set of a ROLLUP query with DISTINCT could lack
      some rollup rows (rows with NULLs for grouping attributes) if GROUP BY
      list contained constant expressions.
      
      Now the JOIN::rollup_init function wraps any constant item referenced in
      the GROYP BY list of a ROLLUP query into an Item_func object of a special
      class that is never detected as constant item. This ensures creation of
      fields for such  constant items in temporary tables and guarantees right
      results when the result of the rollup operation first has to be written
      into a temporary table, e.g. in the cases when duplicate elimination is
      required.
    dd34042e
olap.test 9.97 KB