@@ -299,6 +299,7 @@ bool Item_in_subselect::finalize_materialization_transform(JOIN *join)
299
299
For some reason we cannot use materialization for this IN predicate.
300
300
Delete all materialization-related objects, and return error.
301
301
*/
302
+ new_engine->cleanup ();
302
303
delete new_engine;
303
304
return true ;
304
305
}
@@ -3837,19 +3838,19 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3837
3838
QEP_TAB_standalone *tmp_tab_st= new (thd->mem_root ) QEP_TAB_standalone;
3838
3839
if (tmp_tab_st == NULL )
3839
3840
DBUG_RETURN (TRUE );
3840
- QEP_TAB * const tmp_tab = &tmp_tab_st->as_QEP_TAB ();
3841
- tmp_tab ->set_table (tmp_table);
3842
- tmp_tab ->ref ().key = 0 ; /* The only temp table index. */
3843
- tmp_tab ->ref ().key_length = tmp_key->key_length ;
3844
- if (!(tmp_tab ->ref ().key_buff =
3841
+ tab = &tmp_tab_st->as_QEP_TAB ();
3842
+ tab ->set_table (tmp_table);
3843
+ tab ->ref ().key = 0 ; /* The only temp table index. */
3844
+ tab ->ref ().key_length = tmp_key->key_length ;
3845
+ if (!(tab ->ref ().key_buff =
3845
3846
(uchar*) thd->mem_calloc (key_length)) ||
3846
- !(tmp_tab ->ref ().key_copy =
3847
+ !(tab ->ref ().key_copy =
3847
3848
(store_key**) thd->alloc ((sizeof (store_key*) * tmp_key_parts))) ||
3848
- !(tmp_tab ->ref ().items =
3849
+ !(tab ->ref ().items =
3849
3850
(Item**) thd->alloc (sizeof (Item*) * tmp_key_parts)))
3850
3851
DBUG_RETURN (TRUE );
3851
3852
3852
- uchar *cur_ref_buff= tmp_tab ->ref ().key_buff ;
3853
+ uchar *cur_ref_buff= tab ->ref ().key_buff ;
3853
3854
3854
3855
/*
3855
3856
Like semijoin-materialization-lookup (see create_subquery_equalities()),
@@ -3897,11 +3898,11 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3897
3898
Item_field *right_col_item;
3898
3899
Field *field= tmp_table->visible_field_ptr ()[part_no];
3899
3900
const bool nullable= field->real_maybe_null ();
3900
- tmp_tab ->ref ().items [part_no]= item_in->left_expr ->element_index (part_no);
3901
+ tab ->ref ().items [part_no]= item_in->left_expr ->element_index (part_no);
3901
3902
3902
3903
if (!(right_col_item= new Item_field (thd, context,
3903
3904
field)) ||
3904
- !(eq_cond= new Item_func_eq (tmp_tab ->ref ().items [part_no],
3905
+ !(eq_cond= new Item_func_eq (tab ->ref ().items [part_no],
3905
3906
right_col_item)) ||
3906
3907
((Item_cond_and*)cond)->add (eq_cond))
3907
3908
{
@@ -3911,15 +3912,15 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3911
3912
}
3912
3913
3913
3914
if (tmp_table->hash_field )
3914
- tmp_tab ->ref ().key_copy [part_no]=
3915
+ tab ->ref ().key_copy [part_no]=
3915
3916
new store_key_hash_item (thd, field,
3916
3917
cur_ref_buff,
3917
3918
0 ,
3918
3919
field->pack_length (),
3919
- tmp_tab ->ref ().items [part_no],
3920
+ tab ->ref ().items [part_no],
3920
3921
&hash);
3921
3922
else
3922
- tmp_tab ->ref ().key_copy [part_no]=
3923
+ tab ->ref ().key_copy [part_no]=
3923
3924
new store_key_item (thd, field,
3924
3925
/* TODO:
3925
3926
the NULL byte is taken into account in
@@ -3930,20 +3931,20 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3930
3931
cur_ref_buff + (nullable ? 1 : 0 ),
3931
3932
nullable ? cur_ref_buff : 0 ,
3932
3933
key_parts[part_no].length ,
3933
- tmp_tab ->ref ().items [part_no]);
3934
+ tab ->ref ().items [part_no]);
3934
3935
if (nullable && // nullable column in tmp table,
3935
3936
// and UNKNOWN should not be interpreted as FALSE
3936
3937
!item_in->is_top_level_item ())
3937
3938
{
3938
3939
// It must be the single column, or we wouldn't be here
3939
3940
DBUG_ASSERT (tmp_key_parts == 1 );
3940
3941
// Be ready to search for NULL into inner column:
3941
- tmp_tab ->ref ().null_ref_key = cur_ref_buff;
3942
+ tab ->ref ().null_ref_key = cur_ref_buff;
3942
3943
mat_table_has_nulls= NEX_UNKNOWN;
3943
3944
}
3944
3945
else
3945
3946
{
3946
- tmp_tab ->ref ().null_ref_key = NULL ;
3947
+ tab ->ref ().null_ref_key = NULL ;
3947
3948
mat_table_has_nulls= NEX_IRRELEVANT_OR_FALSE;
3948
3949
}
3949
3950
@@ -3952,15 +3953,12 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3952
3953
else
3953
3954
cur_ref_buff+= key_parts[part_no].store_length ;
3954
3955
}
3955
- tmp_tab ->ref ().key_err = 1 ;
3956
- tmp_tab ->ref ().key_parts = tmp_key_parts;
3956
+ tab ->ref ().key_err = 1 ;
3957
+ tab ->ref ().key_parts = tmp_key_parts;
3957
3958
3958
3959
if (cond->fix_fields (thd, &cond))
3959
3960
DBUG_RETURN (TRUE );
3960
3961
3961
- // Set 'tab' only when function cannot fail, because of assert in destructor
3962
- tab= tmp_tab;
3963
-
3964
3962
/*
3965
3963
Create and optimize the JOIN that will be used to materialize
3966
3964
the subquery if not yet created.
0 commit comments