Skip to content

Commit 2690b7e

Browse files
author
Sreeharsha Ramanavarapu
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents a7a5eb4 + b3ccaee commit 2690b7e

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

sql/item_subselect.cc

+19-21
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ bool Item_in_subselect::finalize_materialization_transform(JOIN *join)
299299
For some reason we cannot use materialization for this IN predicate.
300300
Delete all materialization-related objects, and return error.
301301
*/
302+
new_engine->cleanup();
302303
delete new_engine;
303304
return true;
304305
}
@@ -3837,19 +3838,19 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
38373838
QEP_TAB_standalone *tmp_tab_st= new (thd->mem_root) QEP_TAB_standalone;
38383839
if (tmp_tab_st == NULL)
38393840
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=
38453846
(uchar*) thd->mem_calloc(key_length)) ||
3846-
!(tmp_tab->ref().key_copy=
3847+
!(tab->ref().key_copy=
38473848
(store_key**) thd->alloc((sizeof(store_key*) * tmp_key_parts))) ||
3848-
!(tmp_tab->ref().items=
3849+
!(tab->ref().items=
38493850
(Item**) thd->alloc(sizeof(Item*) * tmp_key_parts)))
38503851
DBUG_RETURN(TRUE);
38513852

3852-
uchar *cur_ref_buff= tmp_tab->ref().key_buff;
3853+
uchar *cur_ref_buff= tab->ref().key_buff;
38533854

38543855
/*
38553856
Like semijoin-materialization-lookup (see create_subquery_equalities()),
@@ -3897,11 +3898,11 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
38973898
Item_field *right_col_item;
38983899
Field *field= tmp_table->visible_field_ptr()[part_no];
38993900
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);
39013902

39023903
if (!(right_col_item= new Item_field(thd, context,
39033904
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],
39053906
right_col_item)) ||
39063907
((Item_cond_and*)cond)->add(eq_cond))
39073908
{
@@ -3911,15 +3912,15 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
39113912
}
39123913

39133914
if (tmp_table->hash_field)
3914-
tmp_tab->ref().key_copy[part_no]=
3915+
tab->ref().key_copy[part_no]=
39153916
new store_key_hash_item(thd, field,
39163917
cur_ref_buff,
39173918
0,
39183919
field->pack_length(),
3919-
tmp_tab->ref().items[part_no],
3920+
tab->ref().items[part_no],
39203921
&hash);
39213922
else
3922-
tmp_tab->ref().key_copy[part_no]=
3923+
tab->ref().key_copy[part_no]=
39233924
new store_key_item(thd, field,
39243925
/* TODO:
39253926
the NULL byte is taken into account in
@@ -3930,20 +3931,20 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
39303931
cur_ref_buff + (nullable ? 1 : 0),
39313932
nullable ? cur_ref_buff : 0,
39323933
key_parts[part_no].length,
3933-
tmp_tab->ref().items[part_no]);
3934+
tab->ref().items[part_no]);
39343935
if (nullable && // nullable column in tmp table,
39353936
// and UNKNOWN should not be interpreted as FALSE
39363937
!item_in->is_top_level_item())
39373938
{
39383939
// It must be the single column, or we wouldn't be here
39393940
DBUG_ASSERT(tmp_key_parts == 1);
39403941
// 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;
39423943
mat_table_has_nulls= NEX_UNKNOWN;
39433944
}
39443945
else
39453946
{
3946-
tmp_tab->ref().null_ref_key= NULL;
3947+
tab->ref().null_ref_key= NULL;
39473948
mat_table_has_nulls= NEX_IRRELEVANT_OR_FALSE;
39483949
}
39493950

@@ -3952,15 +3953,12 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
39523953
else
39533954
cur_ref_buff+= key_parts[part_no].store_length;
39543955
}
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;
39573958

39583959
if (cond->fix_fields(thd, &cond))
39593960
DBUG_RETURN(TRUE);
39603961

3961-
// Set 'tab' only when function cannot fail, because of assert in destructor
3962-
tab= tmp_tab;
3963-
39643962
/*
39653963
Create and optimize the JOIN that will be used to materialize
39663964
the subquery if not yet created.

0 commit comments

Comments
 (0)