diff options
author | unknown <bell@sanja.is.com.ua> | 2003-01-29 10:38:56 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-01-29 10:38:56 +0200 |
commit | cec5bc1de7aa1107ec988601de6a3990c6397446 (patch) | |
tree | 6a44df5398a1db055b33e2b93ad62a7e8693ceda /sql/item_cmpfunc.cc | |
parent | 72455300841e1b00c312c3a03ace3bcbd57a4d2f (diff) | |
download | mariadb-git-cec5bc1de7aa1107ec988601de6a3990c6397446.tar.gz |
fixed functions to be able work with group function as argument
made bisone 1.75 compatible code
mysql-test/r/group_by.result:
test of function with agregate function inside
mysql-test/t/group_by.test:
test of function with agregate function inside
sql/item_cmpfunc.cc:
fixed functions to be able work with group function as argument
sql/item_cmpfunc.h:
fixed functions to be able work with group function as argument
sql/item_func.cc:
fixed functions to be able work with group function as argument
sql/item_func.h:
fixed functions to be able work with group function as argument
sql/item_strfunc.cc:
fixed functions to be able work with group function as argument
sql/item_strfunc.h:
fixed functions to be able work with group function as argument
sql/sql_yacc.yy:
made bisone 1.75 compatible code
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c3381eb76ea..e82dc3f90ce 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -287,6 +287,19 @@ void Item_func_interval::fix_length_and_dec() } maybe_null=0; max_length=2; used_tables_cache|=item->used_tables(); + with_sum_func= with_sum_func || item->with_sum_func; +} + +void Item_func_interval::split_sum_func(List<Item> &fields) +{ + if (item->with_sum_func && item->type() != SUM_FUNC_ITEM) + item->split_sum_func(fields); + else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) + { + fields.push_front(item); + item= new Item_ref((Item**) fields.head_ref(), 0, item->name); + } + Item_int_func::split_sum_func(fields); } /* @@ -739,17 +752,45 @@ Item_func_case::fix_fields(THD *thd,TABLE_LIST *tables) { used_tables_cache|=(first_expr)->used_tables(); const_item_cache&= (first_expr)->const_item(); + with_sum_func= with_sum_func || (first_expr)->with_sum_func; } if (else_expr) { used_tables_cache|=(else_expr)->used_tables(); const_item_cache&= (else_expr)->const_item(); + with_sum_func= with_sum_func || (else_expr)->with_sum_func; } if (!else_expr || else_expr->maybe_null) maybe_null=1; // The result may be NULL return 0; } +void Item_func_case::split_sum_func(List<Item> &fields) +{ + if (first_expr) + { + if (first_expr->with_sum_func && first_expr->type() != SUM_FUNC_ITEM) + first_expr->split_sum_func(fields); + else if (first_expr->used_tables() || first_expr->type() == SUM_FUNC_ITEM) + { + fields.push_front(first_expr); + first_expr= new Item_ref((Item**) fields.head_ref(), 0, + first_expr->name); + } + } + if (else_expr) + { + if (else_expr->with_sum_func && else_expr->type() != SUM_FUNC_ITEM) + else_expr->split_sum_func(fields); + else if (else_expr->used_tables() || else_expr->type() == SUM_FUNC_ITEM) + { + fields.push_front(else_expr); + else_expr= new Item_ref((Item**) fields.head_ref(), 0, else_expr->name); + } + } + Item_func::split_sum_func(fields); +} + void Item_func_case::update_used_tables() { Item_func::update_used_tables(); @@ -1038,7 +1079,7 @@ void Item_func_in::split_sum_func(List<Item> &fields) else if (item->used_tables() || item->type() == SUM_FUNC_ITEM) { fields.push_front(item); - item=new Item_ref((Item**) fields.head_ref(),0,item->name); + item= new Item_ref((Item**) fields.head_ref(), 0, item->name); } Item_func::split_sum_func(fields); } |