a fix for a bug with HAVING sum_func IN (...)

parent c2dcead1
......@@ -30,6 +30,13 @@ Documentation 0
Host communication 0
kkkkkkkkkkk lllllllllll 3
Test Procedures 0
value description COUNT(bug_id)
BBBBBBBBBBBBB - conversion 2
BBBBBBBBBBBBB - eeeeeeeee 0
BBBBBBBBBBBBB - generic 2
Documentation 0
Host communication 0
Test Procedures 0
1+1 a count(*)
2 a 0
1+1 a count(*)
......
......@@ -206,6 +206,7 @@ INSERT INTO t2 VALUES ('Web Interface','AAAAAAAA-AAA','id0001','','');
INSERT INTO t2 VALUES ('Host communication','AAAAA','id0001','','');
select value,description,bug_id from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA";
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value;
select value,description,COUNT(bug_id) from t2 left join t1 on t2.program=t1.product and t2.value=t1.component where program="AAAAA" group by value having COUNT(bug_id) IN (0,2);
drop table t1,t2;
......
......@@ -1029,6 +1029,14 @@ void Item_func_in::update_used_tables()
used_tables_cache|=item->used_tables();
const_item_cache&=item->const_item();
}
void Item_func_in::split_sum_func(List<Item> &fields)
{
if (item->used_tables() || item->type() == SUM_FUNC_ITEM)
{
fields.push_front(item);
item=new Item_ref((Item**) fields.head_ref(),0,item->name);
}
}
longlong Item_func_bit_or::val_int()
......
......@@ -410,6 +410,7 @@ class Item_func_in :public Item_int_func
longlong val_int();
bool fix_fields(THD *thd,struct st_table_list *tlist)
{
with_sum_func= with_sum_func || item->with_sum_func;
return (item->fix_fields(thd,tlist) || Item_func::fix_fields(thd,tlist));
}
void fix_length_and_dec();
......@@ -421,6 +422,7 @@ class Item_func_in :public Item_int_func
enum Functype functype() const { return IN_FUNC; }
const char *func_name() const { return " IN "; }
void update_used_tables();
void split_sum_func(List<Item> &fields);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment