fixed bug of lack of fix_fields call (after merge bugfix (SCRUM))

fixed bug in Item_sum
fixed bug in dependence remover
after merge fix
parent 8c0ba5de
...@@ -1347,7 +1347,7 @@ a ...@@ -1347,7 +1347,7 @@ a
1 1
2 2
10 10
drop table t1,t2; drop table t1,t2,t3;
create table t2 (a int, b int); create table t2 (a int, b int);
create table t3 (a int); create table t3 (a int);
insert into t3 values (6),(7),(3); insert into t3 values (6),(7),(3);
......
...@@ -384,3 +384,17 @@ is_in_group user_name group_name id ...@@ -384,3 +384,17 @@ is_in_group user_name group_name id
0 Tester Group A NULL 0 Tester Group A NULL
0 Tester Group B NULL 0 Tester Group B NULL
drop table t1, t2, t3; drop table t1, t2, t3;
create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
pla_id matintnum
100 a
101 a
102 a
103 b
104 b
105 c
0 0
drop table t1, t2;
...@@ -900,7 +900,7 @@ insert into t1 values (1),(2),(3),(4); ...@@ -900,7 +900,7 @@ insert into t1 values (1),(2),(3),(4);
insert into t2 values (10),(20),(30),(40); insert into t2 values (10),(20),(30),(40);
insert into t3 values (1),(2),(10),(50); insert into t3 values (1),(2),(10),(50);
select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
drop table t1,t2; drop table t1,t2,t3;
# #
# correct ALL optimisation # correct ALL optimisation
......
...@@ -236,3 +236,13 @@ insert into t2 (group_name) values ('Group B'); ...@@ -236,3 +236,13 @@ insert into t2 (group_name) values ('Group B');
insert into t3 (user_id, group_id) values (1,1); insert into t3 (user_id, group_id) values (1,1);
select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c; select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c;
drop table t1, t2, t3; drop table t1, t2, t3;
#
# fix_fields problem
#
create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
drop table t1, t2;
...@@ -99,7 +99,7 @@ bool Item_ident::remove_dependence_processor(byte * arg) ...@@ -99,7 +99,7 @@ bool Item_ident::remove_dependence_processor(byte * arg)
DBUG_ENTER("Item_ident::remove_dependence_processor"); DBUG_ENTER("Item_ident::remove_dependence_processor");
if (depended_from == (st_select_lex *) arg) if (depended_from == (st_select_lex *) arg)
depended_from= 0; depended_from= 0;
DBUG_RETURN(1); DBUG_RETURN(0);
} }
......
...@@ -195,6 +195,7 @@ class Item { ...@@ -195,6 +195,7 @@ class Item {
} }
virtual bool remove_dependence_processor(byte * arg) { return 0; } virtual bool remove_dependence_processor(byte * arg) { return 0; }
virtual bool remove_fixed(byte * arg) { fixed= 0; return 0; }
// Row emulation // Row emulation
virtual uint cols() { return 1; } virtual uint cols() { return 1; }
......
...@@ -206,7 +206,8 @@ class Item_in_subselect :public Item_exists_subselect ...@@ -206,7 +206,8 @@ class Item_in_subselect :public Item_exists_subselect
Item_in_subselect(THD *thd, Item * left_expr, st_select_lex *select_lex); Item_in_subselect(THD *thd, Item * left_expr, st_select_lex *select_lex);
Item_in_subselect(Item_in_subselect *item); Item_in_subselect(Item_in_subselect *item);
Item_in_subselect(): Item_exists_subselect(), abort_on_null(0) {} Item_in_subselect()
:Item_exists_subselect(), abort_on_null(0), upper_not(0) {}
subs_type substype() { return IN_SUBS; } subs_type substype() { return IN_SUBS; }
void reset() void reset()
......
...@@ -118,6 +118,20 @@ Item *Item_sum::get_tmp_table_item(THD *thd) ...@@ -118,6 +118,20 @@ Item *Item_sum::get_tmp_table_item(THD *thd)
return sum_item; return sum_item;
} }
bool Item_sum::walk (Item_processor processor, byte *argument)
{
if (arg_count)
{
Item **arg,**arg_end;
for (arg= args, arg_end= args+arg_count; arg != arg_end; arg++)
{
if ((*arg)->walk(processor, argument))
return 1;
}
}
return (this->*processor)(argument);
}
String * String *
Item_sum_num::val_str(String *str) Item_sum_num::val_str(String *str)
{ {
......
...@@ -82,6 +82,8 @@ class Item_sum :public Item_result_field ...@@ -82,6 +82,8 @@ class Item_sum :public Item_result_field
virtual bool setup(THD *thd) {return 0;} virtual bool setup(THD *thd) {return 0;}
virtual void make_unique() {} virtual void make_unique() {}
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
bool walk (Item_processor processor, byte *argument);
}; };
......
...@@ -625,6 +625,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, ...@@ -625,6 +625,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields,
int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, int setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables,
List<Item> &item, bool set_query_id, List<Item> &item, bool set_query_id,
List<Item> *sum_func_list, bool allow_sum_func); List<Item> *sum_func_list, bool allow_sum_func);
void unfix_item_list(List<Item> item_list);
int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds); int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);
int setup_ftfuncs(SELECT_LEX* select); int setup_ftfuncs(SELECT_LEX* select);
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
......
...@@ -2006,6 +2006,21 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, ...@@ -2006,6 +2006,21 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
DBUG_RETURN(test(thd->net.report_error)); DBUG_RETURN(test(thd->net.report_error));
} }
/*
Mark all items in list as not fixed (0 assigned to 'fixed' field)
SYNOPSYS
unfix_item_list()
item_list - list of items
*/
void unfix_item_list(List<Item> item_list)
{
Item *item;
List_iterator_fast<Item> it(item_list);
while ((item= it++))
item->walk(&Item::remove_fixed, 0);
}
/* /*
Remap table numbers if INSERT ... SELECT Remap table numbers if INSERT ... SELECT
Check also that the 'used keys' and 'ignored keys' exists and set up the Check also that the 'used keys' and 'ignored keys' exists and set up the
......
...@@ -144,6 +144,9 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, ...@@ -144,6 +144,9 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
res= -1; res= -1;
goto exit; goto exit;
} }
// Item list should be fix_fielded yet another time in JOIN::prepare
unfix_item_list(item_list);
bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count= item_list.elements; tmp_table_param.field_count= item_list.elements;
/* /*
......
...@@ -156,6 +156,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, ...@@ -156,6 +156,9 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
setup_fields(thd, select_cursor->ref_pointer_array, first_table, setup_fields(thd, select_cursor->ref_pointer_array, first_table,
item_list, 0, 0, 1)) item_list, 0, 0, 1))
goto err; goto err;
// Item list should be fix_fielded yet another time in JOIN::prepare
unfix_item_list(item_list);
t_and_f= 1; t_and_f= 1;
while((item=it++)) while((item=it++))
{ {
......
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