Commit f5bb5f7f authored by Sergey Petrunya's avatar Sergey Petrunya

[No BUG#] Fixes for problems discovered when running mysql-trunk's subquery testsuite

parent 52a84a24
...@@ -6768,7 +6768,19 @@ my_decimal *Item_ref::val_decimal(my_decimal *decimal_value) ...@@ -6768,7 +6768,19 @@ my_decimal *Item_ref::val_decimal(my_decimal *decimal_value)
int Item_ref::save_in_field(Field *to, bool no_conversions) int Item_ref::save_in_field(Field *to, bool no_conversions)
{ {
int res; int res;
DBUG_ASSERT(!result_field); if (result_field)
{
if (result_field->is_null())
{
null_value= 1;
res= set_field_to_null_with_conversions(to, no_conversions);
return res;
}
to->set_notnull();
res= field_conv(to, result_field);
null_value= 0;
return res;
}
res= (*ref)->save_in_field(to, no_conversions); res= (*ref)->save_in_field(to, no_conversions);
null_value= (*ref)->null_value; null_value= (*ref)->null_value;
return res; return res;
......
...@@ -1215,6 +1215,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) ...@@ -1215,6 +1215,8 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
{ {
tl->table->tablenr= table_no; tl->table->tablenr= table_no;
tl->table->map= ((table_map)1) << table_no; tl->table->map= ((table_map)1) << table_no;
if (tl->is_jtbm())
tl->jtbm_table_no= tl->table->map;
SELECT_LEX *old_sl= tl->select_lex; SELECT_LEX *old_sl= tl->select_lex;
tl->select_lex= parent_join->select_lex; tl->select_lex= parent_join->select_lex;
for (TABLE_LIST *emb= tl->embedding; for (TABLE_LIST *emb= tl->embedding;
...@@ -3106,11 +3108,15 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab) ...@@ -3106,11 +3108,15 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab)
if (item_eq) if (item_eq)
{ {
List_iterator<Item> it(item_eq->equal_items); List_iterator<Item> it(item_eq->equal_items);
/* We're interested in field items only */
if (item_eq->get_const())
it++;
Item *item; Item *item;
while ((item= it++)) while ((item= it++))
{ {
if (!(item->used_tables() & ~emb_sj_nest->sj_inner_tables)) if (!(item->used_tables() & ~emb_sj_nest->sj_inner_tables))
{ {
DBUG_ASSERT(item->real_item()->type() == Item::FIELD_ITEM);
copy_to= ((Item_field *) (item->real_item()))->field; copy_to= ((Item_field *) (item->real_item()))->field;
break; break;
} }
......
...@@ -1766,6 +1766,7 @@ struct TABLE_LIST ...@@ -1766,6 +1766,7 @@ struct TABLE_LIST
*/ */
char *get_table_name() { return view != NULL ? view_name.str : table_name; } char *get_table_name() { return view != NULL ? view_name.str : table_name; }
bool is_active_sjm(); bool is_active_sjm();
bool is_jtbm() { return test(jtbm_subselect!=NULL); }
st_select_lex_unit *get_unit(); st_select_lex_unit *get_unit();
st_select_lex *get_single_select(); st_select_lex *get_single_select();
void wrap_into_nested_join(List<TABLE_LIST> &join_list); void wrap_into_nested_join(List<TABLE_LIST> &join_list);
......
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