summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-03-27 09:48:10 -0700
committerigor@olga.mysql.com <>2007-03-27 09:48:10 -0700
commitadc07255ee9f88cc7521afa26b31545dd1d66d9c (patch)
treecbad086848f82ca4ef82b4b350ce3a4eae03f168 /sql/item_sum.cc
parentce9cc47a731325f8c1e0fac4bfe955bb3dc00d68 (diff)
downloadmariadb-git-adc07255ee9f88cc7521afa26b31545dd1d66d9c.tar.gz
Fixed bug #27348.
If a set function with a outer reference s(outer_ref) cannot be aggregated the outer query against which the reference has been resolved then MySQL interpretes s(outer_ref) in the same way as it would interpret s(const). Hovever the standard requires throwing an error in this situation. Added some code to support this requirement in ansi mode. Corrected another minor bug in Item_sum::check_sum_func.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 368dc9a7d38..e10357dc0e0 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -149,6 +149,8 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
if (register_sum_func(thd, ref))
return TRUE;
invalid= aggr_level < 0 && !(allow_sum_func & (1 << nest_level));
+ if (!invalid && thd->variables.sql_mode & MODE_ANSI)
+ invalid= aggr_level < 0 && max_arg_level < nest_level;
}
if (!invalid && aggr_level < 0)
{
@@ -164,8 +166,9 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref)
Additionally we have to check whether possible nested set functions
are acceptable here: they are not, if the level of aggregation of
some of them is less than aggr_level.
- */
- invalid= aggr_level <= max_sum_func_level;
+ */
+ if (!invalid)
+ invalid= aggr_level <= max_sum_func_level;
if (invalid)
{
my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE),