MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:ramil Date:September 20 2005 9:28am
Subject:bk commit into 5.0 tree (ramil:1.1987) BUG#11553
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram 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
  1.1987 05/09/20 14:28:23 ramil@stripped +1 -0
  a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).

  sql/sql_yacc.yy
    1.426 05/09/20 14:28:14 ramil@stripped +42 -21
    a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).
      - call inc_in_sum_expr() before udf_expr_list rule parsing in case of
        aggregate udf functions.

# 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:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/5.0.b11553

--- 1.425/sql/sql_yacc.yy	2005-09-14 15:34:43 +05:00
+++ 1.426/sql/sql_yacc.yy	2005-09-20 14:28:14 +05:00
@@ -4779,27 +4779,48 @@
 	      $$= new Item_func_sp(Lex->current_context(), name);
 	    lex->safe_to_cache_query=0;
 	  }
-	| IDENT_sys '(' udf_expr_list ')'
+	| IDENT_sys '(' 
           {
 #ifdef HAVE_DLOPEN
-            udf_func *udf;
+            udf_func *udf= 0;
+            if (using_udf_functions &&
+                (udf= find_udf($1.str, $1.length)) &&
+                udf->type == UDFTYPE_AGGREGATE)
+            {
+              LEX *lex= Lex;
+              if (lex->current_select->inc_in_sum_expr())
+              {
+                yyerror(ER(ER_SYNTAX_ERROR));
+                YYABORT;
+              }
+            }
+            $<udf>$= udf;
+#endif
+          }
+          udf_expr_list ')'
+          {
+#ifdef HAVE_DLOPEN
+            udf_func *udf= $<udf>3;
             SELECT_LEX *sel= Select;
 
-            if (using_udf_functions && (udf=find_udf($1.str, $1.length)))
+            if (udf)
             {
+              if (udf->type == UDFTYPE_AGGREGATE)
+                Select->in_sum_expr--;
+
               switch (udf->returns) {
               case STRING_RESULT:
                 if (udf->type == UDFTYPE_FUNCTION)
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_func_udf_str(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_func_udf_str(udf, *$4);
                   else
                     $$ = new Item_func_udf_str(udf);
                 }
                 else
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_sum_udf_str(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_sum_udf_str(udf, *$4);
                   else
                     $$ = new Item_sum_udf_str(udf);
                 }
@@ -4807,15 +4828,15 @@
               case REAL_RESULT:
                 if (udf->type == UDFTYPE_FUNCTION)
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_func_udf_float(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_func_udf_float(udf, *$4);
                   else
                     $$ = new Item_func_udf_float(udf);
                 }
                 else
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_sum_udf_float(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_sum_udf_float(udf, *$4);
                   else
                     $$ = new Item_sum_udf_float(udf);
                 }
@@ -4823,15 +4844,15 @@
               case INT_RESULT:
                 if (udf->type == UDFTYPE_FUNCTION)
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_func_udf_int(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_func_udf_int(udf, *$4);
                   else
                     $$ = new Item_func_udf_int(udf);
                 }
                 else
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_sum_udf_int(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_sum_udf_int(udf, *$4);
                   else
                     $$ = new Item_sum_udf_int(udf);
                 }
@@ -4839,15 +4860,15 @@
               case DECIMAL_RESULT:
                 if (udf->type == UDFTYPE_FUNCTION)
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_func_udf_decimal(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_func_udf_decimal(udf, *$4);
                   else
                     $$ = new Item_func_udf_decimal(udf);
                 }
                 else
                 {
-                  if ($3 != NULL)
-                    $$ = new Item_sum_udf_decimal(udf, *$3);
+                  if ($4 != NULL)
+                    $$ = new Item_sum_udf_decimal(udf, *$4);
                   else
                     $$ = new Item_sum_udf_decimal(udf);
                 }
@@ -4863,8 +4884,8 @@
               sp_name *name= sp_name_current_db_new(YYTHD, $1);
 
               sp_add_used_routine(lex, YYTHD, name, TYPE_ENUM_FUNCTION);
-              if ($3)
-                $$= new Item_func_sp(Lex->current_context(), name, *$3);
+              if ($4)
+                $$= new Item_func_sp(Lex->current_context(), name, *$4);
               else
                 $$= new Item_func_sp(Lex->current_context(), name);
 	      lex->safe_to_cache_query=0;
Thread
bk commit into 5.0 tree (ramil:1.1987) BUG#11553ramil20 Sep