Loading BitKeeper/etc/logging_ok +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ Sinisa@sinisa.nasamreza.org arjen@fred.bitbike.com bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru bell@sanja.is.com.ua bk@admin.bk heikki@donna.mysql.fi heikki@hundin.mysql.fi Loading mysql-test/r/group_by.result +18 −0 Original line number Diff line number Diff line Loading @@ -110,3 +110,21 @@ a count(*) NULL 9 3 b 1 a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) 1 4 2 10 43 6 a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end 1 4 4 10 43 43 a MAX(b) FIELD(MAX(b), '43', '4', '5') 1 4 2 10 43 1 a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5') 1 4 434445 10 43 43434435 a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') 1 4 d 10 43 NULL a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') 1 4 c 10 43 a,b,d,f mysql-test/t/group_by.test +23 −0 Original line number Diff line number Diff line Loading @@ -323,3 +323,26 @@ select a,count(*) from t1 group by a; set option sql_big_tables=1; select a,count(*) from t1 group by a; drop table t1; # # group function arguments in some functions # create table t1 (a int, b int); insert into t1 values (1, 4); insert into t1 values (10, 40); insert into t1 values (1, 4); insert into t1 values (10, 43); insert into t1 values (1, 4); insert into t1 values (10, 41); insert into t1 values (1, 4); insert into t1 values (10, 43); insert into t1 values (1, 4); select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a; select a, MAX(b), CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end from t1 group by a; select a, MAX(b), FIELD(MAX(b), '43', '4', '5') from t1 group by a; select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a; select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a; select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a; drop table t1; sql/item_cmpfunc.cc +42 −1 Original line number Diff line number Diff line Loading @@ -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); } /* Loading Loading @@ -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(); Loading sql/item_cmpfunc.h +2 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ class Item_func_interval :public Item_int_func { return (item->fix_fields(thd,tlist) || Item_func::fix_fields(thd,tlist)); } void split_sum_func(List<Item> &fields); void fix_length_and_dec(); ~Item_func_interval() { delete item; } const char *func_name() const { return "interval"; } Loading Loading @@ -259,6 +260,7 @@ class Item_func_case :public Item_func const char *func_name() const { return "case"; } void print(String *str); bool fix_fields(THD *thd,struct st_table_list *tlist); void split_sum_func(List<Item> &fields); Item *find_item(String *str); }; Loading Loading
BitKeeper/etc/logging_ok +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ Sinisa@sinisa.nasamreza.org arjen@fred.bitbike.com bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru bell@sanja.is.com.ua bk@admin.bk heikki@donna.mysql.fi heikki@hundin.mysql.fi Loading
mysql-test/r/group_by.result +18 −0 Original line number Diff line number Diff line Loading @@ -110,3 +110,21 @@ a count(*) NULL 9 3 b 1 a MAX(b) INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) 1 4 2 10 43 6 a MAX(b) CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end 1 4 4 10 43 43 a MAX(b) FIELD(MAX(b), '43', '4', '5') 1 4 2 10 43 1 a MAX(b) CONCAT_WS(MAX(b), '43', '4', '5') 1 4 434445 10 43 43434435 a MAX(b) ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') 1 4 d 10 43 NULL a MAX(b) MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') 1 4 c 10 43 a,b,d,f
mysql-test/t/group_by.test +23 −0 Original line number Diff line number Diff line Loading @@ -323,3 +323,26 @@ select a,count(*) from t1 group by a; set option sql_big_tables=1; select a,count(*) from t1 group by a; drop table t1; # # group function arguments in some functions # create table t1 (a int, b int); insert into t1 values (1, 4); insert into t1 values (10, 40); insert into t1 values (1, 4); insert into t1 values (10, 43); insert into t1 values (1, 4); insert into t1 values (10, 41); insert into t1 values (1, 4); insert into t1 values (10, 43); insert into t1 values (1, 4); select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a; select a, MAX(b), CASE MAX(b) when 4 then 4 when 43 then 43 else 0 end from t1 group by a; select a, MAX(b), FIELD(MAX(b), '43', '4', '5') from t1 group by a; select a, MAX(b), CONCAT_WS(MAX(b), '43', '4', '5') from t1 group by a; select a, MAX(b), ELT(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f') from t1 group by a; select a, MAX(b), MAKE_SET(MAX(b), 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') from t1 group by a; drop table t1;
sql/item_cmpfunc.cc +42 −1 Original line number Diff line number Diff line Loading @@ -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); } /* Loading Loading @@ -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(); Loading
sql/item_cmpfunc.h +2 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ class Item_func_interval :public Item_int_func { return (item->fix_fields(thd,tlist) || Item_func::fix_fields(thd,tlist)); } void split_sum_func(List<Item> &fields); void fix_length_and_dec(); ~Item_func_interval() { delete item; } const char *func_name() const { return "interval"; } Loading Loading @@ -259,6 +260,7 @@ class Item_func_case :public Item_func const char *func_name() const { return "case"; } void print(String *str); bool fix_fields(THD *thd,struct st_table_list *tlist); void split_sum_func(List<Item> &fields); Item *find_item(String *str); }; Loading