MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:March 27 2007 4:48pm
Subject:bk commit into 5.0 tree (igor:1.2421) BUG#27348
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-27 09:48:10-07:00, igor@stripped +3 -0
  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.
   

  mysql-test/r/subselect.result@stripped, 2007-03-27 09:48:07-07:00, igor@stripped +23 -0
    Added a test case for bug #27348.

  mysql-test/t/subselect.test@stripped, 2007-03-27 09:48:07-07:00, igor@stripped +27 -0
    Added a test case for bug #27348.

  sql/item_sum.cc@stripped, 2007-03-27 09:48:07-07:00, igor@stripped +5 -2
    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
    interprets 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.
     

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug27348

--- 1.201/sql/item_sum.cc	2007-03-27 09:48:17 -07:00
+++ 1.202/sql/item_sum.cc	2007-03-27 09:48:17 -07:00
@@ -149,6 +149,8 @@
     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 @@
     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),

--- 1.181/mysql-test/r/subselect.result	2007-03-27 09:48:17 -07:00
+++ 1.182/mysql-test/r/subselect.result	2007-03-27 09:48:17 -07:00
@@ -3924,3 +3924,26 @@
 3	3	4
 1	4	2,2
 DROP table t1,t2;
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
+a
+1
+2
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
+a
+SELECT a FROM t1 t0
+WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
+a
+1
+2
+SET @@sql_mode='ansi';
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
+ERROR HY000: Invalid use of group function
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
+ERROR HY000: Invalid use of group function
+SELECT a FROM t1 t0
+WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
+ERROR HY000: Invalid use of group function
+SET @@sql_mode=default;
+DROP TABLE t1;

--- 1.146/mysql-test/t/subselect.test	2007-03-27 09:48:17 -07:00
+++ 1.147/mysql-test/t/subselect.test	2007-03-27 09:48:17 -07:00
@@ -2782,3 +2782,30 @@
   FROM t1 GROUP BY a;
 
 DROP table t1,t2;
+
+#
+# Bug #27348: SET FUNCTION used in  a subquery from WHERE condition 
+#  
+
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
+
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
+
+SELECT a FROM t1 t0
+  WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
+
+SET @@sql_mode='ansi';
+--error 1111
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 0 GROUP BY a;
+--error 1111
+SELECT a FROM t1 WHERE (SELECT COUNT(b) FROM DUAL) > 1 GROUP BY a;
+
+--error 1111
+SELECT a FROM t1 t0
+  WHERE (SELECT COUNT(t0.b) FROM t1 t WHERE t.b>20) GROUP BY a;
+
+SET @@sql_mode=default;
+
+DROP TABLE t1;
Thread
bk commit into 5.0 tree (igor:1.2421) BUG#27348igor27 Mar