summaryrefslogtreecommitdiff
path: root/sql/sql_yacc.yy
diff options
context:
space:
mode:
authorunknown <ramil@mysql.com>2005-09-22 11:45:16 +0500
committerunknown <ramil@mysql.com>2005-09-22 11:45:16 +0500
commit072e00a4533202542ba706b537d54e33e035237d (patch)
tree321bf31c96432ae7992d4d1831cecb3ae43a8735 /sql/sql_yacc.yy
parent0870daca166dc12d1b761911b3ff2433dda1ae28 (diff)
downloadmariadb-git-072e00a4533202542ba706b537d54e33e035237d.tar.gz
a fix (#11553: gives error if aggregate user-defined function in HAVING clause).
sql/sql_yacc.yy: a fix (#11553: gives error if aggregate user-defined function in HAVING clause). udf_sum_expr_list rule introduced and used for aggregate udf functions: - call inc_in_sum_expr() before udf_expr_list parsing (as in_sum_expr rule does).
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r--sql/sql_yacc.yy24
1 files changed, 20 insertions, 4 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e29aaac8f94..a85b877838c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -644,7 +644,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
NUM_literal
%type <item_list>
- expr_list udf_expr_list when_list ident_list ident_list_arg
+ expr_list udf_expr_list udf_sum_expr_list when_list ident_list
+ ident_list_arg
%type <key_type>
key_type opt_unique_or_fulltext constraint_key_type
@@ -3137,21 +3138,21 @@ simple_expr:
{ $$= new Item_func_trim($5,$3); }
| TRUNCATE_SYM '(' expr ',' expr ')'
{ $$= new Item_func_round($3,$5,1); }
- | UDA_CHAR_SUM '(' udf_expr_list ')'
+ | UDA_CHAR_SUM '(' udf_sum_expr_list ')'
{
if ($3 != NULL)
$$ = new Item_sum_udf_str($1, *$3);
else
$$ = new Item_sum_udf_str($1);
}
- | UDA_FLOAT_SUM '(' udf_expr_list ')'
+ | UDA_FLOAT_SUM '(' udf_sum_expr_list ')'
{
if ($3 != NULL)
$$ = new Item_sum_udf_float($1, *$3);
else
$$ = new Item_sum_udf_float($1);
}
- | UDA_INT_SUM '(' udf_expr_list ')'
+ | UDA_INT_SUM '(' udf_sum_expr_list ')'
{
if ($3 != NULL)
$$ = new Item_sum_udf_int($1, *$3);
@@ -3289,6 +3290,21 @@ udf_expr_list:
/* empty */ { $$= NULL; }
| expr_list { $$= $1;};
+udf_sum_expr_list:
+ {
+ LEX *lex= Lex;
+ if (lex->current_select->inc_in_sum_expr())
+ {
+ yyerror(ER(ER_SYNTAX_ERROR));
+ YYABORT;
+ }
+ }
+ udf_expr_list
+ {
+ Select->in_sum_expr--;
+ $$= $2;
+ };
+
sum_expr:
AVG_SYM '(' in_sum_expr ')'
{ $$=new Item_sum_avg($3); }