List:Internals« Previous MessageNext Message »
From:ramil Date:September 15 2005 4:06pm
Subject:bk commit into 5.0 tree (ramil:1.1952) 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.1952 05/09/15 19:06:24 ramil@stripped +3 -0
  a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).

  sql/sql_yacc.yy
    1.423 05/09/15 19:06:15 ramil@stripped +37 -21
    a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).
    - set sel->udf slot before udf_expr_list parsing;
    - if an aggregate function found, increment the sel->in_sum_expr
      in order not to create Item_ref (see simple_ident: for example);
    - decrement sel->in_sum_expr after udf_expr_list parsing.

  sql/sql_lex.h
    1.196 05/09/15 19:06:15 ramil@stripped +1 -0
    a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).
    SELECT_LEX->udf slot introduced.

  sql/sql_lex.cc
    1.168 05/09/15 19:06:15 ramil@stripped +1 -0
    a fix (bug #11553: gives error if aggregate user-defined function in HAVING clause).
    clear udf.

# 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.167/sql/sql_lex.cc	2005-09-03 04:13:10 +05:00
+++ 1.168/sql/sql_lex.cc	2005-09-15 19:06:15 +05:00
@@ -1163,6 +1163,7 @@
   select_limit= 0;      /* denotes the default limit = HA_POS_ERROR */
   offset_limit= 0;      /* denotes the default offset = 0 */
   with_sum_func= 0;
+  udf= NULL;
 }
 
 /*

--- 1.195/sql/sql_lex.h	2005-09-03 04:13:10 +05:00
+++ 1.196/sql/sql_lex.h	2005-09-15 19:06:15 +05:00
@@ -557,6 +557,7 @@
   bool no_wrap_view_item;
   /* exclude this select from check of unique_table() */
   bool exclude_from_table_unique_test;
+  udf_func *udf;
 
   void init_query();
   void init_select();

--- 1.422/sql/sql_yacc.yy	2005-09-13 22:17:35 +05:00
+++ 1.423/sql/sql_yacc.yy	2005-09-15 19:06:15 +05:00
@@ -4766,27 +4766,43 @@
 	      $$= new Item_func_sp(Lex->current_context(), name);
 	    lex->safe_to_cache_query=0;
 	  }
-	| IDENT_sys '(' udf_expr_list ')'
+	| IDENT_sys '(' 
+          {
+#ifdef HAVE_DLOPEN
+            SELECT_LEX *sel= Select;
+            if (using_udf_functions && 
+                (sel->udf= find_udf($1.str, $1.length)) &&
+                sel->udf->type == UDFTYPE_AGGREGATE)
+            {
+               sel->in_sum_expr++;
+            }
+#endif
+          }
+          udf_expr_list ')'
           {
 #ifdef HAVE_DLOPEN
-            udf_func *udf;
             SELECT_LEX *sel= Select;
 
-            if (using_udf_functions && (udf=find_udf($1.str, $1.length)))
+            if (sel->udf)
             {
+              udf_func *udf= sel->udf;
+
+              if (udf->type == UDFTYPE_AGGREGATE)
+                sel->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);
                 }
@@ -4794,15 +4810,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);
                 }
@@ -4810,15 +4826,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);
                 }
@@ -4826,15 +4842,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);
                 }
@@ -4850,8 +4866,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.1952) BUG#11553ramil15 Sep