• unknown's avatar
    Bug #16792 query with subselect, join, and group not returning proper values · d3dd6fa0
    unknown authored
     Treat queries with no FROM and aggregate functions as normal queries,
    so the aggregate function get correctly calculated as if there is 1 row. 
    This means that they will be considered to have one row, so COUNT(*) will return
    1 instead of 0. Other aggregates will behave in compatible manner.
    
    
    mysql-test/r/func_gconcat.result:
      Bug #16792 query with subselect, join, and group not returning proper values
       - test case. Note how it improves the support for DUAL.
    mysql-test/r/func_group.result:
      Bug #16792 query with subselect, join, and group not returning proper values
       - test case. Note how it improves the support for DUAL.
    mysql-test/r/subselect.result:
      Bug #16792 query with subselect, join, and group not returning proper values
       - consequence of (SELECT MAX(<const>)) now returning <const> instead of 0
    mysql-test/t/func_group.test:
      Bug #16792 query with subselect, join, and group not returning proper values
       - test case.
    sql/opt_sum.cc:
      Bug #16792 query with subselect, join, and group not returning proper values
       - cannot do the optimization if the index is already opened by (say) UPDATE
         as it invloves opening reading and closing the index.
    sql/sql_select.cc:
      Bug #16792 query with subselect, join, and group not returning proper values
       - Treat queries with no FROM and aggregate functions as normal queries,
      so the aggregate function get correctly calculated as if there is 1 row.
    d3dd6fa0
subselect.result 109 KB