1
- /* Copyright (c) 2002, 2014 , Oracle and/or its affiliates. All rights
1
+ /* Copyright (c) 2002, 2015 , Oracle and/or its affiliates. All rights
2
2
reserved.
3
3
4
4
This program is free software; you can redistribute it and/or modify
@@ -295,6 +295,7 @@ bool Item_in_subselect::finalize_materialization_transform(JOIN *join)
295
295
For some reason we cannot use materialization for this IN predicate.
296
296
Delete all materialization-related objects, and return error.
297
297
*/
298
+ new_engine->cleanup ();
298
299
delete new_engine;
299
300
return true ;
300
301
}
@@ -2747,7 +2748,7 @@ bool subselect_single_select_engine::exec()
2747
2748
if (join->optimize ())
2748
2749
{
2749
2750
optimize_error= true ;
2750
- rc= join-> error ? join-> error : 1 ;
2751
+ rc= 1 ;
2751
2752
goto exit ;
2752
2753
}
2753
2754
if (item->engine_changed )
@@ -3560,21 +3561,20 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3560
3561
- here we initialize only those members that are used by
3561
3562
subselect_indexsubquery_engine, so these objects are incomplete.
3562
3563
*/
3563
- JOIN_TAB * const tmp_tab= new (thd->mem_root ) JOIN_TAB;
3564
- if (tmp_tab == NULL )
3564
+ if (!(tab= new (thd->mem_root ) JOIN_TAB))
3565
3565
DBUG_RETURN (TRUE );
3566
- tmp_tab ->table = tmp_table;
3567
- tmp_tab ->ref .key = 0 ; /* The only temp table index. */
3568
- tmp_tab ->ref .key_length = tmp_key->key_length ;
3569
- if (!(tmp_tab ->ref .key_buff =
3566
+ tab ->table = tmp_table;
3567
+ tab ->ref .key = 0 ; /* The only temp table index. */
3568
+ tab ->ref .key_length = tmp_key->key_length ;
3569
+ if (!(tab ->ref .key_buff =
3570
3570
(uchar*) thd->calloc (ALIGN_SIZE (tmp_key->key_length ) * 2 )) ||
3571
- !(tmp_tab ->ref .key_copy =
3571
+ !(tab ->ref .key_copy =
3572
3572
(store_key**) thd->alloc ((sizeof (store_key*) * tmp_key_parts))) ||
3573
- !(tmp_tab ->ref .items =
3573
+ !(tab ->ref .items =
3574
3574
(Item**) thd->alloc (sizeof (Item*) * tmp_key_parts)))
3575
3575
DBUG_RETURN (TRUE );
3576
3576
3577
- uchar *cur_ref_buff= tmp_tab ->ref .key_buff ;
3577
+ uchar *cur_ref_buff= tab ->ref .key_buff ;
3578
3578
3579
3579
/*
3580
3580
Like semijoin-materialization-lookup (see create_subquery_equalities()),
@@ -3618,11 +3618,11 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3618
3618
/* Item for the corresponding field from the materialized temp table. */
3619
3619
Item_field *right_col_item;
3620
3620
const bool nullable= key_parts[part_no].field ->real_maybe_null ();
3621
- tmp_tab ->ref .items [part_no]= item_in->left_expr ->element_index (part_no);
3621
+ tab ->ref .items [part_no]= item_in->left_expr ->element_index (part_no);
3622
3622
3623
3623
if (!(right_col_item= new Item_field (thd, context,
3624
3624
key_parts[part_no].field )) ||
3625
- !(eq_cond= new Item_func_eq (tmp_tab ->ref .items [part_no],
3625
+ !(eq_cond= new Item_func_eq (tab ->ref .items [part_no],
3626
3626
right_col_item)) ||
3627
3627
((Item_cond_and*)cond)->add (eq_cond))
3628
3628
{
@@ -3631,7 +3631,7 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3631
3631
DBUG_RETURN (TRUE );
3632
3632
}
3633
3633
3634
- tmp_tab ->ref .key_copy [part_no]=
3634
+ tab ->ref .key_copy [part_no]=
3635
3635
new store_key_item (thd, key_parts[part_no].field ,
3636
3636
/* TODO:
3637
3637
the NULL byte is taken into account in
@@ -3642,34 +3642,31 @@ bool subselect_hash_sj_engine::setup(List<Item> *tmp_columns)
3642
3642
cur_ref_buff + (nullable ? 1 : 0 ),
3643
3643
nullable ? cur_ref_buff : 0 ,
3644
3644
key_parts[part_no].length ,
3645
- tmp_tab ->ref .items [part_no]);
3645
+ tab ->ref .items [part_no]);
3646
3646
if (nullable && // nullable column in tmp table,
3647
3647
// and UNKNOWN should not be interpreted as FALSE
3648
3648
!item_in->is_top_level_item ())
3649
3649
{
3650
3650
// It must be the single column, or we wouldn't be here
3651
3651
DBUG_ASSERT (tmp_key_parts == 1 );
3652
3652
// Be ready to search for NULL into inner column:
3653
- tmp_tab ->ref .null_ref_key = cur_ref_buff;
3653
+ tab ->ref .null_ref_key = cur_ref_buff;
3654
3654
mat_table_has_nulls= NEX_UNKNOWN;
3655
3655
}
3656
3656
else
3657
3657
{
3658
- tmp_tab ->ref .null_ref_key = NULL ;
3658
+ tab ->ref .null_ref_key = NULL ;
3659
3659
mat_table_has_nulls= NEX_IRRELEVANT_OR_FALSE;
3660
3660
}
3661
3661
3662
3662
cur_ref_buff+= key_parts[part_no].store_length ;
3663
3663
}
3664
- tmp_tab ->ref .key_err = 1 ;
3665
- tmp_tab ->ref .key_parts = tmp_key_parts;
3664
+ tab ->ref .key_err = 1 ;
3665
+ tab ->ref .key_parts = tmp_key_parts;
3666
3666
3667
3667
if (cond->fix_fields (thd, &cond))
3668
3668
DBUG_RETURN (TRUE );
3669
3669
3670
- // Set 'tab' only when function cannot fail, because of assert in destructor
3671
- tab= tmp_tab;
3672
-
3673
3670
/*
3674
3671
Create and optimize the JOIN that will be used to materialize
3675
3672
the subquery if not yet created.
0 commit comments