diff options
-rw-r--r-- | sql/filesort.cc | 7 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 10 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 8 | ||||
-rw-r--r-- | sql/multi_range_read.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.cc | 13 |
5 files changed, 20 insertions, 24 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 2bce61ba3f6..58f7ecd51ee 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -50,7 +50,7 @@ if (my_b_write((file),(uchar*) (from),param->ref_length)) \ static uchar *read_buffpek_from_file(IO_CACHE *buffer_file, uint count, uchar *buf); -static ha_rows find_all_keys(Sort_param *param,SQL_SELECT *select, +static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, Filesort_info *fs_info, IO_CACHE *buffer_file, IO_CACHE *tempfile, @@ -294,7 +294,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, param.sort_form= table; param.end=(param.local_sortorder=sortorder)+s_length; - num_rows= find_all_keys(¶m, select, + num_rows= find_all_keys(thd, ¶m, select, &table_sort, &buffpek_pointers, &tempfile, @@ -667,7 +667,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid) HA_POS_ERROR on error. */ -static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select, +static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, Filesort_info *fs_info, IO_CACHE *buffpek_pointers, IO_CACHE *tempfile, @@ -679,7 +679,6 @@ static ha_rows find_all_keys(Sort_param *param, SQL_SELECT *select, uchar *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; my_off_t record; TABLE *sort_form; - THD *thd= current_thd; handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a1926756f13..60708432bed 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -5628,14 +5628,14 @@ Item *Item_bool_rowready_func2::negated_item() of the type Item_field or Item_direct_view_ref(Item_field). */ -Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item) +Item_equal::Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item) : Item_bool_func(), eval_item(0), cond_false(0), cond_true(0), context_field(NULL), link_equal_fields(FALSE) { const_item_cache= 0; with_const= with_const_item; - equal_items.push_back(f1); - equal_items.push_back(f2); + equal_items.push_back(f1, thd_arg->mem_root); + equal_items.push_back(f2, thd_arg->mem_root); compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT; upper_levels= NULL; sargable= TRUE; @@ -5654,7 +5654,7 @@ Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item) outer join). */ -Item_equal::Item_equal(Item_equal *item_equal) +Item_equal::Item_equal(THD *thd_arg, Item_equal *item_equal) : Item_bool_func(), eval_item(0), cond_false(0), cond_true(0), context_field(NULL), link_equal_fields(FALSE) { @@ -5663,7 +5663,7 @@ Item_equal::Item_equal(Item_equal *item_equal) Item *item; while ((item= li++)) { - equal_items.push_back(item); + equal_items.push_back(item, thd_arg->mem_root); } with_const= item_equal->with_const; compare_as_dates= item_equal->compare_as_dates; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index f2d0032600b..b077a52279d 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1904,12 +1904,8 @@ public: COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */ - inline Item_equal() - : Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0), - context_field(NULL) - { const_item_cache=0; sargable= TRUE; } - Item_equal(Item *f1, Item *f2, bool with_const_item); - Item_equal(Item_equal *item_equal); + Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item); + Item_equal(THD *thd_arg, Item_equal *item_equal); /* Currently the const item is always the first in the list of equal items */ inline Item* get_const() { return with_const ? equal_items.head() : NULL; } void add_const(THD *thd, Item *c, Item *f = NULL); diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 61f344d8689..6e8428f1aad 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -62,7 +62,7 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, range_seq_t seq_it; ha_rows rows, total_rows= 0; uint n_ranges=0; - THD *thd= current_thd; + THD *thd= table->in_use; /* Default MRR implementation doesn't need buffer */ *bufsz= 0; @@ -814,7 +814,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf) { - THD *thd= current_thd; + THD *thd= h_arg->get_table()->in_use; int res; Key_parameters keypar; uint UNINIT_VAR(key_buff_elem_size); /* set/used when do_sort_keys==TRUE */ @@ -1573,7 +1573,7 @@ bool DsMrr_impl::choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, { Cost_estimate dsmrr_cost; bool res; - THD *thd= current_thd; + THD *thd= primary_file->get_table()->in_use; TABLE_SHARE *share= primary_file->get_table_share(); bool doing_cpk_scan= check_cpk_scan(thd, share, keyno, *flags); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0372a06c469..97bacc571b6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12502,14 +12502,14 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, if (left_copyfl) { /* left_item_equal of an upper level contains left_item */ - left_item_equal= new (thd->mem_root) Item_equal(left_item_equal); + left_item_equal= new (thd->mem_root) Item_equal(thd, left_item_equal); left_item_equal->set_context_field(((Item_field*) left_item)); cond_equal->current_level.push_back(left_item_equal); } if (right_copyfl) { /* right_item_equal of an upper level contains right_item */ - right_item_equal= new (thd->mem_root) Item_equal(right_item_equal); + right_item_equal= new (thd->mem_root) Item_equal(thd, right_item_equal); right_item_equal->set_context_field(((Item_field*) right_item)); cond_equal->current_level.push_back(right_item_equal); } @@ -12537,7 +12537,8 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, else { /* None of the fields was found in multiple equalities */ - Item_equal *item_equal= new (thd->mem_root) Item_equal(orig_left_item, + Item_equal *item_equal= new (thd->mem_root) Item_equal(thd, + orig_left_item, orig_right_item, FALSE); item_equal->set_context_field((Item_field*)left_item); @@ -12596,7 +12597,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, field_item->field, ©fl); if (copyfl) { - item_equal= new (thd->mem_root) Item_equal(item_equal); + item_equal= new (thd->mem_root) Item_equal(thd, item_equal); cond_equal->current_level.push_back(item_equal); item_equal->set_context_field(field_item); } @@ -12611,8 +12612,8 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, } else { - item_equal= new (thd->mem_root) Item_equal(const_item, orig_field_item, - TRUE); + item_equal= new (thd->mem_root) Item_equal(thd, const_item, + orig_field_item, TRUE); item_equal->set_context_field(field_item); cond_equal->current_level.push_back(item_equal, thd->mem_root); } |