diff options
author | unknown <evgen@moonbone.local> | 2006-07-12 01:52:18 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2006-07-12 01:52:18 +0400 |
commit | d2bbf288a93ee50829e09d8faaf26dc0d6125476 (patch) | |
tree | 2400fb7e97c29509ed18c198cccf9b19fa511a1a /sql/sql_select.cc | |
parent | 89e415950cf3b40b15e493cb72784f6ad3dc2b64 (diff) | |
download | mariadb-git-d2bbf288a93ee50829e09d8faaf26dc0d6125476.tar.gz |
Fixed bug#18503: Queries with a quantified subquery returning empty set
may return a wrong result.
An Item_sum_hybrid object has the was_values flag which indicates whether any
values were added to the sum function. By default it is set to true and reset
to false on any no_rows_in_result() call. This method is called only in
return_zero_rows() function. An ALL/ANY subquery can be optimized by MIN/MAX
optimization. The was_values flag is used to indicate whether the subquery
has returned at least one row. This bug occurs because return_zero_rows() is
called only when we know that the select will return zero rows before
starting any scans but often such information is not known.
In the reported case the return_zero_rows() function is not called and
the was_values flag is not reset to false and yet the subquery return no rows
Item_func_not_all and Item_func_nop_all functions return a wrong
comparison result.
The end_send_group() function now calls no_rows_in_result() for each item
in the fields_list if there is no rows were found for the (sub)query.
mysql-test/t/subselect.test:
Added test case for bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.
mysql-test/r/subselect.result:
Added test case for bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.
sql/sql_select.cc:
Fixed bug#18503: Queries with a quantified subquery returning empty set may return a wrong result.
The end_send_group() function now calls no_rows_in_result() for each item
in the fields_list if there is no matching rows were found.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 709ff9726bb..8b3cfab8533 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6746,8 +6746,13 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), { if (!join->first_record) { + List_iterator_fast<Item> it(*join->fields); + Item *item; /* No matching rows for group function */ join->clear(); + + while ((item= it++)) + item->no_rows_in_result(); } if (join->having && join->having->val_int() == 0) error= -1; // Didn't satisfy having |