summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-08-10 16:45:02 +0300
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-08-10 16:45:02 +0300
commitd3dd6fa0084d6c89b71cb7d700a164a9f6e0da87 (patch)
tree08930b60207d2c18d8cacb4cfddc123087266207 /sql/opt_sum.cc
parent84ece59cefafc7a223c65aa7c763f5e72afaa1fc (diff)
downloadmariadb-git-d3dd6fa0084d6c89b71cb7d700a164a9f6e0da87.tar.gz
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. 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.
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index b53fbfd3f80..bc98c96b5a8 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -182,7 +182,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
Type of range for the key part for this field will be
returned in range_fl.
*/
- if ((outer_tables & table->map) ||
+ if (table->file->inited || (outer_tables & table->map) ||
!find_key_for_maxmin(0, &ref, item_field->field, conds,
&range_fl, &prefix_len))
{
@@ -269,7 +269,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
Type of range for the key part for this field will be
returned in range_fl.
*/
- if ((outer_tables & table->map) ||
+ if (table->file->inited || (outer_tables & table->map) ||
!find_key_for_maxmin(1, &ref, item_field->field, conds,
&range_fl, &prefix_len))
{