diff options
author | unknown <monty@mysql.com> | 2005-02-07 18:13:57 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-02-07 18:13:57 +0200 |
commit | d6ed8cd7097391b55936a1dfec248da65e7f64f9 (patch) | |
tree | 3fa14495db5e1376fa69b1a6f662a5e7afdc82da /sql/item_row.cc | |
parent | ad21db5e0727704ee0527c08410bafff4d3150f4 (diff) | |
download | mariadb-git-d6ed8cd7097391b55936a1dfec248da65e7f64f9.tar.gz |
Fixed bug in HAVING when refering to RAND() through alias
(BUG 8216)
mysql-test/r/group_by.result:
New test case
mysql-test/r/user_var.result:
Test changed (to be more correct) with bug fix
mysql-test/t/group_by.test:
Added test for HAVING bug
sql/item_cmpfunc.cc:
Fixed bug in HAVING when refering to RAND()
sql/item_func.cc:
Fixed bug in HAVING when refering to RAND()
sql/item_row.cc:
Fixed bug in HAVING when refering to RAND()
sql/item_strfunc.cc:
Fixed bug in HAVING when refering to RAND()
sql/unireg.h:
Added PSEUDO_TABLES_BITS for easy testing of real table reference
Diffstat (limited to 'sql/item_row.cc')
-rw-r--r-- | sql/item_row.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/item_row.cc b/sql/item_row.cc index 4e4957b980e..0ace0fc0451 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -84,15 +84,20 @@ bool Item_row::fix_fields(THD *thd, TABLE_LIST *tabl, Item **ref) return 0; } + void Item_row::split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields) { Item **arg, **arg_end; for (arg= items, arg_end= items+arg_count; arg != arg_end ; arg++) { - if ((*arg)->with_sum_func && (*arg)->type() != SUM_FUNC_ITEM) - (*arg)->split_sum_func(thd, ref_pointer_array, fields); - else if ((*arg)->used_tables() || (*arg)->type() == SUM_FUNC_ITEM) + Item *item= *arg; + if (item->type() != SUM_FUNC_ITEM && + (item->with_sum_func || + (item->used_tables() & PSEUDO_TABLE_BITS))) + item->split_sum_func(thd, ref_pointer_array, fields); + else if (item->type() == SUM_FUNC_ITEM || + (item->used_tables() && item->type() != REF_ITEM)) { uint el= fields.elements; ref_pointer_array[el]=*arg; |