diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2015-08-11 11:18:38 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2015-08-21 10:40:39 +0400 |
commit | 31e365efae28ba3208e80511c4d18fe11a79541a (patch) | |
tree | f249682cc42490fc86382f5244a051001dc13c9e /sql | |
parent | 4374da63f03abc472f68f42e4e93261a18bfe417 (diff) | |
download | mariadb-git-31e365efae28ba3208e80511c4d18fe11a79541a.tar.gz |
MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)
Added mandatory thd parameter to Item (and all derivative classes) constructor.
Added thd parameter to all routines that may create items.
Also removed "current_thd" from Item::Item. This reduced number of
pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
Diffstat (limited to 'sql')
67 files changed, 2703 insertions, 2453 deletions
diff --git a/sql/events.cc b/sql/events.cc index d1cbd297809..911a683b723 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -639,29 +639,30 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol) if (et->get_create_event(thd, &show_str)) DBUG_RETURN(TRUE); - field_list.push_back(new Item_empty_string("Event", NAME_CHAR_LEN)); + field_list.push_back(new Item_empty_string(thd, "Event", NAME_CHAR_LEN)); if (sql_mode_string_representation(thd, et->sql_mode, &sql_mode)) DBUG_RETURN(TRUE); - field_list.push_back(new Item_empty_string("sql_mode", (uint) sql_mode.length)); + field_list.push_back(new Item_empty_string(thd, "sql_mode", + (uint) sql_mode.length)); tz_name= et->time_zone->get_name(); - field_list.push_back(new Item_empty_string("time_zone", + field_list.push_back(new Item_empty_string(thd, "time_zone", tz_name->length())); - field_list.push_back(new Item_empty_string("Create Event", + field_list.push_back(new Item_empty_string(thd, "Create Event", show_str.length())); field_list.push_back( - new Item_empty_string("character_set_client", MY_CS_NAME_SIZE)); + new Item_empty_string(thd, "character_set_client", MY_CS_NAME_SIZE)); field_list.push_back( - new Item_empty_string("collation_connection", MY_CS_NAME_SIZE)); + new Item_empty_string(thd, "collation_connection", MY_CS_NAME_SIZE)); field_list.push_back( - new Item_empty_string("Database Collation", MY_CS_NAME_SIZE)); + new Item_empty_string(thd, "Database Collation", MY_CS_NAME_SIZE)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/field.cc b/sql/field.cc index 5d45a8d39d1..a65f09acafa 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9987,7 +9987,7 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, /** Create a field suitable for create of table. */ -Create_field::Create_field(Field *old_field,Field *orig_field) +Create_field::Create_field(THD *thd, Field *old_field, Field *orig_field) { field= old_field; field_name=change=old_field->field_name; @@ -10039,7 +10039,6 @@ Create_field::Create_field(Field *old_field,Field *orig_field) case MYSQL_TYPE_YEAR: if (length != 4) { - THD *thd= current_thd; char buff[sizeof("YEAR()") + MY_INT64_NUM_DECIMAL_DIGITS + 1]; my_snprintf(buff, sizeof(buff), "YEAR(%lu)", length); push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, @@ -10098,7 +10097,7 @@ Create_field::Create_field(Field *old_field,Field *orig_field) StringBuffer<MAX_FIELD_WIDTH> tmp(charset); String *res= orig_field->val_str(&tmp); char *pos= (char*) sql_strmake(res->ptr(), res->length()); - def= new Item_string(pos, res->length(), charset); + def= new Item_string(thd, pos, res->length(), charset); } orig_field->move_field_offset(-diff); // Back to record[0] } diff --git a/sql/field.h b/sql/field.h index c059c5c78b9..b577b77ffb6 100644 --- a/sql/field.h +++ b/sql/field.h @@ -3050,7 +3050,7 @@ public: interval_list.empty(); } - Create_field(Field *field, Field *orig_field); + Create_field(THD *thd, Field *field, Field *orig_field); /* Used to make a clone of this object for ALTER/CREATE TABLE */ Create_field *clone(MEM_ROOT *mem_root) const; void create_length_to_internal_length(void); diff --git a/sql/handler.cc b/sql/handler.cc index 51deee44eb6..e2c24c7842a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1983,10 +1983,14 @@ bool mysql_xa_recover(THD *thd) Protocol *protocol= thd->protocol; DBUG_ENTER("mysql_xa_recover"); - field_list.push_back(new Item_int("formatID", 0, MY_INT32_NUM_DECIMAL_DIGITS)); - field_list.push_back(new Item_int("gtrid_length", 0, MY_INT32_NUM_DECIMAL_DIGITS)); - field_list.push_back(new Item_int("bqual_length", 0, MY_INT32_NUM_DECIMAL_DIGITS)); - field_list.push_back(new Item_empty_string("data",XIDDATASIZE)); + field_list.push_back(new Item_int(thd, "formatID", 0, + MY_INT32_NUM_DECIMAL_DIGITS)); + field_list.push_back(new Item_int(thd, "gtrid_length", 0, + MY_INT32_NUM_DECIMAL_DIGITS)); + field_list.push_back(new Item_int(thd, "bqual_length", 0, + MY_INT32_NUM_DECIMAL_DIGITS)); + field_list.push_back(new Item_empty_string(thd, "data", + XIDDATASIZE)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -5523,9 +5527,9 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat) Protocol *protocol= thd->protocol; bool result; - field_list.push_back(new Item_empty_string("Type",10)); - field_list.push_back(new Item_empty_string("Name",FN_REFLEN)); - field_list.push_back(new Item_empty_string("Status",10)); + field_list.push_back(new Item_empty_string(thd, "Type", 10)); + field_list.push_back(new Item_empty_string(thd, "Name", FN_REFLEN)); + field_list.push_back(new Item_empty_string(thd, "Status", 10)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/item.cc b/sql/item.cc index d14701dbd70..da7dbba9f53 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -411,10 +411,11 @@ int Item::save_str_value_in_field(Field *field, String *result) } -Item::Item(): +Item::Item(THD *thd): is_expensive_cache(-1), rsize(0), name(0), orig_name(0), name_length(0), fixed(0), is_autogenerated_name(TRUE) { + DBUG_ASSERT(thd); marker= 0; maybe_null=null_value=with_sum_func=with_field=0; in_rollup= 0; @@ -424,7 +425,6 @@ Item::Item(): join_tab_idx= MAX_TABLES; /* Put item in free list so that we can free all items at end */ - THD *thd= current_thd; next= thd->free_list; thd->free_list= this; /* @@ -666,11 +666,11 @@ Item_result Item::cmp_type() const pointer to newly allocated item is returned. */ -Item* Item::transform(Item_transformer transformer, uchar *arg) +Item* Item::transform(THD *thd, Item_transformer transformer, uchar *arg) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); - return (this->*transformer)(arg); + return (this->*transformer)(thd, arg); } @@ -693,7 +693,7 @@ Item* Item::set_expr_cache(THD *thd) { DBUG_ENTER("Item::set_expr_cache"); Item_cache_wrapper *wrapper; - if ((wrapper= new Item_cache_wrapper(this)) && + if ((wrapper= new Item_cache_wrapper(thd, this)) && !wrapper->fix_fields(thd, (Item**)&wrapper)) { if (wrapper->set_cache(thd)) @@ -704,10 +704,11 @@ Item* Item::set_expr_cache(THD *thd) } -Item_ident::Item_ident(Name_resolution_context *context_arg, +Item_ident::Item_ident(THD *thd, Name_resolution_context *context_arg, const char *db_name_arg,const char *table_name_arg, const char *field_name_arg) - :orig_db_name(db_name_arg), orig_table_name(table_name_arg), + :Item_result_field(thd), orig_db_name(db_name_arg), + orig_table_name(table_name_arg), orig_field_name(field_name_arg), context(context_arg), db_name(db_name_arg), table_name(table_name_arg), field_name(field_name_arg), @@ -718,8 +719,9 @@ Item_ident::Item_ident(Name_resolution_context *context_arg, } -Item_ident::Item_ident(TABLE_LIST *view_arg, const char *field_name_arg) - :orig_db_name(NullS), orig_table_name(view_arg->table_name), +Item_ident::Item_ident(THD *thd, TABLE_LIST *view_arg, const char *field_name_arg) + :Item_result_field(thd), orig_db_name(NullS), + orig_table_name(view_arg->table_name), orig_field_name(field_name_arg), context(&view_arg->view->select_lex.context), db_name(NullS), table_name(view_arg->alias), field_name(field_name_arg), @@ -1040,11 +1042,11 @@ bool Item::eq(const Item *item, bool binary_cmp) const } -Item *Item::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { if (!needs_charset_converter(tocs)) return this; - Item_func_conv_charset *conv= new Item_func_conv_charset(this, tocs, 1); + Item_func_conv_charset *conv= new Item_func_conv_charset(thd, this, tocs, 1); return conv->safe ? conv : NULL; } @@ -1069,17 +1071,17 @@ Item *Item::safe_charset_converter(CHARSET_INFO *tocs) TODO: we should eventually check all other use cases of change_item_tree(). Perhaps some more potentially dangerous substitution examples exist. */ -Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { if (!example) - return Item::safe_charset_converter(tocs); - Item *conv= example->safe_charset_converter(tocs); + return Item::safe_charset_converter(thd, tocs); + Item *conv= example->safe_charset_converter(thd, tocs); if (conv == example) return this; Item_cache *cache; - if (!conv || !(cache= new Item_cache_str(conv))) + if (!conv || !(cache= new Item_cache_str(thd, conv))) return NULL; // Safe conversion is not possible, or OEM - cache->setup(conv); + cache->setup(thd, conv); cache->fixed= false; // Make Item::fix_fields() happy return cache; } @@ -1096,7 +1098,7 @@ Item *Item_cache::safe_charset_converter(CHARSET_INFO *tocs) the latter returns a non-fixed Item, so val_str() crashes afterwards. Override Item_num method, to return a fixed item. */ -Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item_num::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { /* Item_num returns pure ASCII result, @@ -1107,7 +1109,7 @@ Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs) return this; Item *conv; - if ((conv= const_charset_converter(tocs, true))) + if ((conv= const_charset_converter(thd, tocs, true))) conv->fix_char_length(max_char_length()); return conv; } @@ -1125,7 +1127,7 @@ Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs) NULL, if safe conversion is not possible, or a new item representing the converted constant. */ -Item *Item::const_charset_converter(CHARSET_INFO *tocs, +Item *Item::const_charset_converter(THD *thd, CHARSET_INFO *tocs, bool lossless, const char *func_name) { @@ -1134,7 +1136,7 @@ Item *Item::const_charset_converter(CHARSET_INFO *tocs, StringBuffer<64>tmp; String *s= val_str(&tmp); if (!s) - return new Item_null((char *) func_name, tocs); + return new Item_null(thd, (char *) func_name, tocs); if (!needs_charset_converter(s->length(), tocs)) { @@ -1146,11 +1148,11 @@ Item *Item::const_charset_converter(CHARSET_INFO *tocs, uint conv_errors; Item_string *conv= func_name ? - new Item_static_string_func(func_name, + new Item_static_string_func(thd, func_name, s, tocs, &conv_errors, collation.derivation, collation.repertoire) : - new Item_string(s, tocs, &conv_errors, + new Item_string(thd, s, tocs, &conv_errors, collation.derivation, collation.repertoire); @@ -1171,7 +1173,7 @@ Item *Item::const_charset_converter(CHARSET_INFO *tocs, } -Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item_param::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { /* Return "this" if in prepare. result_type may change at execition time, @@ -1185,7 +1187,7 @@ Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs) and INT_RESULT at execution time. */ return !const_item() || state == NULL_VALUE ? - this : const_charset_converter(tocs, true); + this : const_charset_converter(thd, tocs, true); } @@ -1318,9 +1320,9 @@ int Item::save_in_field_no_warnings(Field *field, bool no_conversions) Item_sp_variable methods *****************************************************************************/ -Item_sp_variable::Item_sp_variable(char *sp_var_name_str, - uint sp_var_name_length) - :m_thd(0) +Item_sp_variable::Item_sp_variable(THD *thd, char *sp_var_name_str, + uint sp_var_name_length): + Item(thd), m_thd(0) #ifndef DBUG_OFF , m_sp(0) #endif @@ -1425,13 +1427,13 @@ bool Item_sp_variable::is_null() Item_splocal methods *****************************************************************************/ -Item_splocal::Item_splocal(const LEX_STRING &sp_var_name, +Item_splocal::Item_splocal(THD *thd, const LEX_STRING &sp_var_name, uint sp_var_idx, enum_field_types sp_var_type, - uint pos_in_q, uint len_in_q) - :Item_sp_variable(sp_var_name.str, sp_var_name.length), - Rewritable_query_parameter(pos_in_q, len_in_q), - m_var_idx(sp_var_idx) + uint pos_in_q, uint len_in_q): + Item_sp_variable(thd, sp_var_name.str, sp_var_name.length), + Rewritable_query_parameter(pos_in_q, len_in_q), + m_var_idx(sp_var_idx) { maybe_null= TRUE; @@ -1487,9 +1489,9 @@ bool Item_splocal::set_value(THD *thd, sp_rcontext *ctx, Item **it) Item_case_expr methods *****************************************************************************/ -Item_case_expr::Item_case_expr(uint case_expr_id) - :Item_sp_variable( C_STRING_WITH_LEN("case_expr")), - m_case_expr_id(case_expr_id) +Item_case_expr::Item_case_expr(THD *thd, uint case_expr_id): + Item_sp_variable(thd, C_STRING_WITH_LEN("case_expr")), + m_case_expr_id(case_expr_id) { } @@ -1577,8 +1579,8 @@ bool Item_name_const::is_null() } -Item_name_const::Item_name_const(Item *name_arg, Item *val): - value_item(val), name_item(name_arg) +Item_name_const::Item_name_const(THD *thd, Item *name_arg, Item *val): + Item(thd), value_item(val), name_item(name_arg) { Item::maybe_null= TRUE; valid_args= true; @@ -1689,9 +1691,10 @@ void Item_name_const::print(String *str, enum_query_type query_type) class Item_aggregate_ref : public Item_ref { public: - Item_aggregate_ref(Name_resolution_context *context_arg, Item **item, - const char *table_name_arg, const char *field_name_arg) - :Item_ref(context_arg, item, table_name_arg, field_name_arg) {} + Item_aggregate_ref(THD *thd, Name_resolution_context *context_arg, + Item **item, const char *table_name_arg, + const char *field_name_arg): + Item_ref(thd, context_arg, item, table_name_arg, field_name_arg) {} virtual inline void print (String *str, enum_query_type query_type) { @@ -1794,7 +1797,8 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array, Item *real_itm= real_item(); ref_pointer_array[el]= real_itm; - if (!(item_ref= new Item_aggregate_ref(&thd->lex->current_select->context, + if (!(item_ref= new Item_aggregate_ref(thd, + &thd->lex->current_select->context, ref_pointer_array + el, 0, name))) return; // fatal_error is set if (type() == SUM_FUNC_ITEM) @@ -2083,11 +2087,11 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname, for (i= 0, arg= args; i < nargs; i++, arg+= item_sep) { - Item* conv= (*arg)->safe_charset_converter(coll.collation); + Item* conv= (*arg)->safe_charset_converter(thd, coll.collation); if (conv == *arg) continue; if (!conv && ((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII)) - conv= new Item_func_conv_charset(*arg, coll.collation, 1); + conv= new Item_func_conv_charset(thd, *arg, coll.collation, 1); if (!conv) { @@ -2185,8 +2189,8 @@ void Item_ident_for_show::make_field(Send_field *tmp_field) /**********************************************/ -Item_field::Item_field(Field *f) - :Item_ident(0, NullS, *f->table_name, f->field_name), +Item_field::Item_field(THD *thd, Field *f) + :Item_ident(thd, 0, NullS, *f->table_name, f->field_name), item_equal(0), no_const_subst(0), have_privileges(0), any_privileges(0) { @@ -2209,7 +2213,7 @@ Item_field::Item_field(Field *f) Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, Field *f) - :Item_ident(context_arg, f->table->s->db.str, *f->table_name, f->field_name), + :Item_ident(thd, context_arg, f->table->s->db.str, *f->table_name, f->field_name), item_equal(0), no_const_subst(0), have_privileges(0), any_privileges(0) { @@ -2252,7 +2256,7 @@ Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, Item_field::Item_field(THD *thd, Name_resolution_context *context_arg, const char *db_arg,const char *table_name_arg, const char *field_name_arg) - :Item_ident(context_arg, db_arg,table_name_arg,field_name_arg), + :Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg), field(0), item_equal(0), no_const_subst(0), have_privileges(0), any_privileges(0) { @@ -2681,7 +2685,8 @@ longlong Item_field::val_int_endpoint(bool left_endp, bool *incl_endp) This is always 'signed'. Unsigned values are created with Item_uint() */ -Item_int::Item_int(const char *str_arg, uint length) +Item_int::Item_int(THD *thd, const char *str_arg, uint length): + Item_num(thd) { char *end_ptr= (char*) str_arg + length; int error; @@ -2714,15 +2719,15 @@ void Item_int::print(String *str, enum_query_type query_type) } -Item_uint::Item_uint(const char *str_arg, uint length): - Item_int(str_arg, length) +Item_uint::Item_uint(THD *thd, const char *str_arg, uint length): + Item_int(thd, str_arg, length) { unsigned_flag= 1; } -Item_uint::Item_uint(const char *str_arg, longlong i, uint length): - Item_int(str_arg, i, length) +Item_uint::Item_uint(THD *thd, const char *str_arg, longlong i, uint length): + Item_int(thd, str_arg, i, length) { unsigned_flag= 1; } @@ -2745,8 +2750,9 @@ void Item_uint::print(String *str, enum_query_type query_type) } -Item_decimal::Item_decimal(const char *str_arg, uint length, - CHARSET_INFO *charset) +Item_decimal::Item_decimal(THD *thd, const char *str_arg, uint length, + CHARSET_INFO *charset): + Item_num(thd) { str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value); name= (char*) str_arg; @@ -2758,7 +2764,8 @@ Item_decimal::Item_decimal(const char *str_arg, uint length, unsigned_flag); } -Item_decimal::Item_decimal(longlong val, bool unsig) +Item_decimal::Item_decimal(THD *thd, longlong val, bool unsig): + Item_num(thd) { int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value); decimals= (uint8) decimal_value.frac; @@ -2770,7 +2777,8 @@ Item_decimal::Item_decimal(longlong val, bool unsig) } -Item_decimal::Item_decimal(double val, int precision, int scale) +Item_decimal::Item_decimal(THD *thd, double val, int precision, int scale): + Item_num(thd) { double2my_decimal(E_DEC_FATAL_ERROR, val, &decimal_value); decimals= (uint8) decimal_value.frac; @@ -2782,8 +2790,9 @@ Item_decimal::Item_decimal(double val, int precision, int scale) } -Item_decimal::Item_decimal(const char *str, const my_decimal *val_arg, - uint decimal_par, uint length) +Item_decimal::Item_decimal(THD *thd, const char *str, const my_decimal *val_arg, + uint decimal_par, uint length): + Item_num(thd) { my_decimal2decimal(val_arg, &decimal_value); name= (char*) str; @@ -2793,7 +2802,8 @@ Item_decimal::Item_decimal(const char *str, const my_decimal *val_arg, } -Item_decimal::Item_decimal(my_decimal *value_par) +Item_decimal::Item_decimal(THD *thd, my_decimal *value_par): + Item_num(thd) { my_decimal2decimal(value_par, &decimal_value); decimals= (uint8) decimal_value.frac; @@ -2805,7 +2815,8 @@ Item_decimal::Item_decimal(my_decimal *value_par) } -Item_decimal::Item_decimal(const uchar *bin, int precision, int scale) +Item_decimal::Item_decimal(THD *thd, const uchar *bin, int precision, int scale): + Item_num(thd) { binary2my_decimal(E_DEC_FATAL_ERROR, bin, &decimal_value, precision, scale); @@ -3068,7 +3079,7 @@ my_decimal *Item_null::val_decimal(my_decimal *decimal_value) } -Item *Item_null::safe_charset_converter(CHARSET_INFO *tocs) +Item *Item_null::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { return this; } @@ -3089,7 +3100,8 @@ default_set_param_func(Item_param *param, } -Item_param::Item_param(uint pos_in_query_arg) : +Item_param::Item_param(THD *thd, uint pos_in_query_arg): + Item_basic_value(thd), Rewritable_query_parameter(pos_in_query_arg, 1), state(NO_VALUE), item_result_type(STRING_RESULT), @@ -3687,22 +3699,22 @@ bool Item_param::basic_const_item() const Item * -Item_param::clone_item() +Item_param::clone_item(THD *thd) { /* see comments in the header file */ switch (state) { case NULL_VALUE: - return new Item_null(name); + return new Item_null(thd, name); case INT_VALUE: return (unsigned_flag ? - new Item_uint(name, value.integer, max_length) : - new Item_int(name, value.integer, max_length)); + new Item_uint(thd, name, value.integer, max_length) : + new Item_int(thd, name, value.integer, max_length)); case REAL_VALUE: - return new Item_float(name, value.real, decimals, max_length); + return new Item_float(thd, name, value.real, decimals, max_length); case STRING_VALUE: case LONG_DATA_VALUE: - return new Item_string(name, str_value.c_ptr_quick(), str_value.length(), - str_value.charset(), + return new Item_string(thd, name, str_value.c_ptr_quick(), + str_value.length(), str_value.charset(), collation.derivation, collation.repertoire); case TIME_VALUE: break; @@ -3955,19 +3967,20 @@ bool Item_param::append_for_log(THD *thd, String *str) Item_copy ****************************************************************************/ -Item_copy *Item_copy::create (Item *item) +Item_copy *Item_copy::create(THD *thd, Item *item) { switch (item->result_type()) { case STRING_RESULT: - return new Item_copy_string (item); - case REAL_RESULT: - return new Item_copy_float (item); + return new Item_copy_string(thd, item); + case REAL_RESULT: + return new Item_copy_float(thd, item); case INT_RESULT: - return item->unsigned_flag ? - new Item_copy_uint (item) : new Item_copy_int (item); + return item->unsigned_flag ? + new Item_copy_uint(thd, item) : + new Item_copy_int(thd, item); case DECIMAL_RESULT: - return new Item_copy_decimal (item); + return new Item_copy_decimal(thd, item); case TIME_RESULT: case ROW_RESULT: case IMPOSSIBLE_RESULT: @@ -4765,7 +4778,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) fix_inner_refs() function. */ ; - if (!(rf= new Item_outer_ref(context, this))) + if (!(rf= new Item_outer_ref(thd, context, this))) return -1; thd->change_item_tree(reference, rf); select->inner_refs_list.push_back(rf); @@ -4872,12 +4885,12 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) save= *ref; *ref= NULL; // Don't call set_properties() rf= (place == IN_HAVING ? - new Item_ref(context, ref, (char*) table_name, + new Item_ref(thd, context, ref, (char*) table_name, (char*) field_name, alias_name_used) : (!select->group_list.elements ? - new Item_direct_ref(context, ref, (char*) table_name, + new Item_direct_ref(thd, context, ref, (char*) table_name, (char*) field_name, alias_name_used) : - new Item_outer_ref(context, ref, (char*) table_name, + new Item_outer_ref(thd, context, ref, (char*) table_name, (char*) field_name, alias_name_used))); *ref= save; if (!rf) @@ -4911,7 +4924,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) if (last_checked_context->select_lex->having_fix_field) { Item_ref *rf; - rf= new Item_ref(context, (*from_field)->table->s->db.str, + rf= new Item_ref(thd, context, (*from_field)->table->s->db.str, (*from_field)->table->alias.c_ptr(), (char*) field_name); if (!rf) @@ -5045,7 +5058,8 @@ bool Item_field::fix_fields(THD *thd, Item **reference) Item_ref to point to the Item in the select list and replace the Item_field created by the parser with the new Item_ref. */ - Item_ref *rf= new Item_ref(context, db_name,table_name,field_name); + Item_ref *rf= new Item_ref(thd, context, db_name, table_name, + field_name); if (!rf) return 1; bool err= rf->fix_fields(thd, (Item **) &rf) || rf->check_cols(1); @@ -5329,19 +5343,19 @@ bool Item_field::subst_argument_checker(uchar **arg) the field reference when propagating equalities. */ -static void convert_zerofill_number_to_string(Item **item, Field_num *field) +static void convert_zerofill_number_to_string(THD *thd, Item **item, Field_num *field) { char buff[MAX_FIELD_WIDTH],*pos; String tmp(buff,sizeof(buff), field->charset()), *res; res= (*item)->val_str(&tmp); if ((*item)->is_null()) - *item= new Item_null(); + *item= new Item_null(thd); else { field->prepend_zeros(res); pos= (char *) sql_strmake (res->ptr(), res->length()); - *item= new Item_string(pos, res->length(), field->charset()); + *item= new Item_string(thd, pos, res->length(), field->charset()); } } @@ -5370,7 +5384,7 @@ static void convert_zerofill_number_to_string(Item **item, Field_num *field) - pointer to the field item, otherwise. */ -Item *Item_field::equal_fields_propagator(uchar *arg) +Item *Item_field::equal_fields_propagator(THD *thd, uchar *arg) { if (no_const_subst) return this; @@ -5392,7 +5406,7 @@ Item *Item_field::equal_fields_propagator(uchar *arg) else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type())) { if (item && (cmp_context == STRING_RESULT || cmp_context == IMPOSSIBLE_RESULT)) - convert_zerofill_number_to_string(&item, (Field_num *)field); + convert_zerofill_number_to_string(thd, &item, (Field_num *)field); else item= this; } @@ -5440,7 +5454,7 @@ bool Item_field::set_no_const_sub(uchar *arg) - this - otherwise. */ -Item *Item_field::replace_equal_field(uchar *arg) +Item *Item_field::replace_equal_field(THD *thd, uchar *arg) { REPLACE_EQUAL_FIELD_ARG* param= (REPLACE_EQUAL_FIELD_ARG*)arg; if (item_equal && item_equal == param->item_equal) @@ -6068,7 +6082,7 @@ int Item_decimal::save_in_field(Field *field, bool no_conversions) } -Item *Item_int_with_ref::clone_item() +Item *Item_int_with_ref::clone_item(THD *thd) { DBUG_ASSERT(ref->const_item()); /* @@ -6076,15 +6090,15 @@ Item *Item_int_with_ref::clone_item() parameter markers. */ return (ref->unsigned_flag ? - new Item_uint(ref->name, ref->val_int(), ref->max_length) : - new Item_int(ref->name, ref->val_int(), ref->max_length)); + new Item_uint(thd, ref->name, ref->val_int(), ref->max_length) : + new Item_int(thd, ref->name, ref->val_int(), ref->max_length)); } -Item_num *Item_uint::neg() +Item_num *Item_uint::neg(THD *thd) { - Item_decimal *item= new Item_decimal(value, 1); - return item->neg(); + Item_decimal *item= new Item_decimal(thd, value, 1); + return item->neg(thd); } @@ -6142,7 +6156,8 @@ static uint nr_of_decimals(const char *str, const char *end) Item->name should be fixed to use LEX_STRING eventually. */ -Item_float::Item_float(const char *str_arg, uint length) +Item_float::Item_float(THD *thd, const char *str_arg, uint length): + Item_num(thd) { int error; char *end_not_used; @@ -6285,7 +6300,8 @@ void Item_hex_string::print(String *str, enum_query_type query_type) In number context this is a longlong value. */ -Item_bin_string::Item_bin_string(const char *str, uint str_length) +Item_bin_string::Item_bin_string(THD *thd, const char *str, uint str_length): + Item_hex_hybrid(thd) { const char *end= str + str_length - 1; uchar bits= 0; @@ -6567,15 +6583,15 @@ bool Item::cache_const_expr_analyzer(uchar **arg) @return this otherwise. */ -Item* Item::cache_const_expr_transformer(uchar *arg) +Item* Item::cache_const_expr_transformer(THD *thd, uchar *arg) { if (*(bool*)arg) { *((bool*)arg)= FALSE; - Item_cache *cache= Item_cache::get_cache(this); + Item_cache *cache= Item_cache::get_cache(thd, this); if (!cache) return NULL; - cache->setup(this); + cache->setup(thd, this); cache->store(this); return cache; } @@ -6634,7 +6650,7 @@ void Item_field::update_null_value() this field otherwise */ -Item *Item_field::update_value_transformer(uchar *select_arg) +Item *Item_field::update_value_transformer(THD *thd, uchar *select_arg) { SELECT_LEX *select= (SELECT_LEX*)select_arg; DBUG_ASSERT(fixed); @@ -6649,7 +6665,7 @@ Item *Item_field::update_value_transformer(uchar *select_arg) ref_pointer_array[el]= (Item*)this; all_fields->push_front((Item*)this); - ref= new Item_ref(&select->context, ref_pointer_array + el, + ref= new Item_ref(thd, &select->context, ref_pointer_array + el, table_name, field_name); return ref; } @@ -6668,12 +6684,12 @@ void Item_field::print(String *str, enum_query_type query_type) } -Item_ref::Item_ref(Name_resolution_context *context_arg, +Item_ref::Item_ref(THD *thd, Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, - bool alias_name_used_arg) - :Item_ident(context_arg, NullS, table_name_arg, field_name_arg), - ref(item), reference_trough_name(0) + bool alias_name_used_arg): + Item_ident(thd, context_arg, NullS, table_name_arg, field_name_arg), + ref(item), reference_trough_name(0) { alias_name_used= alias_name_used_arg; /* @@ -6714,10 +6730,10 @@ public: } }; -Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item, - const char *field_name_arg, bool alias_name_used_arg) - :Item_ident(view_arg, field_name_arg), - ref(item), reference_trough_name(0) +Item_ref::Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item, + const char *field_name_arg, bool alias_name_used_arg): + Item_ident(thd, view_arg, field_name_arg), + ref(item), reference_trough_name(0) { alias_name_used= alias_name_used_arg; /* @@ -6943,7 +6959,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) if (from_field != not_found_field) { Item_field* fld; - if (!(fld= new Item_field(from_field))) + if (!(fld= new Item_field(thd, from_field))) goto error; thd->change_item_tree(reference, fld); mark_as_dependent(thd, last_checked_context->select_lex, @@ -7080,13 +7096,13 @@ void Item_ref::cleanup() @retval NULL Out of memory error */ -Item* Item_ref::transform(Item_transformer transformer, uchar *arg) +Item* Item_ref::transform(THD *thd, Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); DBUG_ASSERT((*ref) != NULL); /* Transform the object we are referencing. */ - Item *new_item= (*ref)->transform(transformer, arg); + Item *new_item= (*ref)->transform(thd, transformer, arg); if (!new_item) return NULL; @@ -7097,10 +7113,10 @@ Item* Item_ref::transform(Item_transformer transformer, uchar *arg) change records at each execution. */ if (*ref != new_item) - current_thd->change_item_tree(ref, new_item); + thd->change_item_tree(ref, new_item); /* Transform the item ref object. */ - return (this->*transformer)(arg); + return (this->*transformer)(thd, arg); } @@ -7126,7 +7142,7 @@ Item* Item_ref::transform(Item_transformer transformer, uchar *arg) @return Item returned as the result of transformation of the Item_ref object */ -Item* Item_ref::compile(Item_analyzer analyzer, uchar **arg_p, +Item* Item_ref::compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) { /* Analyze this Item object. */ @@ -7138,13 +7154,13 @@ Item* Item_ref::compile(Item_analyzer analyzer, uchar **arg_p, if (*arg_p) { uchar *arg_v= *arg_p; - Item *new_item= (*ref)->compile(analyzer, &arg_v, transformer, arg_t); + Item *new_item= (*ref)->compile(thd, analyzer, &arg_v, transformer, arg_t); if (new_item && *ref != new_item) - current_thd->change_item_tree(ref, new_item); + thd->change_item_tree(ref, new_item); } /* Transform this Item object. */ - return (this->*transformer)(arg_t); + return (this->*transformer)(thd, arg_t); } @@ -7390,7 +7406,7 @@ Item *Item_ref::get_tmp_table_item(THD *thd) if (!result_field) return (*ref)->get_tmp_table_item(thd); - Item_field *item= new Item_field(result_field); + Item_field *item= new Item_field(thd, result_field); if (item) { item->table_name= table_name; @@ -7475,8 +7491,8 @@ Item_cache_wrapper::~Item_cache_wrapper() DBUG_ASSERT(expr_cache == 0); } -Item_cache_wrapper::Item_cache_wrapper(Item *item_arg) -:orig_item(item_arg), expr_cache(NULL), expr_value(NULL) +Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg): + Item_result_field(thd), orig_item(item_arg), expr_cache(NULL), expr_value(NULL) { DBUG_ASSERT(orig_item->fixed); Type_std_attributes::set(orig_item); @@ -7487,8 +7503,8 @@ Item_cache_wrapper::Item_cache_wrapper(Item *item_arg) name_length= item_arg->name_length; with_subselect= orig_item->with_subselect; - if ((expr_value= Item_cache::get_cache(orig_item))) - expr_value->setup(orig_item); + if ((expr_value= Item_cache::get_cache(thd, orig_item))) + expr_value->setup(thd, orig_item); fixed= 1; } @@ -7871,7 +7887,7 @@ int Item_cache_wrapper::save_in_field(Field *to, bool no_conversions) Item* Item_cache_wrapper::get_tmp_table_item(THD *thd_arg) { if (!orig_item->with_sum_func && !orig_item->const_item()) - return new Item_field(result_field); + return new Item_field(thd_arg, result_field); return copy_or_same(thd_arg); } @@ -8118,12 +8134,12 @@ bool Item_direct_view_ref::subst_argument_checker(uchar **arg) - pointer to the field item, otherwise. */ -Item *Item_direct_view_ref::equal_fields_propagator(uchar *arg) +Item *Item_direct_view_ref::equal_fields_propagator(THD *thd, uchar *arg) { Item *field_item= real_item(); if (field_item->type() != FIELD_ITEM) return this; - Item *item= field_item->equal_fields_propagator(arg); + Item *item= field_item->equal_fields_propagator(thd, arg); set_item_equal(field_item->get_item_equal()); field_item->set_item_equal(NULL); if (item != field_item) @@ -8162,13 +8178,13 @@ Item *Item_direct_view_ref::equal_fields_propagator(uchar *arg) - this - otherwise. */ -Item *Item_direct_view_ref::replace_equal_field(uchar *arg) +Item *Item_direct_view_ref::replace_equal_field(THD *thd, uchar *arg) { Item *field_item= real_item(); if (field_item->type() != FIELD_ITEM) return this; field_item->set_item_equal(item_equal); - Item *item= field_item->replace_equal_field(arg); + Item *item= field_item->replace_equal_field(thd, arg); field_item->set_item_equal(0); return item != field_item ? item : this; } @@ -8290,9 +8306,10 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) same time it can replace some nodes in the tree. */ -Item *Item_default_value::transform(Item_transformer transformer, uchar *args) +Item *Item_default_value::transform(THD *thd, Item_transformer transformer, + uchar *args) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); /* If the value of arg is NULL, then this object represents a constant, @@ -8301,7 +8318,7 @@ Item *Item_default_value::transform(Item_transformer transformer, uchar *args) if (!arg) return 0; - Item *new_item= arg->transform(transformer, args); + Item *new_item= arg->transform(thd, transformer, args); if (!new_item) return 0; @@ -8312,8 +8329,8 @@ Item *Item_default_value::transform(Item_transformer transformer, uchar *args) change records at each execution. */ if (arg != new_item) - current_thd->change_item_tree(&arg, new_item); - return (this->*transformer)(args); + thd->change_item_tree(&arg, new_item); + return (this->*transformer)(thd, args); } @@ -8572,7 +8589,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) /* the following call creates a constant and puts it in new_item */ get_datetime_value(thd, &ref_copy, &new_item, comp_item, &is_null); if (is_null) - new_item= new Item_null(name); + new_item= new Item_null(thd, name); break; } case STRING_RESULT: @@ -8581,12 +8598,12 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) String tmp(buff,sizeof(buff),&my_charset_bin),*result; result=item->val_str(&tmp); if (item->null_value) - new_item= new Item_null(name); + new_item= new Item_null(thd, name); else { uint length= result->length(); char *tmp_str= sql_strmake(result->ptr(), length); - new_item= new Item_string(name, tmp_str, length, result->charset()); + new_item= new Item_string(thd, name, tmp_str, length, result->charset()); } break; } @@ -8595,8 +8612,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) longlong result=item->val_int(); uint length=item->max_length; bool null_value=item->null_value; - new_item= (null_value ? (Item*) new Item_null(name) : - (Item*) new Item_int(name, result, length)); + new_item= (null_value ? (Item*) new Item_null(thd, name) : + (Item*) new Item_int(thd, name, result, length)); break; } case ROW_RESULT: @@ -8634,8 +8651,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) double result= item->val_real(); uint length=item->max_length,decimals=item->decimals; bool null_value=item->null_value; - new_item= (null_value ? (Item*) new Item_null(name) : (Item*) - new Item_float(name, result, decimals, length)); + new_item= (null_value ? (Item*) new Item_null(thd, name) : (Item*) + new Item_float(thd, name, result, decimals, length)); break; } case DECIMAL_RESULT: @@ -8645,8 +8662,8 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) uint length= item->max_length, decimals= item->decimals; bool null_value= item->null_value; new_item= (null_value ? - (Item*) new Item_null(name) : - (Item*) new Item_decimal(name, result, length, decimals)); + (Item*) new Item_null(thd, name) : + (Item*) new Item_decimal(thd, name, result, length, decimals)); break; } case IMPOSSIBLE_RESULT: @@ -8771,9 +8788,9 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) return 0; } -Item_cache* Item_cache::get_cache(const Item *item) +Item_cache* Item_cache::get_cache(THD *thd, const Item *item) { - return get_cache(item, item->cmp_type()); + return get_cache(thd, item, item->cmp_type()); } @@ -8786,21 +8803,21 @@ Item_cache* Item_cache::get_cache(const Item *item) @return cache item */ -Item_cache* Item_cache::get_cache(const Item *item, const Item_result type) +Item_cache* Item_cache::get_cache(THD *thd, const Item *item, const Item_result type) { switch (type) { case INT_RESULT: - return new Item_cache_int(item->field_type()); + return new Item_cache_int(thd, item->field_type()); case REAL_RESULT: - return new Item_cache_real(); + return new Item_cache_real(thd); case DECIMAL_RESULT: - return new Item_cache_decimal(); + return new Item_cache_decimal(thd); case STRING_RESULT: - return new Item_cache_str(item); + return new Item_cache_str(thd, item); case ROW_RESULT: - return new Item_cache_row(); + return new Item_cache_row(thd); case TIME_RESULT: - return new Item_cache_temporal(item->field_type()); + return new Item_cache_temporal(thd, item->field_type()); case IMPOSSIBLE_RESULT: DBUG_ASSERT(0); break; @@ -8905,8 +8922,8 @@ int Item_cache_int::save_in_field(Field *field, bool no_conversions) } -Item_cache_temporal::Item_cache_temporal(enum_field_types field_type_arg): - Item_cache_int(field_type_arg) +Item_cache_temporal::Item_cache_temporal(THD *thd, enum_field_types field_type_arg): + Item_cache_int(thd, field_type_arg) { if (mysql_type_to_time_type(cached_field_type) == MYSQL_TIMESTAMP_ERROR) cached_field_type= MYSQL_TYPE_DATETIME; @@ -9226,7 +9243,7 @@ bool Item_cache_row::allocate(uint num) } -bool Item_cache_row::setup(Item * item) +bool Item_cache_row::setup(THD *thd, Item *item) { example= item; if (!values && allocate(item->cols())) @@ -9235,9 +9252,9 @@ bool Item_cache_row::setup(Item * item) { Item *el= item->element_index(i); Item_cache *tmp; - if (!(tmp= values[i]= Item_cache::get_cache(el))) + if (!(tmp= values[i]= Item_cache::get_cache(thd, el))) return 1; - tmp->setup(el); + tmp->setup(thd, el); } return 0; } diff --git a/sql/item.h b/sql/item.h index b611194d67e..1d0c535e43f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -521,7 +521,7 @@ typedef bool (Item::*Item_processor) (uchar *arg); */ typedef bool (Item::*Item_analyzer) (uchar **argp); -typedef Item* (Item::*Item_transformer) (uchar *arg); +typedef Item* (Item::*Item_transformer) (THD *thd, uchar *arg); typedef void (*Cond_traverser) (const Item *item, void *arg); struct st_cond_statistic; @@ -688,7 +688,7 @@ public: subselect */ Item_result cmp_context; /* Comparison context */ // alloc & destruct is done as start of select using sql_alloc - Item(); + Item(THD *thd); /* Constructor used by Item_field, Item_ref & aggregate (sum) functions. Used for duplicating lists in processing queries with temporary @@ -1056,7 +1056,7 @@ public: */ virtual bool basic_const_item() const { return 0; } /* cloning of constant items (0 if it is not const) */ - virtual Item *clone_item() { return 0; } + virtual Item *clone_item(THD *thd) { return 0; } virtual cond_result eq_cmp_result() const { return COND_OK; } inline uint float_length(uint decimals_par) const { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} @@ -1251,7 +1251,7 @@ public: return (this->*processor)(arg); } - virtual Item* transform(Item_transformer transformer, uchar *arg); + virtual Item* transform(THD *thd, Item_transformer transformer, uchar *arg); /* This function performs a generic "compilation" of the Item tree. @@ -1269,11 +1269,11 @@ public: i.e. analysis is performed top-down while transformation is done bottom-up. */ - virtual Item* compile(Item_analyzer analyzer, uchar **arg_p, + virtual Item* compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) { if ((this->*analyzer) (arg_p)) - return ((this->*transformer) (arg_t)); + return ((this->*transformer) (thd, arg_t)); return 0; } @@ -1343,7 +1343,7 @@ public: virtual bool register_field_in_bitmap(uchar *arg) { return 0; } bool cache_const_expr_analyzer(uchar **arg); - Item* cache_const_expr_transformer(uchar *arg); + Item* cache_const_expr_transformer(THD *thd, uchar *arg); /* Check if a partition function is allowed @@ -1447,10 +1447,10 @@ public: return trace_unsupported_by_check_vcol_func_processor(full_name()); } - virtual Item *equal_fields_propagator(uchar * arg) { return this; } + virtual Item *equal_fields_propagator(THD *thd, uchar * arg) { return this; } virtual bool set_no_const_sub(uchar *arg) { return FALSE; } /* arg points to REPLACE_EQUAL_FIELD_ARG object */ - virtual Item *replace_equal_field(uchar * arg) { return this; } + virtual Item *replace_equal_field(THD *thd, uchar *arg) { return this; } /* Check if an expression value has allowed arguments, like DATE/DATETIME for date functions. Also used by partitioning code to reject @@ -1520,10 +1520,12 @@ public: virtual Item_field *field_for_view_update() { return 0; } virtual Item *neg_transformer(THD *thd) { return NULL; } - virtual Item *update_value_transformer(uchar *select_arg) { return this; } - virtual Item *expr_cache_insert_transformer(uchar *thd_arg) { return this; } + virtual Item *update_value_transformer(THD *thd, uchar *select_arg) + { return this; } + virtual Item *expr_cache_insert_transformer(THD *thd, uchar *unused) + { return this; } virtual bool expr_cache_is_needed(THD *) { return FALSE; } - virtual Item *safe_charset_converter(CHARSET_INFO *tocs); + virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); bool needs_charset_converter(uint32 length, CHARSET_INFO *tocs) { /* @@ -1562,10 +1564,10 @@ public: // Pass 1 as length to force conversion if tocs->mbminlen>1. return needs_charset_converter(1, tocs); } - Item *const_charset_converter(CHARSET_INFO *tocs, bool lossless, + Item *const_charset_converter(THD *thd, CHARSET_INFO *tocs, bool lossless, const char *func_name); - Item *const_charset_converter(CHARSET_INFO *tocs, bool lossless) - { return const_charset_converter(tocs, lossless, NULL); } + Item *const_charset_converter(THD *thd, CHARSET_INFO *tocs, bool lossless) + { return const_charset_converter(thd, tocs, lossless, NULL); } void delete_self() { cleanup(); @@ -1783,7 +1785,7 @@ protected: { fix_charset_and_length_from_str_value(dv, Metadata(&str_value)); } - Item_basic_value(): Item() {} + Item_basic_value(THD *thd): Item(thd) {} /* In the xxx_eq() methods below we need to cast off "const" to call val_xxx(). This is OK for Item_basic_constant and Item_param. @@ -1820,7 +1822,7 @@ class Item_basic_constant :public Item_basic_value { table_map used_table_map; public: - Item_basic_constant(): Item_basic_value(), used_table_map(0) {}; + Item_basic_constant(THD *thd): Item_basic_value(thd), used_table_map(0) {}; void set_used_tables(table_map map) { used_table_map= map; } table_map used_tables() const { return used_table_map; } /* to prevent drop fixed flag (no need parent cleanup call) */ @@ -1866,7 +1868,7 @@ public: #endif public: - Item_sp_variable(char *sp_var_name_str, uint sp_var_name_length); + Item_sp_variable(THD *thd, char *sp_var_name_str, uint sp_var_name_length); public: bool fix_fields(THD *thd, Item **); @@ -1932,7 +1934,7 @@ class Item_splocal :public Item_sp_variable, Item_result m_result_type; enum_field_types m_field_type; public: - Item_splocal(const LEX_STRING &sp_var_name, uint sp_var_idx, + Item_splocal(THD *thd, const LEX_STRING &sp_var_name, uint sp_var_idx, enum_field_types sp_var_type, uint pos_in_q= 0, uint len_in_q= 0); @@ -1998,7 +2000,7 @@ inline Item_result Item_splocal::result_type() const class Item_case_expr :public Item_sp_variable { public: - Item_case_expr(uint case_expr_id); + Item_case_expr(THD *thd, uint case_expr_id); public: Item *this_item(); @@ -2055,7 +2057,7 @@ class Item_name_const : public Item Item *name_item; bool valid_args; public: - Item_name_const(Item *name_arg, Item *val); + Item_name_const(THD *thd, Item *name_arg, Item *val); bool fix_fields(THD *, Item **); @@ -2137,9 +2139,9 @@ agg_item_charsets_for_string_result_with_comparison(DTCollation &c, class Item_num: public Item_basic_constant { public: - Item_num() { collation.set_numeric(); } /* Remove gcc warning */ - virtual Item_num *neg()= 0; - Item *safe_charset_converter(CHARSET_INFO *tocs); + Item_num(THD *thd): Item_basic_constant(thd) { collation.set_numeric(); } + virtual Item_num *neg(THD *thd)= 0; + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); bool check_partition_func_processor(uchar *int_arg) { return FALSE;} bool check_vcol_func_processor(uchar *arg) { return FALSE;} }; @@ -2153,7 +2155,7 @@ class Item_result_field :public Item /* Item with result field */ { public: Field *result_field; /* Save result here */ - Item_result_field() :result_field(0) {} + Item_result_field(THD *thd): Item(thd), result_field(0) {} // Constructor used for Item_sum/Item_cond_and/or (see Item comment) Item_result_field(THD *thd, Item_result_field *item): Item(thd, item), result_field(item->result_field) @@ -2218,11 +2220,11 @@ public: this variable. */ bool can_be_depended; - Item_ident(Name_resolution_context *context_arg, + Item_ident(THD *thd, Name_resolution_context *context_arg, const char *db_name_arg, const char *table_name_arg, const char *field_name_arg); Item_ident(THD *thd, Item_ident *item); - Item_ident(TABLE_LIST *view_arg, const char *field_name_arg); + Item_ident(THD *thd, TABLE_LIST *view_arg, const char *field_name_arg); const char *full_name() const; void cleanup(); st_select_lex *get_depended_from() const; @@ -2248,9 +2250,9 @@ public: const char *db_name; const char *table_name; - Item_ident_for_show(Field *par_field, const char *db_arg, - const char *table_name_arg) - :field(par_field), db_name(db_arg), table_name(table_name_arg) + Item_ident_for_show(THD *thd, Field *par_field, const char *db_arg, + const char *table_name_arg): + Item(thd), field(par_field), db_name(db_arg), table_name(table_name_arg) {} enum Type type() const { return FIELD_ITEM; } @@ -2297,7 +2299,7 @@ public: db_name, table_name and column_name are unknown. It's necessary to call reset_field() before fix_fields() for all fields created this way. */ - Item_field(Field *field); + Item_field(THD *thd, Field *field); enum Type type() const { return FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; double val_real(); @@ -2403,13 +2405,13 @@ public: void set_item_equal(Item_equal *item_eq) { item_equal= item_eq; } Item_equal *find_item_equal(COND_EQUAL *cond_equal); bool subst_argument_checker(uchar **arg); - Item *equal_fields_propagator(uchar *arg); + Item *equal_fields_propagator(THD *thd, uchar *arg); bool set_no_const_sub(uchar *arg); - Item *replace_equal_field(uchar *arg); + Item *replace_equal_field(THD *thd, uchar *arg); inline uint32 max_disp_length() { return field->max_display_length(); } Item_field *field_for_view_update() { return this; } int fix_outer_field(THD *thd, Field **field, Item **reference); - virtual Item *update_value_transformer(uchar *select_arg); + virtual Item *update_value_transformer(THD *thd, uchar *select_arg); virtual void print(String *str, enum_query_type query_type); bool is_outer_field() const { @@ -2431,7 +2433,8 @@ public: class Item_null :public Item_basic_constant { public: - Item_null(char *name_par=0, CHARSET_INFO *cs= &my_charset_bin) + Item_null(THD *thd, char *name_par=0, CHARSET_INFO *cs= &my_charset_bin): + Item_basic_constant(thd) { maybe_null= null_value= TRUE; max_length= 0; @@ -2451,7 +2454,7 @@ public: enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_NULL; } bool basic_const_item() const { return 1; } - Item *clone_item() { return new Item_null(name); } + Item *clone_item(THD *thd) { return new Item_null(thd, name); } bool is_null() { return 1; } virtual inline void print(String *str, enum_query_type query_type) @@ -2459,7 +2462,7 @@ public: str->append(STRING_WITH_LEN("NULL")); } - Item *safe_charset_converter(CHARSET_INFO *tocs); + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *arg) { return FALSE;} }; @@ -2468,7 +2471,7 @@ class Item_null_result :public Item_null { public: Field *result_field; - Item_null_result() : Item_null(), result_field(0) {} + Item_null_result(THD *thd): Item_null(thd), result_field(0) {} bool is_result_field() { return result_field != 0; } void save_in_result_field(bool no_conversions) { @@ -2546,7 +2549,7 @@ public: */ enum enum_field_types param_type; - Item_param(uint pos_in_query_arg); + Item_param(THD *thd, uint pos_in_query_arg); enum Item_result result_type () const { return item_result_type; } enum Type type() const { return item_type; } @@ -2602,8 +2605,8 @@ public: constant, assert otherwise. This method is called only if basic_const_item returned TRUE. */ - Item *safe_charset_converter(CHARSET_INFO *tocs); - Item *clone_item(); + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); + Item *clone_item(THD *thd); /* Implement by-value equality evaluation if parameter value is set and is a basic constant (integer, real or string). @@ -2638,18 +2641,19 @@ class Item_int :public Item_num { public: longlong value; - Item_int(int32 i,uint length= MY_INT32_NUM_DECIMAL_DIGITS) - :value((longlong) i) + Item_int(THD *thd, int32 i,uint length= MY_INT32_NUM_DECIMAL_DIGITS): + Item_num(thd), value((longlong) i) { max_length=length; fixed= 1; } - Item_int(longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS) - :value(i) + Item_int(THD *thd, longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS): + Item_num(thd), value(i) { max_length=length; fixed= 1; } - Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS) - :value((longlong)i) + Item_int(THD *thd, ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS): + Item_num(thd), value((longlong)i) { max_length=length; fixed= 1; unsigned_flag= 1; } - Item_int(const char *str_arg,longlong i,uint length) :value(i) + Item_int(THD *thd, const char *str_arg,longlong i,uint length): + Item_num(thd), value(i) { max_length=length; name=(char*) str_arg; fixed= 1; } - Item_int(const char *str_arg, uint length=64); + Item_int(THD *thd, const char *str_arg, uint length=64); enum Type type() const { return INT_ITEM; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } @@ -2659,9 +2663,9 @@ public: String *val_str(String*); int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } - Item *clone_item() { return new Item_int(name,value,max_length); } + Item *clone_item(THD *thd) { return new Item_int(thd, name, value, max_length); } virtual void print(String *str, enum_query_type query_type); - Item_num *neg() { value= -value; return this; } + Item_num *neg(THD *thd) { value= -value; return this; } uint decimal_precision() const { return (uint) (max_length - MY_TEST(value < 0)); } bool eq(const Item *item, bool binary_cmp) const @@ -2674,15 +2678,16 @@ public: class Item_uint :public Item_int { public: - Item_uint(const char *str_arg, uint length); - Item_uint(ulonglong i) :Item_int(i, 10) {} - Item_uint(const char *str_arg, longlong i, uint length); + Item_uint(THD *thd, const char *str_arg, uint length); + Item_uint(THD *thd, ulonglong i): Item_int(thd, i, 10) {} + Item_uint(THD *thd, const char *str_arg, longlong i, uint length); double val_real() { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); } String *val_str(String*); - Item *clone_item() { return new Item_uint(name, value, max_length); } + Item *clone_item(THD *thd) + { return new Item_uint(thd, name, value, max_length); } virtual void print(String *str, enum_query_type query_type); - Item_num *neg (); + Item_num *neg(THD *thd); uint decimal_precision() const { return max_length; } }; @@ -2692,7 +2697,7 @@ class Item_datetime :public Item_int protected: MYSQL_TIME ltime; public: - Item_datetime() :Item_int(0) { unsigned_flag=0; } + Item_datetime(THD *thd): Item_int(thd, 0) { unsigned_flag=0; } int save_in_field(Field *field, bool no_conversions); longlong val_int(); double val_real() { return (double)val_int(); } @@ -2706,13 +2711,14 @@ class Item_decimal :public Item_num protected: my_decimal decimal_value; public: - Item_decimal(const char *str_arg, uint length, CHARSET_INFO *charset); - Item_decimal(const char *str, const my_decimal *val_arg, + Item_decimal(THD *thd, const char *str_arg, uint length, + CHARSET_INFO *charset); + Item_decimal(THD *thd, const char *str, const my_decimal *val_arg, uint decimal_par, uint length); - Item_decimal(my_decimal *value_par); - Item_decimal(longlong val, bool unsig); - Item_decimal(double val, int precision, int scale); - Item_decimal(const uchar *bin, int precision, int scale); + Item_decimal(THD *thd, my_decimal *value_par); + Item_decimal(THD *thd, longlong val, bool unsig); + Item_decimal(THD *thd, double val, int precision, int scale); + Item_decimal(THD *thd, const uchar *bin, int precision, int scale); enum Type type() const { return DECIMAL_ITEM; } enum Item_result result_type () const { return DECIMAL_RESULT; } @@ -2723,12 +2729,12 @@ public: my_decimal *val_decimal(my_decimal *val) { return &decimal_value; } int save_in_field(Field *field, bool no_conversions); bool basic_const_item() const { return 1; } - Item *clone_item() + Item *clone_item(THD *thd) { - return new Item_decimal(name, &decimal_value, decimals, max_length); + return new Item_decimal(thd, name, &decimal_value, decimals, max_length); } virtual void print(String *str, enum_query_type query_type); - Item_num *neg() + Item_num *neg(THD *thd) { my_decimal_neg(&decimal_value); unsigned_flag= !decimal_value.sign(); @@ -2747,16 +2753,17 @@ class Item_float :public Item_num char *presentation; public: double value; - Item_float(const char *str_arg, uint length); - Item_float(const char *str,double val_arg,uint decimal_par,uint length) - :value(val_arg) + Item_float(THD *thd, const char *str_arg, uint length); + Item_float(THD *thd, const char *str, double val_arg, uint decimal_par, + uint length): Item_num(thd), value(val_arg) { presentation= name=(char*) str; decimals=(uint8) decimal_par; max_length=length; fixed= 1; } - Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par) + Item_float(THD *thd, double value_par, uint decimal_par): + Item_num(thd), presentation(0), value(value_par) { decimals= (uint8) decimal_par; fixed= 1; @@ -2781,9 +2788,9 @@ public: String *val_str(String*); my_decimal *val_decimal(my_decimal *); bool basic_const_item() const { return 1; } - Item *clone_item() - { return new Item_float(name, value, decimals, max_length); } - Item_num *neg() { value= -value; return this; } + Item *clone_item(THD *thd) + { return new Item_float(thd, name, value, decimals, max_length); } + Item_num *neg(THD *thd) { value= -value; return this; } virtual void print(String *str, enum_query_type query_type); bool eq(const Item *item, bool binary_cmp) const { return real_eq(value, item); } @@ -2794,9 +2801,9 @@ class Item_static_float_func :public Item_float { const char *func_name; public: - Item_static_float_func(const char *str, double val_arg, uint decimal_par, - uint length) - :Item_float(NullS, val_arg, decimal_par, length), func_name(str) + Item_static_float_func(THD *thd, const char *str, double val_arg, + uint decimal_par, uint length): + Item_float(thd, NullS, val_arg, decimal_par, length), func_name(str) {} virtual inline void print(String *str, enum_query_type query_type) @@ -2804,9 +2811,9 @@ public: str->append(func_name); } - Item *safe_charset_converter(CHARSET_INFO *tocs) + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { - return const_charset_converter(tocs, true, func_name); + return const_charset_converter(thd, tocs, true, func_name); } }; @@ -2827,7 +2834,8 @@ protected: } protected: /* Just create an item and do not fill string representation */ - Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) + Item_string(THD *thd, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE): + Item_basic_constant(thd) { collation.set(cs, dv); max_length= 0; @@ -2836,7 +2844,8 @@ protected: fixed= 1; } public: - Item_string(CHARSET_INFO *csi, const char *str_arg, uint length_arg) + Item_string(THD *thd, CHARSET_INFO *csi, const char *str_arg, uint length_arg): + Item_basic_constant(thd) { collation.set(csi, DERIVATION_COERCIBLE); set_name(NULL, 0, system_charset_info); @@ -2846,20 +2855,21 @@ public: max_length= str_value.numchars() * csi->mbmaxlen; } // Constructors with the item name set from its value - Item_string(const char *str, uint length, CHARSET_INFO *cs, - Derivation dv, uint repertoire) + Item_string(THD *thd, const char *str, uint length, CHARSET_INFO *cs, + Derivation dv, uint repertoire): Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); fix_and_set_name_from_value(dv, Metadata(&str_value, repertoire)); } - Item_string(const char *str, uint length, - CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) + Item_string(THD *thd, const char *str, uint length, + CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE): + Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); fix_and_set_name_from_value(dv, Metadata(&str_value)); } - Item_string(const String *str, CHARSET_INFO *tocs, uint *conv_errors, - Derivation dv, uint repertoire) + Item_string(THD *thd, const String *str, CHARSET_INFO *tocs, uint *conv_errors, + Derivation dv, uint repertoire): Item_basic_constant(thd) { if (str_value.copy(str, tocs, conv_errors)) str_value.set("", 0, tocs); // EOM ? @@ -2867,15 +2877,17 @@ public: fix_and_set_name_from_value(dv, Metadata(&str_value, repertoire)); } // Constructors with an externally provided item name - Item_string(const char *name_par, const char *str, uint length, - CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) + Item_string(THD *thd, const char *name_par, const char *str, uint length, + CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE): + Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); fix_from_value(dv, Metadata(&str_value)); set_name(name_par, 0, system_charset_info); } - Item_string(const char *name_par, const char *str, uint length, - CHARSET_INFO *cs, Derivation dv, uint repertoire) + Item_string(THD *thd, const char *name_par, const char *str, uint length, + CHARSET_INFO *cs, Derivation dv, uint repertoire): + Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); fix_from_value(dv, Metadata(&str_value, repertoire)); @@ -2902,14 +2914,14 @@ public: { return str_eq(&str_value, item, binary_cmp); } - Item *clone_item() + Item *clone_item(THD *thd) { - return new Item_string(name, str_value.ptr(), + return new Item_string(thd, name, str_value.ptr(), str_value.length(), collation.collation); } - Item *safe_charset_converter(CHARSET_INFO *tocs) + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { - return const_charset_converter(tocs, true); + return const_charset_converter(thd, tocs, true); } inline void append(char *str, uint length) { @@ -2982,12 +2994,13 @@ public: class Item_string_with_introducer :public Item_string { public: - Item_string_with_introducer(const char *str, uint length, CHARSET_INFO *cs) - :Item_string(str, length, cs) + Item_string_with_introducer(THD *thd, const char *str, uint length, + CHARSET_INFO *cs): + Item_string(thd, str, length, cs) { } - Item_string_with_introducer(const char *name_arg, - const char *str, uint length, CHARSET_INFO *tocs) - :Item_string(name_arg, str, length, tocs) + Item_string_with_introducer(THD *thd, const char *name_arg, + const char *str, uint length, CHARSET_INFO *tocs): + Item_string(thd, name_arg, str, length, tocs) { } virtual bool is_cs_specified() const { @@ -2999,11 +3012,11 @@ public: class Item_string_sys :public Item_string { public: - Item_string_sys(const char *str, uint length) - :Item_string(str, length, system_charset_info) + Item_string_sys(THD *thd, const char *str, uint length): + Item_string(thd, str, length, system_charset_info) { } - Item_string_sys(const char *str) - :Item_string(str, strlen(str), system_charset_info) + Item_string_sys(THD *thd, const char *str): + Item_string(thd, str, strlen(str), system_charset_info) { } }; @@ -3011,13 +3024,13 @@ public: class Item_string_ascii :public Item_string { public: - Item_string_ascii(const char *str, uint length) - :Item_string(str, length, &my_charset_latin1, - DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII) + Item_string_ascii(THD *thd, const char *str, uint length): + Item_string(thd, str, length, &my_charset_latin1, + DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII) { } - Item_string_ascii(const char *str) - :Item_string(str, strlen(str), &my_charset_latin1, - DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII) + Item_string_ascii(THD *thd, const char *str): + Item_string(thd, str, strlen(str), &my_charset_latin1, + DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII) { } }; @@ -3033,21 +3046,21 @@ class Item_static_string_func :public Item_string { const char *func_name; public: - Item_static_string_func(const char *name_par, const char *str, uint length, - CHARSET_INFO *cs, - Derivation dv= DERIVATION_COERCIBLE) - :Item_string(NullS, str, length, cs, dv), func_name(name_par) + Item_static_string_func(THD *thd, const char *name_par, const char *str, + uint length, CHARSET_INFO *cs, + Derivation dv= DERIVATION_COERCIBLE): + Item_string(thd, NullS, str, length, cs, dv), func_name(name_par) {} - Item_static_string_func(const char *name_par, + Item_static_string_func(THD *thd, const char *name_par, const String *str, CHARSET_INFO *tocs, uint *conv_errors, - Derivation dv, uint repertoire) - :Item_string(str, tocs, conv_errors, dv, repertoire), - func_name(name_par) + Derivation dv, uint repertoire): + Item_string(thd, str, tocs, conv_errors, dv, repertoire), + func_name(name_par) {} - Item *safe_charset_converter(CHARSET_INFO *tocs) + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { - return const_charset_converter(tocs, true, func_name); + return const_charset_converter(thd, tocs, true, func_name); } virtual inline void print(String *str, enum_query_type query_type) @@ -3067,9 +3080,9 @@ public: class Item_partition_func_safe_string: public Item_string { public: - Item_partition_func_safe_string(const char *name_arg, uint length, + Item_partition_func_safe_string(THD *thd, const char *name_arg, uint length, CHARSET_INFO *cs= NULL): - Item_string(name_arg, length, cs) + Item_string(thd, name_arg, length, cs) {} bool check_vcol_func_processor(uchar *arg) { @@ -3082,10 +3095,10 @@ class Item_return_date_time :public Item_partition_func_safe_string { enum_field_types date_time_field_type; public: - Item_return_date_time(const char *name_arg, uint length_arg, - enum_field_types field_type_arg) - :Item_partition_func_safe_string(name_arg, length_arg, &my_charset_bin), - date_time_field_type(field_type_arg) + Item_return_date_time(THD *thd, const char *name_arg, uint length_arg, + enum_field_types field_type_arg): + Item_partition_func_safe_string(thd, name_arg, length_arg, &my_charset_bin), + date_time_field_type(field_type_arg) { decimals= 0; } enum_field_types field_type() const { return date_time_field_type; } }; @@ -3094,8 +3107,8 @@ public: class Item_blob :public Item_partition_func_safe_string { public: - Item_blob(const char *name_arg, uint length) : - Item_partition_func_safe_string(name_arg, length, &my_charset_bin) + Item_blob(THD *thd, const char *name_arg, uint length): + Item_partition_func_safe_string(thd, name_arg, length, &my_charset_bin) { max_length= length; } enum Type type() const { return TYPE_HOLDER; } enum_field_types field_type() const { return MYSQL_TYPE_BLOB; } @@ -3111,8 +3124,10 @@ public: class Item_empty_string :public Item_partition_func_safe_string { public: - Item_empty_string(const char *header,uint length, CHARSET_INFO *cs= NULL) : - Item_partition_func_safe_string("",0, cs ? cs : &my_charset_utf8_general_ci) + Item_empty_string(THD *thd, const char *header,uint length, + CHARSET_INFO *cs= NULL): + Item_partition_func_safe_string(thd, "", 0, + cs ? cs : &my_charset_utf8_general_ci) { name=(char*) header; max_length= length * collation.collation->mbmaxlen; } void make_field(Send_field *field); }; @@ -3122,9 +3137,9 @@ class Item_return_int :public Item_int { enum_field_types int_field_type; public: - Item_return_int(const char *name_arg, uint length, - enum_field_types field_type_arg, longlong value_arg= 0) - :Item_int(name_arg, value_arg, length), int_field_type(field_type_arg) + Item_return_int(THD *thd, const char *name_arg, uint length, + enum_field_types field_type_arg, longlong value_arg= 0): + Item_int(thd, name_arg, value_arg, length), int_field_type(field_type_arg) { unsigned_flag=1; } @@ -3140,20 +3155,21 @@ class Item_hex_constant: public Item_basic_constant private: void hex_string_init(const char *str, uint str_length); public: - Item_hex_constant() + Item_hex_constant(THD *thd): Item_basic_constant(thd) { hex_string_init("", 0); } - Item_hex_constant(const char *str, uint str_length) + Item_hex_constant(THD *thd, const char *str, uint str_length): + Item_basic_constant(thd) { hex_string_init(str, str_length); } enum Type type() const { return VARBIN_ITEM; } enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } - virtual Item *safe_charset_converter(CHARSET_INFO *tocs) + virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { - return const_charset_converter(tocs, true); + return const_charset_converter(thd, tocs, true); } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *arg) { return FALSE;} @@ -3176,9 +3192,9 @@ public: class Item_hex_hybrid: public Item_hex_constant { public: - Item_hex_hybrid(): Item_hex_constant() {} - Item_hex_hybrid(const char *str, uint str_length): - Item_hex_constant(str, str_length) {} + Item_hex_hybrid(THD *thd): Item_hex_constant(thd) {} + Item_hex_hybrid(THD *thd, const char *str, uint str_length): + Item_hex_constant(thd, str, str_length) {} double val_real() { DBUG_ASSERT(fixed == 1); @@ -3211,9 +3227,9 @@ public: class Item_hex_string: public Item_hex_constant { public: - Item_hex_string(): Item_hex_constant() {} - Item_hex_string(const char *str, uint str_length): - Item_hex_constant(str, str_length) {} + Item_hex_string(THD *thd): Item_hex_constant(thd) {} + Item_hex_string(THD *thd, const char *str, uint str_length): + Item_hex_constant(thd, str, str_length) {} longlong val_int() { DBUG_ASSERT(fixed == 1); @@ -3248,7 +3264,7 @@ public: class Item_bin_string: public Item_hex_hybrid { public: - Item_bin_string(const char *str,uint str_length); + Item_bin_string(THD *thd, const char *str,uint str_length); }; @@ -3261,13 +3277,14 @@ public: Constructor for Item_date_literal. @param ltime DATE value. */ - Item_temporal_literal(MYSQL_TIME *ltime) :Item_basic_constant() + Item_temporal_literal(THD *thd, MYSQL_TIME *ltime): Item_basic_constant(thd) { collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); decimals= 0; cached_time= *ltime; } - Item_temporal_literal(MYSQL_TIME *ltime, uint dec_arg) :Item_basic_constant() + Item_temporal_literal(THD *thd, MYSQL_TIME *ltime, uint dec_arg): + Item_basic_constant(thd) { collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII); decimals= dec_arg; @@ -3307,8 +3324,8 @@ public: class Item_date_literal: public Item_temporal_literal { public: - Item_date_literal(MYSQL_TIME *ltime) - :Item_temporal_literal(ltime) + Item_date_literal(THD *thd, MYSQL_TIME *ltime) + :Item_temporal_literal(thd, ltime) { max_length= MAX_DATE_WIDTH; fixed= 1; @@ -3333,8 +3350,8 @@ public: class Item_time_literal: public Item_temporal_literal { public: - Item_time_literal(MYSQL_TIME *ltime, uint dec_arg) - :Item_temporal_literal(ltime, dec_arg) + Item_time_literal(THD *thd, MYSQL_TIME *ltime, uint dec_arg): + Item_temporal_literal(thd, ltime, dec_arg) { max_length= MIN_TIME_WIDTH + (decimals ? decimals + 1 : 0); fixed= 1; @@ -3351,8 +3368,8 @@ public: class Item_datetime_literal: public Item_temporal_literal { public: - Item_datetime_literal(MYSQL_TIME *ltime, uint dec_arg) - :Item_temporal_literal(ltime, dec_arg) + Item_datetime_literal(THD *thd, MYSQL_TIME *ltime, uint dec_arg): + Item_temporal_literal(thd, ltime, dec_arg) { max_length= MAX_DATETIME_WIDTH + (decimals ? decimals + 1 : 0); fixed= 1; @@ -3383,7 +3400,7 @@ protected: } return false; } - bool transform_args(Item_transformer transformer, uchar *arg); + bool transform_args(THD *thd, Item_transformer transformer, uchar *arg); public: uint arg_count; Item_args(void) @@ -3510,17 +3527,20 @@ public: class Item_func_or_sum: public Item_result_field, public Item_args { public: - Item_func_or_sum() :Item_args() {} - Item_func_or_sum(Item *a) :Item_args(a) { } - Item_func_or_sum(Item *a, Item *b) :Item_args(a, b) { } - Item_func_or_sum(Item *a, Item *b, Item *c) :Item_args(a, b, c) { } - Item_func_or_sum(Item *a, Item *b, Item *c, Item *d) - :Item_args(a, b, c, d) { } - Item_func_or_sum(Item *a, Item *b, Item *c, Item *d, Item *e) - :Item_args(a, b, c, d, e) { } - Item_func_or_sum(THD *thd, Item_func_or_sum *item) - :Item_result_field(thd, item), Item_args(thd, item) { } - Item_func_or_sum(List<Item> &list) :Item_args(list) { } + Item_func_or_sum(THD *thd): Item_result_field(thd), Item_args() {} + Item_func_or_sum(THD *thd, Item *a): Item_result_field(thd), Item_args(a) { } + Item_func_or_sum(THD *thd, Item *a, Item *b): + Item_result_field(thd), Item_args(a, b) { } + Item_func_or_sum(THD *thd, Item *a, Item *b, Item *c): + Item_result_field(thd), Item_args(a, b, c) { } + Item_func_or_sum(THD *thd, Item *a, Item *b, Item *c, Item *d): + Item_result_field(thd), Item_args(a, b, c, d) { } + Item_func_or_sum(THD *thd, Item *a, Item *b, Item *c, Item *d, Item *e): + Item_result_field(thd), Item_args(a, b, c, d, e) { } + Item_func_or_sum(THD *thd, Item_func_or_sum *item): + Item_result_field(thd, item), Item_args(thd, item) { } + Item_func_or_sum(THD *thd, List<Item> &list): + Item_result_field(thd), Item_args(list) { } bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { if (walk_args(processor, walk_subquery, arg)) @@ -3556,10 +3576,10 @@ public: enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF, AGGREGATE_REF }; Item **ref; bool reference_trough_name; - Item_ref(Name_resolution_context *context_arg, + Item_ref(THD *thd, Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, - const char *field_name_arg) - :Item_ident(context_arg, db_arg, table_name_arg, field_name_arg), + const char *field_name_arg): + Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg), ref(0), reference_trough_name(1) {} /* This constructor is used in two scenarios: @@ -3575,10 +3595,10 @@ public: TODO we probably fix a superset of problems like in BUG#6658. Check this with Bar, and if we have a more broader set of problems like this. */ - Item_ref(Name_resolution_context *context_arg, Item **item, + Item_ref(THD *thd, Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, bool alias_name_used_arg= FALSE); - Item_ref(TABLE_LIST *view_arg, Item **item, + Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item, const char *field_name_arg, bool alias_name_used_arg= FALSE); /* Constructor need to process subselect with temporary tables (see Item) */ @@ -3663,8 +3683,8 @@ public: else return FALSE; } - Item* transform(Item_transformer, uchar *arg); - Item* compile(Item_analyzer analyzer, uchar **arg_p, + Item* transform(THD *thd, Item_transformer, uchar *arg); + Item* compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t); bool enumerate_field_refs_processor(uchar *arg) { return (*ref)->enumerate_field_refs_processor(arg); } @@ -3738,20 +3758,20 @@ public: class Item_direct_ref :public Item_ref { public: - Item_direct_ref(Name_resolution_context *context_arg, Item **item, + Item_direct_ref(THD *thd, Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, - bool alias_name_used_arg= FALSE) - :Item_ref(context_arg, item, table_name_arg, - field_name_arg, alias_name_used_arg) + bool alias_name_used_arg= FALSE): + Item_ref(thd, context_arg, item, table_name_arg, + field_name_arg, alias_name_used_arg) {} /* Constructor need to process subselect with temporary tables (see Item) */ Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {} - Item_direct_ref(TABLE_LIST *view_arg, Item **item, + Item_direct_ref(THD *thd, TABLE_LIST *view_arg, Item **item, const char *field_name_arg, - bool alias_name_used_arg= FALSE) - :Item_ref(view_arg, item, field_name_arg, - alias_name_used_arg) + bool alias_name_used_arg= FALSE): + Item_ref(thd, view_arg, item, field_name_arg, + alias_name_used_arg) {} bool fix_fields(THD *thd, Item **it) @@ -3782,9 +3802,9 @@ class Item_direct_ref_to_ident :public Item_direct_ref { Item_ident *ident; public: - Item_direct_ref_to_ident(Item_ident *item) - :Item_direct_ref(item->context, (Item**)&item, item->table_name, item->field_name, - FALSE) + Item_direct_ref_to_ident(THD *thd, Item_ident *item): + Item_direct_ref(thd, item->context, (Item**)&item, item->table_name, + item->field_name, FALSE) { ident= item; ref= (Item**)&ident; @@ -3836,7 +3856,7 @@ private: void init_on_demand(); public: - Item_cache_wrapper(Item *item_arg); + Item_cache_wrapper(THD *thd, Item *item_arg); ~Item_cache_wrapper(); enum Type type() const { return EXPR_CACHE_ITEM; } @@ -3964,11 +3984,12 @@ class Item_direct_view_ref :public Item_direct_ref } public: - Item_direct_view_ref(Name_resolution_context *context_arg, Item **item, + Item_direct_view_ref(THD *thd, Name_resolution_context *context_arg, + Item **item, const char *table_name_arg, const char *field_name_arg, - TABLE_LIST *view_arg) - :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg), + TABLE_LIST *view_arg): + Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg), item_equal(0), view(view_arg), null_ref_table(NULL) { @@ -3989,8 +4010,8 @@ public: void set_item_equal(Item_equal *item_eq) { item_equal= item_eq; } Item_equal *find_item_equal(COND_EQUAL *cond_equal); bool subst_argument_checker(uchar **arg); - Item *equal_fields_propagator(uchar *arg); - Item *replace_equal_field(uchar *arg); + Item *equal_fields_propagator(THD *thd, uchar *arg); + Item *replace_equal_field(THD *thd, uchar *arg); table_map used_tables() const; void update_used_tables(); table_map not_null_tables() const; @@ -4114,10 +4135,10 @@ public: */ bool found_in_select_list; bool found_in_group_by; - Item_outer_ref(Name_resolution_context *context_arg, - Item_field *outer_field_arg) - :Item_direct_ref(context_arg, 0, outer_field_arg->table_name, - outer_field_arg->field_name), + Item_outer_ref(THD *thd, Name_resolution_context *context_arg, + Item_field *outer_field_arg): + Item_direct_ref(thd, context_arg, 0, outer_field_arg->table_name, + outer_field_arg->field_name), outer_ref(outer_field_arg), in_sum_func(0), found_in_select_list(0), found_in_group_by(0) { @@ -4125,11 +4146,11 @@ public: set_properties(); fixed= 0; /* reset flag set in set_properties() */ } - Item_outer_ref(Name_resolution_context *context_arg, Item **item, + Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item, const char *table_name_arg, const char *field_name_arg, - bool alias_name_used_arg) - :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg, - alias_name_used_arg), + bool alias_name_used_arg): + Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg, + alias_name_used_arg), outer_ref(0), in_sum_func(0), found_in_select_list(1), found_in_group_by(0) {} void save_in_result_field(bool no_conversions) @@ -4165,11 +4186,11 @@ class Item_ref_null_helper: public Item_ref protected: Item_in_subselect* owner; public: - Item_ref_null_helper(Name_resolution_context *context_arg, + Item_ref_null_helper(THD *thd, Name_resolution_context *context_arg, Item_in_subselect* master, Item **item, - const char *table_name_arg, const char *field_name_arg) - :Item_ref(context_arg, item, table_name_arg, field_name_arg), - owner(master) {} + const char *table_name_arg, const char *field_name_arg): + Item_ref(thd, context_arg, item, table_name_arg, field_name_arg), + owner(master) {} void save_val(Field *to); double val_real(); longlong val_int(); @@ -4194,8 +4215,8 @@ class Item_int_with_ref :public Item_int { Item *ref; public: - Item_int_with_ref(longlong i, Item *ref_arg, bool unsigned_arg) : - Item_int(i), ref(ref_arg) + Item_int_with_ref(THD *thd, longlong i, Item *ref_arg, bool unsigned_arg): + Item_int(thd, i), ref(ref_arg) { unsigned_flag= unsigned_arg; } @@ -4203,7 +4224,7 @@ public: { return ref->save_in_field(field, no_conversions); } - Item *clone_item(); + Item *clone_item(THD *thd); virtual Item *real_item() { return ref; } }; @@ -4267,7 +4288,7 @@ protected: stores metadata information about the original class as well as a pointer to it. */ - Item_copy(Item *i) + Item_copy(THD *thd, Item *i): Item(thd) { item= i; null_value=maybe_null=item->maybe_null; @@ -4285,7 +4306,7 @@ public: @param item the original item. */ - static Item_copy *create (Item *item); + static Item_copy *create(THD *thd, Item *item); /** Update the cache with the value of the original item @@ -4331,7 +4352,7 @@ public: class Item_copy_string : public Item_copy { public: - Item_copy_string (Item *item_arg) : Item_copy(item_arg) {} + Item_copy_string(THD *thd, Item *item_arg): Item_copy(thd, item_arg) {} String *val_str(String*); my_decimal *val_decimal(my_decimal *); @@ -4347,7 +4368,7 @@ class Item_copy_int : public Item_copy protected: longlong cached_value; public: - Item_copy_int (Item *i) : Item_copy(i) {} + Item_copy_int(THD *thd, Item *i): Item_copy(thd, i) {} int save_in_field(Field *field, bool no_conversions); virtual String *val_str(String*); @@ -4367,7 +4388,7 @@ public: class Item_copy_uint : public Item_copy_int { public: - Item_copy_uint (Item *item_arg) : Item_copy_int(item_arg) + Item_copy_uint(THD *thd, Item *item_arg): Item_copy_int(thd, item_arg) { unsigned_flag= 1; } @@ -4385,7 +4406,7 @@ class Item_copy_float : public Item_copy protected: double cached_value; public: - Item_copy_float (Item *i) : Item_copy(i) {} + Item_copy_float(THD *thd, Item *i): Item_copy(thd, i) {} int save_in_field(Field *field, bool no_conversions); String *val_str(String*); @@ -4411,7 +4432,7 @@ class Item_copy_decimal : public Item_copy protected: my_decimal cached_value; public: - Item_copy_decimal (Item *i) : Item_copy(i) {} + Item_copy_decimal(THD *thd, Item *i): Item_copy(thd, i) {} int save_in_field(Field *field, bool no_conversions); String *val_str(String*); @@ -4537,7 +4558,7 @@ public: (this->*processor)(args); } - Item *transform(Item_transformer transformer, uchar *args); + Item *transform(THD *thd, Item_transformer transformer, uchar *args); }; /* @@ -4701,7 +4722,8 @@ protected: */ bool value_cached; public: - Item_cache(): + Item_cache(THD *thd): + Item_basic_constant(thd), example(0), cached_field(0), cached_field_type(MYSQL_TYPE_STRING), value_cached(0) @@ -4710,7 +4732,8 @@ public: maybe_null= 1; null_value= 1; } - Item_cache(enum_field_types field_type_arg): + Item_cache(THD *thd, enum_field_types field_type_arg): + Item_basic_constant(thd), example(0), cached_field(0), cached_field_type(field_type_arg), value_cached(0) @@ -4721,7 +4744,7 @@ public: } virtual bool allocate(uint i) { return 0; } - virtual bool setup(Item *item) + virtual bool setup(THD *thd, Item *item) { example= item; Type_std_attributes::set(item); @@ -4731,8 +4754,8 @@ public: }; enum Type type() const { return CACHE_ITEM; } enum_field_types field_type() const { return cached_field_type; } - static Item_cache* get_cache(const Item *item); - static Item_cache* get_cache(const Item* item, const Item_result type); + static Item_cache* get_cache(THD *thd, const Item *item); + static Item_cache* get_cache(THD *thd, const Item* item, const Item_result type); virtual void keep_array() {} virtual void print(String *str, enum_query_type query_type); bool eq_def(Field *field) @@ -4783,7 +4806,7 @@ public: return TRUE; return (this->*processor)(arg); } - virtual Item *safe_charset_converter(CHARSET_INFO *tocs); + virtual Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); }; @@ -4792,10 +4815,10 @@ class Item_cache_int: public Item_cache protected: longlong value; public: - Item_cache_int(): Item_cache(MYSQL_TYPE_LONGLONG), + Item_cache_int(THD *thd): Item_cache(thd, MYSQL_TYPE_LONGLONG), value(0) {} - Item_cache_int(enum_field_types field_type_arg): - Item_cache(field_type_arg), value(0) {} + Item_cache_int(THD *thd, enum_field_types field_type_arg): + Item_cache(thd, field_type_arg), value(0) {} double val_real(); longlong val_int(); @@ -4810,7 +4833,7 @@ public: class Item_cache_temporal: public Item_cache_int { public: - Item_cache_temporal(enum_field_types field_type_arg); + Item_cache_temporal(THD *thd, enum_field_types field_type_arg); String* val_str(String *str); my_decimal *val_decimal(my_decimal *); longlong val_int(); @@ -4826,9 +4849,9 @@ public: is a constant and need not be optimized further. Important when storing packed datetime values. */ - Item *clone_item() + Item *clone_item(THD *thd) { - Item_cache_temporal *item= new Item_cache_temporal(cached_field_type); + Item_cache_temporal *item= new Item_cache_temporal(thd, cached_field_type); item->store_packed(value, example); return item; } @@ -4839,7 +4862,7 @@ class Item_cache_real: public Item_cache { double value; public: - Item_cache_real(): Item_cache(MYSQL_TYPE_DOUBLE), + Item_cache_real(THD *thd): Item_cache(thd, MYSQL_TYPE_DOUBLE), value(0) {} double val_real(); @@ -4856,7 +4879,7 @@ class Item_cache_decimal: public Item_cache protected: my_decimal decimal_value; public: - Item_cache_decimal(): Item_cache(MYSQL_TYPE_NEWDECIMAL) {} + Item_cache_decimal(THD *thd): Item_cache(thd, MYSQL_TYPE_NEWDECIMAL) {} double val_real(); longlong val_int(); @@ -4874,8 +4897,8 @@ class Item_cache_str: public Item_cache bool is_varbinary; public: - Item_cache_str(const Item *item) : - Item_cache(item->field_type()), value(0), + Item_cache_str(THD *thd, const Item *item): + Item_cache(thd, item->field_type()), value(0), is_varbinary(item->type() == FIELD_ITEM && cached_field_type == MYSQL_TYPE_VARCHAR && !((const Item_field *) item)->field->has_charset()) @@ -4898,8 +4921,8 @@ class Item_cache_row: public Item_cache uint item_count; bool save_array; public: - Item_cache_row() - :Item_cache(), values(0), item_count(2), + Item_cache_row(THD *thd): + Item_cache(thd), values(0), item_count(2), save_array(0) {} /* @@ -4911,7 +4934,7 @@ public: 'setup' is needed only by row => it not called by simple row subselect (only by IN subselect (in subselect optimizer)) */ - bool setup(Item *item); + bool setup(THD *thd, Item *item); void store(Item *item); void illegal_method_call(const char *); void make_field(Send_field *) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 6ae2b81dcaf..564b445ed09 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -442,7 +442,7 @@ static bool convert_const_to_int(THD *thd, Item_field *field_item, if (0 == field_cmp) { - Item *tmp= new Item_int_with_ref(field->val_int(), *item, + Item *tmp= new Item_int_with_ref(thd, field->val_int(), *item, MY_TEST(field->flags & UNSIGNED_FLAG)); if (tmp) thd->change_item_tree(item, tmp); @@ -789,8 +789,8 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value, (*value)->const_item() && type != (*value)->result_type() && type != TIME_RESULT) { - Item_cache *cache= Item_cache::get_cache(*value, type); - cache->setup(*value); + Item_cache *cache= Item_cache::get_cache(thd_arg, *value, type); + cache->setup(thd_arg, *value); *cache_item= cache; return cache_item; } @@ -878,7 +878,7 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, { Query_arena backup; Query_arena *save_arena= thd->switch_to_arena_for_cached_items(&backup); - Item_cache_temporal *cache= new Item_cache_temporal(f_type); + Item_cache_temporal *cache= new Item_cache_temporal(thd, f_type); if (save_arena) thd->set_query_arena(save_arena); @@ -1411,11 +1411,11 @@ bool Item_in_optimizer::fix_left(THD *thd) { DBUG_ENTER("Item_in_optimizer::fix_left"); if ((!args[0]->fixed && args[0]->fix_fields(thd, args)) || - (!cache && !(cache= Item_cache::get_cache(args[0])))) + (!cache && !(cache= Item_cache::get_cache(thd, args[0])))) DBUG_RETURN(1); DBUG_PRINT("info", ("actual fix fields")); - cache->setup(args[0]); + cache->setup(thd, args[0]); if (cache->cols() == 1) { DBUG_ASSERT(args[0]->type() != ROW_ITEM); @@ -1542,9 +1542,8 @@ bool Item_in_optimizer::invisible_mode() this item - otherwise */ -Item *Item_in_optimizer::expr_cache_insert_transformer(uchar *thd_arg) +Item *Item_in_optimizer::expr_cache_insert_transformer(THD *thd, uchar *unused) { - THD *thd= (THD*) thd_arg; DBUG_ENTER("Item_in_optimizer::expr_cache_insert_transformer"); if (invisible_mode()) @@ -1802,16 +1801,16 @@ bool Item_in_optimizer::is_null() @retval NULL if an error occurred */ -Item *Item_in_optimizer::transform(Item_transformer transformer, +Item *Item_in_optimizer::transform(THD *thd, Item_transformer transformer, uchar *argument) { Item *new_item; - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); DBUG_ASSERT(arg_count == 2); /* Transform the left IN operand. */ - new_item= (*args)->transform(transformer, argument); + new_item= (*args)->transform(thd, transformer, argument); if (!new_item) return 0; /* @@ -1821,16 +1820,16 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, change records at each execution. */ if ((*args) != new_item) - current_thd->change_item_tree(args, new_item); + thd->change_item_tree(args, new_item); if (invisible_mode()) { /* MAX/MIN transformed => pass through */ - new_item= args[1]->transform(transformer, argument); + new_item= args[1]->transform(thd, transformer, argument); if (!new_item) return 0; if (args[1] != new_item) - current_thd->change_item_tree(args + 1, new_item); + thd->change_item_tree(args + 1, new_item); } else { @@ -1852,7 +1851,7 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, Item_in_subselect *in_arg= (Item_in_subselect*)args[1]; current_thd->change_item_tree(&in_arg->left_expr, args[0]); } - return (this->*transformer)(argument); + return (this->*transformer)(thd, argument); } @@ -4285,7 +4284,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) Query_arena backup, *arena; Item *new_item; arena= thd->activate_stmt_arena_if_needed(&backup); - if ((new_item= new Item_func_ne(item, new Item_int(0, 1)))) + if ((new_item= new Item_func_ne(thd, item, new Item_int(thd, 0, 1)))) li.replace(item= new_item); if (arena) thd->restore_active_arena(arena, &backup); @@ -4450,15 +4449,15 @@ bool Item_cond_and::walk_top_and(Item_processor processor, uchar *arg) Item returned as the result of transformation of the root node */ -Item *Item_cond::transform(Item_transformer transformer, uchar *arg) +Item *Item_cond::transform(THD *thd, Item_transformer transformer, uchar *arg) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); List_iterator<Item> li(list); Item *item; while ((item= li++)) { - Item *new_item= item->transform(transformer, arg); + Item *new_item= item->transform(thd, transformer, arg); if (!new_item) return 0; @@ -4469,9 +4468,9 @@ Item *Item_cond::transform(Item_transformer transformer, uchar *arg) change records at each execution. */ if (new_item != item) - current_thd->change_item_tree(li.ref(), new_item); + thd->change_item_tree(li.ref(), new_item); } - return Item_func::transform(transformer, arg); + return Item_func::transform(thd, transformer, arg); } @@ -4499,7 +4498,7 @@ Item *Item_cond::transform(Item_transformer transformer, uchar *arg) Item returned as the result of transformation of the root node */ -Item *Item_cond::compile(Item_analyzer analyzer, uchar **arg_p, +Item *Item_cond::compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) { if (!(this->*analyzer)(arg_p)) @@ -4514,11 +4513,11 @@ Item *Item_cond::compile(Item_analyzer analyzer, uchar **arg_p, to analyze any argument of the condition formula. */ uchar *arg_v= *arg_p; - Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t); + Item *new_item= item->compile(thd, analyzer, &arg_v, transformer, arg_t); if (new_item && new_item != item) - current_thd->change_item_tree(li.ref(), new_item); + thd->change_item_tree(li.ref(), new_item); } - return Item_func::transform(transformer, arg_t); + return Item_func::transform(thd, transformer, arg_t); } void Item_cond::traverse_cond(Cond_traverser traverser, @@ -4607,7 +4606,7 @@ void Item_cond::neg_arguments(THD *thd) Item *new_item= item->neg_transformer(thd); if (!new_item) { - if (!(new_item= new Item_func_not(item))) + if (!(new_item= new Item_func_not(thd, item))) return; // Fatal OEM error } (void) li.replace(new_item); @@ -4703,14 +4702,14 @@ longlong Item_cond_or::val_int() Item */ -Item *and_expressions(Item *a, Item *b, Item **org_item) +Item *and_expressions(THD *thd, Item *a, Item *b, Item **org_item) { if (!a) return (*org_item= (Item*) b); if (a == *org_item) { Item_cond *res; - if ((res= new Item_cond_and(a, (Item*) b))) + if ((res= new Item_cond_and(thd, a, (Item*) b))) { res->used_tables_cache= a->used_tables() | b->used_tables(); res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables(); @@ -5528,7 +5527,7 @@ bool Item_func_not::fix_fields(THD *thd, Item **ref) Item *new_item; bool rc= TRUE; arena= thd->activate_stmt_arena_if_needed(&backup); - if ((new_item= new Item_func_eq(args[0], new Item_int(0, 1)))) + if ((new_item= new Item_func_eq(thd, args[0], new Item_int(thd, 0, 1)))) { new_item->name= name; rc= (*ref= new_item)->fix_fields(thd, ref); @@ -5543,7 +5542,7 @@ bool Item_func_not::fix_fields(THD *thd, Item **ref) Item *Item_bool_rowready_func2::neg_transformer(THD *thd) { - Item *item= negated_item(); + Item *item= negated_item(thd); return item; } @@ -5562,14 +5561,14 @@ Item *Item_func_xor::neg_transformer(THD *thd) Item_func_xor *new_item; if ((neg_operand= args[0]->neg_transformer(thd))) // args[0] has neg_tranformer - new_item= new(thd->mem_root) Item_func_xor(neg_operand, args[1]); + new_item= new(thd->mem_root) Item_func_xor(thd, neg_operand, args[1]); else if ((neg_operand= args[1]->neg_transformer(thd))) // args[1] has neg_tranformer - new_item= new(thd->mem_root) Item_func_xor(args[0], neg_operand); + new_item= new(thd->mem_root) Item_func_xor(thd, args[0], neg_operand); else { - neg_operand= new(thd->mem_root) Item_func_not(args[0]); - new_item= new(thd->mem_root) Item_func_xor(neg_operand, args[1]); + neg_operand= new(thd->mem_root) Item_func_not(thd, args[0]); + new_item= new(thd->mem_root) Item_func_xor(thd, neg_operand, args[1]); } return new_item; } @@ -5580,7 +5579,7 @@ Item *Item_func_xor::neg_transformer(THD *thd) */ Item *Item_func_isnull::neg_transformer(THD *thd) { - Item *item= new Item_func_isnotnull(args[0]); + Item *item= new Item_func_isnotnull(thd, args[0]); return item; } @@ -5590,7 +5589,7 @@ Item *Item_func_isnull::neg_transformer(THD *thd) */ Item *Item_func_isnotnull::neg_transformer(THD *thd) { - Item *item= new Item_func_isnull(args[0]); + Item *item= new Item_func_isnull(thd, args[0]); return item; } @@ -5599,7 +5598,7 @@ Item *Item_cond_and::neg_transformer(THD *thd) /* NOT(a AND b AND ...) -> */ /* NOT a OR NOT b OR ... */ { neg_arguments(thd); - Item *item= new Item_cond_or(list); + Item *item= new Item_cond_or(thd, list); return item; } @@ -5608,7 +5607,7 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */ /* NOT a AND NOT b AND ... */ { neg_arguments(thd); - Item *item= new Item_cond_and(list); + Item *item= new Item_cond_and(thd, list); return item; } @@ -5616,7 +5615,7 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */ Item *Item_func_nop_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ANY (SELECT ...)) -> e $rev_cmp$" ALL (SELECT ...) */ - Item_func_not_all *new_item= new Item_func_not_all(args[0]); + Item_func_not_all *new_item= new Item_func_not_all(thd, args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->create_comp_func(FALSE); allany->all= !allany->all; @@ -5627,7 +5626,7 @@ Item *Item_func_nop_all::neg_transformer(THD *thd) Item *Item_func_not_all::neg_transformer(THD *thd) { /* "NOT (e $cmp$ ALL (SELECT ...)) -> e $rev_cmp$" ANY (SELECT ...) */ - Item_func_nop_all *new_item= new Item_func_nop_all(args[0]); + Item_func_nop_all *new_item= new Item_func_nop_all(thd, args[0]); Item_allany_subselect *allany= (Item_allany_subselect*)args[0]; allany->all= !allany->all; allany->create_comp_func(TRUE); @@ -5635,45 +5634,45 @@ Item *Item_func_not_all::neg_transformer(THD *thd) return new_item; } -Item *Item_func_eq::negated_item() /* a = b -> a != b */ +Item *Item_func_eq::negated_item(THD *thd) /* a = b -> a != b */ { - return new Item_func_ne(args[0], args[1]); + return new Item_func_ne(thd, args[0], args[1]); } -Item *Item_func_ne::negated_item() /* a != b -> a = b */ +Item *Item_func_ne::negated_item(THD *thd) /* a != b -> a = b */ { - return new Item_func_eq(args[0], args[1]); + return new Item_func_eq(thd, args[0], args[1]); } -Item *Item_func_lt::negated_item() /* a < b -> a >= b */ +Item *Item_func_lt::negated_item(THD *thd) /* a < b -> a >= b */ { - return new Item_func_ge(args[0], args[1]); + return new Item_func_ge(thd, args[0], args[1]); } -Item *Item_func_ge::negated_item() /* a >= b -> a < b */ +Item *Item_func_ge::negated_item(THD *thd) /* a >= b -> a < b */ { - return new Item_func_lt(args[0], args[1]); + return new Item_func_lt(thd, args[0], args[1]); } -Item *Item_func_gt::negated_item() /* a > b -> a <= b */ +Item *Item_func_gt::negated_item(THD *thd) /* a > b -> a <= b */ { - return new Item_func_le(args[0], args[1]); + return new Item_func_le(thd, args[0], args[1]); } -Item *Item_func_le::negated_item() /* a <= b -> a > b */ +Item *Item_func_le::negated_item(THD *thd) /* a <= b -> a > b */ { - return new Item_func_gt(args[0], args[1]); + return new Item_func_gt(thd, args[0], args[1]); } /** just fake method, should never be called. */ -Item *Item_bool_rowready_func2::negated_item() +Item *Item_bool_rowready_func2::negated_item(THD *thd) { DBUG_ASSERT(0); return 0; @@ -5696,14 +5695,14 @@ Item *Item_bool_rowready_func2::negated_item() of the type Item_field or Item_direct_view_ref(Item_field). */ -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) +Item_equal::Item_equal(THD *thd, Item *f1, Item *f2, bool with_const_item): + Item_bool_func(thd), 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, thd_arg->mem_root); - equal_items.push_back(f2, thd_arg->mem_root); + equal_items.push_back(f1, thd->mem_root); + equal_items.push_back(f2, thd->mem_root); compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT; upper_levels= NULL; } @@ -5721,16 +5720,16 @@ Item_equal::Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item) outer join). */ -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) +Item_equal::Item_equal(THD *thd, Item_equal *item_equal): + Item_bool_func(thd), eval_item(0), cond_false(0), cond_true(0), + context_field(NULL), link_equal_fields(FALSE) { const_item_cache= 0; List_iterator_fast<Item> li(item_equal->equal_items); Item *item; while ((item= li++)) { - equal_items.push_back(item, thd_arg->mem_root); + equal_items.push_back(item, thd->mem_root); } with_const= item_equal->with_const; compare_as_dates= item_equal->compare_as_dates; @@ -5776,7 +5775,7 @@ void Item_equal::add_const(THD *thd, Item *c, Item *f) } else { - Item_func_eq *func= new (thd->mem_root) Item_func_eq(c, const_item); + Item_func_eq *func= new (thd->mem_root) Item_func_eq(thd, c, const_item); if (func->set_cmp_func()) { /* @@ -6216,15 +6215,15 @@ bool Item_equal::walk(Item_processor processor, bool walk_subquery, uchar *arg) } -Item *Item_equal::transform(Item_transformer transformer, uchar *arg) +Item *Item_equal::transform(THD *thd, Item_transformer transformer, uchar *arg) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); Item *item; Item_equal_fields_iterator it(*this); while ((item= it++)) { - Item *new_item= item->transform(transformer, arg); + Item *new_item= item->transform(thd, transformer, arg); if (!new_item) return 0; @@ -6235,9 +6234,9 @@ Item *Item_equal::transform(Item_transformer transformer, uchar *arg) change records at each execution. */ if (new_item != item) - current_thd->change_item_tree((Item **) it.ref(), new_item); + thd->change_item_tree((Item **) it.ref(), new_item); } - return Item_func::transform(transformer, arg); + return Item_func::transform(thd, transformer, arg); } @@ -6477,3 +6476,75 @@ null: null_value= TRUE; return 0; } + + +Item_bool_rowready_func2 *Eq_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_eq(thd, a, b); +} + + +Item_bool_rowready_func2* Eq_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_eq(thd, b, a); +} + + +Item_bool_rowready_func2* Ne_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_ne(thd, a, b); +} + + +Item_bool_rowready_func2* Ne_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_ne(thd, b, a); +} + + +Item_bool_rowready_func2* Gt_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_gt(thd, a, b); +} + + +Item_bool_rowready_func2* Gt_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_lt(thd, b, a); +} + + +Item_bool_rowready_func2* Lt_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_lt(thd, a, b); +} + + +Item_bool_rowready_func2* Lt_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_gt(thd, b, a); +} + + +Item_bool_rowready_func2* Ge_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_ge(thd, a, b); +} + + +Item_bool_rowready_func2* Ge_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_le(thd, b, a); +} + + +Item_bool_rowready_func2* Le_creator::create(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_le(thd, a, b); +} + + +Item_bool_rowready_func2* Le_creator::create_swap(THD *thd, Item *a, Item *b) const +{ + return new(thd->mem_root) Item_func_ge(thd, b, a); +} diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index b4f5d2dd963..83f3afaa009 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -155,11 +155,11 @@ protected: KEY_PART *key_part, Item_func::Functype type, Item *value); public: - Item_bool_func() :Item_int_func() {} - Item_bool_func(Item *a) :Item_int_func(a) {} - Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {} - Item_bool_func(Item *a, Item *b, Item *c) :Item_int_func(a, b, c) {} - Item_bool_func(List<Item> &list) :Item_int_func(list) { } + Item_bool_func(THD *thd): Item_int_func(thd) {} + Item_bool_func(THD *thd, Item *a): Item_int_func(thd, a) {} + Item_bool_func(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} + Item_bool_func(THD *thd, Item *a, Item *b, Item *c): Item_int_func(thd, a, b, c) {} + Item_bool_func(THD *thd, List<Item> &list): Item_int_func(thd, list) { } Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {} bool is_bool_type() { return true; } void fix_length_and_dec() { decimals=0; max_length=1; } @@ -181,8 +181,8 @@ public: virtual void print(String *str, enum_query_type query_type); protected: - Item_func_truth(Item *a, bool a_value, bool a_affirmative) - : Item_bool_func(a), value(a_value), affirmative(a_affirmative) + Item_func_truth(THD *thd, Item *a, bool a_value, bool a_affirmative): + Item_bool_func(thd, a), value(a_value), affirmative(a_affirmative) {} ~Item_func_truth() @@ -207,7 +207,7 @@ private: class Item_func_istrue : public Item_func_truth { public: - Item_func_istrue(Item *a) : Item_func_truth(a, true, true) {} + Item_func_istrue(THD *thd, Item *a): Item_func_truth(thd, a, true, true) {} ~Item_func_istrue() {} virtual const char* func_name() const { return "istrue"; } }; @@ -220,7 +220,8 @@ public: class Item_func_isnottrue : public Item_func_truth { public: - Item_func_isnottrue(Item *a) : Item_func_truth(a, true, false) {} + Item_func_isnottrue(THD *thd, Item *a): + Item_func_truth(thd, a, true, false) {} ~Item_func_isnottrue() {} virtual const char* func_name() const { return "isnottrue"; } }; @@ -233,7 +234,7 @@ public: class Item_func_isfalse : public Item_func_truth { public: - Item_func_isfalse(Item *a) : Item_func_truth(a, false, true) {} + Item_func_isfalse(THD *thd, Item *a): Item_func_truth(thd, a, false, true) {} ~Item_func_isfalse() {} virtual const char* func_name() const { return "isfalse"; } }; @@ -246,7 +247,8 @@ public: class Item_func_isnotfalse : public Item_func_truth { public: - Item_func_isnotfalse(Item *a) : Item_func_truth(a, false, false) {} + Item_func_isnotfalse(THD *thd, Item *a): + Item_func_truth(thd, a, false, false) {} ~Item_func_isnotfalse() {} virtual const char* func_name() const { return "isnotfalse"; } }; @@ -285,8 +287,8 @@ protected: */ int result_for_null_param; public: - Item_in_optimizer(Item *a, Item *b): - Item_bool_func(a, b), cache(0), expr_cache(0), + Item_in_optimizer(THD *thd, Item *a, Item *b): + Item_bool_func(thd, a, b), cache(0), expr_cache(0), save_cache(0), result_for_null_param(UNKNOWN) { with_subselect= true; } bool fix_fields(THD *, Item **); @@ -298,8 +300,8 @@ public: const char *func_name() const { return "<in_optimizer>"; } Item_cache **get_cache() { return &cache; } void keep_top_level_cache(); - Item *transform(Item_transformer transformer, uchar *arg); - virtual Item *expr_cache_insert_transformer(uchar *thd_arg); + Item *transform(THD *thd, Item_transformer transformer, uchar *arg); + virtual Item *expr_cache_insert_transformer(THD *thd, uchar *unused); bool is_expensive_processor(uchar *arg); bool is_expensive(); void set_join_tab_idx(uint join_tab_idx_arg) @@ -339,8 +341,8 @@ protected: DBUG_RETURN(get_mm_parts(param, field, func_type, value, cmp_type)); } public: - Item_bool_func2(Item *a,Item *b) - :Item_bool_func(a,b) { } + Item_bool_func2(THD *thd, Item *a, Item *b): + Item_bool_func(thd, a, b) { } virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; } bool is_null() { return MY_TEST(args[0]->is_null() || args[1]->is_null()); } @@ -355,8 +357,8 @@ class Item_bool_rowready_func2 :public Item_bool_func2 protected: Arg_comparator cmp; public: - Item_bool_rowready_func2(Item *a, Item *b) - :Item_bool_func2(a, b), cmp(tmp_arg, tmp_arg+1) + Item_bool_rowready_func2(THD *thd, Item *a, Item *b): + Item_bool_func2(thd, a, b), cmp(tmp_arg, tmp_arg + 1) { allowed_arg_cols= 0; // Fetch this value from first argument } @@ -365,7 +367,7 @@ public: Item_func::print_op(str, query_type); } Item *neg_transformer(THD *thd); - virtual Item *negated_item(); + virtual Item *negated_item(THD *thd); bool subst_argument_checker(uchar **arg) { return (*arg != NULL); @@ -408,7 +410,7 @@ public: class Item_func_xor :public Item_bool_func { public: - Item_func_xor(Item *i1, Item *i2) :Item_bool_func(i1, i2) {} + Item_func_xor(THD *thd, Item *i1, Item *i2): Item_bool_func(thd, i1, i2) {} enum Functype functype() const { return XOR_FUNC; } const char *func_name() const { return "xor"; } void print(String *str, enum_query_type query_type) @@ -425,7 +427,8 @@ class Item_func_not :public Item_bool_func { bool abort_on_null; public: - Item_func_not(Item *a) :Item_bool_func(a), abort_on_null(FALSE) {} + Item_func_not(THD *thd, Item *a): + Item_bool_func(thd, a), abort_on_null(FALSE) {} virtual void top_level_item() { abort_on_null= 1; } bool is_top_level_item() { return abort_on_null; } longlong val_int(); @@ -471,7 +474,8 @@ class Item_func_trig_cond: public Item_bool_func { bool *trig_var; public: - Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; } + Item_func_trig_cond(THD *thd, Item *a, bool *f): Item_bool_func(thd, a) + { trig_var= f; } longlong val_int() { return *trig_var ? args[0]->val_int() : 1; } enum Functype functype() const { return TRIG_COND_FUNC; }; const char *func_name() const { return "trigcond"; }; @@ -491,9 +495,8 @@ class Item_func_not_all :public Item_func_not public: bool show; - Item_func_not_all(Item *a) - :Item_func_not(a), test_sum_item(0), test_sub_item(0), - show(0) + Item_func_not_all(THD *thd, Item *a): + Item_func_not(thd, a), test_sum_item(0), test_sub_item(0), show(0) {} table_map not_null_tables() const { return 0; } longlong val_int(); @@ -513,7 +516,7 @@ class Item_func_nop_all :public Item_func_not_all { public: - Item_func_nop_all(Item *a) :Item_func_not_all(a) {} + Item_func_nop_all(THD *thd, Item *a): Item_func_not_all(thd, a) {} longlong val_int(); const char *func_name() const { return "<nop>"; } Item *neg_transformer(THD *thd); @@ -524,8 +527,8 @@ class Item_func_eq :public Item_bool_rowready_func2 { bool abort_on_null; public: - Item_func_eq(Item *a,Item *b) : - Item_bool_rowready_func2(a,b), + Item_func_eq(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b), abort_on_null(false), in_equality_no(UINT_MAX) {} longlong val_int(); @@ -534,7 +537,7 @@ public: cond_result eq_cmp_result() const { return COND_TRUE; } const char *func_name() const { return "="; } void top_level_item() { abort_on_null= true; } - Item *negated_item(); + Item *negated_item(THD *thd); COND *build_equal_items(THD *thd, COND_EQUAL *inherited, bool link_item_fields, COND_EQUAL **cond_equal_ref); @@ -561,7 +564,8 @@ public: class Item_func_equal :public Item_bool_rowready_func2 { public: - Item_func_equal(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}; + Item_func_equal(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {} longlong val_int(); void fix_length_and_dec(); table_map not_null_tables() const { return 0; } @@ -583,52 +587,56 @@ public: class Item_func_ge :public Item_bool_rowready_func2 { public: - Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}; + Item_func_ge(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {}; longlong val_int(); enum Functype functype() const { return GE_FUNC; } enum Functype rev_functype() const { return LE_FUNC; } cond_result eq_cmp_result() const { return COND_TRUE; } const char *func_name() const { return ">="; } - Item *negated_item(); + Item *negated_item(THD *thd); }; class Item_func_gt :public Item_bool_rowready_func2 { public: - Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}; + Item_func_gt(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {}; longlong val_int(); enum Functype functype() const { return GT_FUNC; } enum Functype rev_functype() const { return LT_FUNC; } cond_result eq_cmp_result() const { return COND_FALSE; } const char *func_name() const { return ">"; } - Item *negated_item(); + Item *negated_item(THD *thd); }; class Item_func_le :public Item_bool_rowready_func2 { public: - Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}; + Item_func_le(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {}; longlong val_int(); enum Functype functype() const { return LE_FUNC; } enum Functype rev_functype() const { return GE_FUNC; } cond_result eq_cmp_result() const { return COND_TRUE; } const char *func_name() const { return "<="; } - Item *negated_item(); + Item *negated_item(THD *thd); }; class Item_func_lt :public Item_bool_rowready_func2 { public: - Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {} + Item_func_lt(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {} longlong val_int(); enum Functype functype() const { return LT_FUNC; } enum Functype rev_functype() const { return GT_FUNC; } cond_result eq_cmp_result() const { return COND_FALSE; } const char *func_name() const { return "<"; } - Item *negated_item(); + Item *negated_item(THD *thd); }; @@ -642,13 +650,14 @@ protected: DBUG_RETURN(get_ne_mm_tree(param, field, value, value, cmp_type)); } public: - Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {} + Item_func_ne(THD *thd, Item *a, Item *b): + Item_bool_rowready_func2(thd, a, b) {} longlong val_int(); enum Functype functype() const { return NE_FUNC; } enum Functype rev_functype() const { return NE_FUNC; } cond_result eq_cmp_result() const { return COND_FALSE; } const char *func_name() const { return "<>"; } - Item *negated_item(); + Item *negated_item(THD *thd); void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, table_map usable_tables, SARGABLE_PARAM **sargables); }; @@ -669,10 +678,10 @@ public: bool negated; /* <=> the item represents NOT <func> */ bool pred_level; /* <=> [NOT] <func> is used on a predicate level */ public: - Item_func_opt_neg(Item *a, Item *b, Item *c) - :Item_bool_func(a, b, c), negated(0), pred_level(0) {} - Item_func_opt_neg(List<Item> &list) - :Item_bool_func(list), negated(0), pred_level(0) {} + Item_func_opt_neg(THD *thd, Item *a, Item *b, Item *c): + Item_bool_func(thd, a, b, c), negated(0), pred_level(0) {} + Item_func_opt_neg(THD *thd, List<Item> &list): + Item_bool_func(thd, list), negated(0), pred_level(0) {} public: inline void negate() { negated= !negated; } inline void top_level_item() { pred_level= 1; } @@ -697,8 +706,8 @@ public: String value0,value1,value2; /* TRUE <=> arguments will be compared as dates. */ Item *compare_as_dates; - Item_func_between(Item *a, Item *b, Item *c) - :Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) { } + Item_func_between(THD *thd, Item *a, Item *b, Item *c): + Item_func_opt_neg(thd, a, b, c), compare_as_dates(FALSE) { } longlong val_int(); enum Functype functype() const { return BETWEEN; } const char *func_name() const { return "between"; } @@ -720,7 +729,8 @@ class Item_func_strcmp :public Item_int_func String value1, value2; DTCollation cmp_collation; public: - Item_func_strcmp(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_strcmp(THD *thd, Item *a, Item *b): + Item_int_func(thd, a, b) {} longlong val_int(); uint decimal_precision() const { return 1; } const char *func_name() const { return "strcmp"; } @@ -745,8 +755,8 @@ class Item_func_interval :public Item_int_func bool use_decimal_comparison; interval_range *intervals; public: - Item_func_interval(Item_row *a) - :Item_int_func(a),row(a),intervals(0) + Item_func_interval(THD *thd, Item_row *a): + Item_int_func(thd, a), row(a), intervals(0) { allowed_arg_cols= 0; // Fetch this value from first argument } @@ -765,8 +775,10 @@ public: class Item_func_coalesce :public Item_func_hybrid_field_type { public: - Item_func_coalesce(Item *a, Item *b) :Item_func_hybrid_field_type(a, b) {} - Item_func_coalesce(List<Item> &list) :Item_func_hybrid_field_type(list) {} + Item_func_coalesce(THD *thd, Item *a, Item *b): + Item_func_hybrid_field_type(thd, a, b) {} + Item_func_coalesce(THD *thd, List<Item> &list): + Item_func_hybrid_field_type(thd, list) {} double real_op(); longlong int_op(); String *str_op(String *); @@ -786,10 +798,10 @@ public: class Item_func_case_abbreviation2 :public Item_func_hybrid_field_type { public: - Item_func_case_abbreviation2(Item *a, Item *b) - :Item_func_hybrid_field_type(a, b) { } - Item_func_case_abbreviation2(Item *a, Item *b, Item *c) - :Item_func_hybrid_field_type(a, b, c) { } + Item_func_case_abbreviation2(THD *thd, Item *a, Item *b): + Item_func_hybrid_field_type(thd, a, b) { } + Item_func_case_abbreviation2(THD *thd, Item *a, Item *b, Item *c): + Item_func_hybrid_field_type(thd, a, b, c) { } void fix_length_and_dec2(Item **args); uint decimal_precision2(Item **args) const; }; @@ -798,7 +810,8 @@ public: class Item_func_ifnull :public Item_func_case_abbreviation2 { public: - Item_func_ifnull(Item *a, Item *b) :Item_func_case_abbreviation2(a,b) {} + Item_func_ifnull(THD *thd, Item *a, Item *b): + Item_func_case_abbreviation2(thd, a, b) {} double real_op(); longlong int_op(); String *str_op(String *str); @@ -822,8 +835,8 @@ public: class Item_func_if :public Item_func_case_abbreviation2 { public: - Item_func_if(Item *a,Item *b,Item *c) - :Item_func_case_abbreviation2(a, b, c) + Item_func_if(THD *thd, Item *a, Item *b, Item *c): + Item_func_case_abbreviation2(thd, a, b, c) {} bool date_op(MYSQL_TIME *ltime, uint fuzzydate); longlong int_op(); @@ -857,8 +870,8 @@ class Item_func_nullif :public Item_func_hybrid_field_type */ Item *m_args0_copy; public: - Item_func_nullif(Item *a,Item *b) - :Item_func_hybrid_field_type(a, b), + Item_func_nullif(THD *thd, Item *a, Item *b): + Item_func_hybrid_field_type(thd, a, b), m_args0_copy(a) {} bool date_op(MYSQL_TIME *ltime, uint fuzzydate); @@ -917,7 +930,7 @@ public: vector in form of Item_xxx constants without creating Item_xxx object for every array element you get (i.e. this implements "FlyWeight" pattern) */ - virtual Item* create_item() { return NULL; } + virtual Item* create_item(THD *thd) { return NULL; } /* Store the value at position #pos into provided item object @@ -944,8 +957,8 @@ class in_string :public in_vector class Item_string_for_in_vector: public Item_string { public: - Item_string_for_in_vector(CHARSET_INFO *cs): - Item_string(cs) + Item_string_for_in_vector(THD *thd, CHARSET_INFO *cs): + Item_string(thd, cs) { } void set_value(const String *str) { @@ -958,9 +971,9 @@ public: ~in_string(); void set(uint pos,Item *item); uchar *get_value(Item *item); - Item* create_item() - { - return new Item_string_for_in_vector(collation); + Item* create_item(THD *thd) + { + return new Item_string_for_in_vector(thd, collation); } void value_to_item(uint pos, Item *item) { @@ -989,13 +1002,13 @@ public: void set(uint pos,Item *item); uchar *get_value(Item *item); - Item* create_item() + Item* create_item(THD *thd) { /* We're created a signed INT, this may not be correct in general case (see BUG#19342). */ - return new Item_int((longlong)0); + return new Item_int(thd, (longlong)0); } void value_to_item(uint pos, Item *item) { @@ -1029,9 +1042,9 @@ public: lval_cache(0) {}; void set(uint pos,Item *item); uchar *get_value(Item *item); - Item* create_item() + Item* create_item(THD *thd) { - return new Item_datetime(); + return new Item_datetime(thd); } void value_to_item(uint pos, Item *item) { @@ -1050,9 +1063,9 @@ public: in_double(uint elements); void set(uint pos,Item *item); uchar *get_value(Item *item); - Item *create_item() + Item *create_item(THD *thd) { - return new Item_float(0.0, 0); + return new Item_float(thd, 0.0, 0); } void value_to_item(uint pos, Item *item) { @@ -1069,9 +1082,9 @@ public: in_decimal(uint elements); void set(uint pos, Item *item); uchar *get_value(Item *item); - Item *create_item() + Item *create_item(THD *thd) { - return new Item_decimal(0, FALSE); + return new Item_decimal(thd, 0, FALSE); } void value_to_item(uint pos, Item *item) { @@ -1297,8 +1310,9 @@ class Item_func_case :public Item_func_hybrid_field_type cmp_item *cmp_items[6]; /* For all result types */ cmp_item *case_item; public: - Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg) - :Item_func_hybrid_field_type(), first_expr_num(-1), else_expr_num(-1), + Item_func_case(THD *thd, List<Item> &list, Item *first_expr_arg, + Item *else_expr_arg): + Item_func_hybrid_field_type(thd), first_expr_num(-1), else_expr_num(-1), left_result_type(INT_RESULT), case_item(0) { ncases= list.elements; @@ -1368,9 +1382,9 @@ public: cmp_item *cmp_items[6]; /* One cmp_item for each result type */ DTCollation cmp_collation; - Item_func_in(List<Item> &list) - :Item_func_opt_neg(list), array(0), have_null(0), - arg_types_compatible(FALSE) + Item_func_in(THD *thd, List<Item> &list): + Item_func_opt_neg(thd, list), array(0), have_null(0), + arg_types_compatible(FALSE) { bzero(&cmp_items, sizeof(cmp_items)); allowed_arg_cols= 0; // Fetch this value from first argument @@ -1448,7 +1462,7 @@ protected: KEY_PART *key_part, Item_func::Functype type, Item *value); public: - Item_func_null_predicate(Item *a) :Item_bool_func(a) { } + Item_func_null_predicate(THD *thd, Item *a): Item_bool_func(thd, a) { } void add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level, table_map usable_tables, SARGABLE_PARAM **sargables); SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr); @@ -1462,7 +1476,7 @@ public: class Item_func_isnull :public Item_func_null_predicate { public: - Item_func_isnull(Item *a) :Item_func_null_predicate(a) {} + Item_func_isnull(THD *thd, Item *a): Item_func_null_predicate(thd, a) {} longlong val_int(); enum Functype functype() const { return ISNULL_FUNC; } void fix_length_and_dec() @@ -1504,8 +1518,8 @@ class Item_is_not_null_test :public Item_func_isnull { Item_in_subselect* owner; public: - Item_is_not_null_test(Item_in_subselect* ow, Item *a) - :Item_func_isnull(a), owner(ow) + Item_is_not_null_test(THD *thd, Item_in_subselect* ow, Item *a): + Item_func_isnull(thd, a), owner(ow) {} enum Functype functype() const { return ISNOTNULLTEST_FUNC; } longlong val_int(); @@ -1524,7 +1538,8 @@ class Item_func_isnotnull :public Item_func_null_predicate { bool abort_on_null; public: - Item_func_isnotnull(Item *a) :Item_func_null_predicate(a), abort_on_null(0) + Item_func_isnotnull(THD *thd, Item *a): + Item_func_null_predicate(thd, a), abort_on_null(0) { } longlong val_int(); enum Functype functype() const { return ISNOTNULL_FUNC; } @@ -1569,10 +1584,10 @@ protected: public: int escape; - Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used) - :Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0), - bmGs(0), bmBc(0), escape_item(escape_arg), - escape_used_in_parsing(escape_used), use_sampling(0) {} + Item_func_like(THD *thd, Item *a, Item *b, Item *escape_arg, bool escape_used): + Item_bool_func2(thd, a, b), canDoTurboBM(FALSE), pattern(0), pattern_len(0), + bmGs(0), bmBc(0), escape_item(escape_arg), + escape_used_in_parsing(escape_used), use_sampling(0) {} longlong val_int(); enum Functype functype() const { return LIKE_FUNC; } void print(String *str, enum_query_type query_type) @@ -1728,7 +1743,7 @@ class Item_func_regex :public Item_bool_func Regexp_processor_pcre re; DTCollation cmp_collation; public: - Item_func_regex(Item *a,Item *b) :Item_bool_func(a,b) + Item_func_regex(THD *thd, Item *a, Item *b): Item_bool_func(thd, a, b) {} void cleanup() { @@ -1755,7 +1770,7 @@ class Item_func_regexp_instr :public Item_int_func Regexp_processor_pcre re; DTCollation cmp_collation; public: - Item_func_regexp_instr(Item *a, Item *b) :Item_int_func(a, b) + Item_func_regexp_instr(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} void cleanup() { @@ -1781,17 +1796,17 @@ protected: public: /* Item_cond() is only used to create top level items */ - Item_cond(): Item_bool_func(), abort_on_null(1) + Item_cond(THD *thd): Item_bool_func(thd), abort_on_null(1) { const_item_cache=0; } - Item_cond(Item *i1,Item *i2) - :Item_bool_func(), abort_on_null(0) + Item_cond(THD *thd, Item *i1, Item *i2): + Item_bool_func(thd), abort_on_null(0) { list.push_back(i1); list.push_back(i2); } Item_cond(THD *thd, Item_cond *item); - Item_cond(List<Item> &nlist) - :Item_bool_func(), list(nlist), abort_on_null(0) {} + Item_cond(THD *thd, List<Item> &nlist): + Item_bool_func(thd), list(nlist), abort_on_null(0) {} bool add(Item *item) { DBUG_ASSERT(item); @@ -1841,12 +1856,12 @@ public: bool top_level() { return abort_on_null; } void copy_andor_arguments(THD *thd, Item_cond *item); bool walk(Item_processor processor, bool walk_subquery, uchar *arg); - Item *transform(Item_transformer transformer, uchar *arg); + Item *transform(THD *thd, Item_transformer transformer, uchar *arg); void traverse_cond(Cond_traverser, void *arg, traverse_order order); void neg_arguments(THD *thd); enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } bool subst_argument_checker(uchar **arg) { return TRUE; } - Item *compile(Item_analyzer analyzer, uchar **arg_p, + Item *compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t); bool eval_not_null_tables(uchar *opt_arg); }; @@ -1992,8 +2007,8 @@ public: COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */ - Item_equal(THD *thd_arg, Item *f1, Item *f2, bool with_const_item); - Item_equal(THD *thd_arg, Item_equal *item_equal); + Item_equal(THD *thd, Item *f1, Item *f2, bool with_const_item); + Item_equal(THD *thd, 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); @@ -2023,7 +2038,7 @@ public: SARGABLE_PARAM **sargables); SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr); bool walk(Item_processor processor, bool walk_subquery, uchar *arg); - Item *transform(Item_transformer transformer, uchar *arg); + Item *transform(THD *thd, Item_transformer transformer, uchar *arg); virtual void print(String *str, enum_query_type query_type); CHARSET_INFO *compare_collation() const; @@ -2033,8 +2048,9 @@ public: bool count_sargable_conds(uchar *arg); friend class Item_equal_iterator<List_iterator_fast,Item>; friend class Item_equal_iterator<List_iterator,Item>; - friend Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, - Item_equal *item_equal); + friend Item *eliminate_item_equal(THD *thd, COND *cond, + COND_EQUAL *upper_levels, + Item_equal *item_equal); friend bool setup_sj_materialization_part1(struct st_join_table *tab); friend bool setup_sj_materialization_part2(struct st_join_table *tab); }; @@ -2153,10 +2169,10 @@ public: COND_EQUAL m_cond_equal; /* contains list of Item_equal objects for the current and level and reference to multiple equalities of upper and levels */ - Item_cond_and() :Item_cond() {} - Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {} - Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {} - Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {} + Item_cond_and(THD *thd): Item_cond(thd) {} + Item_cond_and(THD *thd, Item *i1,Item *i2): Item_cond(thd, i1, i2) {} + Item_cond_and(THD *thd, Item_cond_and *item): Item_cond(thd, item) {} + Item_cond_and(THD *thd, List<Item> &list_arg): Item_cond(thd, list_arg) {} enum Functype functype() const { return COND_AND_FUNC; } longlong val_int(); const char *func_name() const { return "and"; } @@ -2193,10 +2209,10 @@ inline bool is_cond_and(Item *item) class Item_cond_or :public Item_cond { public: - Item_cond_or() :Item_cond() {} - Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {} - Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {} - Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {} + Item_cond_or(THD *thd): Item_cond(thd) {} + Item_cond_or(THD *thd, Item *i1,Item *i2): Item_cond(thd, i1, i2) {} + Item_cond_or(THD *thd, Item_cond_or *item): Item_cond(thd, item) {} + Item_cond_or(THD *thd, List<Item> &list_arg): Item_cond(thd, list_arg) {} enum Functype functype() const { return COND_OR_FUNC; } longlong val_int(); const char *func_name() const { return "or"; } @@ -2214,7 +2230,7 @@ public: class Item_func_dyncol_check :public Item_bool_func { public: - Item_func_dyncol_check(Item *str) :Item_bool_func(str) {} + Item_func_dyncol_check(THD *thd, Item *str): Item_bool_func(thd, str) {} longlong val_int(); const char *func_name() const { return "column_check"; } }; @@ -2222,7 +2238,8 @@ public: class Item_func_dyncol_exists :public Item_bool_func { public: - Item_func_dyncol_exists(Item *str, Item *num) :Item_bool_func(str, num) {} + Item_func_dyncol_exists(THD *thd, Item *str, Item *num): + Item_bool_func(thd, str, num) {} longlong val_int(); const char *func_name() const { return "column_exists"; } }; @@ -2238,11 +2255,11 @@ inline bool is_cond_or(Item *item) /* Some useful inline functions */ -inline Item *and_conds(Item *a, Item *b) +inline Item *and_conds(THD *thd, Item *a, Item *b) { if (!b) return a; if (!a) return b; - return new Item_cond_and(a, b); + return new Item_cond_and(thd, a, b); } @@ -2264,12 +2281,12 @@ public: /** Create operation with given arguments. */ - virtual Item_bool_rowready_func2* create(MEM_ROOT *, Item *a, Item *b) + virtual Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const = 0; /** Create operation with given arguments in swap order. */ - virtual Item_bool_rowready_func2* create_swap(MEM_ROOT *, Item *a, Item *b) + virtual Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const = 0; virtual const char* symbol(bool invert) const = 0; virtual bool eqne_op() const = 0; @@ -2281,14 +2298,8 @@ class Eq_creator :public Comp_creator public: Eq_creator() {} /* Remove gcc warning */ virtual ~Eq_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_eq(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_eq(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<>" : "="; } bool eqne_op() const { return 1; } bool l_op() const { return 0; } @@ -2299,14 +2310,8 @@ class Ne_creator :public Comp_creator public: Ne_creator() {} /* Remove gcc warning */ virtual ~Ne_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_ne(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_ne(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "=" : "<>"; } bool eqne_op() const { return 1; } bool l_op() const { return 0; } @@ -2317,14 +2322,8 @@ class Gt_creator :public Comp_creator public: Gt_creator() {} /* Remove gcc warning */ virtual ~Gt_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_gt(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_lt(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<=" : ">"; } bool eqne_op() const { return 0; } bool l_op() const { return 0; } @@ -2335,14 +2334,8 @@ class Lt_creator :public Comp_creator public: Lt_creator() {} /* Remove gcc warning */ virtual ~Lt_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_lt(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_gt(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? ">=" : "<"; } bool eqne_op() const { return 0; } bool l_op() const { return 1; } @@ -2353,14 +2346,8 @@ class Ge_creator :public Comp_creator public: Ge_creator() {} /* Remove gcc warning */ virtual ~Ge_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_ge(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_le(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? "<" : ">="; } bool eqne_op() const { return 0; } bool l_op() const { return 0; } @@ -2371,14 +2358,8 @@ class Le_creator :public Comp_creator public: Le_creator() {} /* Remove gcc warning */ virtual ~Le_creator() {} /* Remove gcc warning */ - Item_bool_rowready_func2* create(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_le(a, b); - } - Item_bool_rowready_func2* create_swap(MEM_ROOT *root, Item *a, Item *b) const - { - return new(root) Item_func_ge(b, a); - } + Item_bool_rowready_func2* create(THD *thd, Item *a, Item *b) const; + Item_bool_rowready_func2* create_swap(THD *thd, Item *a, Item *b) const; const char* symbol(bool invert) const { return invert? ">" : "<="; } bool eqne_op() const { return 0; } bool l_op() const { return 1; } diff --git a/sql/item_create.cc b/sql/item_create.cc index 0d2f794f76e..e7bdc95a3dd 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -2970,16 +2970,16 @@ Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list) if (udf->type == UDFTYPE_FUNCTION) { if (arg_count) - func= new (thd->mem_root) Item_func_udf_str(udf, *item_list); + func= new (thd->mem_root) Item_func_udf_str(thd, udf, *item_list); else - func= new (thd->mem_root) Item_func_udf_str(udf); + func= new (thd->mem_root) Item_func_udf_str(thd, udf); } else { if (arg_count) - func= new (thd->mem_root) Item_sum_udf_str(udf, *item_list); + func= new (thd->mem_root) Item_sum_udf_str(thd, udf, *item_list); else - func= new (thd->mem_root) Item_sum_udf_str(udf); + func= new (thd->mem_root) Item_sum_udf_str(thd, udf); } break; } @@ -2988,16 +2988,16 @@ Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list) if (udf->type == UDFTYPE_FUNCTION) { if (arg_count) - func= new (thd->mem_root) Item_func_udf_float(udf, *item_list); + func= new (thd->mem_root) Item_func_udf_float(thd, udf, *item_list); else - func= new (thd->mem_root) Item_func_udf_float(udf); + func= new (thd->mem_root) Item_func_udf_float(thd, udf); } else { if (arg_count) - func= new (thd->mem_root) Item_sum_udf_float(udf, *item_list); + func= new (thd->mem_root) Item_sum_udf_float(thd, udf, *item_list); else - func= new (thd->mem_root) Item_sum_udf_float(udf); + func= new (thd->mem_root) Item_sum_udf_float(thd, udf); } break; } @@ -3006,16 +3006,16 @@ Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list) if (udf->type == UDFTYPE_FUNCTION) { if (arg_count) - func= new (thd->mem_root) Item_func_udf_int(udf, *item_list); + func= new (thd->mem_root) Item_func_udf_int(thd, udf, *item_list); else - func= new (thd->mem_root) Item_func_udf_int(udf); + func= new (thd->mem_root) Item_func_udf_int(thd, udf); } else { if (arg_count) - func= new (thd->mem_root) Item_sum_udf_int(udf, *item_list); + func= new (thd->mem_root) Item_sum_udf_int(thd, udf, *item_list); else - func= new (thd->mem_root) Item_sum_udf_int(udf); + func= new (thd->mem_root) Item_sum_udf_int(thd, udf); } break; } @@ -3024,16 +3024,16 @@ Create_udf_func::create(THD *thd, udf_func *udf, List<Item> *item_list) if (udf->type == UDFTYPE_FUNCTION) { if (arg_count) - func= new (thd->mem_root) Item_func_udf_decimal(udf, *item_list); + func= new (thd->mem_root) Item_func_udf_decimal(thd, udf, *item_list); else - func= new (thd->mem_root) Item_func_udf_decimal(udf); + func= new (thd->mem_root) Item_func_udf_decimal(thd, udf); } else { if (arg_count) - func= new (thd->mem_root) Item_sum_udf_decimal(udf, *item_list); + func= new (thd->mem_root) Item_sum_udf_decimal(thd, udf, *item_list); else - func= new (thd->mem_root) Item_sum_udf_decimal(udf); + func= new (thd->mem_root) Item_sum_udf_decimal(thd, udf); } break; } @@ -3082,10 +3082,10 @@ Create_sp_func::create_with_db(THD *thd, LEX_STRING db, LEX_STRING name, sp_add_used_routine(lex, thd, qname, TYPE_ENUM_FUNCTION); if (arg_count > 0) - func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname, + func= new (thd->mem_root) Item_func_sp(thd, lex->current_context(), qname, *item_list); else - func= new (thd->mem_root) Item_func_sp(lex->current_context(), qname); + func= new (thd->mem_root) Item_func_sp(thd, lex->current_context(), qname); lex->safe_to_cache_query= 0; return func; @@ -3212,7 +3212,7 @@ Create_func_abs Create_func_abs::s_singleton; Item* Create_func_abs::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_abs(arg1); + return new (thd->mem_root) Item_func_abs(thd, arg1); } @@ -3221,7 +3221,7 @@ Create_func_acos Create_func_acos::s_singleton; Item* Create_func_acos::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_acos(arg1); + return new (thd->mem_root) Item_func_acos(thd, arg1); } @@ -3230,7 +3230,7 @@ Create_func_addtime Create_func_addtime::s_singleton; Item* Create_func_addtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 0); + return new (thd->mem_root) Item_func_add_time(thd, arg1, arg2, 0, 0); } @@ -3239,7 +3239,7 @@ Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton; Item* Create_func_aes_encrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_aes_encrypt(arg1, arg2); + return new (thd->mem_root) Item_func_aes_encrypt(thd, arg1, arg2); } @@ -3248,7 +3248,7 @@ Create_func_aes_decrypt Create_func_aes_decrypt::s_singleton; Item* Create_func_aes_decrypt::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_aes_decrypt(arg1, arg2); + return new (thd->mem_root) Item_func_aes_decrypt(thd, arg1, arg2); } @@ -3258,7 +3258,7 @@ Create_func_area Create_func_area::s_singleton; Item* Create_func_area::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_area(arg1); + return new (thd->mem_root) Item_func_area(thd, arg1); } #endif @@ -3269,7 +3269,7 @@ Create_func_as_wkb Create_func_as_wkb::s_singleton; Item* Create_func_as_wkb::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_as_wkb(arg1); + return new (thd->mem_root) Item_func_as_wkb(thd, arg1); } #endif @@ -3280,7 +3280,7 @@ Create_func_as_wkt Create_func_as_wkt::s_singleton; Item* Create_func_as_wkt::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_as_wkt(arg1); + return new (thd->mem_root) Item_func_as_wkt(thd, arg1); } #endif @@ -3290,7 +3290,7 @@ Create_func_asin Create_func_asin::s_singleton; Item* Create_func_asin::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_asin(arg1); + return new (thd->mem_root) Item_func_asin(thd, arg1); } @@ -3310,14 +3310,14 @@ Create_func_atan::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_atan(param_1); + func= new (thd->mem_root) Item_func_atan(thd, param_1); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_atan(param_1, param_2); + func= new (thd->mem_root) Item_func_atan(thd, param_1, param_2); break; } default: @@ -3337,7 +3337,7 @@ Item* Create_func_benchmark::create_2_arg(THD *thd, Item *arg1, Item *arg2) { thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_benchmark(arg1, arg2); + return new (thd->mem_root) Item_func_benchmark(thd, arg1, arg2); } @@ -3346,9 +3346,9 @@ Create_func_bin Create_func_bin::s_singleton; Item* Create_func_bin::create_1_arg(THD *thd, Item *arg1) { - Item *i10= new (thd->mem_root) Item_int((int32) 10,2); - Item *i2= new (thd->mem_root) Item_int((int32) 2,1); - return new (thd->mem_root) Item_func_conv(arg1, i10, i2); + Item *i10= new (thd->mem_root) Item_int(thd, (int32) 10,2); + Item *i2= new (thd->mem_root) Item_int(thd, (int32) 2,1); + return new (thd->mem_root) Item_func_conv(thd, arg1, i10, i2); } @@ -3365,7 +3365,7 @@ Create_func_binlog_gtid_pos::create_2_arg(THD *thd, Item *arg1, Item *arg2) return NULL; } thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); - return new (thd->mem_root) Item_func_binlog_gtid_pos(arg1, arg2); + return new (thd->mem_root) Item_func_binlog_gtid_pos(thd, arg1, arg2); } @@ -3374,7 +3374,7 @@ Create_func_bit_count Create_func_bit_count::s_singleton; Item* Create_func_bit_count::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_bit_count(arg1); + return new (thd->mem_root) Item_func_bit_count(thd, arg1); } @@ -3383,7 +3383,7 @@ Create_func_bit_length Create_func_bit_length::s_singleton; Item* Create_func_bit_length::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_bit_length(arg1); + return new (thd->mem_root) Item_func_bit_length(thd, arg1); } @@ -3392,7 +3392,7 @@ Create_func_ceiling Create_func_ceiling::s_singleton; Item* Create_func_ceiling::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_ceiling(arg1); + return new (thd->mem_root) Item_func_ceiling(thd, arg1); } @@ -3402,7 +3402,7 @@ Create_func_centroid Create_func_centroid::s_singleton; Item* Create_func_centroid::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_centroid(arg1); + return new (thd->mem_root) Item_func_centroid(thd, arg1); } @@ -3411,7 +3411,7 @@ Create_func_convexhull Create_func_convexhull::s_singleton; Item* Create_func_convexhull::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_convexhull(arg1); + return new (thd->mem_root) Item_func_convexhull(thd, arg1); } @@ -3420,7 +3420,7 @@ Create_func_pointonsurface Create_func_pointonsurface::s_singleton; Item* Create_func_pointonsurface::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_pointonsurface(arg1); + return new (thd->mem_root) Item_func_pointonsurface(thd, arg1); } #endif /*HAVE_SPATIAL*/ @@ -3430,7 +3430,7 @@ Create_func_char_length Create_func_char_length::s_singleton; Item* Create_func_char_length::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_char_length(arg1); + return new (thd->mem_root) Item_func_char_length(thd, arg1); } @@ -3439,7 +3439,7 @@ Create_func_coercibility Create_func_coercibility::s_singleton; Item* Create_func_coercibility::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_coercibility(arg1); + return new (thd->mem_root) Item_func_coercibility(thd, arg1); } @@ -3448,7 +3448,7 @@ Create_func_dyncol_check Create_func_dyncol_check::s_singleton; Item* Create_func_dyncol_check::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dyncol_check(arg1); + return new (thd->mem_root) Item_func_dyncol_check(thd, arg1); } Create_func_dyncol_exists Create_func_dyncol_exists::s_singleton; @@ -3456,7 +3456,7 @@ Create_func_dyncol_exists Create_func_dyncol_exists::s_singleton; Item* Create_func_dyncol_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_dyncol_exists(arg1, arg2); + return new (thd->mem_root) Item_func_dyncol_exists(thd, arg1, arg2); } Create_func_dyncol_list Create_func_dyncol_list::s_singleton; @@ -3464,7 +3464,7 @@ Create_func_dyncol_list Create_func_dyncol_list::s_singleton; Item* Create_func_dyncol_list::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dyncol_list(arg1); + return new (thd->mem_root) Item_func_dyncol_list(thd, arg1); } Create_func_dyncol_json Create_func_dyncol_json::s_singleton; @@ -3472,7 +3472,7 @@ Create_func_dyncol_json Create_func_dyncol_json::s_singleton; Item* Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dyncol_json(arg1); + return new (thd->mem_root) Item_func_dyncol_json(thd, arg1); } Create_func_concat Create_func_concat::s_singleton; @@ -3492,7 +3492,7 @@ Create_func_concat::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_concat(*item_list); + return new (thd->mem_root) Item_func_concat(thd, *item_list); } Create_func_decode_histogram Create_func_decode_histogram::s_singleton; @@ -3500,7 +3500,7 @@ Create_func_decode_histogram Create_func_decode_histogram::s_singleton; Item * Create_func_decode_histogram::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_decode_histogram(arg1, arg2); + return new (thd->mem_root) Item_func_decode_histogram(thd, arg1, arg2); } Create_func_concat_ws Create_func_concat_ws::s_singleton; @@ -3521,7 +3521,7 @@ Create_func_concat_ws::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_concat_ws(*item_list); + return new (thd->mem_root) Item_func_concat_ws(thd, *item_list); } @@ -3530,7 +3530,7 @@ Create_func_compress Create_func_compress::s_singleton; Item* Create_func_compress::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_compress(arg1); + return new (thd->mem_root) Item_func_compress(thd, arg1); } @@ -3540,7 +3540,7 @@ Item* Create_func_connection_id::create_builder(THD *thd) { thd->lex->safe_to_cache_query= 0; - return new (thd->mem_root) Item_func_connection_id(); + return new (thd->mem_root) Item_func_connection_id(thd); } @@ -3550,7 +3550,7 @@ Create_func_mbr_contains Create_func_mbr_contains::s_singleton; Item* Create_func_mbr_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_CONTAINS_FUNC); } @@ -3560,7 +3560,7 @@ Create_func_contains Create_func_contains::s_singleton; Item* Create_func_contains::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_CONTAINS_FUNC); } #endif @@ -3571,7 +3571,7 @@ Create_func_conv Create_func_conv::s_singleton; Item* Create_func_conv::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_conv(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_conv(thd, arg1, arg2, arg3); } @@ -3580,7 +3580,7 @@ Create_func_convert_tz Create_func_convert_tz::s_singleton; Item* Create_func_convert_tz::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_convert_tz(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_convert_tz(thd, arg1, arg2, arg3); } @@ -3589,7 +3589,7 @@ Create_func_cos Create_func_cos::s_singleton; Item* Create_func_cos::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_cos(arg1); + return new (thd->mem_root) Item_func_cos(thd, arg1); } @@ -3598,7 +3598,7 @@ Create_func_cot Create_func_cot::s_singleton; Item* Create_func_cot::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_cot(arg1); + return new (thd->mem_root) Item_func_cot(thd, arg1); } @@ -3607,7 +3607,7 @@ Create_func_crc32 Create_func_crc32::s_singleton; Item* Create_func_crc32::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_crc32(arg1); + return new (thd->mem_root) Item_func_crc32(thd, arg1); } @@ -3617,7 +3617,7 @@ Create_func_crosses Create_func_crosses::s_singleton; Item* Create_func_crosses::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_CROSSES_FUNC); } #endif @@ -3628,7 +3628,7 @@ Create_func_date_format Create_func_date_format::s_singleton; Item* Create_func_date_format::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_date_format(arg1, arg2, 0); + return new (thd->mem_root) Item_func_date_format(thd, arg1, arg2, 0); } @@ -3637,10 +3637,10 @@ Create_func_datediff Create_func_datediff::s_singleton; Item* Create_func_datediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - Item *i1= new (thd->mem_root) Item_func_to_days(arg1); - Item *i2= new (thd->mem_root) Item_func_to_days(arg2); + Item *i1= new (thd->mem_root) Item_func_to_days(thd, arg1); + Item *i2= new (thd->mem_root) Item_func_to_days(thd, arg2); - return new (thd->mem_root) Item_func_minus(i1, i2); + return new (thd->mem_root) Item_func_minus(thd, i1, i2); } @@ -3649,7 +3649,7 @@ Create_func_dayname Create_func_dayname::s_singleton; Item* Create_func_dayname::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dayname(arg1); + return new (thd->mem_root) Item_func_dayname(thd, arg1); } @@ -3658,7 +3658,7 @@ Create_func_dayofmonth Create_func_dayofmonth::s_singleton; Item* Create_func_dayofmonth::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dayofmonth(arg1); + return new (thd->mem_root) Item_func_dayofmonth(thd, arg1); } @@ -3667,7 +3667,7 @@ Create_func_dayofweek Create_func_dayofweek::s_singleton; Item* Create_func_dayofweek::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_weekday(arg1, 1); + return new (thd->mem_root) Item_func_weekday(thd, arg1, 1); } @@ -3676,7 +3676,7 @@ Create_func_dayofyear Create_func_dayofyear::s_singleton; Item* Create_func_dayofyear::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dayofyear(arg1); + return new (thd->mem_root) Item_func_dayofyear(thd, arg1); } @@ -3685,7 +3685,7 @@ Create_func_decode Create_func_decode::s_singleton; Item* Create_func_decode::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_decode(arg1, arg2); + return new (thd->mem_root) Item_func_decode(thd, arg1, arg2); } @@ -3694,7 +3694,7 @@ Create_func_degrees Create_func_degrees::s_singleton; Item* Create_func_degrees::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_units((char*) "degrees", arg1, + return new (thd->mem_root) Item_func_units(thd, (char*) "degrees", arg1, 180/M_PI, 0.0); } @@ -3715,14 +3715,14 @@ Create_func_des_decrypt::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_des_decrypt(param_1); + func= new (thd->mem_root) Item_func_des_decrypt(thd, param_1); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_des_decrypt(param_1, param_2); + func= new (thd->mem_root) Item_func_des_decrypt(thd, param_1, param_2); break; } default: @@ -3752,14 +3752,14 @@ Create_func_des_encrypt::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_des_encrypt(param_1); + func= new (thd->mem_root) Item_func_des_encrypt(thd, param_1); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_des_encrypt(param_1, param_2); + func= new (thd->mem_root) Item_func_des_encrypt(thd, param_1, param_2); break; } default: @@ -3779,7 +3779,7 @@ Create_func_dimension Create_func_dimension::s_singleton; Item* Create_func_dimension::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_dimension(arg1); + return new (thd->mem_root) Item_func_dimension(thd, arg1); } #endif @@ -3790,7 +3790,7 @@ Create_func_mbr_disjoint Create_func_mbr_disjoint::s_singleton; Item* Create_func_mbr_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_DISJOINT_FUNC); } @@ -3800,7 +3800,7 @@ Create_func_disjoint Create_func_disjoint::s_singleton; Item* Create_func_disjoint::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_DISJOINT_FUNC); } @@ -3810,7 +3810,7 @@ Create_func_distance Create_func_distance::s_singleton; Item* Create_func_distance::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_distance(arg1, arg2); + return new (thd->mem_root) Item_func_distance(thd, arg1, arg2); } #endif @@ -3832,7 +3832,7 @@ Create_func_elt::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_elt(*item_list); + return new (thd->mem_root) Item_func_elt(thd, *item_list); } @@ -3841,7 +3841,7 @@ Create_func_encode Create_func_encode::s_singleton; Item* Create_func_encode::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_encode(arg1, arg2); + return new (thd->mem_root) Item_func_encode(thd, arg1, arg2); } @@ -3861,7 +3861,7 @@ Create_func_encrypt::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_encrypt(param_1); + func= new (thd->mem_root) Item_func_encrypt(thd, param_1); thd->lex->uncacheable(UNCACHEABLE_RAND); break; } @@ -3869,7 +3869,7 @@ Create_func_encrypt::create_native(THD *thd, LEX_STRING name, { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_encrypt(param_1, param_2); + func= new (thd->mem_root) Item_func_encrypt(thd, param_1, param_2); break; } default: @@ -3889,7 +3889,7 @@ Create_func_endpoint Create_func_endpoint::s_singleton; Item* Create_func_endpoint::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_spatial_decomp(arg1, + return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1, Item_func::SP_ENDPOINT); } #endif @@ -3901,7 +3901,7 @@ Create_func_envelope Create_func_envelope::s_singleton; Item* Create_func_envelope::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_envelope(arg1); + return new (thd->mem_root) Item_func_envelope(thd, arg1); } @@ -3910,7 +3910,7 @@ Create_func_boundary Create_func_boundary::s_singleton; Item* Create_func_boundary::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_boundary(arg1); + return new (thd->mem_root) Item_func_boundary(thd, arg1); } #endif @@ -3921,7 +3921,7 @@ Create_func_mbr_equals Create_func_mbr_equals::s_singleton; Item* Create_func_mbr_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_EQUALS_FUNC); } @@ -3931,7 +3931,7 @@ Create_func_equals Create_func_equals::s_singleton; Item* Create_func_equals::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_EQUALS_FUNC); } #endif @@ -3942,7 +3942,7 @@ Create_func_exp Create_func_exp::s_singleton; Item* Create_func_exp::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_exp(arg1); + return new (thd->mem_root) Item_func_exp(thd, arg1); } @@ -3964,7 +3964,7 @@ Create_func_export_set::create_native(THD *thd, LEX_STRING name, Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); Item *param_3= item_list->pop(); - func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3); + func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3); break; } case 4: @@ -3973,7 +3973,7 @@ Create_func_export_set::create_native(THD *thd, LEX_STRING name, Item *param_2= item_list->pop(); Item *param_3= item_list->pop(); Item *param_4= item_list->pop(); - func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3, + func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3, param_4); break; } @@ -3984,7 +3984,7 @@ Create_func_export_set::create_native(THD *thd, LEX_STRING name, Item *param_3= item_list->pop(); Item *param_4= item_list->pop(); Item *param_5= item_list->pop(); - func= new (thd->mem_root) Item_func_export_set(param_1, param_2, param_3, + func= new (thd->mem_root) Item_func_export_set(thd, param_1, param_2, param_3, param_4, param_5); break; } @@ -4005,7 +4005,7 @@ Create_func_exteriorring Create_func_exteriorring::s_singleton; Item* Create_func_exteriorring::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_spatial_decomp(arg1, + return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1, Item_func::SP_EXTERIORRING); } #endif @@ -4028,7 +4028,7 @@ Create_func_field::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_field(*item_list); + return new (thd->mem_root) Item_func_field(thd, *item_list); } @@ -4037,7 +4037,7 @@ Create_func_find_in_set Create_func_find_in_set::s_singleton; Item* Create_func_find_in_set::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_find_in_set(arg1, arg2); + return new (thd->mem_root) Item_func_find_in_set(thd, arg1, arg2); } @@ -4046,7 +4046,7 @@ Create_func_floor Create_func_floor::s_singleton; Item* Create_func_floor::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_floor(arg1); + return new (thd->mem_root) Item_func_floor(thd, arg1); } @@ -4064,7 +4064,7 @@ Create_func_format::create_native(THD *thd, LEX_STRING name, { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_format(param_1, param_2); + func= new (thd->mem_root) Item_func_format(thd, param_1, param_2); break; } case 3: @@ -4072,7 +4072,7 @@ Create_func_format::create_native(THD *thd, LEX_STRING name, Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); Item *param_3= item_list->pop(); - func= new (thd->mem_root) Item_func_format(param_1, param_2, param_3); + func= new (thd->mem_root) Item_func_format(thd, param_1, param_2, param_3); break; } default: @@ -4090,7 +4090,7 @@ Create_func_from_base64 Create_func_from_base64::s_singleton; Item * Create_func_from_base64::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_from_base64(arg1); + return new (thd->mem_root) Item_func_from_base64(thd, arg1); } @@ -4102,7 +4102,7 @@ Create_func_found_rows::create_builder(THD *thd) DBUG_ENTER("Create_func_found_rows::create"); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->safe_to_cache_query= 0; - DBUG_RETURN(new (thd->mem_root) Item_func_found_rows()); + DBUG_RETURN(new (thd->mem_root) Item_func_found_rows(thd)); } @@ -4111,7 +4111,7 @@ Create_func_from_days Create_func_from_days::s_singleton; Item* Create_func_from_days::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_from_days(arg1); + return new (thd->mem_root) Item_func_from_days(thd, arg1); } @@ -4131,15 +4131,15 @@ Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_from_unixtime(param_1); + func= new (thd->mem_root) Item_func_from_unixtime(thd, param_1); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - Item *ut= new (thd->mem_root) Item_func_from_unixtime(param_1); - func= new (thd->mem_root) Item_func_date_format(ut, param_2, 0); + Item *ut= new (thd->mem_root) Item_func_from_unixtime(thd, param_1); + func= new (thd->mem_root) Item_func_date_format(thd, ut, param_2, 0); break; } default: @@ -4170,7 +4170,7 @@ Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_geometry_from_text(param_1); + func= new (thd->mem_root) Item_func_geometry_from_text(thd, param_1); thd->lex->uncacheable(UNCACHEABLE_RAND); break; } @@ -4178,7 +4178,7 @@ Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name, { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_geometry_from_text(param_1, param_2); + func= new (thd->mem_root) Item_func_geometry_from_text(thd, param_1, param_2); break; } default: @@ -4210,7 +4210,7 @@ Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_geometry_from_wkb(param_1); + func= new (thd->mem_root) Item_func_geometry_from_wkb(thd, param_1); thd->lex->uncacheable(UNCACHEABLE_RAND); break; } @@ -4218,7 +4218,7 @@ Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name, { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_geometry_from_wkb(param_1, param_2); + func= new (thd->mem_root) Item_func_geometry_from_wkb(thd, param_1, param_2); break; } default: @@ -4239,7 +4239,7 @@ Create_func_geometry_type Create_func_geometry_type::s_singleton; Item* Create_func_geometry_type::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_geometry_type(arg1); + return new (thd->mem_root) Item_func_geometry_type(thd, arg1); } #endif @@ -4250,7 +4250,7 @@ Create_func_geometryn Create_func_geometryn::s_singleton; Item* Create_func_geometryn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2, Item_func::SP_GEOMETRYN); } #endif @@ -4263,7 +4263,7 @@ Create_func_get_lock::create_2_arg(THD *thd, Item *arg1, Item *arg2) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_get_lock(arg1, arg2); + return new (thd->mem_root) Item_func_get_lock(thd, arg1, arg2); } @@ -4273,7 +4273,7 @@ Create_func_gis_debug Create_func_gis_debug::s_singleton; Item* Create_func_gis_debug::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_gis_debug(arg1); + return new (thd->mem_root) Item_func_gis_debug(thd, arg1); } #endif @@ -4284,7 +4284,7 @@ Create_func_glength Create_func_glength::s_singleton; Item* Create_func_glength::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_glength(arg1); + return new (thd->mem_root) Item_func_glength(thd, arg1); } #endif @@ -4306,7 +4306,7 @@ Create_func_greatest::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_max(*item_list); + return new (thd->mem_root) Item_func_max(thd, *item_list); } @@ -4315,7 +4315,7 @@ Create_func_hex Create_func_hex::s_singleton; Item* Create_func_hex::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_hex(arg1); + return new (thd->mem_root) Item_func_hex(thd, arg1); } @@ -4324,7 +4324,7 @@ Create_func_ifnull Create_func_ifnull::s_singleton; Item* Create_func_ifnull::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_ifnull(arg1, arg2); + return new (thd->mem_root) Item_func_ifnull(thd, arg1, arg2); } @@ -4333,7 +4333,7 @@ Create_func_inet_ntoa Create_func_inet_ntoa::s_singleton; Item* Create_func_inet_ntoa::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_inet_ntoa(arg1); + return new (thd->mem_root) Item_func_inet_ntoa(thd, arg1); } @@ -4342,7 +4342,7 @@ Create_func_inet6_aton Create_func_inet6_aton::s_singleton; Item* Create_func_inet6_aton::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_inet6_aton(arg1); + return new (thd->mem_root) Item_func_inet6_aton(thd, arg1); } @@ -4351,7 +4351,7 @@ Create_func_inet6_ntoa Create_func_inet6_ntoa::s_singleton; Item* Create_func_inet6_ntoa::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_inet6_ntoa(arg1); + return new (thd->mem_root) Item_func_inet6_ntoa(thd, arg1); } @@ -4360,7 +4360,7 @@ Create_func_inet_aton Create_func_inet_aton::s_singleton; Item* Create_func_inet_aton::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_inet_aton(arg1); + return new (thd->mem_root) Item_func_inet_aton(thd, arg1); } @@ -4369,7 +4369,7 @@ Create_func_is_ipv4 Create_func_is_ipv4::s_singleton; Item* Create_func_is_ipv4::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_is_ipv4(arg1); + return new (thd->mem_root) Item_func_is_ipv4(thd, arg1); } @@ -4378,7 +4378,7 @@ Create_func_is_ipv6 Create_func_is_ipv6::s_singleton; Item* Create_func_is_ipv6::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_is_ipv6(arg1); + return new (thd->mem_root) Item_func_is_ipv6(thd, arg1); } @@ -4387,7 +4387,7 @@ Create_func_is_ipv4_compat Create_func_is_ipv4_compat::s_singleton; Item* Create_func_is_ipv4_compat::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_is_ipv4_compat(arg1); + return new (thd->mem_root) Item_func_is_ipv4_compat(thd, arg1); } @@ -4396,7 +4396,7 @@ Create_func_is_ipv4_mapped Create_func_is_ipv4_mapped::s_singleton; Item* Create_func_is_ipv4_mapped::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_is_ipv4_mapped(arg1); + return new (thd->mem_root) Item_func_is_ipv4_mapped(thd, arg1); } @@ -4405,7 +4405,7 @@ Create_func_instr Create_func_instr::s_singleton; Item* Create_func_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_locate(arg1, arg2); + return new (thd->mem_root) Item_func_locate(thd, arg1, arg2); } @@ -4415,7 +4415,7 @@ Create_func_interiorringn Create_func_interiorringn::s_singleton; Item* Create_func_interiorringn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2, Item_func::SP_INTERIORRINGN); } #endif @@ -4427,7 +4427,7 @@ Create_func_relate Create_func_relate::s_singleton; Item* Create_func_relate::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *matrix) { - return new (thd->mem_root) Item_func_spatial_relate(arg1, arg2, matrix); + return new (thd->mem_root) Item_func_spatial_relate(thd, arg1, arg2, matrix); } @@ -4436,7 +4436,7 @@ Create_func_mbr_intersects Create_func_mbr_intersects::s_singleton; Item* Create_func_mbr_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_INTERSECTS_FUNC); } @@ -4446,7 +4446,7 @@ Create_func_intersects Create_func_intersects::s_singleton; Item* Create_func_intersects::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_INTERSECTS_FUNC); } @@ -4456,7 +4456,7 @@ Create_func_intersection Create_func_intersection::s_singleton; Item* Create_func_intersection::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2, Gcalc_function::op_intersection); } @@ -4466,7 +4466,7 @@ Create_func_difference Create_func_difference::s_singleton; Item* Create_func_difference::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2, Gcalc_function::op_difference); } @@ -4476,7 +4476,7 @@ Create_func_union Create_func_union::s_singleton; Item* Create_func_union::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2, Gcalc_function::op_union); } @@ -4486,7 +4486,7 @@ Create_func_symdifference Create_func_symdifference::s_singleton; Item* Create_func_symdifference::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_operation(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_operation(thd, arg1, arg2, Gcalc_function::op_symdifference); } @@ -4496,7 +4496,7 @@ Create_func_buffer Create_func_buffer::s_singleton; Item* Create_func_buffer::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_buffer(arg1, arg2); + return new (thd->mem_root) Item_func_buffer(thd, arg1, arg2); } #endif /*HAVE_SPATAI*/ @@ -4508,7 +4508,7 @@ Create_func_is_free_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_is_free_lock(arg1); + return new (thd->mem_root) Item_func_is_free_lock(thd, arg1); } @@ -4519,7 +4519,7 @@ Create_func_is_used_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_is_used_lock(arg1); + return new (thd->mem_root) Item_func_is_used_lock(thd, arg1); } @@ -4529,7 +4529,7 @@ Create_func_isclosed Create_func_isclosed::s_singleton; Item* Create_func_isclosed::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_isclosed(arg1); + return new (thd->mem_root) Item_func_isclosed(thd, arg1); } @@ -4538,7 +4538,7 @@ Create_func_isring Create_func_isring::s_singleton; Item* Create_func_isring::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_isring(arg1); + return new (thd->mem_root) Item_func_isring(thd, arg1); } @@ -4547,7 +4547,7 @@ Create_func_isempty Create_func_isempty::s_singleton; Item* Create_func_isempty::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_isempty(arg1); + return new (thd->mem_root) Item_func_isempty(thd, arg1); } #endif /*HAVE_SPATIAL*/ @@ -4557,7 +4557,7 @@ Create_func_isnull Create_func_isnull::s_singleton; Item* Create_func_isnull::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_isnull(arg1); + return new (thd->mem_root) Item_func_isnull(thd, arg1); } @@ -4567,7 +4567,7 @@ Create_func_issimple Create_func_issimple::s_singleton; Item* Create_func_issimple::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_issimple(arg1); + return new (thd->mem_root) Item_func_issimple(thd, arg1); } #endif @@ -4577,7 +4577,7 @@ Create_func_last_day Create_func_last_day::s_singleton; Item* Create_func_last_day::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_last_day(arg1); + return new (thd->mem_root) Item_func_last_day(thd, arg1); } @@ -4596,14 +4596,14 @@ Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name, switch (arg_count) { case 0: { - func= new (thd->mem_root) Item_func_last_insert_id(); + func= new (thd->mem_root) Item_func_last_insert_id(thd); thd->lex->safe_to_cache_query= 0; break; } case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_last_insert_id(param_1); + func= new (thd->mem_root) Item_func_last_insert_id(thd, param_1); thd->lex->safe_to_cache_query= 0; break; } @@ -4623,7 +4623,7 @@ Create_func_lcase Create_func_lcase::s_singleton; Item* Create_func_lcase::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_lcase(arg1); + return new (thd->mem_root) Item_func_lcase(thd, arg1); } @@ -4644,7 +4644,7 @@ Create_func_least::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_min(*item_list); + return new (thd->mem_root) Item_func_min(thd, *item_list); } @@ -4653,7 +4653,7 @@ Create_func_length Create_func_length::s_singleton; Item* Create_func_length::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_length(arg1); + return new (thd->mem_root) Item_func_length(thd, arg1); } @@ -4663,7 +4663,7 @@ Create_func_like_range_min Create_func_like_range_min::s_singleton; Item* Create_func_like_range_min::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_like_range_min(arg1, arg2); + return new (thd->mem_root) Item_func_like_range_min(thd, arg1, arg2); } @@ -4672,7 +4672,7 @@ Create_func_like_range_max Create_func_like_range_max::s_singleton; Item* Create_func_like_range_max::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_like_range_max(arg1, arg2); + return new (thd->mem_root) Item_func_like_range_max(thd, arg1, arg2); } #endif @@ -4682,7 +4682,7 @@ Create_func_ln Create_func_ln::s_singleton; Item* Create_func_ln::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_ln(arg1); + return new (thd->mem_root) Item_func_ln(thd, arg1); } @@ -4694,7 +4694,7 @@ Create_func_load_file::create_1_arg(THD *thd, Item *arg1) DBUG_ENTER("Create_func_load_file::create"); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - DBUG_RETURN(new (thd->mem_root) Item_load_file(arg1)); + DBUG_RETURN(new (thd->mem_root) Item_load_file(thd, arg1)); } @@ -4716,7 +4716,7 @@ Create_func_locate::create_native(THD *thd, LEX_STRING name, Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); /* Yes, parameters in that order : 2, 1 */ - func= new (thd->mem_root) Item_func_locate(param_2, param_1); + func= new (thd->mem_root) Item_func_locate(thd, param_2, param_1); break; } case 3: @@ -4725,7 +4725,7 @@ Create_func_locate::create_native(THD *thd, LEX_STRING name, Item *param_2= item_list->pop(); Item *param_3= item_list->pop(); /* Yes, parameters in that order : 2, 1, 3 */ - func= new (thd->mem_root) Item_func_locate(param_2, param_1, param_3); + func= new (thd->mem_root) Item_func_locate(thd, param_2, param_1, param_3); break; } default: @@ -4755,14 +4755,14 @@ Create_func_log::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_log(param_1); + func= new (thd->mem_root) Item_func_log(thd, param_1); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_log(param_1, param_2); + func= new (thd->mem_root) Item_func_log(thd, param_1, param_2); break; } default: @@ -4781,7 +4781,7 @@ Create_func_log10 Create_func_log10::s_singleton; Item* Create_func_log10::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_log10(arg1); + return new (thd->mem_root) Item_func_log10(thd, arg1); } @@ -4790,7 +4790,7 @@ Create_func_log2 Create_func_log2::s_singleton; Item* Create_func_log2::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_log2(arg1); + return new (thd->mem_root) Item_func_log2(thd, arg1); } @@ -4799,7 +4799,7 @@ Create_func_lpad Create_func_lpad::s_singleton; Item* Create_func_lpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_lpad(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_lpad(thd, arg1, arg2, arg3); } @@ -4808,7 +4808,7 @@ Create_func_ltrim Create_func_ltrim::s_singleton; Item* Create_func_ltrim::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_ltrim(arg1); + return new (thd->mem_root) Item_func_ltrim(thd, arg1); } @@ -4817,7 +4817,7 @@ Create_func_makedate Create_func_makedate::s_singleton; Item* Create_func_makedate::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_makedate(arg1, arg2); + return new (thd->mem_root) Item_func_makedate(thd, arg1, arg2); } @@ -4826,7 +4826,7 @@ Create_func_maketime Create_func_maketime::s_singleton; Item* Create_func_maketime::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_maketime(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_maketime(thd, arg1, arg2, arg3); } @@ -4847,7 +4847,7 @@ Create_func_make_set::create_native(THD *thd, LEX_STRING name, return NULL; } - return new (thd->mem_root) Item_func_make_set(*item_list); + return new (thd->mem_root) Item_func_make_set(thd, *item_list); } @@ -4879,20 +4879,20 @@ Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name, switch (arg_count) { case 2: { - func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2); + func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2); break; } case 3: { Item *param_3= item_list->pop(); - func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3); + func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2, param_3); break; } case 4: { Item *param_3= item_list->pop(); Item *param_4= item_list->pop(); - func= new (thd->mem_root) Item_master_pos_wait(param_1, param_2, param_3, + func= new (thd->mem_root) Item_master_pos_wait(thd, param_1, param_2, param_3, param_4); break; } @@ -4928,13 +4928,13 @@ Create_func_master_gtid_wait::create_native(THD *thd, LEX_STRING name, switch (arg_count) { case 1: { - func= new (thd->mem_root) Item_master_gtid_wait(param_1); + func= new (thd->mem_root) Item_master_gtid_wait(thd, param_1); break; } case 2: { Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_master_gtid_wait(param_1, param_2); + func= new (thd->mem_root) Item_master_gtid_wait(thd, param_1, param_2); break; } } @@ -4948,7 +4948,7 @@ Create_func_md5 Create_func_md5::s_singleton; Item* Create_func_md5::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_md5(arg1); + return new (thd->mem_root) Item_func_md5(thd, arg1); } @@ -4957,7 +4957,7 @@ Create_func_monthname Create_func_monthname::s_singleton; Item* Create_func_monthname::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_monthname(arg1); + return new (thd->mem_root) Item_func_monthname(thd, arg1); } @@ -4966,7 +4966,7 @@ Create_func_name_const Create_func_name_const::s_singleton; Item* Create_func_name_const::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_name_const(arg1, arg2); + return new (thd->mem_root) Item_name_const(thd, arg1, arg2); } @@ -4975,7 +4975,7 @@ Create_func_nullif Create_func_nullif::s_singleton; Item* Create_func_nullif::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_nullif(arg1, arg2); + return new (thd->mem_root) Item_func_nullif(thd, arg1, arg2); } @@ -4985,7 +4985,7 @@ Create_func_numgeometries Create_func_numgeometries::s_singleton; Item* Create_func_numgeometries::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_numgeometries(arg1); + return new (thd->mem_root) Item_func_numgeometries(thd, arg1); } #endif @@ -4996,7 +4996,7 @@ Create_func_numinteriorring Create_func_numinteriorring::s_singleton; Item* Create_func_numinteriorring::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_numinteriorring(arg1); + return new (thd->mem_root) Item_func_numinteriorring(thd, arg1); } #endif @@ -5007,7 +5007,7 @@ Create_func_numpoints Create_func_numpoints::s_singleton; Item* Create_func_numpoints::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_numpoints(arg1); + return new (thd->mem_root) Item_func_numpoints(thd, arg1); } #endif @@ -5017,9 +5017,9 @@ Create_func_oct Create_func_oct::s_singleton; Item* Create_func_oct::create_1_arg(THD *thd, Item *arg1) { - Item *i10= new (thd->mem_root) Item_int((int32) 10,2); - Item *i8= new (thd->mem_root) Item_int((int32) 8,1); - return new (thd->mem_root) Item_func_conv(arg1, i10, i8); + Item *i10= new (thd->mem_root) Item_int(thd, (int32) 10,2); + Item *i8= new (thd->mem_root) Item_int(thd, (int32) 8,1); + return new (thd->mem_root) Item_func_conv(thd, arg1, i10, i8); } @@ -5028,7 +5028,7 @@ Create_func_ord Create_func_ord::s_singleton; Item* Create_func_ord::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_ord(arg1); + return new (thd->mem_root) Item_func_ord(thd, arg1); } @@ -5038,7 +5038,7 @@ Create_func_mbr_overlaps Create_func_mbr_overlaps::s_singleton; Item* Create_func_mbr_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_OVERLAPS_FUNC); } @@ -5048,7 +5048,7 @@ Create_func_overlaps Create_func_overlaps::s_singleton; Item* Create_func_overlaps::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_OVERLAPS_FUNC); } #endif @@ -5059,7 +5059,7 @@ Create_func_period_add Create_func_period_add::s_singleton; Item* Create_func_period_add::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_period_add(arg1, arg2); + return new (thd->mem_root) Item_func_period_add(thd, arg1, arg2); } @@ -5068,7 +5068,7 @@ Create_func_period_diff Create_func_period_diff::s_singleton; Item* Create_func_period_diff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_period_diff(arg1, arg2); + return new (thd->mem_root) Item_func_period_diff(thd, arg1, arg2); } @@ -5077,7 +5077,7 @@ Create_func_pi Create_func_pi::s_singleton; Item* Create_func_pi::create_builder(THD *thd) { - return new (thd->mem_root) Item_static_float_func("pi()", M_PI, 6, 8); + return new (thd->mem_root) Item_static_float_func(thd, "pi()", M_PI, 6, 8); } @@ -5087,7 +5087,7 @@ Create_func_pointn Create_func_pointn::s_singleton; Item* Create_func_pointn::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_decomp_n(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_decomp_n(thd, arg1, arg2, Item_func::SP_POINTN); } #endif @@ -5098,7 +5098,7 @@ Create_func_pow Create_func_pow::s_singleton; Item* Create_func_pow::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_pow(arg1, arg2); + return new (thd->mem_root) Item_func_pow(thd, arg1, arg2); } @@ -5107,7 +5107,7 @@ Create_func_quote Create_func_quote::s_singleton; Item* Create_func_quote::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_quote(arg1); + return new (thd->mem_root) Item_func_quote(thd, arg1); } @@ -5116,7 +5116,7 @@ Create_func_regexp_instr Create_func_regexp_instr::s_singleton; Item* Create_func_regexp_instr::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_regexp_instr(arg1, arg2); + return new (thd->mem_root) Item_func_regexp_instr(thd, arg1, arg2); } @@ -5125,7 +5125,7 @@ Create_func_regexp_replace Create_func_regexp_replace::s_singleton; Item* Create_func_regexp_replace::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_regexp_replace(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_regexp_replace(thd, arg1, arg2, arg3); } @@ -5134,7 +5134,7 @@ Create_func_regexp_substr Create_func_regexp_substr::s_singleton; Item* Create_func_regexp_substr::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_regexp_substr(arg1, arg2); + return new (thd->mem_root) Item_func_regexp_substr(thd, arg1, arg2); } @@ -5143,7 +5143,7 @@ Create_func_radians Create_func_radians::s_singleton; Item* Create_func_radians::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_units((char*) "radians", arg1, + return new (thd->mem_root) Item_func_units(thd, (char*) "radians", arg1, M_PI/180, 0.0); } @@ -5176,14 +5176,14 @@ Create_func_rand::create_native(THD *thd, LEX_STRING name, switch (arg_count) { case 0: { - func= new (thd->mem_root) Item_func_rand(); + func= new (thd->mem_root) Item_func_rand(thd); thd->lex->uncacheable(UNCACHEABLE_RAND); break; } case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_rand(param_1); + func= new (thd->mem_root) Item_func_rand(thd, param_1); thd->lex->uncacheable(UNCACHEABLE_RAND); break; } @@ -5205,7 +5205,7 @@ Create_func_release_lock::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_release_lock(arg1); + return new (thd->mem_root) Item_func_release_lock(thd, arg1); } @@ -5214,7 +5214,7 @@ Create_func_reverse Create_func_reverse::s_singleton; Item* Create_func_reverse::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_reverse(arg1); + return new (thd->mem_root) Item_func_reverse(thd, arg1); } @@ -5234,15 +5234,15 @@ Create_func_round::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - Item *i0 = new (thd->mem_root) Item_int((char*)"0", 0, 1); - func= new (thd->mem_root) Item_func_round(param_1, i0, 0); + Item *i0 = new (thd->mem_root) Item_int(thd, (char*)"0", 0, 1); + func= new (thd->mem_root) Item_func_round(thd, param_1, i0, 0); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_round(param_1, param_2, 0); + func= new (thd->mem_root) Item_func_round(thd, param_1, param_2, 0); break; } default: @@ -5261,7 +5261,7 @@ Create_func_rpad Create_func_rpad::s_singleton; Item* Create_func_rpad::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_rpad(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_rpad(thd, arg1, arg2, arg3); } @@ -5270,7 +5270,7 @@ Create_func_rtrim Create_func_rtrim::s_singleton; Item* Create_func_rtrim::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_rtrim(arg1); + return new (thd->mem_root) Item_func_rtrim(thd, arg1); } @@ -5279,7 +5279,7 @@ Create_func_sec_to_time Create_func_sec_to_time::s_singleton; Item* Create_func_sec_to_time::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_sec_to_time(arg1); + return new (thd->mem_root) Item_func_sec_to_time(thd, arg1); } @@ -5288,7 +5288,7 @@ Create_func_sha Create_func_sha::s_singleton; Item* Create_func_sha::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_sha(arg1); + return new (thd->mem_root) Item_func_sha(thd, arg1); } @@ -5297,7 +5297,7 @@ Create_func_sha2 Create_func_sha2::s_singleton; Item* Create_func_sha2::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_sha2(arg1, arg2); + return new (thd->mem_root) Item_func_sha2(thd, arg1, arg2); } @@ -5306,7 +5306,7 @@ Create_func_sign Create_func_sign::s_singleton; Item* Create_func_sign::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_sign(arg1); + return new (thd->mem_root) Item_func_sign(thd, arg1); } @@ -5315,7 +5315,7 @@ Create_func_sin Create_func_sin::s_singleton; Item* Create_func_sin::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_sin(arg1); + return new (thd->mem_root) Item_func_sin(thd, arg1); } @@ -5326,7 +5326,7 @@ Create_func_sleep::create_1_arg(THD *thd, Item *arg1) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); - return new (thd->mem_root) Item_func_sleep(arg1); + return new (thd->mem_root) Item_func_sleep(thd, arg1); } @@ -5335,7 +5335,7 @@ Create_func_soundex Create_func_soundex::s_singleton; Item* Create_func_soundex::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_soundex(arg1); + return new (thd->mem_root) Item_func_soundex(thd, arg1); } @@ -5344,7 +5344,7 @@ Create_func_space Create_func_space::s_singleton; Item* Create_func_space::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_space(arg1); + return new (thd->mem_root) Item_func_space(thd, arg1); } @@ -5353,7 +5353,7 @@ Create_func_sqrt Create_func_sqrt::s_singleton; Item* Create_func_sqrt::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_sqrt(arg1); + return new (thd->mem_root) Item_func_sqrt(thd, arg1); } @@ -5363,7 +5363,7 @@ Create_func_srid Create_func_srid::s_singleton; Item* Create_func_srid::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_srid(arg1); + return new (thd->mem_root) Item_func_srid(thd, arg1); } #endif @@ -5374,7 +5374,7 @@ Create_func_startpoint Create_func_startpoint::s_singleton; Item* Create_func_startpoint::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_spatial_decomp(arg1, + return new (thd->mem_root) Item_func_spatial_decomp(thd, arg1, Item_func::SP_STARTPOINT); } #endif @@ -5385,7 +5385,7 @@ Create_func_str_to_date Create_func_str_to_date::s_singleton; Item* Create_func_str_to_date::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_str_to_date(arg1, arg2); + return new (thd->mem_root) Item_func_str_to_date(thd, arg1, arg2); } @@ -5394,7 +5394,7 @@ Create_func_strcmp Create_func_strcmp::s_singleton; Item* Create_func_strcmp::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_strcmp(arg1, arg2); + return new (thd->mem_root) Item_func_strcmp(thd, arg1, arg2); } @@ -5403,7 +5403,7 @@ Create_func_substr_index Create_func_substr_index::s_singleton; Item* Create_func_substr_index::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_substr_index(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_substr_index(thd, arg1, arg2, arg3); } @@ -5412,7 +5412,7 @@ Create_func_subtime Create_func_subtime::s_singleton; Item* Create_func_subtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_add_time(arg1, arg2, 0, 1); + return new (thd->mem_root) Item_func_add_time(thd, arg1, arg2, 0, 1); } @@ -5421,7 +5421,7 @@ Create_func_tan Create_func_tan::s_singleton; Item* Create_func_tan::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_tan(arg1); + return new (thd->mem_root) Item_func_tan(thd, arg1); } @@ -5430,7 +5430,7 @@ Create_func_time_format Create_func_time_format::s_singleton; Item* Create_func_time_format::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_date_format(arg1, arg2, 1); + return new (thd->mem_root) Item_func_date_format(thd, arg1, arg2, 1); } @@ -5439,7 +5439,7 @@ Create_func_time_to_sec Create_func_time_to_sec::s_singleton; Item* Create_func_time_to_sec::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_time_to_sec(arg1); + return new (thd->mem_root) Item_func_time_to_sec(thd, arg1); } @@ -5448,7 +5448,7 @@ Create_func_timediff Create_func_timediff::s_singleton; Item* Create_func_timediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_timediff(arg1, arg2); + return new (thd->mem_root) Item_func_timediff(thd, arg1, arg2); } @@ -5457,7 +5457,7 @@ Create_func_to_base64 Create_func_to_base64::s_singleton; Item* Create_func_to_base64::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_to_base64(arg1); + return new (thd->mem_root) Item_func_to_base64(thd, arg1); } @@ -5466,7 +5466,7 @@ Create_func_to_days Create_func_to_days::s_singleton; Item* Create_func_to_days::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_to_days(arg1); + return new (thd->mem_root) Item_func_to_days(thd, arg1); } @@ -5475,7 +5475,7 @@ Create_func_to_seconds Create_func_to_seconds::s_singleton; Item* Create_func_to_seconds::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_to_seconds(arg1); + return new (thd->mem_root) Item_func_to_seconds(thd, arg1); } @@ -5485,7 +5485,7 @@ Create_func_touches Create_func_touches::s_singleton; Item* Create_func_touches::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_TOUCHES_FUNC); } #endif @@ -5496,7 +5496,7 @@ Create_func_ucase Create_func_ucase::s_singleton; Item* Create_func_ucase::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_ucase(arg1); + return new (thd->mem_root) Item_func_ucase(thd, arg1); } @@ -5505,7 +5505,7 @@ Create_func_uncompress Create_func_uncompress::s_singleton; Item* Create_func_uncompress::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_uncompress(arg1); + return new (thd->mem_root) Item_func_uncompress(thd, arg1); } @@ -5514,7 +5514,7 @@ Create_func_uncompressed_length Create_func_uncompressed_length::s_singleton; Item* Create_func_uncompressed_length::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_uncompressed_length(arg1); + return new (thd->mem_root) Item_func_uncompressed_length(thd, arg1); } @@ -5523,7 +5523,7 @@ Create_func_unhex Create_func_unhex::s_singleton; Item* Create_func_unhex::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_unhex(arg1); + return new (thd->mem_root) Item_func_unhex(thd, arg1); } @@ -5542,14 +5542,14 @@ Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name, switch (arg_count) { case 0: { - func= new (thd->mem_root) Item_func_unix_timestamp(); + func= new (thd->mem_root) Item_func_unix_timestamp(thd); thd->lex->safe_to_cache_query= 0; break; } case 1: { Item *param_1= item_list->pop(); - func= new (thd->mem_root) Item_func_unix_timestamp(param_1); + func= new (thd->mem_root) Item_func_unix_timestamp(thd, param_1); break; } default: @@ -5571,7 +5571,7 @@ Create_func_uuid::create_builder(THD *thd) DBUG_ENTER("Create_func_uuid::create"); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->safe_to_cache_query= 0; - DBUG_RETURN(new (thd->mem_root) Item_func_uuid()); + DBUG_RETURN(new (thd->mem_root) Item_func_uuid(thd)); } @@ -5583,7 +5583,7 @@ Create_func_uuid_short::create_builder(THD *thd) DBUG_ENTER("Create_func_uuid_short::create"); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); thd->lex->safe_to_cache_query= 0; - DBUG_RETURN(new (thd->mem_root) Item_func_uuid_short()); + DBUG_RETURN(new (thd->mem_root) Item_func_uuid_short(thd)); } @@ -5593,7 +5593,7 @@ Item* Create_func_version::create_builder(THD *thd) { thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); - return new (thd->mem_root) Item_static_string_func("version()", + return new (thd->mem_root) Item_static_string_func(thd, "version()", server_version, (uint) strlen(server_version), system_charset_info, @@ -5606,7 +5606,7 @@ Create_func_weekday Create_func_weekday::s_singleton; Item* Create_func_weekday::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_weekday(arg1, 0); + return new (thd->mem_root) Item_func_weekday(thd, arg1, 0); } @@ -5615,8 +5615,8 @@ Create_func_weekofyear Create_func_weekofyear::s_singleton; Item* Create_func_weekofyear::create_1_arg(THD *thd, Item *arg1) { - Item *i1= new (thd->mem_root) Item_int((char*) "0", 3, 1); - return new (thd->mem_root) Item_func_week(arg1, i1); + Item *i1= new (thd->mem_root) Item_int(thd, (char*) "0", 3, 1); + return new (thd->mem_root) Item_func_week(thd, arg1, i1); } @@ -5626,7 +5626,7 @@ Create_func_mbr_within Create_func_mbr_within::s_singleton; Item* Create_func_mbr_within::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_mbr_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_mbr_rel(thd, arg1, arg2, Item_func::SP_WITHIN_FUNC); } @@ -5636,7 +5636,7 @@ Create_func_within Create_func_within::s_singleton; Item* Create_func_within::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_spatial_precise_rel(arg1, arg2, + return new (thd->mem_root) Item_func_spatial_precise_rel(thd, arg1, arg2, Item_func::SP_WITHIN_FUNC); } #endif @@ -5648,7 +5648,7 @@ Create_func_x Create_func_x::s_singleton; Item* Create_func_x::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_x(arg1); + return new (thd->mem_root) Item_func_x(thd, arg1); } #endif @@ -5658,7 +5658,7 @@ Create_func_xml_extractvalue Create_func_xml_extractvalue::s_singleton; Item* Create_func_xml_extractvalue::create_2_arg(THD *thd, Item *arg1, Item *arg2) { - return new (thd->mem_root) Item_func_xml_extractvalue(arg1, arg2); + return new (thd->mem_root) Item_func_xml_extractvalue(thd, arg1, arg2); } @@ -5667,7 +5667,7 @@ Create_func_xml_update Create_func_xml_update::s_singleton; Item* Create_func_xml_update::create_3_arg(THD *thd, Item *arg1, Item *arg2, Item *arg3) { - return new (thd->mem_root) Item_func_xml_update(arg1, arg2, arg3); + return new (thd->mem_root) Item_func_xml_update(thd, arg1, arg2, arg3); } @@ -5677,7 +5677,7 @@ Create_func_y Create_func_y::s_singleton; Item* Create_func_y::create_1_arg(THD *thd, Item *arg1) { - return new (thd->mem_root) Item_func_y(arg1); + return new (thd->mem_root) Item_func_y(thd, arg1); } #endif @@ -5698,15 +5698,15 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name, case 1: { Item *param_1= item_list->pop(); - Item *i0= new (thd->mem_root) Item_int((char*) "0", 0, 1); - func= new (thd->mem_root) Item_func_yearweek(param_1, i0); + Item *i0= new (thd->mem_root) Item_int(thd, (char*) "0", 0, 1); + func= new (thd->mem_root) Item_func_yearweek(thd, param_1, i0); break; } case 2: { Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); - func= new (thd->mem_root) Item_func_yearweek(param_1, param_2); + func= new (thd->mem_root) Item_func_yearweek(thd, param_1, param_2); break; } default: @@ -6165,16 +6165,16 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, switch (cast_type) { case ITEM_CAST_BINARY: - res= new (thd->mem_root) Item_func_binary(a); + res= new (thd->mem_root) Item_func_binary(thd, a); break; case ITEM_CAST_SIGNED_INT: - res= new (thd->mem_root) Item_func_signed(a); + res= new (thd->mem_root) Item_func_signed(thd, a); break; case ITEM_CAST_UNSIGNED_INT: - res= new (thd->mem_root) Item_func_unsigned(a); + res= new (thd->mem_root) Item_func_unsigned(thd, a); break; case ITEM_CAST_DATE: - res= new (thd->mem_root) Item_date_typecast(a); + res= new (thd->mem_root) Item_date_typecast(thd, a); break; case ITEM_CAST_TIME: if (decimals > MAX_DATETIME_PRECISION) @@ -6183,7 +6183,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, MAX_DATETIME_PRECISION); return 0; } - res= new (thd->mem_root) Item_time_typecast(a, (uint) decimals); + res= new (thd->mem_root) Item_time_typecast(thd, a, (uint) decimals); break; case ITEM_CAST_DATETIME: if (decimals > MAX_DATETIME_PRECISION) @@ -6192,7 +6192,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, MAX_DATETIME_PRECISION); return 0; } - res= new (thd->mem_root) Item_datetime_typecast(a, (uint) decimals); + res= new (thd->mem_root) Item_datetime_typecast(thd, a, (uint) decimals); break; case ITEM_CAST_DECIMAL: { @@ -6202,7 +6202,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, DECIMAL_MAX_PRECISION, DECIMAL_MAX_SCALE, a)) return NULL; - res= new (thd->mem_root) Item_decimal_typecast(a, len, dec); + res= new (thd->mem_root) Item_decimal_typecast(thd, a, len, dec); break; } case ITEM_CAST_DOUBLE: @@ -6219,7 +6219,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, DECIMAL_MAX_PRECISION, NOT_FIXED_DEC-1, a)) return NULL; - res= new (thd->mem_root) Item_double_typecast(a, (uint) length, + res= new (thd->mem_root) Item_double_typecast(thd, a, (uint) length, (uint) decimals); break; } @@ -6239,7 +6239,7 @@ create_func_cast(THD *thd, Item *a, Cast_target cast_type, } len= (int) length; } - res= new (thd->mem_root) Item_char_typecast(a, len, real_cs); + res= new (thd->mem_root) Item_char_typecast(thd, a, len, real_cs); break; } default: @@ -6287,20 +6287,20 @@ Item *create_temporal_literal(THD *thd, case MYSQL_TYPE_NEWDATE: if (!str_to_datetime(cs, str, length, <ime, flags, &status) && ltime.time_type == MYSQL_TIMESTAMP_DATE && !status.warnings) - item= new (thd->mem_root) Item_date_literal(<ime); + item= new (thd->mem_root) Item_date_literal(thd, <ime); break; case MYSQL_TYPE_DATETIME: if (!str_to_datetime(cs, str, length, <ime, flags, &status) && ltime.time_type == MYSQL_TIMESTAMP_DATETIME && !have_important_literal_warnings(&status)) - item= new (thd->mem_root) Item_datetime_literal(<ime, + item= new (thd->mem_root) Item_datetime_literal(thd, <ime, status.precision); break; case MYSQL_TYPE_TIME: if (!str_to_time(cs, str, length, <ime, 0, &status) && ltime.time_type == MYSQL_TIMESTAMP_TIME && !have_important_literal_warnings(&status)) - item= new (thd->mem_root) Item_time_literal(<ime, + item= new (thd->mem_root) Item_time_literal(thd, <ime, status.precision); break; default: @@ -6362,7 +6362,7 @@ Item *create_func_dyncol_create(THD *thd, List<DYNCALL_CREATE_DEF> &list) if (!(args= create_func_dyncol_prepare(thd, &dfs, list))) return NULL; - return new (thd->mem_root) Item_func_dyncol_create(*args, dfs); + return new (thd->mem_root) Item_func_dyncol_create(thd, *args, dfs); } Item *create_func_dyncol_add(THD *thd, Item *str, @@ -6376,7 +6376,7 @@ Item *create_func_dyncol_add(THD *thd, Item *str, args->push_back(str); - return new (thd->mem_root) Item_func_dyncol_add(*args, dfs); + return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs); } @@ -6397,7 +6397,7 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums) for (uint i= 0; (key= it++); i++) { dfs[i].key= key; - dfs[i].value= new Item_null(); + dfs[i].value= new Item_null(thd); dfs[i].type= DYN_COL_INT; args->push_back(dfs[i].key); args->push_back(dfs[i].value); @@ -6405,7 +6405,7 @@ Item *create_func_dyncol_delete(THD *thd, Item *str, List<Item> &nums) args->push_back(str); - return new (thd->mem_root) Item_func_dyncol_add(*args, dfs); + return new (thd->mem_root) Item_func_dyncol_add(thd, *args, dfs); } @@ -6416,7 +6416,7 @@ Item *create_func_dyncol_get(THD *thd, Item *str, Item *num, { Item *res; - if (!(res= new (thd->mem_root) Item_dyncol_get(str, num))) + if (!(res= new (thd->mem_root) Item_dyncol_get(thd, str, num))) return res; // Return NULL return create_func_cast(thd, res, cast_type, c_len, c_dec, cs); } diff --git a/sql/item_func.cc b/sql/item_func.cc index f3e5e844048..3da1e62a6d2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -319,11 +319,11 @@ void Item_func::traverse_cond(Cond_traverser traverser, } -bool Item_args::transform_args(Item_transformer transformer, uchar *arg) +bool Item_args::transform_args(THD *thd, Item_transformer transformer, uchar *arg) { for (uint i= 0; i < arg_count; i++) { - Item *new_item= args[i]->transform(transformer, arg); + Item *new_item= args[i]->transform(thd, transformer, arg); if (!new_item) return true; /* @@ -333,7 +333,7 @@ bool Item_args::transform_args(Item_transformer transformer, uchar *arg) change records at each execution. */ if (args[i] != new_item) - current_thd->change_item_tree(&args[i], new_item); + thd->change_item_tree(&args[i], new_item); } return false; } @@ -356,12 +356,12 @@ bool Item_args::transform_args(Item_transformer transformer, uchar *arg) Item returned as the result of transformation of the root node */ -Item *Item_func::transform(Item_transformer transformer, uchar *argument) +Item *Item_func::transform(THD *thd, Item_transformer transformer, uchar *argument) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); - if (transform_args(transformer, argument)) + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); + if (transform_args(thd, transformer, argument)) return 0; - return (this->*transformer)(argument); + return (this->*transformer)(thd, argument); } @@ -391,7 +391,7 @@ Item *Item_func::transform(Item_transformer transformer, uchar *argument) Item returned as the result of transformation of the root node */ -Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p, +Item *Item_func::compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) { if (!(this->*analyzer)(arg_p)) @@ -406,12 +406,13 @@ Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p, to analyze any argument of the condition formula. */ uchar *arg_v= *arg_p; - Item *new_item= (*arg)->compile(analyzer, &arg_v, transformer, arg_t); + Item *new_item= (*arg)->compile(thd, analyzer, &arg_v, transformer, + arg_t); if (new_item && *arg != new_item) - current_thd->change_item_tree(arg, new_item); + thd->change_item_tree(arg, new_item); } } - return (this->*transformer)(arg_t); + return (this->*transformer)(thd, arg_t); } /** @@ -726,7 +727,7 @@ void Item_func::signal_divide_by_null() Item *Item_func::get_tmp_table_item(THD *thd) { if (!with_sum_func && !const_item()) - return new Item_field(result_field); + return new Item_field(thd, result_field); return copy_or_same(thd); } @@ -5533,8 +5534,8 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command, LEX *sav_lex= thd->lex, lex_tmp; thd->lex= &lex_tmp; lex_start(thd); - tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(name, - new Item_null()))); + tmp_var_list.push_back(new set_var_user(new Item_func_set_user_var(thd, name, + new Item_null(thd)))); /* Create the variable */ if (sql_set_variables(thd, &tmp_var_list, false)) { @@ -5698,7 +5699,7 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const bool Item_func_get_user_var::set_value(THD *thd, sp_rcontext * /*ctx*/, Item **it) { - Item_func_set_user_var *suv= new Item_func_set_user_var(get_name(), *it); + Item_func_set_user_var *suv= new Item_func_set_user_var(thd, get_name(), *it); /* Item_func_set_user_var is not fixed after construction, call fix_fields(). @@ -5779,11 +5780,11 @@ void Item_user_var_as_out_param::print_for_load(THD *thd, String *str) Item_func_get_system_var:: -Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg, +Item_func_get_system_var(THD *thd, sys_var *var_arg, enum_var_type var_type_arg, LEX_STRING *component_arg, const char *name_arg, - size_t name_len_arg) - :var(var_arg), var_type(var_type_arg), orig_var_type(var_type_arg), - component(*component_arg), cache_present(0) + size_t name_len_arg): + Item_func(thd), var(var_arg), var_type(var_type_arg), + orig_var_type(var_type_arg), component(*component_arg), cache_present(0) { /* set_name() will allocate the name */ set_name(name_arg, (uint) name_len_arg, system_charset_info); @@ -6095,7 +6096,7 @@ void Item_func_get_system_var::cleanup() } -void Item_func_match::init_search(bool no_order) +void Item_func_match::init_search(THD *thd, bool no_order) { DBUG_ENTER("Item_func_match::init_search"); @@ -6113,10 +6114,10 @@ void Item_func_match::init_search(bool no_order) if (key == NO_SUCH_KEY) { List<Item> fields; - fields.push_back(new Item_string(" ", 1, cmp_collation.collation)); + fields.push_back(new Item_string(thd, " ", 1, cmp_collation.collation)); for (uint i= 1; i < arg_count; i++) fields.push_back(args[i]); - concat_ws= new Item_func_concat_ws(fields); + concat_ws= new Item_func_concat_ws(thd, fields); /* Above function used only to get value and do not need fix_fields for it: Item_string - basic constant @@ -6129,7 +6130,7 @@ void Item_func_match::init_search(bool no_order) if (master) { join_key= master->join_key= join_key | master->join_key; - master->init_search(no_order); + master->init_search(thd, no_order); ft_handler= master->ft_handler; join_key= master->join_key; DBUG_VOID_RETURN; @@ -6464,7 +6465,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, set_if_smaller(component_name->length, MAX_SYS_VAR_LENGTH); - return new Item_func_get_system_var(var, var_type, component_name, + return new Item_func_get_system_var(thd, var, var_type, component_name, NULL, 0); } @@ -6480,8 +6481,9 @@ longlong Item_func_row_count::val_int() -Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name) - :Item_func(), context(context_arg), m_name(name), m_sp(NULL), sp_result_field(NULL) +Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg, + sp_name *name): + Item_func(thd), context(context_arg), m_name(name), m_sp(NULL), sp_result_field(NULL) { maybe_null= 1; m_name->init_qname(current_thd); @@ -6490,10 +6492,10 @@ Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, sp_name *name) } -Item_func_sp::Item_func_sp(Name_resolution_context *context_arg, - sp_name *name_arg, List<Item> &list) - :Item_func(list), context(context_arg), m_name(name_arg), m_sp(NULL), - sp_result_field(NULL) +Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg, + sp_name *name_arg, List<Item> &list): + Item_func(thd, list), context(context_arg), m_name(name_arg), m_sp(NULL), + sp_result_field(NULL) { maybe_null= 1; m_name->init_qname(current_thd); diff --git a/sql/item_func.h b/sql/item_func.h index 7fbe65998ee..244e5b05b1d 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -62,48 +62,46 @@ public: NEG_FUNC, GSYSVAR_FUNC, DYNCOL_FUNC }; enum Type type() const { return FUNC_ITEM; } virtual enum Functype functype() const { return UNKNOWN_FUNC; } - Item_func(void): - Item_func_or_sum(), allowed_arg_cols(1) + Item_func(THD *thd): Item_func_or_sum(thd), allowed_arg_cols(1) { with_sum_func= 0; with_field= 0; } - Item_func(Item *a): - Item_func_or_sum(a), allowed_arg_cols(1) + Item_func(THD *thd, Item *a): Item_func_or_sum(thd, a), allowed_arg_cols(1) { with_sum_func= a->with_sum_func; with_field= a->with_field; } - Item_func(Item *a,Item *b): - Item_func_or_sum(a, b), allowed_arg_cols(1) + Item_func(THD *thd, Item *a, Item *b): + Item_func_or_sum(thd, a, b), allowed_arg_cols(1) { with_sum_func= a->with_sum_func || b->with_sum_func; with_field= a->with_field || b->with_field; } - Item_func(Item *a,Item *b,Item *c): - Item_func_or_sum(a, b, c), allowed_arg_cols(1) + Item_func(THD *thd, Item *a, Item *b, Item *c): + Item_func_or_sum(thd, a, b, c), allowed_arg_cols(1) { with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func; with_field= a->with_field || b->with_field || c->with_field; } - Item_func(Item *a,Item *b,Item *c,Item *d): - Item_func_or_sum(a, b, c, d), allowed_arg_cols(1) + Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d): + Item_func_or_sum(thd, a, b, c, d), allowed_arg_cols(1) { with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func || d->with_sum_func; with_field= a->with_field || b->with_field || c->with_field || d->with_field; } - Item_func(Item *a,Item *b,Item *c,Item *d,Item* e): - Item_func_or_sum(a, b, c, d, e), allowed_arg_cols(1) + Item_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e): + Item_func_or_sum(thd, a, b, c, d, e), allowed_arg_cols(1) { with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func || d->with_sum_func || e->with_sum_func; with_field= a->with_field || b->with_field || c->with_field || d->with_field || e->with_field; } - Item_func(List<Item> &list) - :Item_func_or_sum(list), allowed_arg_cols(1) + Item_func(THD *thd, List<Item> &list): + Item_func_or_sum(thd, list), allowed_arg_cols(1) { set_arguments(list); } @@ -233,8 +231,8 @@ public: items, nitems, item_sep); } - Item *transform(Item_transformer transformer, uchar *arg); - Item* compile(Item_analyzer analyzer, uchar **arg_p, + Item *transform(THD *thd, Item_transformer transformer, uchar *arg); + Item* compile(THD *thd, Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t); void traverse_cond(Cond_traverser traverser, void * arg, traverse_order order); @@ -406,10 +404,13 @@ public: class Item_real_func :public Item_func { public: - Item_real_func() :Item_func() { collation.set_numeric(); } - Item_real_func(Item *a) :Item_func(a) { collation.set_numeric(); } - Item_real_func(Item *a,Item *b) :Item_func(a,b) { collation.set_numeric(); } - Item_real_func(List<Item> &list) :Item_func(list) { collation.set_numeric(); } + Item_real_func(THD *thd): Item_func(thd) { collation.set_numeric(); } + Item_real_func(THD *thd, Item *a): Item_func(thd, a) + { collation.set_numeric(); } + Item_real_func(THD *thd, Item *a, Item *b): Item_func(thd, a, b) + { collation.set_numeric(); } + Item_real_func(THD *thd, List<Item> &list): Item_func(thd, list) + { collation.set_numeric(); } String *val_str(String*str); my_decimal *val_decimal(my_decimal *decimal_value); longlong val_int() @@ -426,18 +427,20 @@ protected: Item_result cached_result_type; public: - Item_func_hybrid_result_type() :Item_func(), cached_result_type(REAL_RESULT) + Item_func_hybrid_result_type(THD *thd): + Item_func(thd), cached_result_type(REAL_RESULT) { collation.set_numeric(); } - Item_func_hybrid_result_type(Item *a) :Item_func(a), cached_result_type(REAL_RESULT) + Item_func_hybrid_result_type(THD *thd, Item *a): + Item_func(thd, a), cached_result_type(REAL_RESULT) { collation.set_numeric(); } - Item_func_hybrid_result_type(Item *a,Item *b) - :Item_func(a,b), cached_result_type(REAL_RESULT) + Item_func_hybrid_result_type(THD *thd, Item *a, Item *b): + Item_func(thd, a, b), cached_result_type(REAL_RESULT) { collation.set_numeric(); } - Item_func_hybrid_result_type(Item *a,Item *b,Item *c) - :Item_func(a,b,c), cached_result_type(REAL_RESULT) + Item_func_hybrid_result_type(THD *thd, Item *a, Item *b, Item *c): + Item_func(thd, a, b, c), cached_result_type(REAL_RESULT) { collation.set_numeric(); } - Item_func_hybrid_result_type(List<Item> &list) - :Item_func(list), cached_result_type(REAL_RESULT) + Item_func_hybrid_result_type(THD *thd, List<Item> &list): + Item_func(thd, list), cached_result_type(REAL_RESULT) { collation.set_numeric(); } enum Item_result result_type () const { return cached_result_type; } @@ -500,18 +503,19 @@ class Item_func_hybrid_field_type :public Item_func_hybrid_result_type protected: enum_field_types cached_field_type; public: - Item_func_hybrid_field_type() - :Item_func_hybrid_result_type(), cached_field_type(MYSQL_TYPE_DOUBLE) + Item_func_hybrid_field_type(THD *thd): + Item_func_hybrid_result_type(thd), cached_field_type(MYSQL_TYPE_DOUBLE) {} - Item_func_hybrid_field_type(Item *a, Item *b) - :Item_func_hybrid_result_type(a, b), cached_field_type(MYSQL_TYPE_DOUBLE) + Item_func_hybrid_field_type(THD *thd, Item *a, Item *b): + Item_func_hybrid_result_type(thd, a, b), + cached_field_type(MYSQL_TYPE_DOUBLE) {} - Item_func_hybrid_field_type(Item *a, Item *b, Item *c) - :Item_func_hybrid_result_type(a, b, c), + Item_func_hybrid_field_type(THD *thd, Item *a, Item *b, Item *c): + Item_func_hybrid_result_type(thd, a, b, c), cached_field_type(MYSQL_TYPE_DOUBLE) {} - Item_func_hybrid_field_type(List<Item> &list) - :Item_func_hybrid_result_type(list), + Item_func_hybrid_field_type(THD *thd, List<Item> &list): + Item_func_hybrid_result_type(thd, list), cached_field_type(MYSQL_TYPE_DOUBLE) {} enum_field_types field_type() const { return cached_field_type; } @@ -531,18 +535,18 @@ protected: } public: - Item_func_numhybrid() :Item_func_hybrid_result_type() + Item_func_numhybrid(THD *thd): Item_func_hybrid_result_type(thd) { } - Item_func_numhybrid(Item *a) :Item_func_hybrid_result_type(a) + Item_func_numhybrid(THD *thd, Item *a): Item_func_hybrid_result_type(thd, a) { } - Item_func_numhybrid(Item *a,Item *b) - :Item_func_hybrid_result_type(a,b) + Item_func_numhybrid(THD *thd, Item *a, Item *b): + Item_func_hybrid_result_type(thd, a, b) { } - Item_func_numhybrid(Item *a,Item *b,Item *c) - :Item_func_hybrid_result_type(a,b,c) + Item_func_numhybrid(THD *thd, Item *a, Item *b, Item *c): + Item_func_hybrid_result_type(thd, a, b, c) { } - Item_func_numhybrid(List<Item> &list) - :Item_func_hybrid_result_type(list) + Item_func_numhybrid(THD *thd, List<Item> &list): + Item_func_hybrid_result_type(thd, list) { } String *str_op(String *str) { DBUG_ASSERT(0); return 0; } bool date_op(MYSQL_TIME *ltime, uint fuzzydate) { DBUG_ASSERT(0); return true; } @@ -553,8 +557,8 @@ public: class Item_func_num1: public Item_func_numhybrid { public: - Item_func_num1(Item *a) :Item_func_numhybrid(a) {} - Item_func_num1(Item *a, Item *b) :Item_func_numhybrid(a, b) {} + Item_func_num1(THD *thd, Item *a): Item_func_numhybrid(thd, a) {} + Item_func_num1(THD *thd, Item *a, Item *b): Item_func_numhybrid(thd, a, b) {} void fix_length_and_dec(); }; @@ -563,7 +567,7 @@ public: class Item_num_op :public Item_func_numhybrid { public: - Item_num_op(Item *a,Item *b) :Item_func_numhybrid(a, b) {} + Item_num_op(THD *thd, Item *a, Item *b): Item_func_numhybrid(thd, a, b) {} virtual void result_precision()= 0; virtual inline void print(String *str, enum_query_type query_type) @@ -578,17 +582,18 @@ class Item_num_op :public Item_func_numhybrid class Item_int_func :public Item_func { public: - Item_int_func() :Item_func() + Item_int_func(THD *thd): Item_func(thd) { collation.set_numeric(); fix_char_length(21); } - Item_int_func(Item *a) :Item_func(a) + Item_int_func(THD *thd, Item *a): Item_func(thd, a) { collation.set_numeric(); fix_char_length(21); } - Item_int_func(Item *a,Item *b) :Item_func(a,b) + Item_int_func(THD *thd, Item *a, Item *b): Item_func(thd, a, b) { collation.set_numeric(); fix_char_length(21); } - Item_int_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) + Item_int_func(THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b, c) { collation.set_numeric(); fix_char_length(21); } - Item_int_func(Item *a,Item *b,Item *c, Item *d) :Item_func(a,b,c,d) + Item_int_func(THD *thd, Item *a, Item *b, Item *c, Item *d): + Item_func(thd, a, b, c, d) { collation.set_numeric(); fix_char_length(21); } - Item_int_func(List<Item> &list) :Item_func(list) + Item_int_func(THD *thd, List<Item> &list): Item_func(thd, list) { collation.set_numeric(); fix_char_length(21); } Item_int_func(THD *thd, Item_int_func *item) :Item_func(thd, item) { collation.set_numeric(); } @@ -604,7 +609,7 @@ class Item_func_connection_id :public Item_int_func longlong value; public: - Item_func_connection_id() {} + Item_func_connection_id(THD *thd): Item_int_func(thd) {} const char *func_name() const { return "connection_id"; } void fix_length_and_dec(); bool fix_fields(THD *thd, Item **ref); @@ -616,7 +621,7 @@ public: class Item_func_signed :public Item_int_func { public: - Item_func_signed(Item *a) :Item_int_func(a) + Item_func_signed(THD *thd, Item *a): Item_int_func(thd, a) { unsigned_flag= 0; } @@ -636,7 +641,7 @@ public: class Item_func_unsigned :public Item_func_signed { public: - Item_func_unsigned(Item *a) :Item_func_signed(a) + Item_func_unsigned(THD *thd, Item *a): Item_func_signed(thd, a) { unsigned_flag= 1; } @@ -650,7 +655,7 @@ class Item_decimal_typecast :public Item_func { my_decimal decimal_value; public: - Item_decimal_typecast(Item *a, int len, int dec) :Item_func(a) + Item_decimal_typecast(THD *thd, Item *a, int len, int dec): Item_func(thd, a) { decimals= (uint8) dec; collation.set_numeric(); @@ -672,7 +677,8 @@ public: class Item_double_typecast :public Item_real_func { public: - Item_double_typecast(Item *a, int len, int dec) :Item_real_func(a) + Item_double_typecast(THD *thd, Item *a, int len, int dec): + Item_real_func(thd, a) { decimals= (uint8) dec; max_length= (uint32) len; @@ -689,7 +695,7 @@ public: class Item_func_additive_op :public Item_num_op { public: - Item_func_additive_op(Item *a,Item *b) :Item_num_op(a,b) {} + Item_func_additive_op(THD *thd, Item *a, Item *b): Item_num_op(thd, a, b) {} void result_precision(); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} @@ -699,7 +705,8 @@ public: class Item_func_plus :public Item_func_additive_op { public: - Item_func_plus(Item *a,Item *b) :Item_func_additive_op(a,b) {} + Item_func_plus(THD *thd, Item *a, Item *b): + Item_func_additive_op(thd, a, b) {} const char *func_name() const { return "+"; } longlong int_op(); double real_op(); @@ -709,7 +716,8 @@ public: class Item_func_minus :public Item_func_additive_op { public: - Item_func_minus(Item *a,Item *b) :Item_func_additive_op(a,b) {} + Item_func_minus(THD *thd, Item *a, Item *b): + Item_func_additive_op(thd, a, b) {} const char *func_name() const { return "-"; } longlong int_op(); double real_op(); @@ -721,7 +729,8 @@ public: class Item_func_mul :public Item_num_op { public: - Item_func_mul(Item *a,Item *b) :Item_num_op(a,b) {} + Item_func_mul(THD *thd, Item *a, Item *b): + Item_num_op(thd, a, b) {} const char *func_name() const { return "*"; } longlong int_op(); double real_op(); @@ -736,7 +745,7 @@ class Item_func_div :public Item_num_op { public: uint prec_increment; - Item_func_div(Item *a,Item *b) :Item_num_op(a,b) {} + Item_func_div(THD *thd, Item *a, Item *b): Item_num_op(thd, a, b) {} longlong int_op() { DBUG_ASSERT(0); return 0; } double real_op(); my_decimal *decimal_op(my_decimal *); @@ -749,7 +758,7 @@ public: class Item_func_int_div :public Item_int_func { public: - Item_func_int_div(Item *a,Item *b) :Item_int_func(a,b) + Item_func_int_div(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "DIV"; } @@ -768,7 +777,7 @@ public: class Item_func_mod :public Item_num_op { public: - Item_func_mod(Item *a,Item *b) :Item_num_op(a,b) {} + Item_func_mod(THD *thd, Item *a, Item *b): Item_num_op(thd, a, b) {} longlong int_op(); double real_op(); my_decimal *decimal_op(my_decimal *); @@ -783,7 +792,7 @@ public: class Item_func_neg :public Item_func_num1 { public: - Item_func_neg(Item *a) :Item_func_num1(a) {} + Item_func_neg(THD *thd, Item *a): Item_func_num1(thd, a) {} double real_op(); longlong int_op(); my_decimal *decimal_op(my_decimal *); @@ -799,7 +808,7 @@ public: class Item_func_abs :public Item_func_num1 { public: - Item_func_abs(Item *a) :Item_func_num1(a) {} + Item_func_abs(THD *thd, Item *a): Item_func_num1(thd, a) {} double real_op(); longlong int_op(); my_decimal *decimal_op(my_decimal *); @@ -814,8 +823,8 @@ public: class Item_dec_func :public Item_real_func { public: - Item_dec_func(Item *a) :Item_real_func(a) {} - Item_dec_func(Item *a,Item *b) :Item_real_func(a,b) {} + Item_dec_func(THD *thd, Item *a): Item_real_func(thd, a) {} + Item_dec_func(THD *thd, Item *a, Item *b): Item_real_func(thd, a, b) {} void fix_length_and_dec() { decimals=NOT_FIXED_DEC; max_length=float_length(decimals); @@ -826,7 +835,7 @@ class Item_dec_func :public Item_real_func class Item_func_exp :public Item_dec_func { public: - Item_func_exp(Item *a) :Item_dec_func(a) {} + Item_func_exp(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "exp"; } }; @@ -835,7 +844,7 @@ public: class Item_func_ln :public Item_dec_func { public: - Item_func_ln(Item *a) :Item_dec_func(a) {} + Item_func_ln(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "ln"; } }; @@ -844,8 +853,8 @@ public: class Item_func_log :public Item_dec_func { public: - Item_func_log(Item *a) :Item_dec_func(a) {} - Item_func_log(Item *a,Item *b) :Item_dec_func(a,b) {} + Item_func_log(THD *thd, Item *a): Item_dec_func(thd, a) {} + Item_func_log(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {} double val_real(); const char *func_name() const { return "log"; } }; @@ -854,7 +863,7 @@ public: class Item_func_log2 :public Item_dec_func { public: - Item_func_log2(Item *a) :Item_dec_func(a) {} + Item_func_log2(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "log2"; } }; @@ -863,7 +872,7 @@ public: class Item_func_log10 :public Item_dec_func { public: - Item_func_log10(Item *a) :Item_dec_func(a) {} + Item_func_log10(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "log10"; } }; @@ -872,7 +881,7 @@ public: class Item_func_sqrt :public Item_dec_func { public: - Item_func_sqrt(Item *a) :Item_dec_func(a) {} + Item_func_sqrt(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "sqrt"; } }; @@ -881,7 +890,7 @@ public: class Item_func_pow :public Item_dec_func { public: - Item_func_pow(Item *a,Item *b) :Item_dec_func(a,b) {} + Item_func_pow(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {} double val_real(); const char *func_name() const { return "pow"; } }; @@ -890,7 +899,7 @@ public: class Item_func_acos :public Item_dec_func { public: - Item_func_acos(Item *a) :Item_dec_func(a) {} + Item_func_acos(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "acos"; } }; @@ -898,7 +907,7 @@ public: class Item_func_asin :public Item_dec_func { public: - Item_func_asin(Item *a) :Item_dec_func(a) {} + Item_func_asin(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "asin"; } }; @@ -906,8 +915,8 @@ public: class Item_func_atan :public Item_dec_func { public: - Item_func_atan(Item *a) :Item_dec_func(a) {} - Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {} + Item_func_atan(THD *thd, Item *a): Item_dec_func(thd, a) {} + Item_func_atan(THD *thd, Item *a, Item *b): Item_dec_func(thd, a, b) {} double val_real(); const char *func_name() const { return "atan"; } }; @@ -915,7 +924,7 @@ public: class Item_func_cos :public Item_dec_func { public: - Item_func_cos(Item *a) :Item_dec_func(a) {} + Item_func_cos(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "cos"; } }; @@ -923,7 +932,7 @@ public: class Item_func_sin :public Item_dec_func { public: - Item_func_sin(Item *a) :Item_dec_func(a) {} + Item_func_sin(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "sin"; } }; @@ -931,7 +940,7 @@ public: class Item_func_tan :public Item_dec_func { public: - Item_func_tan(Item *a) :Item_dec_func(a) {} + Item_func_tan(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "tan"; } }; @@ -939,7 +948,7 @@ public: class Item_func_cot :public Item_dec_func { public: - Item_func_cot(Item *a) :Item_dec_func(a) {} + Item_func_cot(THD *thd, Item *a): Item_dec_func(thd, a) {} double val_real(); const char *func_name() const { return "cot"; } }; @@ -947,7 +956,7 @@ public: class Item_func_integer :public Item_int_func { public: - inline Item_func_integer(Item *a) :Item_int_func(a) {} + inline Item_func_integer(THD *thd, Item *a): Item_int_func(thd, a) {} void fix_length_and_dec(); }; @@ -955,7 +964,7 @@ public: class Item_func_int_val :public Item_func_num1 { public: - Item_func_int_val(Item *a) :Item_func_num1(a) {} + Item_func_int_val(THD *thd, Item *a): Item_func_num1(thd, a) {} void fix_length_and_dec(); }; @@ -963,7 +972,7 @@ public: class Item_func_ceiling :public Item_func_int_val { public: - Item_func_ceiling(Item *a) :Item_func_int_val(a) {} + Item_func_ceiling(THD *thd, Item *a): Item_func_int_val(thd, a) {} const char *func_name() const { return "ceiling"; } longlong int_op(); double real_op(); @@ -976,7 +985,7 @@ public: class Item_func_floor :public Item_func_int_val { public: - Item_func_floor(Item *a) :Item_func_int_val(a) {} + Item_func_floor(THD *thd, Item *a): Item_func_int_val(thd, a) {} const char *func_name() const { return "floor"; } longlong int_op(); double real_op(); @@ -991,8 +1000,8 @@ class Item_func_round :public Item_func_num1 { bool truncate; public: - Item_func_round(Item *a, Item *b, bool trunc_arg) - :Item_func_num1(a,b), truncate(trunc_arg) {} + Item_func_round(THD *thd, Item *a, Item *b, bool trunc_arg) + :Item_func_num1(thd, a, b), truncate(trunc_arg) {} const char *func_name() const { return truncate ? "truncate" : "round"; } double real_op(); longlong int_op(); @@ -1006,8 +1015,9 @@ class Item_func_rand :public Item_real_func struct my_rnd_struct *rand; bool first_eval; // TRUE if val_real() is called 1st time public: - Item_func_rand(Item *a) :Item_real_func(a), rand(0), first_eval(TRUE) {} - Item_func_rand() :Item_real_func() {} + Item_func_rand(THD *thd, Item *a): + Item_real_func(thd, a), rand(0), first_eval(TRUE) {} + Item_func_rand(THD *thd): Item_real_func(thd) {} double val_real(); const char *func_name() const { return "rand"; } bool const_item() const { return 0; } @@ -1026,7 +1036,7 @@ private: class Item_func_sign :public Item_int_func { public: - Item_func_sign(Item *a) :Item_int_func(a) {} + Item_func_sign(THD *thd, Item *a): Item_int_func(thd, a) {} const char *func_name() const { return "sign"; } longlong val_int(); }; @@ -1037,8 +1047,9 @@ class Item_func_units :public Item_real_func char *name; double mul,add; public: - Item_func_units(char *name_arg,Item *a,double mul_arg,double add_arg) - :Item_real_func(a),name(name_arg),mul(mul_arg),add(add_arg) {} + Item_func_units(THD *thd, char *name_arg, Item *a, double mul_arg, + double add_arg): + Item_real_func(thd, a), name(name_arg), mul(mul_arg), add(add_arg) {} double val_real(); const char *func_name() const { return name; } void fix_length_and_dec() @@ -1057,8 +1068,9 @@ class Item_func_min_max :public Item_func protected: enum_field_types cached_field_type; public: - Item_func_min_max(List<Item> &list,int cmp_sign_arg) :Item_func(list), - cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), compare_as_dates(0) {} + Item_func_min_max(THD *thd, List<Item> &list, int cmp_sign_arg): + Item_func(thd, list), cmp_type(INT_RESULT), cmp_sign(cmp_sign_arg), + compare_as_dates(0) {} double val_real(); longlong val_int(); String *val_str(String *); @@ -1072,14 +1084,14 @@ public: class Item_func_min :public Item_func_min_max { public: - Item_func_min(List<Item> &list) :Item_func_min_max(list,1) {} + Item_func_min(THD *thd, List<Item> &list): Item_func_min_max(thd, list, 1) {} const char *func_name() const { return "least"; } }; class Item_func_max :public Item_func_min_max { public: - Item_func_max(List<Item> &list) :Item_func_min_max(list,-1) {} + Item_func_max(THD *thd, List<Item> &list): Item_func_min_max(thd, list, -1) {} const char *func_name() const { return "greatest"; } }; @@ -1092,7 +1104,7 @@ public: class Item_func_rollup_const :public Item_func { public: - Item_func_rollup_const(Item *a) :Item_func(a) + Item_func_rollup_const(THD *thd, Item *a): Item_func(thd, a) { name= a->name; name_length= a->name_length; @@ -1119,7 +1131,7 @@ class Item_func_length :public Item_int_func { String value; public: - Item_func_length(Item *a) :Item_int_func(a) {} + Item_func_length(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "length"; } void fix_length_and_dec() { max_length=10; } @@ -1128,7 +1140,7 @@ public: class Item_func_bit_length :public Item_func_length { public: - Item_func_bit_length(Item *a) :Item_func_length(a) {} + Item_func_bit_length(THD *thd, Item *a): Item_func_length(thd, a) {} longlong val_int() { DBUG_ASSERT(fixed == 1); return Item_func_length::val_int()*8; } const char *func_name() const { return "bit_length"; } @@ -1138,7 +1150,7 @@ class Item_func_char_length :public Item_int_func { String value; public: - Item_func_char_length(Item *a) :Item_int_func(a) {} + Item_func_char_length(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "char_length"; } void fix_length_and_dec() { max_length=10; } @@ -1147,7 +1159,7 @@ public: class Item_func_coercibility :public Item_int_func { public: - Item_func_coercibility(Item *a) :Item_int_func(a) {} + Item_func_coercibility(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "coercibility"; } void fix_length_and_dec() { max_length=10; maybe_null= 0; } @@ -1159,8 +1171,8 @@ class Item_func_locate :public Item_int_func String value1,value2; DTCollation cmp_collation; public: - Item_func_locate(Item *a,Item *b) :Item_int_func(a,b) {} - Item_func_locate(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {} + Item_func_locate(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} + Item_func_locate(THD *thd, Item *a, Item *b, Item *c): Item_int_func(thd, a, b, c) {} const char *func_name() const { return "locate"; } longlong val_int(); void fix_length_and_dec(); @@ -1174,7 +1186,7 @@ class Item_func_field :public Item_int_func Item_result cmp_type; DTCollation cmp_collation; public: - Item_func_field(List<Item> &list) :Item_int_func(list) {} + Item_func_field(THD *thd, List<Item> &list): Item_int_func(thd, list) {} longlong val_int(); const char *func_name() const { return "field"; } void fix_length_and_dec(); @@ -1185,7 +1197,7 @@ class Item_func_ascii :public Item_int_func { String value; public: - Item_func_ascii(Item *a) :Item_int_func(a) {} + Item_func_ascii(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "ascii"; } void fix_length_and_dec() { max_length=3; } @@ -1195,7 +1207,7 @@ class Item_func_ord :public Item_int_func { String value; public: - Item_func_ord(Item *a) :Item_int_func(a) {} + Item_func_ord(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "ord"; } }; @@ -1207,7 +1219,8 @@ class Item_func_find_in_set :public Item_int_func ulonglong enum_bit; DTCollation cmp_collation; public: - Item_func_find_in_set(Item *a,Item *b) :Item_int_func(a,b),enum_value(0) {} + Item_func_find_in_set(THD *thd, Item *a, Item *b): + Item_int_func(thd, a, b), enum_value(0) {} longlong val_int(); const char *func_name() const { return "find_in_set"; } void fix_length_and_dec(); @@ -1218,8 +1231,8 @@ public: class Item_func_bit: public Item_int_func { public: - Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {} - Item_func_bit(Item *a) :Item_int_func(a) {} + Item_func_bit(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} + Item_func_bit(THD *thd, Item *a): Item_int_func(thd, a) {} void fix_length_and_dec() { unsigned_flag= 1; } virtual inline void print(String *str, enum_query_type query_type) @@ -1231,7 +1244,7 @@ public: class Item_func_bit_or :public Item_func_bit { public: - Item_func_bit_or(Item *a, Item *b) :Item_func_bit(a, b) {} + Item_func_bit_or(THD *thd, Item *a, Item *b): Item_func_bit(thd, a, b) {} longlong val_int(); const char *func_name() const { return "|"; } }; @@ -1239,7 +1252,7 @@ public: class Item_func_bit_and :public Item_func_bit { public: - Item_func_bit_and(Item *a, Item *b) :Item_func_bit(a, b) {} + Item_func_bit_and(THD *thd, Item *a, Item *b): Item_func_bit(thd, a, b) {} longlong val_int(); const char *func_name() const { return "&"; } }; @@ -1247,7 +1260,7 @@ public: class Item_func_bit_count :public Item_int_func { public: - Item_func_bit_count(Item *a) :Item_int_func(a) {} + Item_func_bit_count(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "bit_count"; } void fix_length_and_dec() { max_length=2; } @@ -1256,7 +1269,7 @@ public: class Item_func_shift_left :public Item_func_bit { public: - Item_func_shift_left(Item *a, Item *b) :Item_func_bit(a, b) {} + Item_func_shift_left(THD *thd, Item *a, Item *b): Item_func_bit(thd, a, b) {} longlong val_int(); const char *func_name() const { return "<<"; } }; @@ -1264,7 +1277,7 @@ public: class Item_func_shift_right :public Item_func_bit { public: - Item_func_shift_right(Item *a, Item *b) :Item_func_bit(a, b) {} + Item_func_shift_right(THD *thd, Item *a, Item *b): Item_func_bit(thd, a, b) {} longlong val_int(); const char *func_name() const { return ">>"; } }; @@ -1272,7 +1285,7 @@ public: class Item_func_bit_neg :public Item_func_bit { public: - Item_func_bit_neg(Item *a) :Item_func_bit(a) {} + Item_func_bit_neg(THD *thd, Item *a): Item_func_bit(thd, a) {} longlong val_int(); const char *func_name() const { return "~"; } @@ -1286,8 +1299,8 @@ public: class Item_func_last_insert_id :public Item_int_func { public: - Item_func_last_insert_id() :Item_int_func() {} - Item_func_last_insert_id(Item *a) :Item_int_func(a) {} + Item_func_last_insert_id(THD *thd): Item_int_func(thd) {} + Item_func_last_insert_id(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "last_insert_id"; } void fix_length_and_dec() @@ -1308,8 +1321,8 @@ public: class Item_func_benchmark :public Item_int_func { public: - Item_func_benchmark(Item *count_expr, Item *expr) - :Item_int_func(count_expr, expr) + Item_func_benchmark(THD *thd, Item *count_expr, Item *expr): + Item_int_func(thd, count_expr, expr) {} longlong val_int(); const char *func_name() const { return "benchmark"; } @@ -1328,7 +1341,7 @@ void item_func_sleep_free(void); class Item_func_sleep :public Item_int_func { public: - Item_func_sleep(Item *a) :Item_int_func(a) {} + Item_func_sleep(THD *thd, Item *a): Item_int_func(thd, a) {} bool const_item() const { return 0; } const char *func_name() const { return "sleep"; } table_map used_tables() const @@ -1354,10 +1367,10 @@ protected: bool is_expensive_processor(uchar *arg) { return TRUE; } public: - Item_udf_func(udf_func *udf_arg) - :Item_func(), udf(udf_arg) {} - Item_udf_func(udf_func *udf_arg, List<Item> &list) - :Item_func(list), udf(udf_arg) {} + Item_udf_func(THD *thd, udf_func *udf_arg): + Item_func(thd), udf(udf_arg) {} + Item_udf_func(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_func(thd, list), udf(udf_arg) {} const char *func_name() const { return udf.name(); } enum Functype functype() const { return UDF_FUNC; } bool fix_fields(THD *thd, Item **ref) @@ -1430,11 +1443,11 @@ public: class Item_func_udf_float :public Item_udf_func { public: - Item_func_udf_float(udf_func *udf_arg) - :Item_udf_func(udf_arg) {} - Item_func_udf_float(udf_func *udf_arg, - List<Item> &list) - :Item_udf_func(udf_arg, list) {} + Item_func_udf_float(THD *thd, udf_func *udf_arg): + Item_udf_func(thd, udf_arg) {} + Item_func_udf_float(THD *thd, udf_func *udf_arg, + List<Item> &list): + Item_udf_func(thd, udf_arg, list) {} longlong val_int() { DBUG_ASSERT(fixed == 1); @@ -1457,11 +1470,11 @@ class Item_func_udf_float :public Item_udf_func class Item_func_udf_int :public Item_udf_func { public: - Item_func_udf_int(udf_func *udf_arg) - :Item_udf_func(udf_arg) {} - Item_func_udf_int(udf_func *udf_arg, - List<Item> &list) - :Item_udf_func(udf_arg, list) {} + Item_func_udf_int(THD *thd, udf_func *udf_arg): + Item_udf_func(thd, udf_arg) {} + Item_func_udf_int(THD *thd, udf_func *udf_arg, + List<Item> &list): + Item_udf_func(thd, udf_arg, list) {} longlong val_int(); double val_real() { return (double) Item_func_udf_int::val_int(); } String *val_str(String *str); @@ -1473,10 +1486,10 @@ public: class Item_func_udf_decimal :public Item_udf_func { public: - Item_func_udf_decimal(udf_func *udf_arg) - :Item_udf_func(udf_arg) {} - Item_func_udf_decimal(udf_func *udf_arg, List<Item> &list) - :Item_udf_func(udf_arg, list) {} + Item_func_udf_decimal(THD *thd, udf_func *udf_arg): + Item_udf_func(thd, udf_arg) {} + Item_func_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_func(thd, udf_arg, list) {} longlong val_int(); double val_real(); my_decimal *val_decimal(my_decimal *); @@ -1489,10 +1502,10 @@ public: class Item_func_udf_str :public Item_udf_func { public: - Item_func_udf_str(udf_func *udf_arg) - :Item_udf_func(udf_arg) {} - Item_func_udf_str(udf_func *udf_arg, List<Item> &list) - :Item_udf_func(udf_arg, list) {} + Item_func_udf_str(THD *thd, udf_func *udf_arg): + Item_udf_func(thd, udf_arg) {} + Item_func_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_func(thd, udf_arg, list) {} String *val_str(String *); double val_real() { @@ -1527,10 +1540,10 @@ public: class Item_func_udf_float :public Item_real_func { public: - Item_func_udf_float(udf_func *udf_arg) - :Item_real_func() {} - Item_func_udf_float(udf_func *udf_arg, List<Item> &list) - :Item_real_func(list) {} + Item_func_udf_float(THD *thd, udf_func *udf_arg): + Item_real_func(thd) {} + Item_func_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_real_func(thd, list) {} double val_real() { DBUG_ASSERT(fixed == 1); return 0.0; } }; @@ -1538,10 +1551,10 @@ class Item_func_udf_float :public Item_real_func class Item_func_udf_int :public Item_int_func { public: - Item_func_udf_int(udf_func *udf_arg) - :Item_int_func() {} - Item_func_udf_int(udf_func *udf_arg, List<Item> &list) - :Item_int_func(list) {} + Item_func_udf_int(THD *thd, udf_func *udf_arg): + Item_int_func(thd) {} + Item_func_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_int_func(thd, list) {} longlong val_int() { DBUG_ASSERT(fixed == 1); return 0; } }; @@ -1549,10 +1562,10 @@ public: class Item_func_udf_decimal :public Item_int_func { public: - Item_func_udf_decimal(udf_func *udf_arg) - :Item_int_func() {} - Item_func_udf_decimal(udf_func *udf_arg, List<Item> &list) - :Item_int_func(list) {} + Item_func_udf_decimal(THD *thd, udf_func *udf_arg): + Item_int_func(thd) {} + Item_func_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_int_func(thd, list) {} my_decimal *val_decimal(my_decimal *) { DBUG_ASSERT(fixed == 1); return 0; } }; @@ -1560,10 +1573,10 @@ public: class Item_func_udf_str :public Item_func { public: - Item_func_udf_str(udf_func *udf_arg) - :Item_func() {} - Item_func_udf_str(udf_func *udf_arg, List<Item> &list) - :Item_func(list) {} + Item_func_udf_str(THD *thd, udf_func *udf_arg): + Item_func(thd) {} + Item_func_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_func(thd, list) {} String *val_str(String *) { DBUG_ASSERT(fixed == 1); null_value=1; return 0; } double val_real() { DBUG_ASSERT(fixed == 1); null_value= 1; return 0.0; } @@ -1581,7 +1594,7 @@ class Item_func_get_lock :public Item_int_func { String value; public: - Item_func_get_lock(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_get_lock(THD *thd, Item *a, Item *b) :Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "get_lock"; } void fix_length_and_dec() { max_length=1; maybe_null=1;} @@ -1601,7 +1614,7 @@ class Item_func_release_lock :public Item_int_func { String value; public: - Item_func_release_lock(Item *a) :Item_int_func(a) {} + Item_func_release_lock(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "release_lock"; } void fix_length_and_dec() { max_length= 1; maybe_null= 1;} @@ -1623,9 +1636,11 @@ class Item_master_pos_wait :public Item_int_func { String value; public: - Item_master_pos_wait(Item *a,Item *b) :Item_int_func(a,b) {} - Item_master_pos_wait(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {} - Item_master_pos_wait(Item *a,Item *b, Item *c, Item *d) :Item_int_func(a,b,c,d) {} + Item_master_pos_wait(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} + Item_master_pos_wait(THD *thd, Item *a, Item *b, Item *c): + Item_int_func(thd, a, b, c) {} + Item_master_pos_wait(THD *thd, Item *a, Item *b, Item *c, Item *d): + Item_int_func(thd, a, b, c, d) {} longlong val_int(); const char *func_name() const { return "master_pos_wait"; } void fix_length_and_dec() { max_length=21; maybe_null=1;} @@ -1640,8 +1655,8 @@ class Item_master_gtid_wait :public Item_int_func { String value; public: - Item_master_gtid_wait(Item *a) :Item_int_func(a) {} - Item_master_gtid_wait(Item *a,Item *b) :Item_int_func(a,b) {} + Item_master_gtid_wait(THD *thd, Item *a): Item_int_func(thd, a) {} + Item_master_gtid_wait(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "master_gtid_wait"; } void fix_length_and_dec() { max_length=10+1+10+1+20+1; maybe_null=0;} @@ -1685,9 +1700,9 @@ class Item_func_set_user_var :public Item_func public: LEX_STRING name; // keep it public - Item_func_set_user_var(LEX_STRING a,Item *b) - :Item_func(b), cached_result_type(INT_RESULT), - entry(NULL), entry_thread_id(0), name(a) + Item_func_set_user_var(THD *thd, LEX_STRING a, Item *b): + Item_func(thd, b), cached_result_type(INT_RESULT), + entry(NULL), entry_thread_id(0), name(a) {} Item_func_set_user_var(THD *thd, Item_func_set_user_var *item) :Item_func(thd, item), cached_result_type(item->cached_result_type), @@ -1752,8 +1767,8 @@ class Item_func_get_user_var :public Item_func, public: LEX_STRING name; // keep it public - Item_func_get_user_var(LEX_STRING a): - Item_func(), m_cached_result_type(STRING_RESULT), name(a) {} + Item_func_get_user_var(THD *thd, LEX_STRING a): + Item_func(thd), m_cached_result_type(STRING_RESULT), name(a) {} enum Functype functype() const { return GUSERVAR_FUNC; } LEX_STRING get_name() { return name; } double val_real(); @@ -1798,7 +1813,7 @@ class Item_user_var_as_out_param :public Item LEX_STRING name; user_var_entry *entry; public: - Item_user_var_as_out_param(LEX_STRING a) : name(a) + Item_user_var_as_out_param(THD *thd, LEX_STRING a): Item(thd), name(a) { set_name(a.str, 0, system_charset_info); } /* We should return something different from FIELD_ITEM here */ enum Type type() const { return STRING_ITEM;} @@ -1833,7 +1848,8 @@ class Item_func_get_system_var :public Item_func uchar cache_present; public: - Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg, + Item_func_get_system_var(THD *thd, sys_var *var_arg, + enum_var_type var_type_arg, LEX_STRING *component_arg, const char *name_arg, size_t name_len_arg); enum Functype functype() const { return GSYSVAR_FUNC; } @@ -1882,8 +1898,9 @@ public: String value; // value of concat_ws String search_value; // key_item()'s value converted to cmp_collation - Item_func_match(List<Item> &a, uint b): Item_real_func(a), key(0), flags(b), - join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { } + Item_func_match(THD *thd, List<Item> &a, uint b): + Item_real_func(thd, a), key(0), flags(b), join_key(0), ft_handler(0), + table(0), master(0), concat_ws(0) { } void cleanup() { DBUG_ENTER("Item_func_match::cleanup"); @@ -1907,7 +1924,7 @@ public: virtual void print(String *str, enum_query_type query_type); bool fix_index(); - void init_search(bool no_order); + void init_search(THD *thd, bool no_order); bool check_vcol_func_processor(uchar *int_arg) { /* TODO: consider adding in support for the MATCH-based virtual columns */ @@ -1954,7 +1971,7 @@ private: class Item_func_bit_xor : public Item_func_bit { public: - Item_func_bit_xor(Item *a, Item *b) :Item_func_bit(a, b) {} + Item_func_bit_xor(THD *thd, Item *a, Item *b): Item_func_bit(thd, a, b) {} longlong val_int(); const char *func_name() const { return "^"; } }; @@ -1963,7 +1980,7 @@ class Item_func_is_free_lock :public Item_int_func { String value; public: - Item_func_is_free_lock(Item *a) :Item_int_func(a) {} + Item_func_is_free_lock(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "is_free_lock"; } void fix_length_and_dec() { decimals=0; max_length=1; maybe_null=1;} @@ -1977,7 +1994,7 @@ class Item_func_is_used_lock :public Item_int_func { String value; public: - Item_func_is_used_lock(Item *a) :Item_int_func(a) {} + Item_func_is_used_lock(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "is_used_lock"; } void fix_length_and_dec() { decimals=0; max_length=10; maybe_null=1;} @@ -2000,7 +2017,7 @@ enum Cast_target class Item_func_row_count :public Item_int_func { public: - Item_func_row_count() :Item_int_func() {} + Item_func_row_count(THD *thd): Item_int_func(thd) {} longlong val_int(); const char *func_name() const { return "row_count"; } void fix_length_and_dec() { decimals= 0; maybe_null=0; } @@ -2045,9 +2062,9 @@ protected: public: - Item_func_sp(Name_resolution_context *context_arg, sp_name *name); + Item_func_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name); - Item_func_sp(Name_resolution_context *context_arg, + Item_func_sp(THD *thd, Name_resolution_context *context_arg, sp_name *name, List<Item> &list); virtual ~Item_func_sp() @@ -2141,7 +2158,7 @@ public: class Item_func_found_rows :public Item_int_func { public: - Item_func_found_rows() :Item_int_func() {} + Item_func_found_rows(THD *thd): Item_int_func(thd) {} longlong val_int(); const char *func_name() const { return "found_rows"; } void fix_length_and_dec() { decimals= 0; maybe_null=0; } @@ -2157,7 +2174,7 @@ void uuid_short_init(); class Item_func_uuid_short :public Item_int_func { public: - Item_func_uuid_short() :Item_int_func() {} + Item_func_uuid_short(THD *thd): Item_int_func(thd) {} const char *func_name() const { return "uuid_short"; } longlong val_int(); void fix_length_and_dec() @@ -2174,7 +2191,7 @@ class Item_func_last_value :public Item_func protected: Item *last_value; public: - Item_func_last_value(List<Item> &list) :Item_func(list) {} + Item_func_last_value(THD *thd, List<Item> &list): Item_func(thd, list) {} double val_real(); longlong val_int(); String *val_str(String *); diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index e88fd266af7..b64360de394 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -32,11 +32,12 @@ class Item_geometry_func: public Item_str_func { public: - Item_geometry_func() :Item_str_func() {} - Item_geometry_func(Item *a) :Item_str_func(a) {} - Item_geometry_func(Item *a,Item *b) :Item_str_func(a,b) {} - Item_geometry_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} - Item_geometry_func(List<Item> &list) :Item_str_func(list) {} + Item_geometry_func(THD *thd): Item_str_func(thd) {} + Item_geometry_func(THD *thd, Item *a): Item_str_func(thd, a) {} + Item_geometry_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} + Item_geometry_func(THD *thd, Item *a, Item *b, Item *c): + Item_str_func(thd, a, b, c) {} + Item_geometry_func(THD *thd, List<Item> &list): Item_str_func(thd, list) {} void fix_length_and_dec(); enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } Field *tmp_table_field(TABLE *t_arg); @@ -46,8 +47,9 @@ public: class Item_func_geometry_from_text: public Item_geometry_func { public: - Item_func_geometry_from_text(Item *a) :Item_geometry_func(a) {} - Item_func_geometry_from_text(Item *a, Item *srid) :Item_geometry_func(a, srid) {} + Item_func_geometry_from_text(THD *thd, Item *a): Item_geometry_func(thd, a) {} + Item_func_geometry_from_text(THD *thd, Item *a, Item *srid): + Item_geometry_func(thd, a, srid) {} const char *func_name() const { return "st_geometryfromtext"; } String *val_str(String *); }; @@ -55,8 +57,9 @@ public: class Item_func_geometry_from_wkb: public Item_geometry_func { public: - Item_func_geometry_from_wkb(Item *a): Item_geometry_func(a) {} - Item_func_geometry_from_wkb(Item *a, Item *srid): Item_geometry_func(a, srid) {} + Item_func_geometry_from_wkb(THD *thd, Item *a): Item_geometry_func(thd, a) {} + Item_func_geometry_from_wkb(THD *thd, Item *a, Item *srid): + Item_geometry_func(thd, a, srid) {} const char *func_name() const { return "st_geometryfromwkb"; } String *val_str(String *); }; @@ -64,7 +67,7 @@ public: class Item_func_as_wkt: public Item_str_ascii_func { public: - Item_func_as_wkt(Item *a): Item_str_ascii_func(a) {} + Item_func_as_wkt(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} const char *func_name() const { return "st_astext"; } String *val_str_ascii(String *); void fix_length_and_dec(); @@ -73,7 +76,7 @@ public: class Item_func_as_wkb: public Item_geometry_func { public: - Item_func_as_wkb(Item *a): Item_geometry_func(a) {} + Item_func_as_wkb(THD *thd, Item *a): Item_geometry_func(thd, a) {} const char *func_name() const { return "st_aswkb"; } String *val_str(String *); enum_field_types field_type() const { return MYSQL_TYPE_BLOB; } @@ -82,7 +85,7 @@ public: class Item_func_geometry_type: public Item_str_ascii_func { public: - Item_func_geometry_type(Item *a): Item_str_ascii_func(a) {} + Item_func_geometry_type(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} String *val_str_ascii(String *); const char *func_name() const { return "st_geometrytype"; } void fix_length_and_dec() @@ -118,7 +121,7 @@ class Item_func_convexhull: public Item_geometry_func ch_node *new_ch_node() { return (ch_node *) res_heap.new_item(); } int add_node_to_line(ch_node **p_cur, int dir, const Gcalc_heap::Info *pi); public: - Item_func_convexhull(Item *a): Item_geometry_func(a), + Item_func_convexhull(THD *thd, Item *a): Item_geometry_func(thd, a), res_heap(8192, sizeof(ch_node)) {} const char *func_name() const { return "st_convexhull"; } @@ -129,7 +132,7 @@ public: class Item_func_centroid: public Item_geometry_func { public: - Item_func_centroid(Item *a): Item_geometry_func(a) {} + Item_func_centroid(THD *thd, Item *a): Item_geometry_func(thd, a) {} const char *func_name() const { return "st_centroid"; } String *val_str(String *); Field::geometry_type get_geometry_type() const; @@ -138,7 +141,7 @@ public: class Item_func_envelope: public Item_geometry_func { public: - Item_func_envelope(Item *a): Item_geometry_func(a) {} + Item_func_envelope(THD *thd, Item *a): Item_geometry_func(thd, a) {} const char *func_name() const { return "st_envelope"; } String *val_str(String *); Field::geometry_type get_geometry_type() const; @@ -170,7 +173,7 @@ class Item_func_boundary: public Item_geometry_func }; Gcalc_result_receiver res_receiver; public: - Item_func_boundary(Item *a): Item_geometry_func(a) {} + Item_func_boundary(THD *thd, Item *a): Item_geometry_func(thd, a) {} const char *func_name() const { return "st_boundary"; } String *val_str(String *); }; @@ -179,8 +182,9 @@ public: class Item_func_point: public Item_geometry_func { public: - Item_func_point(Item *a, Item *b): Item_geometry_func(a, b) {} - Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {} + Item_func_point(THD *thd, Item *a, Item *b): Item_geometry_func(thd, a, b) {} + Item_func_point(THD *thd, Item *a, Item *b, Item *srid): + Item_geometry_func(thd, a, b, srid) {} const char *func_name() const { return "point"; } String *val_str(String *); Field::geometry_type get_geometry_type() const; @@ -190,8 +194,8 @@ class Item_func_spatial_decomp: public Item_geometry_func { enum Functype decomp_func; public: - Item_func_spatial_decomp(Item *a, Item_func::Functype ft) : - Item_geometry_func(a) { decomp_func = ft; } + Item_func_spatial_decomp(THD *thd, Item *a, Item_func::Functype ft): + Item_geometry_func(thd, a) { decomp_func = ft; } const char *func_name() const { switch (decomp_func) @@ -214,8 +218,8 @@ class Item_func_spatial_decomp_n: public Item_geometry_func { enum Functype decomp_func_n; public: - Item_func_spatial_decomp_n(Item *a, Item *b, Item_func::Functype ft): - Item_geometry_func(a, b) { decomp_func_n = ft; } + Item_func_spatial_decomp_n(THD *thd, Item *a, Item *b, Item_func::Functype ft): + Item_geometry_func(thd, a, b) { decomp_func_n = ft; } const char *func_name() const { switch (decomp_func_n) @@ -240,9 +244,9 @@ class Item_func_spatial_collection: public Item_geometry_func enum Geometry::wkbType coll_type; enum Geometry::wkbType item_type; public: - Item_func_spatial_collection( + Item_func_spatial_collection(THD *thd, List<Item> &list, enum Geometry::wkbType ct, enum Geometry::wkbType it): - Item_geometry_func(list) + Item_geometry_func(thd, list) { coll_type=ct; item_type=it; @@ -281,8 +285,8 @@ protected: KEY_PART *key_part, Item_func::Functype type, Item *value); public: - Item_func_spatial_rel(Item *a, Item *b, enum Functype sp_rel) - :Item_bool_func2(a, b), spatial_rel(sp_rel) + Item_func_spatial_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel): + Item_bool_func2(thd, a, b), spatial_rel(sp_rel) { } enum Functype functype() const { return spatial_rel; } enum Functype rev_functype() const { return spatial_rel; } @@ -300,8 +304,8 @@ public: class Item_func_spatial_mbr_rel: public Item_func_spatial_rel { public: - Item_func_spatial_mbr_rel(Item *a, Item *b, enum Functype sp_rel) - :Item_func_spatial_rel(a, b, sp_rel) + Item_func_spatial_mbr_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel): + Item_func_spatial_rel(thd, a, b, sp_rel) { } longlong val_int(); const char *func_name() const; @@ -314,8 +318,8 @@ class Item_func_spatial_precise_rel: public Item_func_spatial_rel Gcalc_scan_iterator scan_it; Gcalc_function func; public: - Item_func_spatial_precise_rel(Item *a, Item *b, enum Functype sp_rel) - :Item_func_spatial_rel(a, b, sp_rel), collector() + Item_func_spatial_precise_rel(THD *thd, Item *a, Item *b, enum Functype sp_rel): + Item_func_spatial_rel(thd, a, b, sp_rel), collector() { } longlong val_int(); const char *func_name() const; @@ -329,8 +333,8 @@ class Item_func_spatial_relate: public Item_bool_func Gcalc_function func; String tmp_value1, tmp_value2, tmp_matrix; public: - Item_func_spatial_relate(Item *a, Item *b, Item *matrix) - :Item_bool_func(a, b, matrix) + Item_func_spatial_relate(THD *thd, Item *a, Item *b, Item *matrix): + Item_bool_func(thd, a, b, matrix) { } longlong val_int(); const char *func_name() const { return "st_relate"; } @@ -352,8 +356,9 @@ public: Gcalc_operation_reducer operation; String tmp_value1,tmp_value2; public: - Item_func_spatial_operation(Item *a,Item *b, Gcalc_function::op_type sp_op) : - Item_geometry_func(a, b), spatial_op(sp_op) + Item_func_spatial_operation(THD *thd, Item *a,Item *b, + Gcalc_function::op_type sp_op): + Item_geometry_func(thd, a, b), spatial_op(sp_op) {} virtual ~Item_func_spatial_operation(); String *val_str(String *); @@ -409,8 +414,8 @@ protected: String tmp_value; public: - Item_func_buffer(Item *obj, Item *distance): - Item_geometry_func(obj, distance) {} + Item_func_buffer(THD *thd, Item *obj, Item *distance): + Item_geometry_func(thd, obj, distance) {} const char *func_name() const { return "st_buffer"; } String *val_str(String *); }; @@ -419,7 +424,7 @@ public: class Item_func_isempty: public Item_bool_func { public: - Item_func_isempty(Item *a): Item_bool_func(a) {} + Item_func_isempty(THD *thd, Item *a): Item_bool_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_isempty"; } void fix_length_and_dec() { maybe_null= 1; } @@ -432,7 +437,7 @@ class Item_func_issimple: public Item_int_func Gcalc_scan_iterator scan_it; String tmp; public: - Item_func_issimple(Item *a): Item_int_func(a) {} + Item_func_issimple(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_issimple"; } void fix_length_and_dec() { decimals=0; max_length=2; } @@ -442,7 +447,7 @@ public: class Item_func_isclosed: public Item_int_func { public: - Item_func_isclosed(Item *a): Item_int_func(a) {} + Item_func_isclosed(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_isclosed"; } void fix_length_and_dec() { decimals=0; max_length=2; } @@ -452,7 +457,7 @@ public: class Item_func_isring: public Item_func_issimple { public: - Item_func_isring(Item *a): Item_func_issimple(a) {} + Item_func_isring(THD *thd, Item *a): Item_func_issimple(thd, a) {} longlong val_int(); const char *func_name() const { return "st_isring"; } }; @@ -461,7 +466,7 @@ class Item_func_dimension: public Item_int_func { String value; public: - Item_func_dimension(Item *a): Item_int_func(a) {} + Item_func_dimension(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_dimension"; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; } @@ -471,7 +476,7 @@ class Item_func_x: public Item_real_func { String value; public: - Item_func_x(Item *a): Item_real_func(a) {} + Item_func_x(THD *thd, Item *a): Item_real_func(thd, a) {} double val_real(); const char *func_name() const { return "st_x"; } void fix_length_and_dec() @@ -486,7 +491,7 @@ class Item_func_y: public Item_real_func { String value; public: - Item_func_y(Item *a): Item_real_func(a) {} + Item_func_y(THD *thd, Item *a): Item_real_func(thd, a) {} double val_real(); const char *func_name() const { return "st_y"; } void fix_length_and_dec() @@ -501,7 +506,7 @@ class Item_func_numgeometries: public Item_int_func { String value; public: - Item_func_numgeometries(Item *a): Item_int_func(a) {} + Item_func_numgeometries(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_numgeometries"; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; } @@ -512,7 +517,7 @@ class Item_func_numinteriorring: public Item_int_func { String value; public: - Item_func_numinteriorring(Item *a): Item_int_func(a) {} + Item_func_numinteriorring(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_numinteriorrings"; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; } @@ -523,7 +528,7 @@ class Item_func_numpoints: public Item_int_func { String value; public: - Item_func_numpoints(Item *a): Item_int_func(a) {} + Item_func_numpoints(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "st_numpoints"; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; } @@ -534,7 +539,7 @@ class Item_func_area: public Item_real_func { String value; public: - Item_func_area(Item *a): Item_real_func(a) {} + Item_func_area(THD *thd, Item *a): Item_real_func(thd, a) {} double val_real(); const char *func_name() const { return "st_area"; } void fix_length_and_dec() @@ -549,7 +554,7 @@ class Item_func_glength: public Item_real_func { String value; public: - Item_func_glength(Item *a): Item_real_func(a) {} + Item_func_glength(THD *thd, Item *a): Item_real_func(thd, a) {} double val_real(); const char *func_name() const { return "st_length"; } void fix_length_and_dec() @@ -564,7 +569,7 @@ class Item_func_srid: public Item_int_func { String value; public: - Item_func_srid(Item *a): Item_int_func(a) {} + Item_func_srid(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "srid"; } void fix_length_and_dec() { max_length= 10; maybe_null= 1; } @@ -579,7 +584,7 @@ class Item_func_distance: public Item_real_func Gcalc_function func; Gcalc_scan_iterator scan_it; public: - Item_func_distance(Item *a, Item *b): Item_real_func(a, b) {} + Item_func_distance(THD *thd, Item *a, Item *b): Item_real_func(thd, a, b) {} double val_real(); const char *func_name() const { return "st_distance"; } }; @@ -592,7 +597,7 @@ class Item_func_pointonsurface: public Item_geometry_func Gcalc_function func; Gcalc_scan_iterator scan_it; public: - Item_func_pointonsurface(Item *a): Item_geometry_func(a) {} + Item_func_pointonsurface(THD *thd, Item *a): Item_geometry_func(thd, a) {} const char *func_name() const { return "st_pointonsurface"; } String *val_str(String *); Field::geometry_type get_geometry_type() const; @@ -603,7 +608,8 @@ public: class Item_func_gis_debug: public Item_int_func { public: - Item_func_gis_debug(Item *a) :Item_int_func(a) { null_value= false; } + Item_func_gis_debug(THD *thd, Item *a): Item_int_func(thd, a) + { null_value= false; } const char *func_name() const { return "st_gis_debug"; } longlong val_int(); }; diff --git a/sql/item_inetfunc.h b/sql/item_inetfunc.h index 3a85d367ff1..82a4405df1e 100644 --- a/sql/item_inetfunc.h +++ b/sql/item_inetfunc.h @@ -27,7 +27,7 @@ class Item_func_inet_aton : public Item_int_func { public: - Item_func_inet_aton(Item *a) :Item_int_func(a) {} + Item_func_inet_aton(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "inet_aton"; } void fix_length_and_dec() @@ -47,8 +47,7 @@ public: class Item_func_inet_ntoa : public Item_str_func { public: - Item_func_inet_ntoa(Item *a) - : Item_str_func(a) + Item_func_inet_ntoa(THD *thd, Item *a): Item_str_func(thd, a) { } String* val_str(String* str); const char *func_name() const { return "inet_ntoa"; } @@ -69,8 +68,8 @@ public: class Item_func_inet_bool_base : public Item_bool_func { public: - inline Item_func_inet_bool_base(Item *ip_addr) - : Item_bool_func(ip_addr) + inline Item_func_inet_bool_base(THD *thd, Item *ip_addr): + Item_bool_func(thd, ip_addr) { null_value= false; } @@ -91,8 +90,8 @@ protected: class Item_func_inet_str_base : public Item_str_ascii_func { public: - inline Item_func_inet_str_base(Item *arg) - : Item_str_ascii_func(arg) + inline Item_func_inet_str_base(THD *thd, Item *arg): + Item_str_ascii_func(thd, arg) { } public: @@ -110,8 +109,8 @@ protected: class Item_func_inet6_aton : public Item_func_inet_str_base { public: - inline Item_func_inet6_aton(Item *ip_addr) - : Item_func_inet_str_base(ip_addr) + inline Item_func_inet6_aton(THD *thd, Item *ip_addr): + Item_func_inet_str_base(thd, ip_addr) { } public: @@ -137,8 +136,8 @@ protected: class Item_func_inet6_ntoa : public Item_func_inet_str_base { public: - inline Item_func_inet6_ntoa(Item *ip_addr) - : Item_func_inet_str_base(ip_addr) + inline Item_func_inet6_ntoa(THD *thd, Item *ip_addr): + Item_func_inet_str_base(thd, ip_addr) { } public: @@ -169,8 +168,8 @@ protected: class Item_func_is_ipv4 : public Item_func_inet_bool_base { public: - inline Item_func_is_ipv4(Item *ip_addr) - : Item_func_inet_bool_base(ip_addr) + inline Item_func_is_ipv4(THD *thd, Item *ip_addr): + Item_func_inet_bool_base(thd, ip_addr) { } public: @@ -189,8 +188,8 @@ protected: class Item_func_is_ipv6 : public Item_func_inet_bool_base { public: - inline Item_func_is_ipv6(Item *ip_addr) - : Item_func_inet_bool_base(ip_addr) + inline Item_func_is_ipv6(THD *thd, Item *ip_addr): + Item_func_inet_bool_base(thd, ip_addr) { } public: @@ -209,8 +208,8 @@ protected: class Item_func_is_ipv4_compat : public Item_func_inet_bool_base { public: - inline Item_func_is_ipv4_compat(Item *ip_addr) - : Item_func_inet_bool_base(ip_addr) + inline Item_func_is_ipv4_compat(THD *thd, Item *ip_addr): + Item_func_inet_bool_base(thd, ip_addr) { } public: @@ -229,8 +228,8 @@ protected: class Item_func_is_ipv4_mapped : public Item_func_inet_bool_base { public: - inline Item_func_is_ipv4_mapped(Item *ip_addr) - : Item_func_inet_bool_base(ip_addr) + inline Item_func_is_ipv4_mapped(THD *thd, Item *ip_addr): + Item_func_inet_bool_base(thd, ip_addr) { } public: diff --git a/sql/item_row.cc b/sql/item_row.cc index 8b32f56973a..b1575b81087 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -146,13 +146,13 @@ void Item_row::print(String *str, enum_query_type query_type) } -Item *Item_row::transform(Item_transformer transformer, uchar *arg) +Item *Item_row::transform(THD *thd, Item_transformer transformer, uchar *arg) { - DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare()); + DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); - if (transform_args(transformer, arg)) + if (transform_args(thd, transformer, arg)) return 0; - return (this->*transformer)(arg); + return (this->*transformer)(thd, arg); } void Item_row::bring_value() diff --git a/sql/item_row.h b/sql/item_row.h index c5cbf0aff8b..0de547be327 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -35,10 +35,11 @@ class Item_row: public Item, table_map not_null_tables_cache; bool with_null; public: - Item_row(List<Item> &list) - :Item_args(list), not_null_tables_cache(0), with_null(0) + Item_row(THD *thd, List<Item> &list): + Item(thd), Item_args(list), not_null_tables_cache(0), with_null(0) { } - Item_row(Item_row *item): + Item_row(THD *thd, Item_row *item): + Item(thd), Item_args(item), Used_tables_and_const_cache(item), not_null_tables_cache(0), @@ -95,7 +96,7 @@ public: return true; return (this->*processor)(arg); } - Item *transform(Item_transformer transformer, uchar *arg); + Item *transform(THD *thd, Item_transformer transformer, uchar *arg); bool eval_not_null_tables(uchar *opt_arg); uint cols() { return arg_count; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b31b95babb8..387e349300e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4273,9 +4273,9 @@ String *Item_func_uuid::val_str(String *str) } -Item_func_dyncol_create::Item_func_dyncol_create(List<Item> &args, - DYNCALL_CREATE_DEF *dfs) - : Item_str_func(args), defs(dfs), vals(0), keys_num(NULL), keys_str(NULL), +Item_func_dyncol_create::Item_func_dyncol_create(THD *thd, List<Item> &args, + DYNCALL_CREATE_DEF *dfs): + Item_str_func(thd, args), defs(dfs), vals(0), keys_num(NULL), keys_str(NULL), names(FALSE), force_names(FALSE) { DBUG_ASSERT((args.elements & 0x1) == 0); // even number of arguments diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 9a8c79966d0..cba91bb9f00 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -49,13 +49,18 @@ protected: return &str_value; } public: - Item_str_func() :Item_func() { decimals=NOT_FIXED_DEC; } - Item_str_func(Item *a) :Item_func(a) {decimals=NOT_FIXED_DEC; } - Item_str_func(Item *a,Item *b) :Item_func(a,b) { decimals=NOT_FIXED_DEC; } - Item_str_func(Item *a,Item *b,Item *c) :Item_func(a,b,c) { decimals=NOT_FIXED_DEC; } - Item_str_func(Item *a,Item *b,Item *c,Item *d) :Item_func(a,b,c,d) {decimals=NOT_FIXED_DEC; } - Item_str_func(Item *a,Item *b,Item *c,Item *d, Item* e) :Item_func(a,b,c,d,e) {decimals=NOT_FIXED_DEC; } - Item_str_func(List<Item> &list) :Item_func(list) {decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd): Item_func(thd) { decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, Item *a): Item_func(thd, a) {decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, Item *a, Item *b): + Item_func(thd, a, b) { decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, Item *a, Item *b, Item *c): + Item_func(thd, a, b, c) { decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, Item *a, Item *b, Item *c, Item *d): + Item_func(thd, a, b, c, d) { decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, Item *a, Item *b, Item *c, Item *d, Item* e): + Item_func(thd, a, b, c, d, e) { decimals=NOT_FIXED_DEC; } + Item_str_func(THD *thd, List<Item> &list): + Item_func(thd, list) { decimals=NOT_FIXED_DEC; } longlong val_int(); double val_real(); my_decimal *val_decimal(my_decimal *); @@ -73,10 +78,11 @@ class Item_str_ascii_func :public Item_str_func { String ascii_buf; public: - Item_str_ascii_func() :Item_str_func() {} - Item_str_ascii_func(Item *a) :Item_str_func(a) {} - Item_str_ascii_func(Item *a,Item *b) :Item_str_func(a,b) {} - Item_str_ascii_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} + Item_str_ascii_func(THD *thd): Item_str_func(thd) {} + Item_str_ascii_func(THD *thd, Item *a): Item_str_func(thd, a) {} + Item_str_ascii_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} + Item_str_ascii_func(THD *thd, Item *a, Item *b, Item *c): + Item_str_func(thd, a, b, c) {} String *val_str(String *str) { return val_str_from_val_str_ascii(str, &ascii_buf); @@ -89,7 +95,7 @@ class Item_func_md5 :public Item_str_ascii_func { String tmp_value; public: - Item_func_md5(Item *a) :Item_str_ascii_func(a) {} + Item_func_md5(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "md5"; } @@ -99,7 +105,7 @@ public: class Item_func_sha :public Item_str_ascii_func { public: - Item_func_sha(Item *a) :Item_str_ascii_func(a) {} + Item_func_sha(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "sha"; } @@ -108,7 +114,7 @@ public: class Item_func_sha2 :public Item_str_ascii_func { public: - Item_func_sha2(Item *a, Item *b) :Item_str_ascii_func(a, b) {} + Item_func_sha2(THD *thd, Item *a, Item *b): Item_str_ascii_func(thd, a, b) {} String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "sha2"; } @@ -118,7 +124,7 @@ class Item_func_to_base64 :public Item_str_ascii_func { String tmp_value; public: - Item_func_to_base64(Item *a) :Item_str_ascii_func(a) {} + Item_func_to_base64(THD *thd, Item *a): Item_str_ascii_func(thd, a) {} String *val_str_ascii(String *); void fix_length_and_dec(); const char *func_name() const { return "to_base64"; } @@ -128,7 +134,7 @@ class Item_func_from_base64 :public Item_str_func { String tmp_value; public: - Item_func_from_base64(Item *a) :Item_str_func(a) {} + Item_func_from_base64(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "from_base64"; } @@ -147,14 +153,15 @@ protected: int no_padding); public: - Item_aes_crypt(Item *a, Item *b) :Item_str_func(a,b) {} + Item_aes_crypt(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); }; class Item_func_aes_encrypt :public Item_aes_crypt { public: - Item_func_aes_encrypt(Item *a, Item *b) :Item_aes_crypt(a,b) {} + Item_func_aes_encrypt(THD *thd, Item *a, Item *b): + Item_aes_crypt(thd, a, b) {} void fix_length_and_dec(); const char *func_name() const { return "aes_encrypt"; } }; @@ -162,7 +169,8 @@ public: class Item_func_aes_decrypt :public Item_aes_crypt { public: - Item_func_aes_decrypt(Item *a, Item *b) :Item_aes_crypt(a,b) {} + Item_func_aes_decrypt(THD *thd, Item *a, Item *b): + Item_aes_crypt(thd, a, b) {} void fix_length_and_dec(); const char *func_name() const { return "aes_decrypt"; } }; @@ -172,8 +180,8 @@ class Item_func_concat :public Item_str_func { String tmp_value; public: - Item_func_concat(List<Item> &list) :Item_str_func(list) {} - Item_func_concat(Item *a,Item *b) :Item_str_func(a,b) {} + Item_func_concat(THD *thd, List<Item> &list): Item_str_func(thd, list) {} + Item_func_concat(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "concat"; } @@ -183,8 +191,8 @@ class Item_func_decode_histogram :public Item_str_func { String tmp_value; public: - Item_func_decode_histogram(Item *a, Item *b) - :Item_str_func(a, b) {} + Item_func_decode_histogram(THD *thd, Item *a, Item *b): + Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec() { @@ -199,7 +207,7 @@ class Item_func_concat_ws :public Item_str_func { String tmp_value; public: - Item_func_concat_ws(List<Item> &list) :Item_str_func(list) {} + Item_func_concat_ws(THD *thd, List<Item> &list): Item_str_func(thd, list) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "concat_ws"; } @@ -210,7 +218,7 @@ class Item_func_reverse :public Item_str_func { String tmp_value; public: - Item_func_reverse(Item *a) :Item_str_func(a) {} + Item_func_reverse(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "reverse"; } @@ -221,8 +229,8 @@ class Item_func_replace :public Item_str_func { String tmp_value,tmp_value2; public: - Item_func_replace(Item *org,Item *find,Item *replace) - :Item_str_func(org,find,replace) {} + Item_func_replace(THD *thd, Item *org, Item *find, Item *replace): + Item_str_func(thd, org, find, replace) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "replace"; } @@ -236,8 +244,8 @@ class Item_func_regexp_replace :public Item_str_func const LEX_CSTRING *source, const LEX_CSTRING *replace); public: - Item_func_regexp_replace(Item *a, Item *b, Item *c) - :Item_str_func(a, b, c) + Item_func_regexp_replace(THD *thd, Item *a, Item *b, Item *c): + Item_str_func(thd, a, b, c) {} void cleanup() { @@ -256,8 +264,8 @@ class Item_func_regexp_substr :public Item_str_func { Regexp_processor_pcre re; public: - Item_func_regexp_substr(Item *a, Item *b) - :Item_str_func(a, b) + Item_func_regexp_substr(THD *thd, Item *a, Item *b): + Item_str_func(thd, a, b) {} void cleanup() { @@ -276,8 +284,9 @@ class Item_func_insert :public Item_str_func { String tmp_value; public: - Item_func_insert(Item *org,Item *start,Item *length,Item *new_str) - :Item_str_func(org,start,length,new_str) {} + Item_func_insert(THD *thd, Item *org, Item *start, Item *length, + Item *new_str): + Item_str_func(thd, org, start, length, new_str) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "insert"; } @@ -291,7 +300,7 @@ protected: my_charset_conv_case converter; String tmp_value; public: - Item_str_conv(Item *item) :Item_str_func(item) {} + Item_str_conv(THD *thd, Item *item): Item_str_func(thd, item) {} String *val_str(String *); }; @@ -299,7 +308,7 @@ public: class Item_func_lcase :public Item_str_conv { public: - Item_func_lcase(Item *item) :Item_str_conv(item) {} + Item_func_lcase(THD *thd, Item *item): Item_str_conv(thd, item) {} const char *func_name() const { return "lcase"; } void fix_length_and_dec(); }; @@ -307,7 +316,7 @@ public: class Item_func_ucase :public Item_str_conv { public: - Item_func_ucase(Item *item) :Item_str_conv(item) {} + Item_func_ucase(THD *thd, Item *item): Item_str_conv(thd, item) {} const char *func_name() const { return "ucase"; } void fix_length_and_dec(); }; @@ -317,7 +326,7 @@ class Item_func_left :public Item_str_func { String tmp_value; public: - Item_func_left(Item *a,Item *b) :Item_str_func(a,b) {} + Item_func_left(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "left"; } @@ -328,7 +337,7 @@ class Item_func_right :public Item_str_func { String tmp_value; public: - Item_func_right(Item *a,Item *b) :Item_str_func(a,b) {} + Item_func_right(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "right"; } @@ -339,8 +348,8 @@ class Item_func_substr :public Item_str_func { String tmp_value; public: - Item_func_substr(Item *a,Item *b) :Item_str_func(a,b) {} - Item_func_substr(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} + Item_func_substr(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} + Item_func_substr(THD *thd, Item *a, Item *b, Item *c): Item_str_func(thd, a, b, c) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "substr"; } @@ -351,7 +360,8 @@ class Item_func_substr_index :public Item_str_func { String tmp_value; public: - Item_func_substr_index(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} + Item_func_substr_index(THD *thd, Item *a,Item *b,Item *c): + Item_str_func(thd, a, b, c) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "substring_index"; } @@ -379,8 +389,8 @@ protected: return trimmed_value(res, 0, res->length()); } public: - Item_func_trim(Item *a,Item *b) :Item_str_func(a,b) {} - Item_func_trim(Item *a) :Item_str_func(a) {} + Item_func_trim(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} + Item_func_trim(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "trim"; } @@ -392,8 +402,8 @@ public: class Item_func_ltrim :public Item_func_trim { public: - Item_func_ltrim(Item *a,Item *b) :Item_func_trim(a,b) {} - Item_func_ltrim(Item *a) :Item_func_trim(a) {} + Item_func_ltrim(THD *thd, Item *a, Item *b): Item_func_trim(thd, a, b) {} + Item_func_ltrim(THD *thd, Item *a): Item_func_trim(thd, a) {} String *val_str(String *); const char *func_name() const { return "ltrim"; } const char *mode_name() const { return "leading"; } @@ -403,8 +413,8 @@ public: class Item_func_rtrim :public Item_func_trim { public: - Item_func_rtrim(Item *a,Item *b) :Item_func_trim(a,b) {} - Item_func_rtrim(Item *a) :Item_func_trim(a) {} + Item_func_rtrim(THD *thd, Item *a, Item *b): Item_func_trim(thd, a, b) {} + Item_func_rtrim(THD *thd, Item *a): Item_func_trim(thd, a) {} String *val_str(String *); const char *func_name() const { return "rtrim"; } const char *mode_name() const { return "trailing"; } @@ -428,9 +438,10 @@ private: enum PW_Alg alg; bool deflt; public: - Item_func_password(Item *a) :Item_str_ascii_func(a), alg(NEW), deflt(1) {} - Item_func_password(Item *a, PW_Alg al) :Item_str_ascii_func(a), - alg(al), deflt(0) {} + Item_func_password(THD *thd, Item *a): + Item_str_ascii_func(thd, a), alg(NEW), deflt(1) {} + Item_func_password(THD *thd, Item *a, PW_Alg al): + Item_str_ascii_func(thd, a), alg(al), deflt(0) {} String *val_str_ascii(String *str); bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec() @@ -452,8 +463,8 @@ class Item_func_des_encrypt :public Item_str_func { String tmp_value,tmp_arg; public: - Item_func_des_encrypt(Item *a) :Item_str_func(a) {} - Item_func_des_encrypt(Item *a, Item *b): Item_str_func(a,b) {} + Item_func_des_encrypt(THD *thd, Item *a): Item_str_func(thd, a) {} + Item_func_des_encrypt(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec() { @@ -468,8 +479,8 @@ class Item_func_des_decrypt :public Item_str_func { String tmp_value; public: - Item_func_des_decrypt(Item *a) :Item_str_func(a) {} - Item_func_des_decrypt(Item *a, Item *b): Item_str_func(a,b) {} + Item_func_des_decrypt(THD *thd, Item *a): Item_str_func(thd, a) {} + Item_func_des_decrypt(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec() { @@ -492,11 +503,11 @@ class Item_func_encrypt :public Item_str_func collation.set(&my_charset_bin); } public: - Item_func_encrypt(Item *a) :Item_str_func(a) + Item_func_encrypt(THD *thd, Item *a): Item_str_func(thd, a) { constructor_helper(); } - Item_func_encrypt(Item *a, Item *b): Item_str_func(a,b) + Item_func_encrypt(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) { constructor_helper(); } @@ -520,8 +531,8 @@ private: protected: SQL_CRYPT sql_crypt; public: - Item_func_encode(Item *a, Item *seed_arg): - Item_str_func(a, seed_arg) {} + Item_func_encode(THD *thd, Item *a, Item *seed_arg): + Item_str_func(thd, a, seed_arg) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "encode"; } @@ -536,7 +547,7 @@ private: class Item_func_decode :public Item_func_encode { public: - Item_func_decode(Item *a, Item *seed_arg): Item_func_encode(a, seed_arg) {} + Item_func_decode(THD *thd, Item *a, Item *seed_arg): Item_func_encode(thd, a, seed_arg) {} const char *func_name() const { return "decode"; } protected: void crypto_transform(String *); @@ -546,11 +557,11 @@ protected: class Item_func_sysconst :public Item_str_func { public: - Item_func_sysconst() + Item_func_sysconst(THD *thd): Item_str_func(thd) { collation.set(system_charset_info,DERIVATION_SYSCONST); } - Item *safe_charset_converter(CHARSET_INFO *tocs) + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { - return const_charset_converter(tocs, true, fully_qualified_func_name()); + return const_charset_converter(thd, tocs, true, fully_qualified_func_name()); } /* Used to create correct Item name in new converted item in @@ -569,7 +580,7 @@ public: class Item_func_database :public Item_func_sysconst { public: - Item_func_database() :Item_func_sysconst() {} + Item_func_database(THD *thd): Item_func_sysconst(thd) {} String *val_str(String *); void fix_length_and_dec() { @@ -587,7 +598,7 @@ protected: bool init (const char *user, const char *host); public: - Item_func_user() + Item_func_user(THD *thd): Item_func_sysconst(thd) { str_value.set("", 0, system_charset_info); } @@ -616,8 +627,8 @@ class Item_func_current_user :public Item_func_user Name_resolution_context *context; public: - Item_func_current_user(Name_resolution_context *context_arg) - : context(context_arg) {} + Item_func_current_user(THD *thd, Name_resolution_context *context_arg): + Item_func_user(thd), context(context_arg) {} bool fix_fields(THD *thd, Item **ref); const char *func_name() const { return "current_user"; } const char *fully_qualified_func_name() const { return "current_user()"; } @@ -629,8 +640,8 @@ class Item_func_current_role :public Item_func_sysconst Name_resolution_context *context; public: - Item_func_current_role(Name_resolution_context *context_arg) - : context(context_arg) {} + Item_func_current_role(THD *thd, Name_resolution_context *context_arg): + Item_func_sysconst(thd), context(context_arg) {} bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec() { max_length= username_char_length * SYSTEM_CHARSET_MBMAXLEN; } @@ -650,7 +661,7 @@ class Item_func_soundex :public Item_str_func { String tmp_value; public: - Item_func_soundex(Item *a) :Item_str_func(a) {} + Item_func_soundex(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "soundex"; } @@ -660,7 +671,7 @@ public: class Item_func_elt :public Item_str_func { public: - Item_func_elt(List<Item> &list) :Item_str_func(list) {} + Item_func_elt(THD *thd, List<Item> &list): Item_str_func(thd, list) {} double val_real(); longlong val_int(); String *val_str(String *str); @@ -674,7 +685,7 @@ class Item_func_make_set :public Item_str_func String tmp_str; public: - Item_func_make_set(List<Item> &list) :Item_str_func(list) {} + Item_func_make_set(THD *thd, List<Item> &list): Item_str_func(thd, list) {} String *val_str(String *str); void fix_length_and_dec(); const char *func_name() const { return "make_set"; } @@ -686,10 +697,11 @@ class Item_func_format :public Item_str_ascii_func String tmp_str; MY_LOCALE *locale; public: - Item_func_format(Item *org, Item *dec): Item_str_ascii_func(org, dec) {} - Item_func_format(Item *org, Item *dec, Item *lang): - Item_str_ascii_func(org, dec, lang) {} - + Item_func_format(THD *thd, Item *org, Item *dec): + Item_str_ascii_func(thd, org, dec) {} + Item_func_format(THD *thd, Item *org, Item *dec, Item *lang): + Item_str_ascii_func(thd, org, dec, lang) {} + MY_LOCALE *get_locale(Item *item); String *val_str_ascii(String *); void fix_length_and_dec(); @@ -701,10 +713,11 @@ public: class Item_func_char :public Item_str_func { public: - Item_func_char(List<Item> &list) :Item_str_func(list) + Item_func_char(THD *thd, List<Item> &list): Item_str_func(thd, list) { collation.set(&my_charset_bin); } - Item_func_char(List<Item> &list, CHARSET_INFO *cs) :Item_str_func(list) - { collation.set(cs); } + Item_func_char(THD *thd, List<Item> &list, CHARSET_INFO *cs): + Item_str_func(thd, list) + { collation.set(cs); } String *val_str(String *); void fix_length_and_dec() { @@ -718,7 +731,8 @@ class Item_func_repeat :public Item_str_func { String tmp_value; public: - Item_func_repeat(Item *arg1,Item *arg2) :Item_str_func(arg1,arg2) {} + Item_func_repeat(THD *thd, Item *arg1, Item *arg2): + Item_str_func(thd, arg1, arg2) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "repeat"; } @@ -728,7 +742,7 @@ public: class Item_func_space :public Item_str_func { public: - Item_func_space(Item *arg1):Item_str_func(arg1) {} + Item_func_space(THD *thd, Item *arg1): Item_str_func(thd, arg1) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "space"; } @@ -739,7 +753,8 @@ class Item_func_binlog_gtid_pos :public Item_str_func { String tmp_value; public: - Item_func_binlog_gtid_pos(Item *arg1,Item *arg2) :Item_str_func(arg1,arg2) {} + Item_func_binlog_gtid_pos(THD *thd, Item *arg1, Item *arg2): + Item_str_func(thd, arg1, arg2) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "binlog_gtid_pos"; } @@ -750,8 +765,8 @@ class Item_func_rpad :public Item_str_func { String tmp_value, rpad_str; public: - Item_func_rpad(Item *arg1,Item *arg2,Item *arg3) - :Item_str_func(arg1,arg2,arg3) {} + Item_func_rpad(THD *thd, Item *arg1, Item *arg2, Item *arg3): + Item_str_func(thd, arg1, arg2, arg3) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "rpad"; } @@ -762,8 +777,8 @@ class Item_func_lpad :public Item_str_func { String tmp_value, lpad_str; public: - Item_func_lpad(Item *arg1,Item *arg2,Item *arg3) - :Item_str_func(arg1,arg2,arg3) {} + Item_func_lpad(THD *thd, Item *arg1, Item *arg2, Item *arg3): + Item_str_func(thd, arg1, arg2, arg3) {} String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "lpad"; } @@ -773,7 +788,8 @@ public: class Item_func_conv :public Item_str_func { public: - Item_func_conv(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {} + Item_func_conv(THD *thd, Item *a, Item *b, Item *c): + Item_str_func(thd, a, b, c) {} const char *func_name() const { return "conv"; } String *val_str(String *); void fix_length_and_dec() @@ -789,7 +805,8 @@ class Item_func_hex :public Item_str_ascii_func { String tmp_value; public: - Item_func_hex(Item *a) :Item_str_ascii_func(a) {} + Item_func_hex(THD *thd, Item *a): + Item_str_ascii_func(thd, a) {} const char *func_name() const { return "hex"; } String *val_str_ascii(String *); void fix_length_and_dec() @@ -804,10 +821,10 @@ class Item_func_unhex :public Item_str_func { String tmp_value; public: - Item_func_unhex(Item *a) :Item_str_func(a) - { + Item_func_unhex(THD *thd, Item *a): Item_str_func(thd, a) + { /* there can be bad hex strings */ - maybe_null= 1; + maybe_null= 1; } const char *func_name() const { return "unhex"; } String *val_str(String *); @@ -828,8 +845,8 @@ protected: String max_str; const bool is_min; public: - Item_func_like_range(Item *a, Item *b, bool is_min_arg) - :Item_str_func(a, b), is_min(is_min_arg) + Item_func_like_range(THD *thd, Item *a, Item *b, bool is_min_arg): + Item_str_func(thd, a, b), is_min(is_min_arg) { maybe_null= 1; } String *val_str(String *); void fix_length_and_dec() @@ -844,8 +861,8 @@ public: class Item_func_like_range_min :public Item_func_like_range { public: - Item_func_like_range_min(Item *a, Item *b) - :Item_func_like_range(a, b, true) { } + Item_func_like_range_min(THD *thd, Item *a, Item *b): + Item_func_like_range(thd, a, b, true) { } const char *func_name() const { return "like_range_min"; } }; @@ -853,8 +870,8 @@ public: class Item_func_like_range_max :public Item_func_like_range { public: - Item_func_like_range_max(Item *a, Item *b) - :Item_func_like_range(a, b, false) { } + Item_func_like_range_max(THD *thd, Item *a, Item *b): + Item_func_like_range(thd, a, b, false) { } const char *func_name() const { return "like_range_max"; } }; #endif @@ -863,7 +880,7 @@ public: class Item_func_binary :public Item_str_func { public: - Item_func_binary(Item *a) :Item_str_func(a) {} + Item_func_binary(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *a) { DBUG_ASSERT(fixed == 1); @@ -887,7 +904,7 @@ class Item_load_file :public Item_str_func { String tmp_value; public: - Item_load_file(Item *a) :Item_str_func(a) {} + Item_load_file(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); const char *func_name() const { return "load_file"; } void fix_length_and_dec() @@ -906,9 +923,12 @@ public: class Item_func_export_set: public Item_str_func { public: - Item_func_export_set(Item *a,Item *b,Item* c) :Item_str_func(a,b,c) {} - Item_func_export_set(Item *a,Item *b,Item* c,Item* d) :Item_str_func(a,b,c,d) {} - Item_func_export_set(Item *a,Item *b,Item* c,Item* d,Item* e) :Item_str_func(a,b,c,d,e) {} + Item_func_export_set(THD *thd, Item *a, Item *b, Item* c): + Item_str_func(thd, a, b, c) {} + Item_func_export_set(THD *thd, Item *a, Item *b, Item* c, Item* d): + Item_str_func(thd, a, b, c, d) {} + Item_func_export_set(THD *thd, Item *a, Item *b, Item* c, Item* d, Item* e): + Item_str_func(thd, a, b, c, d, e) {} String *val_str(String *str); void fix_length_and_dec(); const char *func_name() const { return "export_set"; } @@ -919,7 +939,7 @@ class Item_func_quote :public Item_str_func { String tmp_value; public: - Item_func_quote(Item *a) :Item_str_func(a) {} + Item_func_quote(THD *thd, Item *a): Item_str_func(thd, a) {} const char *func_name() const { return "quote"; } String *val_str(String *); void fix_length_and_dec() @@ -938,10 +958,11 @@ class Item_func_conv_charset :public Item_str_func public: bool safe; CHARSET_INFO *conv_charset; // keep it public - Item_func_conv_charset(Item *a, CHARSET_INFO *cs) :Item_str_func(a) + Item_func_conv_charset(THD *thd, Item *a, CHARSET_INFO *cs): + Item_str_func(thd, a) { conv_charset= cs; use_cached_value= 0; safe= 0; } - Item_func_conv_charset(Item *a, CHARSET_INFO *cs, bool cache_if_const) - :Item_str_func(a) + Item_func_conv_charset(THD *thd, Item *a, CHARSET_INFO *cs, bool cache_if_const): + Item_str_func(thd, a) { conv_charset= cs; if (cache_if_const && args[0]->const_item() && !args[0]->is_expensive()) @@ -1013,7 +1034,8 @@ public: class Item_func_set_collation :public Item_str_func { public: - Item_func_set_collation(Item *a, Item *b) :Item_str_func(a,b) {}; + Item_func_set_collation(THD *thd, Item *a, Item *b): + Item_str_func(thd, a, b) {} String *val_str(String *); void fix_length_and_dec(); bool eq(const Item *item, bool binary_cmp) const; @@ -1030,7 +1052,7 @@ public: class Item_func_charset :public Item_str_func { public: - Item_func_charset(Item *a) :Item_str_func(a) {} + Item_func_charset(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); const char *func_name() const { return "charset"; } void fix_length_and_dec() @@ -1045,7 +1067,7 @@ public: class Item_func_collation :public Item_str_func { public: - Item_func_collation(Item *a) :Item_str_func(a) {} + Item_func_collation(THD *thd, Item *a): Item_str_func(thd, a) {} String *val_str(String *); const char *func_name() const { return "collation"; } void fix_length_and_dec() @@ -1064,9 +1086,9 @@ class Item_func_weight_string :public Item_str_func uint nweights; uint result_length; public: - Item_func_weight_string(Item *a, uint result_length_arg, - uint nweights_arg, uint flags_arg) - :Item_str_func(a) + Item_func_weight_string(THD *thd, Item *a, uint result_length_arg, + uint nweights_arg, uint flags_arg): + Item_str_func(thd, a) { nweights= nweights_arg; flags= flags_arg; @@ -1090,7 +1112,8 @@ class Item_func_crc32 :public Item_int_func { String value; public: - Item_func_crc32(Item *a) :Item_int_func(a) { unsigned_flag= 1; } + Item_func_crc32(THD *thd, Item *a): Item_int_func(thd, a) + { unsigned_flag= 1; } const char *func_name() const { return "crc32"; } void fix_length_and_dec() { max_length=10; } longlong val_int(); @@ -1100,7 +1123,7 @@ class Item_func_uncompressed_length : public Item_int_func { String value; public: - Item_func_uncompressed_length(Item *a):Item_int_func(a){} + Item_func_uncompressed_length(THD *thd, Item *a): Item_int_func(thd, a) {} const char *func_name() const{return "uncompressed_length";} void fix_length_and_dec() { max_length=10; maybe_null= true; } longlong val_int(); @@ -1116,7 +1139,7 @@ class Item_func_compress: public Item_str_func { String buffer; public: - Item_func_compress(Item *a):Item_str_func(a){} + Item_func_compress(THD *thd, Item *a): Item_str_func(thd, a) {} void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;} const char *func_name() const{return "compress";} String *val_str(String *) ZLIB_DEPENDED_FUNCTION @@ -1126,7 +1149,7 @@ class Item_func_uncompress: public Item_str_func { String buffer; public: - Item_func_uncompress(Item *a): Item_str_func(a){} + Item_func_uncompress(THD *thd, Item *a): Item_str_func(thd, a) {} void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; } const char *func_name() const{return "uncompress";} String *val_str(String *) ZLIB_DEPENDED_FUNCTION @@ -1136,7 +1159,7 @@ public: class Item_func_uuid: public Item_str_func { public: - Item_func_uuid(): Item_str_func() {} + Item_func_uuid(THD *thd): Item_str_func(thd) {} void fix_length_and_dec() { collation.set(system_charset_info, @@ -1163,7 +1186,7 @@ protected: bool prepare_arguments(bool force_names); void print_arguments(String *str, enum_query_type query_type); public: - Item_func_dyncol_create(List<Item> &args, DYNCALL_CREATE_DEF *dfs); + Item_func_dyncol_create(THD *thd, List<Item> &args, DYNCALL_CREATE_DEF *dfs); bool fix_fields(THD *thd, Item **ref); void fix_length_and_dec(); const char *func_name() const{ return "column_create"; } @@ -1176,8 +1199,8 @@ public: class Item_func_dyncol_add: public Item_func_dyncol_create { public: - Item_func_dyncol_add(List<Item> &args_arg, DYNCALL_CREATE_DEF *dfs) - :Item_func_dyncol_create(args_arg, dfs) + Item_func_dyncol_add(THD *thd, List<Item> &args_arg, DYNCALL_CREATE_DEF *dfs): + Item_func_dyncol_create(thd, args_arg, dfs) {} const char *func_name() const{ return "column_add"; } String *val_str(String *); @@ -1187,7 +1210,7 @@ public: class Item_func_dyncol_json: public Item_str_func { public: - Item_func_dyncol_json(Item *str) :Item_str_func(str) {} + Item_func_dyncol_json(THD *thd, Item *str): Item_str_func(thd, str) {} const char *func_name() const{ return "column_json"; } String *val_str(String *); void fix_length_and_dec() @@ -1206,8 +1229,7 @@ public: class Item_dyncol_get: public Item_str_func { public: - Item_dyncol_get(Item *str, Item *num) - :Item_str_func(str, num) + Item_dyncol_get(THD *thd, Item *str, Item *num): Item_str_func(thd, str, num) {} void fix_length_and_dec() { maybe_null= 1;; max_length= MAX_BLOB_WIDTH; } @@ -1228,7 +1250,7 @@ public: class Item_func_dyncol_list: public Item_str_func { public: - Item_func_dyncol_list(Item *str) :Item_str_func(str) {}; + Item_func_dyncol_list(THD *thd, Item *str): Item_str_func(thd, str) {}; void fix_length_and_dec() { maybe_null= 1; max_length= MAX_BLOB_WIDTH; }; const char *func_name() const{ return "column_list"; } String *val_str(String *); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 4eb10cf71f3..ba283a11563 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -48,9 +48,9 @@ const char *exists_outer_expr_name= "<exists outer expr>"; int check_and_do_in_subquery_rewrites(JOIN *join); -Item_subselect::Item_subselect(): - Item_result_field(), Used_tables_and_const_cache(), - value_assigned(0), own_engine(0), thd(0), old_engine(0), +Item_subselect::Item_subselect(THD *thd_arg): + Item_result_field(thd_arg), Used_tables_and_const_cache(), + value_assigned(0), own_engine(0), thd(0), old_engine(0), have_to_be_excluded(0), inside_first_fix_fields(0), done_first_fix_fields(FALSE), expr_cache(0), forced_const(FALSE), substitution(0), engine(0), eliminated(FALSE), @@ -875,7 +875,7 @@ bool Item_subselect::const_item() const Item *Item_subselect::get_tmp_table_item(THD *thd_arg) { if (!with_sum_func && !const_item()) - return new Item_field(result_field); + return new Item_field(thd_arg, result_field); return copy_or_same(thd_arg); } @@ -922,12 +922,11 @@ void Item_subselect::print(String *str, enum_query_type query_type) } -Item_singlerow_subselect::Item_singlerow_subselect(THD *thd_arg, st_select_lex *select_lex) - :Item_subselect(), value(0) +Item_singlerow_subselect::Item_singlerow_subselect(THD *thd, st_select_lex *select_lex): + Item_subselect(thd), value(0) { DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect"); - init(select_lex, new (thd_arg->mem_root) select_singlerow_subselect(thd_arg, - this)); + init(select_lex, new (thd->mem_root) select_singlerow_subselect(thd, this)); maybe_null= 1; max_columns= UINT_MAX; DBUG_VOID_RETURN; @@ -953,16 +952,16 @@ Item_singlerow_subselect::invalidate_and_restore_select_lex() DBUG_RETURN(result); } -Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param, +Item_maxmin_subselect::Item_maxmin_subselect(THD *thd, Item_subselect *parent, st_select_lex *select_lex, - bool max_arg) - :Item_singlerow_subselect(), was_values(TRUE) + bool max_arg): + Item_singlerow_subselect(thd), was_values(TRUE) { DBUG_ENTER("Item_maxmin_subselect::Item_maxmin_subselect"); max= max_arg; init(select_lex, - new (thd_param->mem_root) select_max_min_finder_subselect(thd_param, + new (thd->mem_root) select_max_min_finder_subselect(thd, this, max_arg, parent->substype() == Item_subselect::ALL_SUBS)); max_columns= 1; maybe_null= 1; @@ -975,12 +974,6 @@ Item_maxmin_subselect::Item_maxmin_subselect(THD *thd_param, used_tables_cache= parent->get_used_tables_cache(); const_item_cache= parent->const_item(); - /* - this subquery always creates during preparation, so we can assign - thd here - */ - thd= thd_param; - DBUG_VOID_RETURN; } @@ -1020,7 +1013,7 @@ void Item_maxmin_subselect::no_rows_in_result() */ if (parsing_place != SELECT_LIST || const_item()) return; - value= Item_cache::get_cache(new Item_null()); + value= Item_cache::get_cache(thd, new Item_null(thd)); null_value= 0; was_values= 0; make_const(); @@ -1038,7 +1031,7 @@ void Item_singlerow_subselect::no_rows_in_result() */ if (parsing_place != SELECT_LIST || const_item()) return; - value= Item_cache::get_cache(new Item_null()); + value= Item_cache::get_cache(thd, new Item_null(thd)); reset(); make_const(); } @@ -1192,9 +1185,9 @@ void Item_singlerow_subselect::fix_length_and_dec() this item - otherwise */ -Item* Item_singlerow_subselect::expr_cache_insert_transformer(uchar *thd_arg) +Item* Item_singlerow_subselect::expr_cache_insert_transformer(THD *tmp_thd, + uchar *unused) { - THD *tmp_thd= (THD*) thd_arg; DBUG_ENTER("Item_singlerow_subselect::expr_cache_insert_transformer"); DBUG_ASSERT(thd == tmp_thd); @@ -1351,13 +1344,13 @@ bool Item_singlerow_subselect::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate) } -Item_exists_subselect::Item_exists_subselect(THD *thd_arg, +Item_exists_subselect::Item_exists_subselect(THD *thd, st_select_lex *select_lex): - Item_subselect(), upper_not(NULL), abort_on_null(0), + Item_subselect(thd), upper_not(NULL), abort_on_null(0), emb_on_expr_nest(NULL), optimizer(0), exists_transformed(0) { DBUG_ENTER("Item_exists_subselect::Item_exists_subselect"); - init(select_lex, new (thd_arg->mem_root) select_exists_subselect(thd_arg, this)); + init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); max_columns= UINT_MAX; null_value= FALSE; //can't be NULL maybe_null= 0; //can't be NULL @@ -1388,9 +1381,9 @@ bool Item_in_subselect::test_limit(st_select_lex_unit *unit_arg) return(0); } -Item_in_subselect::Item_in_subselect(THD *thd_arg, Item * left_exp, +Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp, st_select_lex *select_lex): - Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE), + Item_exists_subselect(thd), left_expr_cache(0), first_execution(TRUE), in_strategy(SUBS_NOT_TRANSFORMED), pushed_cond_guards(NULL), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE), is_flattenable_semijoin(FALSE), is_registered_semijoin(FALSE), @@ -1400,8 +1393,7 @@ Item_in_subselect::Item_in_subselect(THD *thd_arg, Item * left_exp, DBUG_PRINT("info", ("in_strategy: %u", (uint)in_strategy)); left_expr= left_exp; func= &eq_creator; - init(select_lex, new (thd_arg->mem_root) select_exists_subselect(thd_arg, - this)); + init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); max_columns= UINT_MAX; maybe_null= 1; reset(); @@ -1415,17 +1407,16 @@ int Item_in_subselect::get_identifier() return engine->get_identifier(); } -Item_allany_subselect::Item_allany_subselect(THD *thd_arg, Item * left_exp, +Item_allany_subselect::Item_allany_subselect(THD *thd, Item * left_exp, chooser_compare_func_creator fc, st_select_lex *select_lex, - bool all_arg) - :Item_in_subselect(), func_creator(fc), all(all_arg) + bool all_arg): + Item_in_subselect(thd), func_creator(fc), all(all_arg) { DBUG_ENTER("Item_allany_subselect::Item_allany_subselect"); left_expr= left_exp; func= func_creator(all_arg); - init(select_lex, new (thd_arg->mem_root) select_exists_subselect(thd_arg, - this)); + init(select_lex, new (thd->mem_root) select_exists_subselect(thd, this)); max_columns= 1; abort_on_null= 0; reset(); @@ -1457,7 +1448,7 @@ void Item_exists_subselect::fix_length_and_dec() an IN always requires LIMIT 1) */ thd->change_item_tree(&unit->global_parameters()->select_limit, - new Item_int((int32) 1)); + new Item_int(thd, (int32) 1)); DBUG_PRINT("info", ("Set limit to 1")); DBUG_VOID_RETURN; } @@ -1493,9 +1484,9 @@ void Item_in_subselect::fix_length_and_dec() this item - otherwise */ -Item* Item_exists_subselect::expr_cache_insert_transformer(uchar *thd_arg) +Item* Item_exists_subselect::expr_cache_insert_transformer(THD *tmp_thd, + uchar *unused) { - THD *tmp_thd= (THD*) thd_arg; DBUG_ENTER("Item_exists_subselect::expr_cache_insert_transformer"); DBUG_ASSERT(thd == tmp_thd); @@ -1789,7 +1780,7 @@ Item_in_subselect::single_value_transformer(JOIN *join) of the statement. Thus one of 'substitution' arguments can be broken in case of PS. */ - substitution= func->create(thd->mem_root, left_expr, where_item); + substitution= func->create(thd, left_expr, where_item); have_to_be_excluded= 1; if (thd->lex->describe) { @@ -1828,7 +1819,7 @@ Item_in_subselect::single_value_transformer(JOIN *join) As far as Item_in_optimizer does not substitute itself on fix_fields we can use same item for all selects. */ - expr= new Item_direct_ref(&select_lex->context, + expr= new Item_direct_ref(thd, &select_lex->context, (Item**)optimizer->get_cache(), (char *)"<no matter>", (char *)in_left_expr_name); @@ -1866,7 +1857,6 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) if (!test_strategy(SUBS_MAXMIN_INJECTED | SUBS_MAXMIN_ENGINE)) DBUG_RETURN(false); Item **place= optimizer->arguments() + 1; - THD *thd= join->thd; SELECT_LEX *select_lex= join->select_lex; Item *subs; @@ -1897,7 +1887,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) (ALL && (> || =>)) || (ANY && (< || =<)) for ALL condition is inverted */ - item= new Item_sum_max(*select_lex->ref_pointer_array); + item= new Item_sum_max(thd, *select_lex->ref_pointer_array); } else { @@ -1905,7 +1895,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) (ALL && (< || =<)) || (ANY && (> || =>)) for ALL condition is inverted */ - item= new Item_sum_min(*select_lex->ref_pointer_array); + item= new Item_sum_min(thd, *select_lex->ref_pointer_array); } if (upper_item) upper_item->set_sum_test(item); @@ -1959,7 +1949,7 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join) The swap is needed for expressions of type 'f1 < ALL ( SELECT ....)' where we want to evaluate the sub query even if f1 would be null. */ - subs= func->create_swap(thd->mem_root, *(optimizer->get_cache()), subs); + subs= func->create_swap(thd, *(optimizer->get_cache()), subs); thd->change_item_tree(place, subs); if (subs->fix_fields(thd, &subs)) DBUG_RETURN(true); @@ -2051,8 +2041,9 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, if (join_having || select_lex->with_sum_func || select_lex->group_list.elements) { - Item *item= func->create(thd->mem_root, expr, + Item *item= func->create(thd, expr, new (thd->mem_root) Item_ref_null_helper( + thd, &select_lex->context, this, select_lex-> @@ -2065,7 +2056,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, We can encounter "NULL IN (SELECT ...)". Wrap the added condition within a trig_cond. */ - item= new Item_func_trig_cond(item, get_cond_guard(0)); + item= new Item_func_trig_cond(thd, item, get_cond_guard(0)); } if (!join_having) @@ -2083,13 +2074,13 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, Item *having= item; Item *orig_item= item; - item= func->create(thd->mem_root, expr, item); + item= func->create(thd, expr, item); if (!abort_on_null && orig_item->maybe_null) { - having= new (thd->mem_root) Item_is_not_null_test(this, having); + having= new (thd->mem_root) Item_is_not_null_test(thd, this, having); if (left_expr->maybe_null) { - if (!(having= new (thd->mem_root) Item_func_trig_cond(having, + if (!(having= new (thd->mem_root) Item_func_trig_cond(thd, having, get_cond_guard(0)))) DBUG_RETURN(true); } @@ -2098,8 +2089,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, DBUG_RETURN(true); *having_item= having; - item= new (thd->mem_root) Item_cond_or(item, - new (thd->mem_root) Item_func_isnull(orig_item)); + item= new (thd->mem_root) Item_cond_or(thd, item, + new (thd->mem_root) Item_func_isnull(thd, orig_item)); } /* If we may encounter NULL IN (SELECT ...) and care whether subquery @@ -2107,7 +2098,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, */ if (!abort_on_null && left_expr->maybe_null) { - if (!(item= new (thd->mem_root) Item_func_trig_cond(item, + if (!(item= new (thd->mem_root) Item_func_trig_cond(thd, item, get_cond_guard(0)))) DBUG_RETURN(true); } @@ -2127,8 +2118,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, if (select_lex->master_unit()->is_union()) { Item *new_having= - func->create(thd->mem_root, expr, - new (thd->mem_root) Item_ref_null_helper( + func->create(thd, expr, + new (thd->mem_root) Item_ref_null_helper(thd, &select_lex->context, this, select_lex->ref_pointer_array, @@ -2136,7 +2127,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN * join, (char *)"<result>")); if (!abort_on_null && left_expr->maybe_null) { - if (!(new_having= new (thd->mem_root) Item_func_trig_cond(new_having, + if (!(new_having= new (thd->mem_root) Item_func_trig_cond(thd, new_having, get_cond_guard(0)))) DBUG_RETURN(true); } @@ -2309,34 +2300,34 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, check_cols(left_expr->element_index(i)->cols())) DBUG_RETURN(true); Item *item_eq= - new Item_func_eq(new - Item_direct_ref(&select_lex->context, + new Item_func_eq(thd, new + Item_direct_ref(thd, &select_lex->context, (*optimizer->get_cache())-> addr(i), (char *)"<no matter>", (char *)in_left_expr_name), new - Item_ref(&select_lex->context, + Item_ref(thd, &select_lex->context, select_lex->ref_pointer_array + i, (char *)"<no matter>", (char *)"<list ref>")); Item *item_isnull= - new Item_func_isnull(new - Item_ref(&select_lex->context, + new Item_func_isnull(thd, new + Item_ref(thd, &select_lex->context, select_lex->ref_pointer_array+i, (char *)"<no matter>", (char *)"<list ref>")); - Item *col_item= new Item_cond_or(item_eq, item_isnull); + Item *col_item= new Item_cond_or(thd, item_eq, item_isnull); if (!abort_on_null && left_expr->element_index(i)->maybe_null) { - if (!(col_item= new Item_func_trig_cond(col_item, get_cond_guard(i)))) + if (!(col_item= new Item_func_trig_cond(thd, col_item, get_cond_guard(i)))) DBUG_RETURN(true); } - *having_item= and_items(*having_item, col_item); + *having_item= and_items(thd, *having_item, col_item); Item *item_nnull_test= - new Item_is_not_null_test(this, - new Item_ref(&select_lex->context, + new Item_is_not_null_test(thd, this, + new Item_ref(thd, &select_lex->context, select_lex-> ref_pointer_array + i, (char *)"<no matter>", @@ -2344,13 +2335,13 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, if (!abort_on_null && left_expr->element_index(i)->maybe_null) { if (!(item_nnull_test= - new Item_func_trig_cond(item_nnull_test, get_cond_guard(i)))) + new Item_func_trig_cond(thd, item_nnull_test, get_cond_guard(i)))) DBUG_RETURN(true); } - item_having_part2= and_items(item_having_part2, item_nnull_test); + item_having_part2= and_items(thd, item_having_part2, item_nnull_test); item_having_part2->top_level_item(); } - *having_item= and_items(*having_item, item_having_part2); + *having_item= and_items(thd, *having_item, item_having_part2); } else { @@ -2366,14 +2357,14 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, check_cols(left_expr->element_index(i)->cols())) DBUG_RETURN(true); item= - new Item_func_eq(new - Item_direct_ref(&select_lex->context, + new Item_func_eq(thd, new + Item_direct_ref(thd, &select_lex->context, (*optimizer->get_cache())-> addr(i), (char *)"<no matter>", (char *)in_left_expr_name), new - Item_direct_ref(&select_lex->context, + Item_direct_ref(thd, &select_lex->context, select_lex-> ref_pointer_array+i, (char *)"<no matter>", @@ -2381,38 +2372,38 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join, if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null) { Item *having_col_item= - new Item_is_not_null_test(this, + new Item_is_not_null_test(thd, this, new - Item_ref(&select_lex->context, + Item_ref(thd, &select_lex->context, select_lex->ref_pointer_array + i, (char *)"<no matter>", (char *)"<list ref>")); item_isnull= new - Item_func_isnull(new - Item_direct_ref(&select_lex->context, + Item_func_isnull(thd, new + Item_direct_ref(thd, &select_lex->context, select_lex-> ref_pointer_array+i, (char *)"<no matter>", (char *)"<list ref>")); - item= new Item_cond_or(item, item_isnull); + item= new Item_cond_or(thd, item, item_isnull); if (left_expr->element_index(i)->maybe_null) { - if (!(item= new Item_func_trig_cond(item, get_cond_guard(i)))) + if (!(item= new Item_func_trig_cond(thd, item, get_cond_guard(i)))) DBUG_RETURN(true); - if (!(having_col_item= - new Item_func_trig_cond(having_col_item, get_cond_guard(i)))) + if (!(having_col_item= + new Item_func_trig_cond(thd, having_col_item, get_cond_guard(i)))) DBUG_RETURN(true); } - *having_item= and_items(*having_item, having_col_item); + *having_item= and_items(thd, *having_item, having_col_item); } if (!abort_on_null && left_expr->element_index(i)->maybe_null) { - if (!(item= new Item_func_trig_cond(item, get_cond_guard(i)))) + if (!(item= new Item_func_trig_cond(thd, item, get_cond_guard(i)))) DBUG_RETURN(true); } - *where_item= and_items(*where_item, item); + *where_item= and_items(thd, *where_item, item); } } @@ -2542,7 +2533,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) and_args->disjoin((List<Item> *) &join_arg->cond_equal->current_level); } - where_item= and_items(join_arg->conds, where_item); + where_item= and_items(thd, join_arg->conds, where_item); if (!where_item->fixed && where_item->fix_fields(thd, 0)) DBUG_RETURN(true); // TIMOUR TODO: call optimize_cond() for the new where clause @@ -2567,7 +2558,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) if (having_item) { Item* join_having= join_arg->having ? join_arg->having:join_arg->tmp_having; - having_item= and_items(join_having, having_item); + having_item= and_items(thd, join_having, having_item); if (fix_having(having_item, select_lex)) DBUG_RETURN(true); // TIMOUR TODO: call optimize_cond() for the new having clause @@ -2576,7 +2567,7 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg) join_arg->having= select_lex->having; } join_arg->thd->change_item_tree(&unit->global_parameters()->select_limit, - new Item_int((int32) 1)); + new Item_int(thd, (int32) 1)); unit->select_limit_cnt= 1; DBUG_RETURN(false); @@ -2603,7 +2594,7 @@ bool Item_exists_subselect::select_prepare_to_be_in() Query_arena *arena, backup; bool result; arena= thd->activate_stmt_arena_if_needed(&backup); - result= (!(optimizer= new Item_in_optimizer(new Item_int(1), this))); + result= (!(optimizer= new Item_in_optimizer(thd, new Item_int(thd, 1), this))); if (arena) thd->restore_active_arena(arena, &backup); if (result) @@ -2823,10 +2814,10 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) /* remove the parts from condition */ if (!upper_not || !local_field->maybe_null) - *eq_ref= new Item_int(1); + *eq_ref= new Item_int(thd, 1); else { - *eq_ref= new Item_func_isnotnull( + *eq_ref= new Item_func_isnotnull(thd, new Item_field(thd, ((Item_field*)(local_field->real_item()))->context, ((Item_field*)(local_field->real_item()))->field)); @@ -2849,7 +2840,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) left_exp= outer_exp; else { - if (!(left_exp= new Item_row(outer))) + if (!(left_exp= new Item_row(thd, outer))) { res= TRUE; goto out; @@ -2861,7 +2852,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) first_select->select_limit= NULL; if (!(in_subs= new (thd->mem_root) Item_in_subselect(thd, left_exp, - first_select))) + first_select))) { res= TRUE; goto out; @@ -2891,7 +2882,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) As far as Item_ref_in_optimizer do not substitute itself on fix_fields we can use same item for all selects. */ - in_subs->expr= new Item_direct_ref(&first_select->context, + in_subs->expr= new Item_direct_ref(thd, &first_select->context, (Item**)optimizer->get_cache(), (char *)"<no matter>", (char *)in_left_expr_name); @@ -2957,9 +2948,9 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) { exp= (optimizer->arguments()[0]->maybe_null ? (Item*) - new Item_cond_and( - new Item_func_isnotnull( - new Item_direct_ref(&unit->outer_select()->context, + new Item_cond_and(thd, + new Item_func_isnotnull(thd, + new Item_direct_ref(thd, &unit->outer_select()->context, optimizer->arguments(), (char *)"<no matter>", (char *)exists_outer_expr_name)), @@ -2980,8 +2971,8 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) { and_list-> push_front( - new Item_func_isnotnull( - new Item_direct_ref(&unit->outer_select()->context, + new Item_func_isnotnull(thd, + new Item_direct_ref(thd, &unit->outer_select()->context, optimizer->arguments()[0]->addr(i), (char *)"<no matter>", (char *)exists_outer_expr_name))); @@ -2990,7 +2981,7 @@ bool Item_exists_subselect::exists2in_processor(uchar *opt_arg) if (and_list->elements > 0) { and_list->push_front(optimizer); - exp= new Item_cond_and(*and_list); + exp= new Item_cond_and(thd, *and_list); } else exp= optimizer; @@ -3065,7 +3056,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join) arena= thd->activate_stmt_arena_if_needed(&backup); if (!optimizer) { - result= (!(optimizer= new Item_in_optimizer(left_expr, this))); + result= (!(optimizer= new Item_in_optimizer(thd, left_expr, this))); if (result) goto out; } @@ -3127,12 +3118,12 @@ void Item_in_subselect::print(String *str, enum_query_type query_type) Item_subselect::print(str, query_type); } -bool Item_exists_subselect::fix_fields(THD *thd_arg, Item **ref) +bool Item_exists_subselect::fix_fields(THD *thd, Item **ref) { DBUG_ENTER("Item_exists_subselect::fix_fields"); if (exists_transformed) - DBUG_RETURN( !( (*ref)= new Item_int(1))); - DBUG_RETURN(Item_subselect::fix_fields(thd_arg, ref)); + DBUG_RETURN( !( (*ref)= new Item_int(thd, 1))); + DBUG_RETURN(Item_subselect::fix_fields(thd, ref)); } @@ -3143,7 +3134,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref) DBUG_ENTER("Item_in_subselect::fix_fields"); if (test_strategy(SUBS_SEMI_JOIN)) - DBUG_RETURN( !( (*ref)= new Item_int(1)) ); + DBUG_RETURN( !( (*ref)= new Item_int(thd, 1)) ); /* Check if the outer and inner IN operands match in those cases when we @@ -3574,9 +3565,9 @@ void subselect_engine::set_row(List<Item> &item_list, Item_cache **row) item->decimals= sel_item->decimals; item->unsigned_flag= sel_item->unsigned_flag; maybe_null= sel_item->maybe_null; - if (!(row[i]= Item_cache::get_cache(sel_item, sel_item->cmp_type()))) + if (!(row[i]= Item_cache::get_cache(thd, sel_item, sel_item->cmp_type()))) return; - row[i]->setup(sel_item); + row[i]->setup(thd, sel_item); //psergey-backport-timours: row[i]->store(sel_item); } if (item_list.elements > 1) @@ -4897,7 +4888,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds() DBUG_ENTER("subselect_hash_sj_engine::make_semi_join_conds"); DBUG_ASSERT(semi_join_conds == NULL); - if (!(semi_join_conds= new Item_cond_and)) + if (!(semi_join_conds= new Item_cond_and(thd))) DBUG_RETURN(TRUE); if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST)))) @@ -4922,7 +4913,7 @@ bool subselect_hash_sj_engine::make_semi_join_conds() Item_field *right_col_item; if (!(right_col_item= new Item_field(thd, context, tmp_table->field[i])) || - !(eq_cond= new Item_func_eq(item_in->left_expr->element_index(i), + !(eq_cond= new Item_func_eq(thd, item_in->left_expr->element_index(i), right_col_item)) || (((Item_cond_and*)semi_join_conds)->add(eq_cond))) { @@ -5529,9 +5520,9 @@ bool Ordered_key::init(MY_BITMAP *columns_to_index) { if (!bitmap_is_set(columns_to_index, i)) continue; - cur_tmp_field= new Item_field(tbl->field[i]); + cur_tmp_field= new Item_field(thd, tbl->field[i]); /* Create the predicate (tmp_column[i] < outer_ref[i]). */ - fn_less_than= new Item_func_lt(cur_tmp_field, + fn_less_than= new Item_func_lt(thd, cur_tmp_field, search_key->element_index(i)); fn_less_than->fix_fields(thd, (Item**) &fn_less_than); key_columns[cur_key_col]= cur_tmp_field; @@ -5563,9 +5554,9 @@ bool Ordered_key::init(int col_idx) key_columns= (Item_field**) thd->alloc(sizeof(Item_field*)); compare_pred= (Item_func_lt**) thd->alloc(sizeof(Item_func_lt*)); - key_columns[0]= new Item_field(tbl->field[col_idx]); + key_columns[0]= new Item_field(thd, tbl->field[col_idx]); /* Create the predicate (tmp_column[i] < outer_ref[i]). */ - compare_pred[0]= new Item_func_lt(key_columns[0], + compare_pred[0]= new Item_func_lt(thd, key_columns[0], search_key->element_index(col_idx)); compare_pred[0]->fix_fields(thd, (Item**)&compare_pred[0]); diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 4702d5abbfa..27d06d715b5 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -128,7 +128,7 @@ public: enum subs_type {UNKNOWN_SUBS, SINGLEROW_SUBS, EXISTS_SUBS, IN_SUBS, ALL_SUBS, ANY_SUBS}; - Item_subselect(); + Item_subselect(THD *thd); virtual subs_type substype() { return UNKNOWN_SUBS; } bool is_in_predicate() @@ -269,7 +269,7 @@ protected: Item_cache *value, **row; public: Item_singlerow_subselect(THD *thd_arg, st_select_lex *select_lex); - Item_singlerow_subselect() :Item_subselect(), value(0), row (0) + Item_singlerow_subselect(THD *thd_arg): Item_subselect(thd_arg), value(0), row (0) {} void cleanup(); @@ -311,7 +311,7 @@ public: */ st_select_lex* invalidate_and_restore_select_lex(); - Item* expr_cache_insert_transformer(uchar *thd_arg); + Item* expr_cache_insert_transformer(THD *thd, uchar *unused); friend class select_singlerow_subselect; }; @@ -364,8 +364,8 @@ public: bool exists_transformed; Item_exists_subselect(THD *thd_arg, st_select_lex *select_lex); - Item_exists_subselect() - :Item_subselect(), upper_not(NULL),abort_on_null(0), + Item_exists_subselect(THD *thd_arg): + Item_subselect(thd_arg), upper_not(NULL), abort_on_null(0), emb_on_expr_nest(NULL), optimizer(0), exists_transformed(0) {} @@ -391,7 +391,7 @@ public: inline bool is_top_level_item() { return abort_on_null; } bool exists2in_processor(uchar *opt_arg); - Item* expr_cache_insert_transformer(uchar *thd_arg); + Item* expr_cache_insert_transformer(THD *thd, uchar *unused); void mark_as_condition_AND_part(TABLE_LIST *embedding) { @@ -570,8 +570,8 @@ public: Item_func_not_all *upper_item; // point on NOT/NOP before ALL/SOME subquery Item_in_subselect(THD *thd_arg, Item * left_expr, st_select_lex *select_lex); - Item_in_subselect() - :Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE), + Item_in_subselect(THD *thd_arg): + Item_exists_subselect(thd_arg), left_expr_cache(0), first_execution(TRUE), in_strategy(SUBS_NOT_TRANSFORMED), pushed_cond_guards(NULL), func(NULL), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE), upper_item(0) {} diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 65f5d834bbd..e6748263072 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -401,7 +401,7 @@ bool Item_sum::collect_outer_ref_processor(uchar *param) } -Item_sum::Item_sum(List<Item> &list) :Item_func_or_sum(list), +Item_sum::Item_sum(THD *thd, List<Item> &list): Item_func_or_sum(thd, list), forced_const(FALSE) { if (!(orig_args= (Item **) sql_alloc(sizeof(Item *) * arg_count))) @@ -490,7 +490,7 @@ Item *Item_sum::get_tmp_table_item(THD *thd) if (arg->type() == Item::FIELD_ITEM) ((Item_field*) arg)->field= result_field_tmp++; else - sum_item->args[i]= new Item_field(result_field_tmp++); + sum_item->args[i]= new Item_field(thd, result_field_tmp++); } } } @@ -1197,7 +1197,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) case IMPOSSIBLE_RESULT: DBUG_ASSERT(0); }; - setup_hybrid(args[0], NULL); + setup_hybrid(thd, args[0], NULL); /* MIN/MAX can return NULL for empty set indepedent of the used column */ maybe_null= 1; unsigned_flag=item->unsigned_flag; @@ -1236,18 +1236,18 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) and Item_sum_min::add() to use different values! */ -void Item_sum_hybrid::setup_hybrid(Item *item, Item *value_arg) +void Item_sum_hybrid::setup_hybrid(THD *thd, Item *item, Item *value_arg) { - if (!(value= Item_cache::get_cache(item, item->cmp_type()))) + if (!(value= Item_cache::get_cache(thd, item, item->cmp_type()))) return; - value->setup(item); + value->setup(thd, item); value->store(value_arg); /* Don't cache value, as it will change */ if (!item->const_item()) value->set_used_tables(RAND_TABLE_BIT); - if (!(arg_cache= Item_cache::get_cache(item, item->cmp_type()))) + if (!(arg_cache= Item_cache::get_cache(thd, item, item->cmp_type()))) return; - arg_cache->setup(item); + arg_cache->setup(thd, item); /* Don't cache value, as it will change */ if (!item->const_item()) arg_cache->set_used_tables(RAND_TABLE_BIT); @@ -2088,7 +2088,7 @@ void Item_sum_hybrid::restore_to_before_no_rows_in_result() Item *Item_sum_min::copy_or_same(THD* thd) { Item_sum_min *item= new (thd->mem_root) Item_sum_min(thd, this); - item->setup_hybrid(args[0], value); + item->setup_hybrid(thd, args[0], value); return item; } @@ -2111,7 +2111,7 @@ bool Item_sum_min::add() Item *Item_sum_max::copy_or_same(THD* thd) { Item_sum_max *item= new (thd->mem_root) Item_sum_max(thd, this); - item->setup_hybrid(args[0], value); + item->setup_hybrid(thd, args[0], value); return item; } @@ -2591,7 +2591,9 @@ Item_sum_hybrid::min_max_update_decimal_field() } -Item_avg_field::Item_avg_field(Item_result res_type, Item_sum_avg *item) +Item_avg_field::Item_avg_field(THD *thd, Item_result res_type, + Item_sum_avg *item): + Item_result_field(thd) { name=item->name; decimals=item->decimals; @@ -2664,8 +2666,8 @@ String *Item_avg_field::val_str(String *str) } -Item_std_field::Item_std_field(Item_sum_std *item) - : Item_variance_field(item) +Item_std_field::Item_std_field(THD *thd, Item_sum_std *item): + Item_variance_field(thd, item) { } @@ -2703,7 +2705,8 @@ my_decimal *Item_std_field::val_decimal(my_decimal *dec_buf) } -Item_variance_field::Item_variance_field(Item_sum_variance *item) +Item_variance_field::Item_variance_field(THD *thd, Item_sum_variance *item): + Item_result_field(thd) { name=item->name; decimals=item->decimals; @@ -3147,11 +3150,11 @@ int dump_leaf_key(void* key_arg, element_count count __attribute__((unused)), */ Item_func_group_concat:: -Item_func_group_concat(Name_resolution_context *context_arg, +Item_func_group_concat(THD *thd, Name_resolution_context *context_arg, bool distinct_arg, List<Item> *select_list, const SQL_I_List<ORDER> &order_list, String *separator_arg) - :tmp_table_param(0), separator(separator_arg), tree(0), + :Item_sum(thd), tmp_table_param(0), separator(separator_arg), tree(0), unique_filter(NULL), table(0), order(0), context(context_arg), arg_count_order(order_list.elements), diff --git a/sql/item_sum.h b/sql/item_sum.h index 056c62355fb..c061d0f833b 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -381,24 +381,24 @@ protected: public: void mark_as_sum_func(); - Item_sum() :Item_func_or_sum(), quick_group(1), forced_const(FALSE) + Item_sum(THD *thd): Item_func_or_sum(thd), quick_group(1), forced_const(FALSE) { mark_as_sum_func(); init_aggregator(); } - Item_sum(Item *a) :Item_func_or_sum(a), quick_group(1), + Item_sum(THD *thd, Item *a): Item_func_or_sum(thd, a), quick_group(1), orig_args(tmp_orig_args), forced_const(FALSE) { mark_as_sum_func(); init_aggregator(); } - Item_sum(Item *a, Item *b) :Item_func_or_sum(a, b), quick_group(1), - orig_args(tmp_orig_args), forced_const(FALSE) + Item_sum(THD *thd, Item *a, Item *b): Item_func_or_sum(thd, a, b), + quick_group(1), orig_args(tmp_orig_args), forced_const(FALSE) { mark_as_sum_func(); init_aggregator(); } - Item_sum(List<Item> &list); + Item_sum(THD *thd, List<Item> &list); //Copy constructor, need to perform subselects with temporary tables Item_sum(THD *thd, Item_sum *item); enum Type type() const { return SUM_FUNC_ITEM; } @@ -431,8 +431,8 @@ public: virtual void update_field()=0; virtual bool keep_field_type(void) const { return 0; } virtual void fix_length_and_dec() { maybe_null=1; null_value=1; } - virtual Item *result_item(Field *field) - { return new Item_field(field); } + virtual Item *result_item(THD *thd, Field *field) + { return new Item_field(thd, field); } /* Return bitmap of tables that are needed to evaluate the item. @@ -694,14 +694,15 @@ protected: */ bool is_evaluated; public: - Item_sum_num() :Item_sum(),is_evaluated(FALSE) {} - Item_sum_num(Item *item_par) - :Item_sum(item_par), is_evaluated(FALSE) {} - Item_sum_num(Item *a, Item* b) :Item_sum(a,b),is_evaluated(FALSE) {} - Item_sum_num(List<Item> &list) - :Item_sum(list), is_evaluated(FALSE) {} - Item_sum_num(THD *thd, Item_sum_num *item) - :Item_sum(thd, item),is_evaluated(item->is_evaluated) {} + Item_sum_num(THD *thd): Item_sum(thd), is_evaluated(FALSE) {} + Item_sum_num(THD *thd, Item *item_par): + Item_sum(thd, item_par), is_evaluated(FALSE) {} + Item_sum_num(THD *thd, Item *a, Item* b): + Item_sum(thd, a, b), is_evaluated(FALSE) {} + Item_sum_num(THD *thd, List<Item> &list): + Item_sum(thd, list), is_evaluated(FALSE) {} + Item_sum_num(THD *thd, Item_sum_num *item): + Item_sum(thd, item),is_evaluated(item->is_evaluated) {} bool fix_fields(THD *, Item **); longlong val_int() { @@ -717,8 +718,8 @@ public: class Item_sum_int :public Item_sum_num { public: - Item_sum_int(Item *item_par) :Item_sum_num(item_par) {} - Item_sum_int(List<Item> &list) :Item_sum_num(list) {} + Item_sum_int(THD *thd, Item *item_par): Item_sum_num(thd, item_par) {} + Item_sum_int(THD *thd, List<Item> &list): Item_sum_num(thd, list) {} Item_sum_int(THD *thd, Item_sum_int *item) :Item_sum_num(thd, item) {} double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } String *val_str(String*str); @@ -739,7 +740,8 @@ protected: void fix_length_and_dec(); public: - Item_sum_sum(Item *item_par, bool distinct) :Item_sum_num(item_par) + Item_sum_sum(THD *thd, Item *item_par, bool distinct): + Item_sum_num(thd, item_par) { set_distinct(distinct); } @@ -777,8 +779,8 @@ class Item_sum_count :public Item_sum_int void cleanup(); public: - Item_sum_count(Item *item_par) - :Item_sum_int(item_par),count(0) + Item_sum_count(THD *thd, Item *item_par): + Item_sum_int(thd, item_par), count(0) {} /** @@ -789,13 +791,13 @@ class Item_sum_count :public Item_sum_int This constructor is called by the parser only for COUNT (DISTINCT). */ - Item_sum_count(List<Item> &list) - :Item_sum_int(list),count(0) + Item_sum_count(THD *thd, List<Item> &list): + Item_sum_int(thd, list), count(0) { set_distinct(TRUE); } - Item_sum_count(THD *thd, Item_sum_count *item) - :Item_sum_int(thd, item), count(item->count) + Item_sum_count(THD *thd, Item_sum_count *item): + Item_sum_int(thd, item), count(item->count) {} enum Sumfunctype sum_func () const { @@ -829,7 +831,7 @@ public: Item_result hybrid_type; uint f_precision, f_scale, dec_bin_size; uint prec_increment; - Item_avg_field(Item_result res_type, Item_sum_avg *item); + Item_avg_field(THD *thd, Item_result res_type, Item_sum_avg *item); enum Type type() const { return FIELD_AVG_ITEM; } double val_real(); longlong val_int(); @@ -856,8 +858,8 @@ public: uint prec_increment; uint f_precision, f_scale, dec_bin_size; - Item_sum_avg(Item *item_par, bool distinct) - :Item_sum_sum(item_par, distinct), count(0) + Item_sum_avg(THD *thd, Item *item_par, bool distinct): + Item_sum_sum(thd, item_par, distinct), count(0) {} Item_sum_avg(THD *thd, Item_sum_avg *item) :Item_sum_sum(thd, item), count(item->count), @@ -877,8 +879,8 @@ public: String *val_str(String *str); void reset_field(); void update_field(); - Item *result_item(Field *field) - { return new Item_avg_field(hybrid_type, this); } + Item *result_item(THD *thd, Field *field) + { return new Item_avg_field(thd, hybrid_type, this); } void no_rows_in_result() {} const char *func_name() const { @@ -905,7 +907,7 @@ public: uint dec_bin_size0, dec_bin_size1; uint sample; uint prec_increment; - Item_variance_field(Item_sum_variance *item); + Item_variance_field(THD *thd, Item_sum_variance *item); enum Type type() const {return FIELD_VARIANCE_ITEM; } double val_real(); longlong val_int() @@ -963,8 +965,9 @@ public: uint sample; uint prec_increment; - Item_sum_variance(Item *item_par, uint sample_arg) :Item_sum_num(item_par), - hybrid_type(REAL_RESULT), count(0), sample(sample_arg) + Item_sum_variance(THD *thd, Item *item_par, uint sample_arg): + Item_sum_num(thd, item_par), hybrid_type(REAL_RESULT), count(0), + sample(sample_arg) {} Item_sum_variance(THD *thd, Item_sum_variance *item); enum Sumfunctype sum_func () const { return VARIANCE_FUNC; } @@ -974,8 +977,8 @@ public: my_decimal *val_decimal(my_decimal *); void reset_field(); void update_field(); - Item *result_item(Field *field) - { return new Item_variance_field(this); } + Item *result_item(THD *thd, Field *field) + { return new Item_variance_field(thd, this); } void no_rows_in_result() {} const char *func_name() const { return sample ? "var_samp(" : "variance("; } @@ -994,7 +997,7 @@ class Item_sum_std; class Item_std_field :public Item_variance_field { public: - Item_std_field(Item_sum_std *item); + Item_std_field(THD *thd, Item_sum_std *item); enum Type type() const { return FIELD_STD_ITEM; } double val_real(); my_decimal *val_decimal(my_decimal *); @@ -1009,15 +1012,15 @@ public: class Item_sum_std :public Item_sum_variance { public: - Item_sum_std(Item *item_par, uint sample_arg) - :Item_sum_variance(item_par, sample_arg) {} + Item_sum_std(THD *thd, Item *item_par, uint sample_arg): + Item_sum_variance(thd, item_par, sample_arg) {} Item_sum_std(THD *thd, Item_sum_std *item) :Item_sum_variance(thd, item) {} enum Sumfunctype sum_func () const { return STD_FUNC; } double val_real(); - Item *result_item(Field *field) - { return new Item_std_field(this); } + Item *result_item(THD *thd, Field *field) + { return new Item_std_field(thd, this); } const char *func_name() const { return "std("; } Item *copy_or_same(THD* thd); enum Item_result result_type () const { return REAL_RESULT; } @@ -1039,8 +1042,8 @@ protected: bool was_null_value; public: - Item_sum_hybrid(Item *item_par,int sign) - :Item_sum(item_par), value(0), arg_cache(0), cmp(0), + Item_sum_hybrid(THD *thd, Item *item_par,int sign): + Item_sum(thd, item_par), value(0), arg_cache(0), cmp(0), hybrid_type(INT_RESULT), hybrid_field_type(MYSQL_TYPE_LONGLONG), cmp_sign(sign), was_values(TRUE) { collation.set(&my_charset_bin); } @@ -1050,7 +1053,7 @@ protected: cmp_sign(item->cmp_sign), was_values(item->was_values) { } bool fix_fields(THD *, Item **); - void setup_hybrid(Item *item, Item *value_arg); + void setup_hybrid(THD *thd, Item *item, Item *value_arg); void clear(); double val_real(); longlong val_int(); @@ -1077,7 +1080,7 @@ protected: class Item_sum_min :public Item_sum_hybrid { public: - Item_sum_min(Item *item_par) :Item_sum_hybrid(item_par,1) {} + Item_sum_min(THD *thd, Item *item_par): Item_sum_hybrid(thd, item_par, 1) {} Item_sum_min(THD *thd, Item_sum_min *item) :Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func () const {return MIN_FUNC;} @@ -1090,7 +1093,7 @@ public: class Item_sum_max :public Item_sum_hybrid { public: - Item_sum_max(Item *item_par) :Item_sum_hybrid(item_par,-1) {} + Item_sum_max(THD *thd, Item *item_par): Item_sum_hybrid(thd, item_par, -1) {} Item_sum_max(THD *thd, Item_sum_max *item) :Item_sum_hybrid(thd, item) {} enum Sumfunctype sum_func () const {return MAX_FUNC;} @@ -1106,8 +1109,8 @@ protected: ulonglong reset_bits,bits; public: - Item_sum_bit(Item *item_par,ulonglong reset_arg) - :Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {} + Item_sum_bit(THD *thd, Item *item_par, ulonglong reset_arg): + Item_sum_int(thd, item_par), reset_bits(reset_arg), bits(reset_arg) {} Item_sum_bit(THD *thd, Item_sum_bit *item): Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {} enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} @@ -1128,7 +1131,7 @@ public: class Item_sum_or :public Item_sum_bit { public: - Item_sum_or(Item *item_par) :Item_sum_bit(item_par, 0) {} + Item_sum_or(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {} Item_sum_or(THD *thd, Item_sum_or *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_or("; } @@ -1139,7 +1142,8 @@ public: class Item_sum_and :public Item_sum_bit { public: - Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {} + Item_sum_and(THD *thd, Item *item_par): + Item_sum_bit(thd, item_par, ULONGLONG_MAX) {} Item_sum_and(THD *thd, Item_sum_and *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_and("; } @@ -1149,7 +1153,7 @@ class Item_sum_and :public Item_sum_bit class Item_sum_xor :public Item_sum_bit { public: - Item_sum_xor(Item *item_par) :Item_sum_bit(item_par, 0) {} + Item_sum_xor(THD *thd, Item *item_par): Item_sum_bit(thd, item_par, 0) {} Item_sum_xor(THD *thd, Item_sum_xor *item) :Item_sum_bit(thd, item) {} bool add(); const char *func_name() const { return "bit_xor("; } @@ -1169,11 +1173,11 @@ protected: udf_handler udf; public: - Item_udf_sum(udf_func *udf_arg) - :Item_sum(), udf(udf_arg) + Item_udf_sum(THD *thd, udf_func *udf_arg): + Item_sum(thd), udf(udf_arg) { quick_group=0; } - Item_udf_sum(udf_func *udf_arg, List<Item> &list) - :Item_sum(list), udf(udf_arg) + Item_udf_sum(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_sum(thd, list), udf(udf_arg) { quick_group=0;} Item_udf_sum(THD *thd, Item_udf_sum *item) :Item_sum(thd, item), udf(item->udf) @@ -1208,10 +1212,10 @@ public: class Item_sum_udf_float :public Item_udf_sum { public: - Item_sum_udf_float(udf_func *udf_arg) - :Item_udf_sum(udf_arg) {} - Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) - :Item_udf_sum(udf_arg, list) {} + Item_sum_udf_float(THD *thd, udf_func *udf_arg): + Item_udf_sum(thd, udf_arg) {} + Item_sum_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_sum(thd, udf_arg, list) {} Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) :Item_udf_sum(thd, item) {} longlong val_int() @@ -1230,10 +1234,10 @@ class Item_sum_udf_float :public Item_udf_sum class Item_sum_udf_int :public Item_udf_sum { public: - Item_sum_udf_int(udf_func *udf_arg) - :Item_udf_sum(udf_arg) {} - Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) - :Item_udf_sum(udf_arg, list) {} + Item_sum_udf_int(THD *thd, udf_func *udf_arg): + Item_udf_sum(thd, udf_arg) {} + Item_sum_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_sum(thd, udf_arg, list) {} Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) :Item_udf_sum(thd, item) {} longlong val_int(); @@ -1250,10 +1254,10 @@ public: class Item_sum_udf_str :public Item_udf_sum { public: - Item_sum_udf_str(udf_func *udf_arg) - :Item_udf_sum(udf_arg) {} - Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) - :Item_udf_sum(udf_arg,list) {} + Item_sum_udf_str(THD *thd, udf_func *udf_arg): + Item_udf_sum(thd, udf_arg) {} + Item_sum_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_sum(thd, udf_arg, list) {} Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) :Item_udf_sum(thd, item) {} String *val_str(String *); @@ -1289,10 +1293,10 @@ public: class Item_sum_udf_decimal :public Item_udf_sum { public: - Item_sum_udf_decimal(udf_func *udf_arg) - :Item_udf_sum(udf_arg) {} - Item_sum_udf_decimal(udf_func *udf_arg, List<Item> &list) - :Item_udf_sum(udf_arg, list) {} + Item_sum_udf_decimal(THD *thd, udf_func *udf_arg): + Item_udf_sum(thd, udf_arg) {} + Item_sum_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_udf_sum(thd, udf_arg, list) {} Item_sum_udf_decimal(THD *thd, Item_sum_udf_decimal *item) :Item_udf_sum(thd, item) {} String *val_str(String *); @@ -1309,9 +1313,10 @@ public: class Item_sum_udf_float :public Item_sum_num { public: - Item_sum_udf_float(udf_func *udf_arg) - :Item_sum_num() {} - Item_sum_udf_float(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {} + Item_sum_udf_float(THD *thd, udf_func *udf_arg): + Item_sum_num(thd) {} + Item_sum_udf_float(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_sum_num(thd) {} Item_sum_udf_float(THD *thd, Item_sum_udf_float *item) :Item_sum_num(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } @@ -1325,9 +1330,10 @@ class Item_sum_udf_float :public Item_sum_num class Item_sum_udf_int :public Item_sum_num { public: - Item_sum_udf_int(udf_func *udf_arg) - :Item_sum_num() {} - Item_sum_udf_int(udf_func *udf_arg, List<Item> &list) :Item_sum_num() {} + Item_sum_udf_int(THD *thd, udf_func *udf_arg): + Item_sum_num(thd) {} + Item_sum_udf_int(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_sum_num(thd) {} Item_sum_udf_int(THD *thd, Item_sum_udf_int *item) :Item_sum_num(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } @@ -1342,10 +1348,10 @@ public: class Item_sum_udf_decimal :public Item_sum_num { public: - Item_sum_udf_decimal(udf_func *udf_arg) - :Item_sum_num() {} - Item_sum_udf_decimal(udf_func *udf_arg, List<Item> &list) - :Item_sum_num() {} + Item_sum_udf_decimal(THD *thd, udf_func *udf_arg): + Item_sum_num(thd) {} + Item_sum_udf_decimal(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_sum_num(thd) {} Item_sum_udf_decimal(THD *thd, Item_sum_udf_float *item) :Item_sum_num(thd, item) {} enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } @@ -1360,10 +1366,10 @@ class Item_sum_udf_decimal :public Item_sum_num class Item_sum_udf_str :public Item_sum_num { public: - Item_sum_udf_str(udf_func *udf_arg) - :Item_sum_num() {} - Item_sum_udf_str(udf_func *udf_arg, List<Item> &list) - :Item_sum_num() {} + Item_sum_udf_str(THD *thd, udf_func *udf_arg): + Item_sum_num(thd) {} + Item_sum_udf_str(THD *thd, udf_func *udf_arg, List<Item> &list): + Item_sum_num(thd) {} Item_sum_udf_str(THD *thd, Item_sum_udf_str *item) :Item_sum_num(thd, item) {} String *val_str(String *) @@ -1434,7 +1440,7 @@ class Item_func_group_concat : public Item_sum void* item_arg); public: - Item_func_group_concat(Name_resolution_context *context_arg, + Item_func_group_concat(THD *thd, Name_resolution_context *context_arg, bool is_distinct, List<Item> *is_select, const SQL_I_List<ORDER> &is_order, String *is_separator); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index e7a37ed7bb1..edc77038f89 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -46,7 +46,7 @@ bool get_interval_value(Item *args,interval_type int_type, INTERVAL *interval); class Item_func_period_add :public Item_int_func { public: - Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_period_add(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "period_add"; } void fix_length_and_dec() @@ -59,7 +59,7 @@ public: class Item_func_period_diff :public Item_int_func { public: - Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_period_diff(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "period_diff"; } void fix_length_and_dec() @@ -73,7 +73,7 @@ public: class Item_func_to_days :public Item_int_func { public: - Item_func_to_days(Item *a) :Item_int_func(a) {} + Item_func_to_days(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "to_days"; } void fix_length_and_dec() @@ -96,7 +96,7 @@ public: class Item_func_to_seconds :public Item_int_func { public: - Item_func_to_seconds(Item *a) :Item_int_func(a) {} + Item_func_to_seconds(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "to_seconds"; } void fix_length_and_dec() @@ -129,7 +129,7 @@ public: class Item_func_dayofmonth :public Item_int_func { public: - Item_func_dayofmonth(Item *a) :Item_int_func(a) {} + Item_func_dayofmonth(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "dayofmonth"; } void fix_length_and_dec() @@ -150,7 +150,8 @@ public: class Item_func_month :public Item_func { public: - Item_func_month(Item *a) :Item_func(a) { collation.set_numeric(); } + Item_func_month(THD *thd, Item *a): Item_func(thd, a) + { collation.set_numeric(); } longlong val_int(); double val_real() { DBUG_ASSERT(fixed == 1); return (double) Item_func_month::val_int(); } @@ -183,7 +184,7 @@ class Item_func_monthname :public Item_str_func { MY_LOCALE *locale; public: - Item_func_monthname(Item *a) :Item_str_func(a) {} + Item_func_monthname(THD *thd, Item *a): Item_str_func(thd, a) {} const char *func_name() const { return "monthname"; } String *val_str(String *str); void fix_length_and_dec(); @@ -199,7 +200,7 @@ public: class Item_func_dayofyear :public Item_int_func { public: - Item_func_dayofyear(Item *a) :Item_int_func(a) {} + Item_func_dayofyear(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "dayofyear"; } void fix_length_and_dec() @@ -220,7 +221,7 @@ public: class Item_func_hour :public Item_int_func { public: - Item_func_hour(Item *a) :Item_int_func(a) {} + Item_func_hour(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "hour"; } void fix_length_and_dec() @@ -241,7 +242,7 @@ public: class Item_func_minute :public Item_int_func { public: - Item_func_minute(Item *a) :Item_int_func(a) {} + Item_func_minute(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "minute"; } void fix_length_and_dec() @@ -262,7 +263,7 @@ public: class Item_func_quarter :public Item_int_func { public: - Item_func_quarter(Item *a) :Item_int_func(a) {} + Item_func_quarter(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "quarter"; } void fix_length_and_dec() @@ -283,7 +284,7 @@ public: class Item_func_second :public Item_int_func { public: - Item_func_second(Item *a) :Item_int_func(a) {} + Item_func_second(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "second"; } void fix_length_and_dec() @@ -304,7 +305,7 @@ public: class Item_func_week :public Item_int_func { public: - Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_week(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "week"; } void fix_length_and_dec() @@ -318,7 +319,7 @@ public: class Item_func_yearweek :public Item_int_func { public: - Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {} + Item_func_yearweek(THD *thd, Item *a, Item *b): Item_int_func(thd, a, b) {} longlong val_int(); const char *func_name() const { return "yearweek"; } void fix_length_and_dec() @@ -339,7 +340,7 @@ public: class Item_func_year :public Item_int_func { public: - Item_func_year(Item *a) :Item_int_func(a) {} + Item_func_year(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "year"; } enum_monotonicity_info get_monotonicity_info() const; @@ -363,8 +364,8 @@ class Item_func_weekday :public Item_func { bool odbc_type; public: - Item_func_weekday(Item *a,bool type_arg) - :Item_func(a), odbc_type(type_arg) { collation.set_numeric(); } + Item_func_weekday(THD *thd, Item *a, bool type_arg): + Item_func(thd, a), odbc_type(type_arg) { collation.set_numeric(); } longlong val_int(); double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); } String *val_str(String *str) @@ -396,7 +397,7 @@ class Item_func_dayname :public Item_func_weekday { MY_LOCALE *locale; public: - Item_func_dayname(Item *a) :Item_func_weekday(a,0) {} + Item_func_dayname(THD *thd, Item *a): Item_func_weekday(thd, a, 0) {} const char *func_name() const { return "dayname"; } String *val_str(String *str); enum Item_result result_type () const { return STRING_RESULT; } @@ -411,8 +412,8 @@ class Item_func_seconds_hybrid: public Item_func_numhybrid protected: virtual enum_field_types arg0_expected_type() const = 0; public: - Item_func_seconds_hybrid() :Item_func_numhybrid() {} - Item_func_seconds_hybrid(Item *a) :Item_func_numhybrid(a) {} + Item_func_seconds_hybrid(THD *thd): Item_func_numhybrid(thd) {} + Item_func_seconds_hybrid(THD *thd, Item *a): Item_func_numhybrid(thd, a) {} void fix_length_and_dec() { if (arg_count) @@ -434,8 +435,9 @@ class Item_func_unix_timestamp :public Item_func_seconds_hybrid protected: enum_field_types arg0_expected_type() const { return MYSQL_TYPE_DATETIME; } public: - Item_func_unix_timestamp() :Item_func_seconds_hybrid() {} - Item_func_unix_timestamp(Item *a) :Item_func_seconds_hybrid(a) {} + Item_func_unix_timestamp(THD *thd): Item_func_seconds_hybrid(thd) {} + Item_func_unix_timestamp(THD *thd, Item *a): + Item_func_seconds_hybrid(thd, a) {} const char *func_name() const { return "unix_timestamp"; } enum_monotonicity_info get_monotonicity_info() const; longlong val_int_endpoint(bool left_endp, bool *incl_endp); @@ -467,7 +469,8 @@ class Item_func_time_to_sec :public Item_func_seconds_hybrid protected: enum_field_types arg0_expected_type() const { return MYSQL_TYPE_TIME; } public: - Item_func_time_to_sec(Item *item) :Item_func_seconds_hybrid(item) {} + Item_func_time_to_sec(THD *thd, Item *item): + Item_func_seconds_hybrid(thd, item) {} const char *func_name() const { return "time_to_sec"; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} bool check_vcol_func_processor(uchar *int_arg) { return FALSE;} @@ -484,10 +487,10 @@ class Item_temporal_func: public Item_func { ulonglong sql_mode; public: - Item_temporal_func() :Item_func() {} - Item_temporal_func(Item *a) :Item_func(a) {} - Item_temporal_func(Item *a, Item *b) :Item_func(a,b) {} - Item_temporal_func(Item *a, Item *b, Item *c) :Item_func(a,b,c) {} + Item_temporal_func(THD *thd): Item_func(thd) {} + Item_temporal_func(THD *thd, Item *a): Item_func(thd, a) {} + Item_temporal_func(THD *thd, Item *a, Item *b): Item_func(thd, a, b) {} + Item_temporal_func(THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b, c) {} enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } Item_result cmp_type() const { return TIME_RESULT; } @@ -515,8 +518,8 @@ protected: enum_field_types cached_field_type; // TIME, DATE, DATETIME or STRING String ascii_buf; // Conversion buffer public: - Item_temporal_hybrid_func(Item *a,Item *b) - :Item_temporal_func(a,b) {} + Item_temporal_hybrid_func(THD *thd, Item *a, Item *b): + Item_temporal_func(thd, a, b) {} enum_field_types field_type() const { return cached_field_type; } Item_result cmp_type() const { @@ -557,8 +560,8 @@ public: class Item_datefunc :public Item_temporal_func { public: - Item_datefunc() :Item_temporal_func() { } - Item_datefunc(Item *a) :Item_temporal_func(a) { } + Item_datefunc(THD *thd): Item_temporal_func(thd) { } + Item_datefunc(THD *thd, Item *a): Item_temporal_func(thd, a) { } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } }; @@ -566,10 +569,11 @@ public: class Item_timefunc :public Item_temporal_func { public: - Item_timefunc() :Item_temporal_func() {} - Item_timefunc(Item *a) :Item_temporal_func(a) {} - Item_timefunc(Item *a,Item *b) :Item_temporal_func(a,b) {} - Item_timefunc(Item *a, Item *b, Item *c) :Item_temporal_func(a, b ,c) {} + Item_timefunc(THD *thd): Item_temporal_func(thd) {} + Item_timefunc(THD *thd, Item *a): Item_temporal_func(thd, a) {} + Item_timefunc(THD *thd, Item *a, Item *b): Item_temporal_func(thd, a, b) {} + Item_timefunc(THD *thd, Item *a, Item *b, Item *c): + Item_temporal_func(thd, a, b ,c) {} enum_field_types field_type() const { return MYSQL_TYPE_TIME; } }; @@ -580,7 +584,7 @@ class Item_func_curtime :public Item_timefunc { MYSQL_TIME ltime; public: - Item_func_curtime(uint dec) :Item_timefunc() { decimals= dec; } + Item_func_curtime(THD *thd, uint dec): Item_timefunc(thd) { decimals= dec; } bool fix_fields(THD *, Item **); void fix_length_and_dec() { @@ -605,7 +609,7 @@ public: class Item_func_curtime_local :public Item_func_curtime { public: - Item_func_curtime_local(uint dec) :Item_func_curtime(dec) {} + Item_func_curtime_local(THD *thd, uint dec): Item_func_curtime(thd, dec) {} const char *func_name() const { return "curtime"; } virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -614,7 +618,7 @@ public: class Item_func_curtime_utc :public Item_func_curtime { public: - Item_func_curtime_utc(uint dec) :Item_func_curtime(dec) {} + Item_func_curtime_utc(THD *thd, uint dec): Item_func_curtime(thd, dec) {} const char *func_name() const { return "utc_time"; } virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -626,7 +630,7 @@ class Item_func_curdate :public Item_datefunc { MYSQL_TIME ltime; public: - Item_func_curdate() :Item_datefunc() {} + Item_func_curdate(THD *thd): Item_datefunc(thd) {} void fix_length_and_dec(); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); virtual void store_now_in_TIME(MYSQL_TIME *now_time)=0; @@ -640,7 +644,7 @@ public: class Item_func_curdate_local :public Item_func_curdate { public: - Item_func_curdate_local() :Item_func_curdate() {} + Item_func_curdate_local(THD *thd): Item_func_curdate(thd) {} const char *func_name() const { return "curdate"; } void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -649,7 +653,7 @@ public: class Item_func_curdate_utc :public Item_func_curdate { public: - Item_func_curdate_utc() :Item_func_curdate() {} + Item_func_curdate_utc(THD *thd): Item_func_curdate(thd) {} const char *func_name() const { return "utc_date"; } void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -662,7 +666,7 @@ class Item_func_now :public Item_temporal_func { MYSQL_TIME ltime; public: - Item_func_now(uint dec) :Item_temporal_func() { decimals= dec; } + Item_func_now(THD *thd, uint dec): Item_temporal_func(thd) { decimals= dec; } bool fix_fields(THD *, Item **); void fix_length_and_dec() { @@ -682,7 +686,7 @@ public: class Item_func_now_local :public Item_func_now { public: - Item_func_now_local(uint dec) :Item_func_now(dec) {} + Item_func_now_local(THD *thd, uint dec): Item_func_now(thd, dec) {} const char *func_name() const { return "now"; } virtual void store_now_in_TIME(MYSQL_TIME *now_time); virtual enum Functype functype() const { return NOW_FUNC; } @@ -692,7 +696,7 @@ public: class Item_func_now_utc :public Item_func_now { public: - Item_func_now_utc(uint dec) :Item_func_now(dec) {} + Item_func_now_utc(THD *thd, uint dec): Item_func_now(thd, dec) {} const char *func_name() const { return "utc_timestamp"; } virtual void store_now_in_TIME(MYSQL_TIME *now_time); }; @@ -705,7 +709,7 @@ public: class Item_func_sysdate_local :public Item_func_now { public: - Item_func_sysdate_local(uint dec) :Item_func_now(dec) {} + Item_func_sysdate_local(THD *thd, uint dec): Item_func_now(thd, dec) {} bool const_item() const { return 0; } const char *func_name() const { return "sysdate"; } void store_now_in_TIME(MYSQL_TIME *now_time); @@ -722,7 +726,7 @@ public: class Item_func_from_days :public Item_datefunc { public: - Item_func_from_days(Item *a) :Item_datefunc(a) {} + Item_func_from_days(THD *thd, Item *a): Item_datefunc(thd, a) {} const char *func_name() const { return "from_days"; } bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} @@ -741,8 +745,8 @@ class Item_func_date_format :public Item_str_func const bool is_time_format; String value; public: - Item_func_date_format(Item *a,Item *b,bool is_time_format_arg) - :Item_str_func(a,b),is_time_format(is_time_format_arg) {} + Item_func_date_format(THD *thd, Item *a, Item *b, bool is_time_format_arg): + Item_str_func(thd, a, b), is_time_format(is_time_format_arg) {} String *val_str(String *str); const char *func_name() const { return is_time_format ? "time_format" : "date_format"; } @@ -756,7 +760,7 @@ class Item_func_from_unixtime :public Item_temporal_func { Time_zone *tz; public: - Item_func_from_unixtime(Item *a) :Item_temporal_func(a) {} + Item_func_from_unixtime(THD *thd, Item *a): Item_temporal_func(thd, a) {} const char *func_name() const { return "from_unixtime"; } void fix_length_and_dec(); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); @@ -788,8 +792,8 @@ class Item_func_convert_tz :public Item_temporal_func bool from_tz_cached, to_tz_cached; Time_zone *from_tz, *to_tz; public: - Item_func_convert_tz(Item *a, Item *b, Item *c): - Item_temporal_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {} + Item_func_convert_tz(THD *thd, Item *a, Item *b, Item *c): + Item_temporal_func(thd, a, b, c), from_tz_cached(0), to_tz_cached(0) {} const char *func_name() const { return "convert_tz"; } void fix_length_and_dec(); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); @@ -800,7 +804,7 @@ class Item_func_convert_tz :public Item_temporal_func class Item_func_sec_to_time :public Item_timefunc { public: - Item_func_sec_to_time(Item *item) :Item_timefunc(item) {} + Item_func_sec_to_time(THD *thd, Item *item): Item_timefunc(thd, item) {} bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); void fix_length_and_dec() { @@ -816,8 +820,10 @@ class Item_date_add_interval :public Item_temporal_hybrid_func public: const interval_type int_type; // keep it public const bool date_sub_interval; // keep it public - Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg) - :Item_temporal_hybrid_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {} + Item_date_add_interval(THD *thd, Item *a, Item *b, interval_type type_arg, + bool neg_arg): + Item_temporal_hybrid_func(thd, a, b),int_type(type_arg), + date_sub_interval(neg_arg) {} const char *func_name() const { return "date_add_interval"; } void fix_length_and_dec(); bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); @@ -831,8 +837,8 @@ class Item_extract :public Item_int_func bool date_value; public: const interval_type int_type; // keep it public - Item_extract(interval_type type_arg, Item *a) - :Item_int_func(a), int_type(type_arg) {} + Item_extract(THD *thd, interval_type type_arg, Item *a): + Item_int_func(thd, a), int_type(type_arg) {} longlong val_int(); enum Functype functype() const { return EXTRACT_FUNC; } const char *func_name() const { return "extract"; } @@ -892,8 +898,8 @@ class Item_char_typecast :public Item_str_func uint adjusted_length_with_warn(uint length); void check_truncation_with_warn(String *src, uint dstlen); public: - Item_char_typecast(Item *a, uint length_arg, CHARSET_INFO *cs_arg) - :Item_str_func(a), cast_length(length_arg), cast_cs(cs_arg) {} + Item_char_typecast(THD *thd, Item *a, uint length_arg, CHARSET_INFO *cs_arg): + Item_str_func(thd, a), cast_length(length_arg), cast_cs(cs_arg) {} enum Functype functype() const { return CHAR_TYPECAST_FUNC; } bool eq(const Item *item, bool binary_cmp) const; const char *func_name() const { return "cast_as_char"; } @@ -906,7 +912,7 @@ public: class Item_temporal_typecast: public Item_temporal_func { public: - Item_temporal_typecast(Item *a) :Item_temporal_func(a) {} + Item_temporal_typecast(THD *thd, Item *a): Item_temporal_func(thd, a) {} virtual const char *cast_type() const = 0; void print(String *str, enum_query_type query_type); void fix_length_and_dec() @@ -920,7 +926,7 @@ public: class Item_date_typecast :public Item_temporal_typecast { public: - Item_date_typecast(Item *a) :Item_temporal_typecast(a) {} + Item_date_typecast(THD *thd, Item *a): Item_temporal_typecast(thd, a) {} const char *func_name() const { return "cast_as_date"; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); const char *cast_type() const { return "date"; } @@ -931,8 +937,8 @@ public: class Item_time_typecast :public Item_temporal_typecast { public: - Item_time_typecast(Item *a, uint dec_arg) - :Item_temporal_typecast(a) { decimals= dec_arg; } + Item_time_typecast(THD *thd, Item *a, uint dec_arg): + Item_temporal_typecast(thd, a) { decimals= dec_arg; } const char *func_name() const { return "cast_as_time"; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); const char *cast_type() const { return "time"; } @@ -943,8 +949,8 @@ public: class Item_datetime_typecast :public Item_temporal_typecast { public: - Item_datetime_typecast(Item *a, uint dec_arg) - :Item_temporal_typecast(a) { decimals= dec_arg; } + Item_datetime_typecast(THD *thd, Item *a, uint dec_arg): + Item_temporal_typecast(thd, a) { decimals= dec_arg; } const char *func_name() const { return "cast_as_datetime"; } const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } @@ -955,7 +961,8 @@ public: class Item_func_makedate :public Item_temporal_func { public: - Item_func_makedate(Item *a,Item *b) :Item_temporal_func(a,b) {} + Item_func_makedate(THD *thd, Item *a, Item *b): + Item_temporal_func(thd, a, b) {} const char *func_name() const { return "makedate"; } enum_field_types field_type() const { return MYSQL_TYPE_DATE; } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); @@ -968,8 +975,9 @@ class Item_func_add_time :public Item_temporal_hybrid_func int sign; public: - Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg) - :Item_temporal_hybrid_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; } + Item_func_add_time(THD *thd, Item *a, Item *b, bool type_arg, bool neg_arg): + Item_temporal_hybrid_func(thd, a, b), is_date(type_arg) + { sign= neg_arg ? -1 : 1; } void fix_length_and_dec(); bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); void print(String *str, enum_query_type query_type); @@ -979,8 +987,7 @@ public: class Item_func_timediff :public Item_timefunc { public: - Item_func_timediff(Item *a, Item *b) - :Item_timefunc(a, b) {} + Item_func_timediff(THD *thd, Item *a, Item *b): Item_timefunc(thd, a, b) {} const char *func_name() const { return "timediff"; } void fix_length_and_dec() { @@ -994,8 +1001,8 @@ public: class Item_func_maketime :public Item_timefunc { public: - Item_func_maketime(Item *a, Item *b, Item *c) - :Item_timefunc(a, b, c) + Item_func_maketime(THD *thd, Item *a, Item *b, Item *c): + Item_timefunc(thd, a, b, c) {} void fix_length_and_dec() { @@ -1010,7 +1017,7 @@ public: class Item_func_microsecond :public Item_int_func { public: - Item_func_microsecond(Item *a) :Item_int_func(a) {} + Item_func_microsecond(THD *thd, Item *a): Item_int_func(thd, a) {} longlong val_int(); const char *func_name() const { return "microsecond"; } void fix_length_and_dec() @@ -1031,8 +1038,8 @@ class Item_func_timestamp_diff :public Item_int_func { const interval_type int_type; public: - Item_func_timestamp_diff(Item *a,Item *b,interval_type type_arg) - :Item_int_func(a,b), int_type(type_arg) {} + Item_func_timestamp_diff(THD *thd, Item *a, Item *b, interval_type type_arg): + Item_int_func(thd, a, b), int_type(type_arg) {} const char *func_name() const { return "timestampdiff"; } longlong val_int(); void fix_length_and_dec() @@ -1053,8 +1060,8 @@ class Item_func_get_format :public Item_str_ascii_func { public: const timestamp_type type; // keep it public - Item_func_get_format(timestamp_type type_arg, Item *a) - :Item_str_ascii_func(a), type(type_arg) + Item_func_get_format(THD *thd, timestamp_type type_arg, Item *a): + Item_str_ascii_func(thd, a), type(type_arg) {} String *val_str_ascii(String *str); const char *func_name() const { return "get_format"; } @@ -1076,8 +1083,8 @@ class Item_func_str_to_date :public Item_temporal_hybrid_func String format_converter; CHARSET_INFO *internal_charset; public: - Item_func_str_to_date(Item *a, Item *b) - :Item_temporal_hybrid_func(a, b), const_item(false), + Item_func_str_to_date(THD *thd, Item *a, Item *b): + Item_temporal_hybrid_func(thd, a, b), const_item(false), internal_charset(NULL) {} bool get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date); @@ -1089,7 +1096,7 @@ public: class Item_func_last_day :public Item_datefunc { public: - Item_func_last_day(Item *a) :Item_datefunc(a) {} + Item_func_last_day(THD *thd, Item *a): Item_datefunc(thd, a) {} const char *func_name() const { return "last_day"; } bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date); }; diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 94925216dd7..1508c501c06 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -99,6 +99,7 @@ typedef struct my_xpath_function_names_st /* XPath query parser */ typedef struct my_xpath_st { + THD *thd; int debug; MY_XPATH_LEX query; /* Whole query */ MY_XPATH_LEX lasttok; /* last scanned token */ @@ -166,13 +167,14 @@ protected: public: String *pxml; String context_cache; - Item_nodeset_func(String *pxml_arg) :Item_str_func(), pxml(pxml_arg) {} - Item_nodeset_func(Item *a, String *pxml_arg) - :Item_str_func(a), pxml(pxml_arg) {} - Item_nodeset_func(Item *a, Item *b, String *pxml_arg) - :Item_str_func(a, b), pxml(pxml_arg) {} - Item_nodeset_func(Item *a, Item *b, Item *c, String *pxml_arg) - :Item_str_func(a,b,c), pxml(pxml_arg) {} + Item_nodeset_func(THD *thd, String *pxml_arg): + Item_str_func(thd), pxml(pxml_arg) {} + Item_nodeset_func(THD *thd, Item *a, String *pxml_arg): + Item_str_func(thd, a), pxml(pxml_arg) {} + Item_nodeset_func(THD *thd, Item *a, Item *b, String *pxml_arg): + Item_str_func(thd, a, b), pxml(pxml_arg) {} + Item_nodeset_func(THD *thd, Item *a, Item *b, Item *c, String *pxml_arg): + Item_str_func(thd, a, b, c), pxml(pxml_arg) {} void prepare_nodes() { nodebeg= (MY_XML_NODE*) pxml->ptr(); @@ -244,7 +246,8 @@ public: class Item_nodeset_func_rootelement :public Item_nodeset_func { public: - Item_nodeset_func_rootelement(String *pxml): Item_nodeset_func(pxml) {} + Item_nodeset_func_rootelement(THD *thd, String *pxml): + Item_nodeset_func(thd, pxml) {} const char *func_name() const { return "xpath_rootelement"; } String *val_nodeset(String *nodeset); }; @@ -254,8 +257,8 @@ public: class Item_nodeset_func_union :public Item_nodeset_func { public: - Item_nodeset_func_union(Item *a, Item *b, String *pxml) - :Item_nodeset_func(a, b, pxml) {} + Item_nodeset_func_union(THD *thd, Item *a, Item *b, String *pxml): + Item_nodeset_func(thd, a, b, pxml) {} const char *func_name() const { return "xpath_union"; } String *val_nodeset(String *nodeset); }; @@ -267,9 +270,9 @@ class Item_nodeset_func_axisbyname :public Item_nodeset_func const char *node_name; uint node_namelen; public: - Item_nodeset_func_axisbyname(Item *a, const char *n_arg, uint l_arg, - String *pxml): - Item_nodeset_func(a, pxml), node_name(n_arg), node_namelen(l_arg) { } + Item_nodeset_func_axisbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, + String *pxml): + Item_nodeset_func(thd, a, pxml), node_name(n_arg), node_namelen(l_arg) { } const char *func_name() const { return "xpath_axisbyname"; } bool validname(MY_XML_NODE *n) { @@ -285,9 +288,9 @@ public: class Item_nodeset_func_selfbyname: public Item_nodeset_func_axisbyname { public: - Item_nodeset_func_selfbyname(Item *a, const char *n_arg, uint l_arg, - String *pxml): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml) {} + Item_nodeset_func_selfbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, + String *pxml): + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {} const char *func_name() const { return "xpath_selfbyname"; } String *val_nodeset(String *nodeset); }; @@ -297,9 +300,9 @@ public: class Item_nodeset_func_childbyname: public Item_nodeset_func_axisbyname { public: - Item_nodeset_func_childbyname(Item *a, const char *n_arg, uint l_arg, + Item_nodeset_func_childbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, String *pxml): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml) {} + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {} const char *func_name() const { return "xpath_childbyname"; } String *val_nodeset(String *nodeset); }; @@ -310,9 +313,9 @@ class Item_nodeset_func_descendantbyname: public Item_nodeset_func_axisbyname { bool need_self; public: - Item_nodeset_func_descendantbyname(Item *a, const char *n_arg, uint l_arg, - String *pxml, bool need_self_arg): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml), + Item_nodeset_func_descendantbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, + String *pxml, bool need_self_arg): + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml), need_self(need_self_arg) {} const char *func_name() const { return "xpath_descendantbyname"; } String *val_nodeset(String *nodeset); @@ -324,9 +327,9 @@ class Item_nodeset_func_ancestorbyname: public Item_nodeset_func_axisbyname { bool need_self; public: - Item_nodeset_func_ancestorbyname(Item *a, const char *n_arg, uint l_arg, - String *pxml, bool need_self_arg): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml), + Item_nodeset_func_ancestorbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, + String *pxml, bool need_self_arg): + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml), need_self(need_self_arg) {} const char *func_name() const { return "xpath_ancestorbyname"; } String *val_nodeset(String *nodeset); @@ -337,9 +340,9 @@ public: class Item_nodeset_func_parentbyname: public Item_nodeset_func_axisbyname { public: - Item_nodeset_func_parentbyname(Item *a, const char *n_arg, uint l_arg, - String *pxml): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml) {} + Item_nodeset_func_parentbyname(THD *thd, Item *a, const char *n_arg, uint l_arg, + String *pxml): + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {} const char *func_name() const { return "xpath_parentbyname"; } String *val_nodeset(String *nodeset); }; @@ -349,9 +352,9 @@ public: class Item_nodeset_func_attributebyname: public Item_nodeset_func_axisbyname { public: - Item_nodeset_func_attributebyname(Item *a, const char *n_arg, uint l_arg, - String *pxml): - Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml) {} + Item_nodeset_func_attributebyname(THD *thd, Item *a, const char *n_arg, + uint l_arg, String *pxml): + Item_nodeset_func_axisbyname(thd, a, n_arg, l_arg, pxml) {} const char *func_name() const { return "xpath_attributebyname"; } String *val_nodeset(String *nodeset); }; @@ -365,8 +368,8 @@ public: class Item_nodeset_func_predicate :public Item_nodeset_func { public: - Item_nodeset_func_predicate(Item *a, Item *b, String *pxml): - Item_nodeset_func(a, b, pxml) {} + Item_nodeset_func_predicate(THD *thd, Item *a, Item *b, String *pxml): + Item_nodeset_func(thd, a, b, pxml) {} const char *func_name() const { return "xpath_predicate"; } String *val_nodeset(String *nodeset); }; @@ -376,8 +379,8 @@ public: class Item_nodeset_func_elementbyindex :public Item_nodeset_func { public: - Item_nodeset_func_elementbyindex(Item *a, Item *b, String *pxml): - Item_nodeset_func(a, b, pxml) { } + Item_nodeset_func_elementbyindex(THD *thd, Item *a, Item *b, String *pxml): + Item_nodeset_func(thd, a, b, pxml) { } const char *func_name() const { return "xpath_elementbyindex"; } String *val_nodeset(String *nodeset); }; @@ -390,7 +393,7 @@ public: class Item_bool :public Item_int { public: - Item_bool(int32 i): Item_int(i) {} + Item_bool(THD *thd, int32 i): Item_int(thd, i) {} const char *func_name() const { return "xpath_bool"; } bool is_bool_type() { return true; } }; @@ -407,8 +410,8 @@ class Item_xpath_cast_bool :public Item_bool_func String *pxml; String tmp_value; public: - Item_xpath_cast_bool(Item *a, String *pxml_arg) - :Item_bool_func(a), pxml(pxml_arg) {} + Item_xpath_cast_bool(THD *thd, Item *a, String *pxml_arg): + Item_bool_func(thd, a), pxml(pxml_arg) {} const char *func_name() const { return "xpath_cast_bool"; } longlong val_int() { @@ -428,7 +431,7 @@ public: class Item_xpath_cast_number :public Item_real_func { public: - Item_xpath_cast_number(Item *a): Item_real_func(a) {} + Item_xpath_cast_number(THD *thd, Item *a): Item_real_func(thd, a) {} const char *func_name() const { return "xpath_cast_number"; } virtual double val_real() { return args[0]->val_real(); } }; @@ -441,8 +444,8 @@ class Item_nodeset_context_cache :public Item_nodeset_func { public: String *string_cache; - Item_nodeset_context_cache(String *str_arg, String *pxml): - Item_nodeset_func(pxml), string_cache(str_arg) { } + Item_nodeset_context_cache(THD *thd, String *str_arg, String *pxml): + Item_nodeset_func(thd, pxml), string_cache(str_arg) { } String *val_nodeset(String *res) { return string_cache; } void fix_length_and_dec() { max_length= MAX_BLOB_WIDTH; } @@ -454,8 +457,8 @@ class Item_func_xpath_position :public Item_int_func String *pxml; String tmp_value; public: - Item_func_xpath_position(Item *a, String *p) - :Item_int_func(a), pxml(p) {} + Item_func_xpath_position(THD *thd, Item *a, String *p): + Item_int_func(thd, a), pxml(p) {} const char *func_name() const { return "xpath_position"; } void fix_length_and_dec() { max_length=10; } longlong val_int() @@ -473,8 +476,8 @@ class Item_func_xpath_count :public Item_int_func String *pxml; String tmp_value; public: - Item_func_xpath_count(Item *a, String *p) - :Item_int_func(a), pxml(p) {} + Item_func_xpath_count(THD *thd, Item *a, String *p): + Item_int_func(thd, a), pxml(p) {} const char *func_name() const { return "xpath_count"; } void fix_length_and_dec() { max_length=10; } longlong val_int() @@ -494,8 +497,8 @@ class Item_func_xpath_sum :public Item_real_func String *pxml; String tmp_value; public: - Item_func_xpath_sum(Item *a, String *p) - :Item_real_func(a), pxml(p) {} + Item_func_xpath_sum(THD *thd, Item *a, String *p): + Item_real_func(thd, a), pxml(p) {} const char *func_name() const { return "xpath_sum"; } double val_real() @@ -538,8 +541,9 @@ public: class Item_string_xml_non_const: public Item_string { public: - Item_string_xml_non_const(const char *str, uint length, CHARSET_INFO *cs) - :Item_string(str, length, cs) + Item_string_xml_non_const(THD *thd, const char *str, uint length, + CHARSET_INFO *cs): + Item_string(thd, str, length, cs) { } bool const_item() const { return false ; } bool basic_const_item() const { return false; } @@ -547,7 +551,7 @@ public: { str_value.set(str, length, cs); } - Item *safe_charset_converter(CHARSET_INFO *tocs) + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) { /* Item_string::safe_charset_converter() does not accept non-constants. @@ -563,8 +567,9 @@ class Item_nodeset_to_const_comparator :public Item_bool_func String *pxml; String tmp_nodeset; public: - Item_nodeset_to_const_comparator(Item *nodeset, Item *cmpfunc, String *p) - :Item_bool_func(nodeset,cmpfunc), pxml(p) {} + Item_nodeset_to_const_comparator(THD *thd, Item *nodeset, Item *cmpfunc, + String *p): + Item_bool_func(thd, nodeset, cmpfunc), pxml(p) {} enum Type type() const { return XPATH_NODESET_CMP; }; const char *func_name() const { return "xpath_nodeset_to_const_comparator"; } bool check_vcol_func_processor(uchar *int_arg) @@ -835,7 +840,7 @@ String *Item_nodeset_func_elementbyindex::val_nodeset(String *nodeset) static Item* nodeset2bool(MY_XPATH *xpath, Item *item) { if (item->type() == Item::XPATH_NODESET) - return new Item_xpath_cast_bool(item, xpath->pxml); + return new Item_xpath_cast_bool(xpath->thd, item, xpath->pxml); return item; } @@ -905,16 +910,16 @@ static Item* nodeset2bool(MY_XPATH *xpath, Item *item) RETURN The newly created item. */ -static Item *eq_func(int oper, Item *a, Item *b) +static Item *eq_func(THD *thd, int oper, Item *a, Item *b) { switch (oper) { - case '=': return new Item_func_eq(a, b); - case '!': return new Item_func_ne(a, b); - case MY_XPATH_LEX_GE: return new Item_func_ge(a, b); - case MY_XPATH_LEX_LE: return new Item_func_le(a, b); - case MY_XPATH_LEX_GREATER: return new Item_func_gt(a, b); - case MY_XPATH_LEX_LESS: return new Item_func_lt(a, b); + case '=': return new Item_func_eq(thd, a, b); + case '!': return new Item_func_ne(thd, a, b); + case MY_XPATH_LEX_GE: return new Item_func_ge(thd, a, b); + case MY_XPATH_LEX_LE: return new Item_func_le(thd, a, b); + case MY_XPATH_LEX_GREATER: return new Item_func_gt(thd, a, b); + case MY_XPATH_LEX_LESS: return new Item_func_lt(thd, a, b); } return 0; } @@ -932,16 +937,16 @@ static Item *eq_func(int oper, Item *a, Item *b) RETURN The newly created item. */ -static Item *eq_func_reverse(int oper, Item *a, Item *b) +static Item *eq_func_reverse(THD *thd, int oper, Item *a, Item *b) { switch (oper) { - case '=': return new Item_func_eq(a, b); - case '!': return new Item_func_ne(a, b); - case MY_XPATH_LEX_GE: return new Item_func_le(a, b); - case MY_XPATH_LEX_LE: return new Item_func_ge(a, b); - case MY_XPATH_LEX_GREATER: return new Item_func_lt(a, b); - case MY_XPATH_LEX_LESS: return new Item_func_gt(a, b); + case '=': return new Item_func_eq(thd, a, b); + case '!': return new Item_func_ne(thd, a, b); + case MY_XPATH_LEX_GE: return new Item_func_le(thd, a, b); + case MY_XPATH_LEX_LE: return new Item_func_ge(thd, a, b); + case MY_XPATH_LEX_GREATER: return new Item_func_lt(thd, a, b); + case MY_XPATH_LEX_LESS: return new Item_func_gt(thd, a, b); } return 0; } @@ -964,7 +969,7 @@ static Item *create_comparator(MY_XPATH *xpath, if (a->type() != Item::XPATH_NODESET && b->type() != Item::XPATH_NODESET) { - return eq_func(oper, a, b); // two scalar arguments + return eq_func(xpath->thd, oper, a, b); // two scalar arguments } else if (a->type() == Item::XPATH_NODESET && b->type() == Item::XPATH_NODESET) @@ -987,22 +992,24 @@ static Item *create_comparator(MY_XPATH *xpath, in a loop through all of the nodes in the node set. */ - Item_string *fake= new Item_string_xml_non_const("", 0, xpath->cs); + Item_string *fake= new Item_string_xml_non_const(xpath->thd, "", 0, + xpath->cs); Item_nodeset_func *nodeset; Item *scalar, *comp; if (a->type() == Item::XPATH_NODESET) { nodeset= (Item_nodeset_func*) a; scalar= b; - comp= eq_func(oper, (Item*)fake, scalar); + comp= eq_func(xpath->thd, oper, (Item*)fake, scalar); } else { nodeset= (Item_nodeset_func*) b; scalar= a; - comp= eq_func_reverse(oper, fake, scalar); + comp= eq_func_reverse(xpath->thd, oper, fake, scalar); } - return new Item_nodeset_to_const_comparator(nodeset, comp, xpath->pxml); + return new Item_nodeset_to_const_comparator(xpath->thd, nodeset, comp, + xpath->pxml); } } @@ -1028,28 +1035,36 @@ static Item* nametestfunc(MY_XPATH *xpath, switch (type) { case MY_XPATH_AXIS_ANCESTOR: - res= new Item_nodeset_func_ancestorbyname(arg, beg, len, xpath->pxml, 0); + res= new Item_nodeset_func_ancestorbyname(xpath->thd, arg, beg, len, + xpath->pxml, 0); break; case MY_XPATH_AXIS_ANCESTOR_OR_SELF: - res= new Item_nodeset_func_ancestorbyname(arg, beg, len, xpath->pxml, 1); + res= new Item_nodeset_func_ancestorbyname(xpath->thd, arg, beg, len, + xpath->pxml, 1); break; case MY_XPATH_AXIS_PARENT: - res= new Item_nodeset_func_parentbyname(arg, beg, len, xpath->pxml); + res= new Item_nodeset_func_parentbyname(xpath->thd, arg, beg, len, + xpath->pxml); break; case MY_XPATH_AXIS_DESCENDANT: - res= new Item_nodeset_func_descendantbyname(arg, beg, len, xpath->pxml, 0); + res= new Item_nodeset_func_descendantbyname(xpath->thd, arg, beg, len, + xpath->pxml, 0); break; case MY_XPATH_AXIS_DESCENDANT_OR_SELF: - res= new Item_nodeset_func_descendantbyname(arg, beg, len, xpath->pxml, 1); + res= new Item_nodeset_func_descendantbyname(xpath->thd, arg, beg, len, + xpath->pxml, 1); break; case MY_XPATH_AXIS_ATTRIBUTE: - res= new Item_nodeset_func_attributebyname(arg, beg, len, xpath->pxml); + res= new Item_nodeset_func_attributebyname(xpath->thd, arg, beg, len, + xpath->pxml); break; case MY_XPATH_AXIS_SELF: - res= new Item_nodeset_func_selfbyname(arg, beg, len, xpath->pxml); + res= new Item_nodeset_func_selfbyname(xpath->thd, arg, beg, len, + xpath->pxml); break; default: - res= new Item_nodeset_func_childbyname(arg, beg, len, xpath->pxml); + res= new Item_nodeset_func_childbyname(xpath->thd, arg, beg, len, + xpath->pxml); } return res; } @@ -1157,101 +1172,106 @@ my_xpath_keyword(MY_XPATH *x, */ static Item *create_func_true(MY_XPATH *xpath, Item **args, uint nargs) -{ - return new Item_bool(1); +{ + return new Item_bool(xpath->thd, 1); } static Item *create_func_false(MY_XPATH *xpath, Item **args, uint nargs) -{ - return new Item_bool(0); +{ + return new Item_bool(xpath->thd, 0); } static Item *create_func_not(MY_XPATH *xpath, Item **args, uint nargs) -{ - return new Item_func_not(nodeset2bool(xpath, args[0])); +{ + return new Item_func_not(xpath->thd, nodeset2bool(xpath, args[0])); } static Item *create_func_ceiling(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_func_ceiling(args[0]); + return new Item_func_ceiling(xpath->thd, args[0]); } static Item *create_func_floor(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_func_floor(args[0]); + return new Item_func_floor(xpath->thd, args[0]); } static Item *create_func_bool(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_xpath_cast_bool(args[0], xpath->pxml); + return new Item_xpath_cast_bool(xpath->thd, args[0], xpath->pxml); } static Item *create_func_number(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_xpath_cast_number(args[0]); + return new Item_xpath_cast_number(xpath->thd, args[0]); } -static Item *create_func_string_length(MY_XPATH *xpath, Item **args, uint nargs) +static Item *create_func_string_length(MY_XPATH *xpath, Item **args, + uint nargs) { Item *arg= nargs ? args[0] : xpath->context; - return arg ? new Item_func_char_length(arg) : 0; + return arg ? new Item_func_char_length(xpath->thd, arg) : 0; } static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_func_round(args[0], new Item_int((char*)"0",0,1),0); + return new Item_func_round(xpath->thd, args[0], + new Item_int(xpath->thd, (char *) "0", 0, 1), 0); } static Item *create_func_last(MY_XPATH *xpath, Item **args, uint nargs) { - return xpath->context ? - new Item_func_xpath_count(xpath->context, xpath->pxml) : NULL; + return xpath->context ? + new Item_func_xpath_count(xpath->thd, xpath->context, xpath->pxml) : + NULL; } static Item *create_func_position(MY_XPATH *xpath, Item **args, uint nargs) { - return xpath->context ? - new Item_func_xpath_position(xpath->context, xpath->pxml) : NULL; + return xpath->context ? + new Item_func_xpath_position(xpath->thd, xpath->context, + xpath->pxml) : NULL; } static Item *create_func_contains(MY_XPATH *xpath, Item **args, uint nargs) { - return new Item_xpath_cast_bool(new Item_func_locate(args[0], args[1]), - xpath->pxml); + return new Item_xpath_cast_bool(xpath->thd, + new Item_func_locate(xpath->thd, args[0], + args[1]), xpath->pxml); } static Item *create_func_concat(MY_XPATH *xpath, Item **args, uint nargs) -{ - return new Item_func_concat(args[0], args[1]); +{ + return new Item_func_concat(xpath->thd, args[0], args[1]); } static Item *create_func_substr(MY_XPATH *xpath, Item **args, uint nargs) { if (nargs == 2) - return new Item_func_substr(args[0], args[1]); + return new Item_func_substr(xpath->thd, args[0], args[1]); else - return new Item_func_substr(args[0], args[1], args[2]); + return new Item_func_substr(xpath->thd, args[0], args[1], args[2]); } static Item *create_func_count(MY_XPATH *xpath, Item **args, uint nargs) -{ +{ if (args[0]->type() != Item::XPATH_NODESET) return 0; - return new Item_func_xpath_count(args[0], xpath->pxml); + return new Item_func_xpath_count(xpath->thd, args[0], xpath->pxml); } @@ -1259,7 +1279,7 @@ static Item *create_func_sum(MY_XPATH *xpath, Item **args, uint nargs) { if (args[0]->type() != Item::XPATH_NODESET) return 0; - return new Item_func_xpath_sum(args[0], xpath->pxml); + return new Item_func_xpath_sum(xpath->thd, args[0], xpath->pxml); } @@ -1632,7 +1652,8 @@ static int my_xpath_parse_AbsoluteLocationPath(MY_XPATH *xpath) if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH)) { - xpath->context= new Item_nodeset_func_descendantbyname(xpath->context, + xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd, + xpath->context, "*", 1, xpath->pxml, 1); return my_xpath_parse_RelativeLocationPath(xpath); @@ -1673,7 +1694,8 @@ static int my_xpath_parse_RelativeLocationPath(MY_XPATH *xpath) while (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH)) { if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH)) - xpath->context= new Item_nodeset_func_descendantbyname(xpath->context, + xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd, + xpath->context, "*", 1, xpath->pxml, 1); if (!my_xpath_parse_Step(xpath)) @@ -1713,7 +1735,8 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath) Item *prev_context= xpath->context; String *context_cache; context_cache= &((Item_nodeset_func*)xpath->context)->context_cache; - xpath->context= new Item_nodeset_context_cache(context_cache, xpath->pxml); + xpath->context= new Item_nodeset_context_cache(xpath->thd, context_cache, + xpath->pxml); xpath->context_cache= context_cache; if(!my_xpath_parse_PredicateExpr(xpath)) @@ -1732,13 +1755,14 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath) if (xpath->item->is_bool_type()) { - xpath->context= new Item_nodeset_func_predicate(prev_context, + xpath->context= new Item_nodeset_func_predicate(xpath->thd, prev_context, xpath->item, xpath->pxml); } else { - xpath->context= new Item_nodeset_func_elementbyindex(prev_context, + xpath->context= new Item_nodeset_func_elementbyindex(xpath->thd, + prev_context, xpath->item, xpath->pxml); } @@ -1748,7 +1772,7 @@ my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(MY_XPATH *xpath) static int my_xpath_parse_Step(MY_XPATH *xpath) -{ +{ return my_xpath_parse_AxisSpecifier_NodeTest_opt_Predicate_list(xpath) || my_xpath_parse_AbbreviatedStep(xpath); @@ -1862,8 +1886,9 @@ static int my_xpath_parse_AbbreviatedStep(MY_XPATH *xpath) if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT)) return 0; if (my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT)) - xpath->context= new Item_nodeset_func_parentbyname(xpath->context, "*", 1, - xpath->pxml); + xpath->context= new Item_nodeset_func_parentbyname(xpath->thd, + xpath->context, "*", + 1, xpath->pxml); return 1; } @@ -1892,7 +1917,7 @@ static int my_xpath_parse_PrimaryExpr_literal(MY_XPATH *xpath) { if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_STRING)) return 0; - xpath->item= new Item_string(xpath->prevtok.beg + 1, + xpath->item= new Item_string(xpath->thd, xpath->prevtok.beg + 1, xpath->prevtok.end - xpath->prevtok.beg - 2, xpath->cs); return 1; @@ -1987,7 +2012,8 @@ static int my_xpath_parse_UnionExpr(MY_XPATH *xpath) xpath->error= 1; return 0; } - xpath->item= new Item_nodeset_func_union(prev, xpath->item, xpath->pxml); + xpath->item= new Item_nodeset_func_union(xpath->thd, prev, xpath->item, + xpath->pxml); } return 1; } @@ -2033,8 +2059,10 @@ my_xpath_parse_FilterExpr_opt_slashes_RelativeLocationPath(MY_XPATH *xpath) /* treat double slash (//) as /descendant-or-self::node()/ */ if (my_xpath_parse_term(xpath, MY_XPATH_LEX_SLASH)) - xpath->context= new Item_nodeset_func_descendantbyname(xpath->context, - "*", 1, xpath->pxml, 1); + xpath->context= new Item_nodeset_func_descendantbyname(xpath->thd, + xpath->context, + "*", 1, + xpath->pxml, 1); rc= my_xpath_parse_RelativeLocationPath(xpath); /* push back the context and restore the item */ @@ -2096,7 +2124,7 @@ static int my_xpath_parse_OrExpr(MY_XPATH *xpath) xpath->error= 1; return 0; } - xpath->item= new Item_cond_or(nodeset2bool(xpath, prev), + xpath->item= new Item_cond_or(xpath->thd, nodeset2bool(xpath, prev), nodeset2bool(xpath, xpath->item)); } return 1; @@ -2128,8 +2156,8 @@ static int my_xpath_parse_AndExpr(MY_XPATH *xpath) return 0; } - xpath->item= new Item_cond_and(nodeset2bool(xpath,prev), - nodeset2bool(xpath,xpath->item)); + xpath->item= new Item_cond_and(xpath->thd, nodeset2bool(xpath, prev), + nodeset2bool(xpath, xpath->item)); } return 1; } @@ -2298,9 +2326,9 @@ static int my_xpath_parse_AdditiveExpr(MY_XPATH *xpath) } if (oper == MY_XPATH_LEX_PLUS) - xpath->item= new Item_func_plus(prev, xpath->item); + xpath->item= new Item_func_plus(xpath->thd, prev, xpath->item); else - xpath->item= new Item_func_minus(prev, xpath->item); + xpath->item= new Item_func_minus(xpath->thd, prev, xpath->item); }; return 1; } @@ -2347,13 +2375,13 @@ static int my_xpath_parse_MultiplicativeExpr(MY_XPATH *xpath) switch (oper) { case MY_XPATH_LEX_ASTERISK: - xpath->item= new Item_func_mul(prev, xpath->item); + xpath->item= new Item_func_mul(xpath->thd, prev, xpath->item); break; case MY_XPATH_LEX_DIV: - xpath->item= new Item_func_int_div(prev, xpath->item); + xpath->item= new Item_func_int_div(xpath->thd, prev, xpath->item); break; case MY_XPATH_LEX_MOD: - xpath->item= new Item_func_mod(prev, xpath->item); + xpath->item= new Item_func_mod(xpath->thd, prev, xpath->item); break; } } @@ -2378,7 +2406,7 @@ static int my_xpath_parse_UnaryExpr(MY_XPATH *xpath) return my_xpath_parse_UnionExpr(xpath); if (!my_xpath_parse_UnaryExpr(xpath)) return 0; - xpath->item= new Item_func_neg(xpath->item); + xpath->item= new Item_func_neg(xpath->thd, xpath->item); return 1; } @@ -2415,13 +2443,13 @@ static int my_xpath_parse_Number(MY_XPATH *xpath) beg= xpath->prevtok.beg; if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_DOT)) { - xpath->item= new Item_int(xpath->prevtok.beg, + xpath->item= new Item_int(xpath->thd, xpath->prevtok.beg, xpath->prevtok.end - xpath->prevtok.beg); return 1; } my_xpath_parse_term(xpath, MY_XPATH_LEX_DIGITS); - xpath->item= new Item_float(beg, xpath->prevtok.end - beg); + xpath->item= new Item_float(xpath->thd, beg, xpath->prevtok.end - beg); return 1; } @@ -2525,7 +2553,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath) name.str= (char*) xpath->prevtok.beg; if (user_var) - xpath->item= new Item_func_get_user_var(name); + xpath->item= new Item_func_get_user_var(xpath->thd, name); else { sp_variable *spv; @@ -2535,7 +2563,8 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath) (spc= lex->spcont) && (spv= spc->find_variable(name, false))) { - Item_splocal *splocal= new Item_splocal(name, spv->offset, spv->type, 0); + Item_splocal *splocal= new Item_splocal(xpath->thd, name, spv->offset, + spv->type, 0); #ifndef DBUG_OFF if (splocal) splocal->m_sp= lex->sphead; @@ -2614,7 +2643,8 @@ my_xpath_parse(MY_XPATH *xpath, const char *str, const char *strend) my_xpath_lex_init(&xpath->prevtok, str, strend); my_xpath_lex_scan(xpath, &xpath->lasttok, str, strend); - xpath->rootelement= new Item_nodeset_func_rootelement(xpath->pxml); + xpath->rootelement= new Item_nodeset_func_rootelement(xpath->thd, + xpath->pxml); return my_xpath_parse_Expr(xpath) && @@ -2662,6 +2692,7 @@ bool Item_xml_str_func::fix_fields(THD *thd, Item **ref) if (!(xp= args[1]->val_str(&tmp))) return false; // Will return NULL my_xpath_init(&xpath); + xpath.thd= thd; xpath.cs= collation.collation; xpath.debug= 0; xpath.pxml= xml.parsed(); diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index 5b699869b2e..3758025fc90 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -76,13 +76,12 @@ protected: return xml_arg->parse(args[0], cache); } public: - Item_xml_str_func(Item *a, Item *b): - Item_str_func(a,b) + Item_xml_str_func(THD *thd, Item *a, Item *b): Item_str_func(thd, a, b) { maybe_null= TRUE; } - Item_xml_str_func(Item *a, Item *b, Item *c): - Item_str_func(a,b,c) + Item_xml_str_func(THD *thd, Item *a, Item *b, Item *c): + Item_str_func(thd, a, b, c) { maybe_null= TRUE; } @@ -102,7 +101,8 @@ public: class Item_func_xml_extractvalue: public Item_xml_str_func { public: - Item_func_xml_extractvalue(Item *a,Item *b) :Item_xml_str_func(a,b) {} + Item_func_xml_extractvalue(THD *thd, Item *a, Item *b): + Item_xml_str_func(thd, a, b) {} const char *func_name() const { return "extractvalue"; } String *val_str(String *); }; @@ -115,7 +115,8 @@ class Item_func_xml_update: public Item_xml_str_func const MY_XML_NODE *cut, const String *replace); public: - Item_func_xml_update(Item *a,Item *b,Item *c) :Item_xml_str_func(a,b,c) {} + Item_func_xml_update(THD *thd, Item *a, Item *b, Item *c): + Item_xml_str_func(thd, a, b, c) {} const char *func_name() const { return "updatexml"; } String *val_str(String *); }; diff --git a/sql/log_event.cc b/sql/log_event.cc index 786b249db39..60636a58550 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1034,18 +1034,19 @@ int Log_event::net_send(THD *thd, Protocol *protocol, const char* log_name, EVENTS. */ -void Log_event::init_show_field_list(List<Item>* field_list) +void Log_event::init_show_field_list(THD *thd, List<Item>* field_list) { - field_list->push_back(new Item_empty_string("Log_name", 20)); - field_list->push_back(new Item_return_int("Pos", MY_INT32_NUM_DECIMAL_DIGITS, + field_list->push_back(new Item_empty_string(thd, "Log_name", 20)); + field_list->push_back(new Item_return_int(thd, "Pos", + MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG)); - field_list->push_back(new Item_empty_string("Event_type", 20)); - field_list->push_back(new Item_return_int("Server_id", 10, + field_list->push_back(new Item_empty_string(thd, "Event_type", 20)); + field_list->push_back(new Item_return_int(thd, "Server_id", 10, MYSQL_TYPE_LONG)); - field_list->push_back(new Item_return_int("End_log_pos", + field_list->push_back(new Item_return_int(thd, "End_log_pos", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG)); - field_list->push_back(new Item_empty_string("Info", 20)); + field_list->push_back(new Item_empty_string(thd, "Info", 20)); } /** @@ -7853,33 +7854,33 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) if (is_null) { - it= new Item_null(); + it= new Item_null(thd); } else { switch (type) { case REAL_RESULT: float8get(real_val, val); - it= new Item_float(real_val, 0); + it= new Item_float(thd, real_val, 0); val= (char*) &real_val; // Pointer to value in native format val_len= 8; break; case INT_RESULT: int_val= (longlong) uint8korr(val); - it= new Item_int(int_val); + it= new Item_int(thd, int_val); val= (char*) &int_val; // Pointer to value in native format val_len= 8; break; case DECIMAL_RESULT: { - Item_decimal *dec= new Item_decimal((uchar*) val+2, val[0], val[1]); + Item_decimal *dec= new Item_decimal(thd, (uchar*) val+2, val[0], val[1]); it= dec; val= (char *)dec->val_decimal(NULL); val_len= sizeof(my_decimal); break; } case STRING_RESULT: - it= new Item_string(val, val_len, charset); + it= new Item_string(thd, val, val_len, charset); break; case ROW_RESULT: default: @@ -7888,7 +7889,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi) } } - Item_func_set_user_var *e= new Item_func_set_user_var(user_var_name, it); + Item_func_set_user_var *e= new Item_func_set_user_var(thd, user_var_name, it); /* Item_func_set_user_var can't substitute something else on its place => 0 can be passed as last argument (reference on item) diff --git a/sql/log_event.h b/sql/log_event.h index 95b68e627ff..b154cd370ff 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1177,7 +1177,7 @@ public: output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG EVENTS. */ - static void init_show_field_list(List<Item>* field_list); + static void init_show_field_list(THD *thd, List<Item>* field_list); #ifdef HAVE_REPLICATION int net_send(THD *thd, Protocol *protocol, const char* log_name, my_off_t pos); diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index be33e46bf94..43ad8494a74 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -181,8 +181,8 @@ bool uses_index_fields_only(Item *item, TABLE *tbl, uint keyno, Index condition, or NULL if no condition could be inferred. */ -Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, - bool other_tbls_ok) +static Item *make_cond_for_index(THD *thd, Item *cond, TABLE *table, uint keyno, + bool other_tbls_ok) { if (!cond) return NULL; @@ -192,14 +192,14 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) { table_map used_tables= 0; - Item_cond_and *new_cond=new Item_cond_and; + Item_cond_and *new_cond= new Item_cond_and(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok); + Item *fix= make_cond_for_index(thd, item, table, keyno, other_tbls_ok); if (fix) { new_cond->argument_list()->push_back(fix); @@ -227,14 +227,14 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, } else /* It's OR */ { - Item_cond_or *new_cond=new Item_cond_or; + Item_cond_or *new_cond= new Item_cond_or(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok); + Item *fix= make_cond_for_index(thd, item, table, keyno, other_tbls_ok); if (!fix) return (COND*) 0; new_cond->argument_list()->push_back(fix); @@ -260,8 +260,8 @@ Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno, } -Item *make_cond_remainder(Item *cond, TABLE *table, uint keyno, - bool other_tbls_ok, bool exclude_index) +static Item *make_cond_remainder(THD *thd, Item *cond, TABLE *table, uint keyno, + bool other_tbls_ok, bool exclude_index) { if (cond->type() == Item::COND_ITEM) { @@ -269,14 +269,14 @@ Item *make_cond_remainder(Item *cond, TABLE *table, uint keyno, if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) { /* Create new top level AND item */ - Item_cond_and *new_cond=new Item_cond_and; + Item_cond_and *new_cond= new Item_cond_and(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_remainder(item, table, keyno, + Item *fix= make_cond_remainder(thd, item, table, keyno, other_tbls_ok, exclude_index); if (fix) { @@ -297,14 +297,14 @@ Item *make_cond_remainder(Item *cond, TABLE *table, uint keyno, } else /* It's OR */ { - Item_cond_or *new_cond=new Item_cond_or; + Item_cond_or *new_cond= new Item_cond_or(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_remainder(item, table, keyno, + Item *fix= make_cond_remainder(thd, item, table, keyno, other_tbls_ok, FALSE); if (!fix) return (COND*) 0; @@ -366,8 +366,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) DBUG_EXECUTE("where", print_where(tab->select_cond, "full cond", QT_ORDINARY);); - idx_cond= make_cond_for_index(tab->select_cond, tab->table, keyno, - tab->icp_other_tables_ok); + idx_cond= make_cond_for_index(tab->join->thd, tab->select_cond, tab->table, + keyno, tab->icp_other_tables_ok); DBUG_EXECUTE("where", print_where(idx_cond, "idx cond", QT_ORDINARY);); @@ -406,7 +406,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) tab->ref.disable_cache= TRUE; Item *row_cond= tab->idx_cond_fact_out ? - make_cond_remainder(tab->select_cond, tab->table, keyno, + make_cond_remainder(tab->join->thd, tab->select_cond, + tab->table, keyno, tab->icp_other_tables_ok, TRUE) : tab->pre_idx_push_select_cond; @@ -419,7 +420,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) tab->select_cond= row_cond; else { - COND *new_cond= new Item_cond_and(row_cond, idx_remainder_cond); + COND *new_cond= new Item_cond_and(tab->join->thd, row_cond, + idx_remainder_cond); tab->select_cond= new_cond; tab->select_cond->quick_fix_field(); ((Item_cond_and*)tab->select_cond)->used_tables_cache= diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c73284f3113..8e9a0cbd445 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7039,7 +7039,7 @@ SEL_TREE *Item_func_in::get_func_mm_tree(RANGE_OPT_PARAM *param, per-statement mem_root (while thd->mem_root is currently pointing to mem_root local to range optimizer). */ - Item *value_item= array->create_item(); + Item *value_item= array->create_item(param->thd); param->thd->mem_root= tmp_root; if (array->count > NOT_IN_IGNORE_THRESHOLD || !value_item) diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index d56fb7c3a9b..b419997a8d6 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -461,7 +461,7 @@ void best_access_path(JOIN *join, JOIN_TAB *s, static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, Item_in_subselect *subq_pred); -static void remove_sj_conds(Item **tree); +static void remove_sj_conds(THD *thd, Item **tree); static bool is_cond_sj_in_equality(Item *item); static bool sj_table_is_included(JOIN *join, JOIN_TAB *join_tab); static Item *remove_additional_cond(Item* conds); @@ -1135,7 +1135,8 @@ bool convert_join_subqueries_to_semijoins(JOIN *join) Item **tree= (in_subq->emb_on_expr_nest == NO_JOIN_NEST)? &join->conds : &(in_subq->emb_on_expr_nest->on_expr); Item *replace_me= in_subq->original_item(); - if (replace_where_subcondition(join, tree, replace_me, new Item_int(1), + if (replace_where_subcondition(join, tree, replace_me, + new Item_int(thd, 1), FALSE)) goto restore_arena_and_fail; } @@ -1594,9 +1595,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) { nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr); Item_func_eq *item_eq= - new Item_func_eq(subq_pred->left_expr, subq_lex->ref_pointer_array[0]); + new Item_func_eq(thd, subq_pred->left_expr, + subq_lex->ref_pointer_array[0]); item_eq->in_equality_no= 0; - sj_nest->sj_on_expr= and_items(sj_nest->sj_on_expr, item_eq); + sj_nest->sj_on_expr= and_items(thd, sj_nest->sj_on_expr, item_eq); } else { @@ -1605,10 +1607,10 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) nested_join->sj_outer_expr_list.push_back(subq_pred->left_expr-> element_index(i)); Item_func_eq *item_eq= - new Item_func_eq(subq_pred->left_expr->element_index(i), + new Item_func_eq(thd, subq_pred->left_expr->element_index(i), subq_lex->ref_pointer_array[i]); item_eq->in_equality_no= i; - sj_nest->sj_on_expr= and_items(sj_nest->sj_on_expr, item_eq); + sj_nest->sj_on_expr= and_items(thd, sj_nest->sj_on_expr, item_eq); } } /* @@ -1643,7 +1645,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) /* Inject sj_on_expr into the parent's WHERE or ON */ if (emb_tbl_nest) { - emb_tbl_nest->on_expr= and_items(emb_tbl_nest->on_expr, + emb_tbl_nest->on_expr= and_items(thd, emb_tbl_nest->on_expr, sj_nest->sj_on_expr); emb_tbl_nest->on_expr->top_level_item(); if (!emb_tbl_nest->on_expr->fixed && @@ -1656,7 +1658,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) else { /* Inject into the WHERE */ - parent_join->conds= and_items(parent_join->conds, sj_nest->sj_on_expr); + parent_join->conds= and_items(thd, parent_join->conds, sj_nest->sj_on_expr); parent_join->conds->top_level_item(); /* fix_fields must update the properties (e.g. st_select_lex::cond_count of @@ -3650,9 +3652,9 @@ bool setup_sj_materialization_part2(JOIN_TAB *sjm_tab) */ for (i= 0; i < sjm->tables; i++) { - remove_sj_conds(&tab[i].select_cond); + remove_sj_conds(thd, &tab[i].select_cond); if (tab[i].select) - remove_sj_conds(&tab[i].select->cond); + remove_sj_conds(thd, &tab[i].select->cond); } if (!(sjm->in_equality= create_subq_in_equalities(thd, sjm, emb_sj_nest->sj_subq_pred))) @@ -3795,8 +3797,8 @@ static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, Item *res= NULL; if (subq_pred->left_expr->cols() == 1) { - if (!(res= new Item_func_eq(subq_pred->left_expr, - new Item_field(sjm->table->field[0])))) + if (!(res= new Item_func_eq(thd, subq_pred->left_expr, + new Item_field(thd, sjm->table->field[0])))) return NULL; /* purecov: inspected */ } else @@ -3804,9 +3806,9 @@ static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, Item *conj; for (uint i= 0; i < subq_pred->left_expr->cols(); i++) { - if (!(conj= new Item_func_eq(subq_pred->left_expr->element_index(i), - new Item_field(sjm->table->field[i]))) || - !(res= and_items(res, conj))) + if (!(conj= new Item_func_eq(thd, subq_pred->left_expr->element_index(i), + new Item_field(thd, sjm->table->field[i]))) || + !(res= and_items(thd, res, conj))) return NULL; /* purecov: inspected */ } } @@ -3818,7 +3820,7 @@ static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm, -static void remove_sj_conds(Item **tree) +static void remove_sj_conds(THD *thd, Item **tree) { if (*tree) { @@ -3834,7 +3836,7 @@ static void remove_sj_conds(Item **tree) while ((item= li++)) { if (is_cond_sj_in_equality(item)) - li.replace(new Item_int(1)); + li.replace(new Item_int(thd, 1)); } } } @@ -5100,7 +5102,7 @@ TABLE *create_dummy_tmp_table(THD *thd) sjm_table_param.init(); sjm_table_param.field_count= 1; List<Item> sjm_table_cols; - Item *column_item= new Item_int(1); + Item *column_item= new Item_int(thd, 1); sjm_table_cols.push_back(column_item); if (!(table= create_tmp_table(thd, &sjm_table_param, sjm_table_cols, (ORDER*) 0, @@ -5143,16 +5145,16 @@ int select_value_catcher::setup(List<Item> *items) assigned= FALSE; n_elements= items->elements; - if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*n_elements))) + if (!(row= (Item_cache**) thd->alloc(sizeof(Item_cache*) * n_elements))) return TRUE; Item *sel_item; List_iterator<Item> li(*items); for (uint i= 0; (sel_item= li++); i++) { - if (!(row[i]= Item_cache::get_cache(sel_item))) + if (!(row[i]= Item_cache::get_cache(thd, sel_item))) return TRUE; - row[i]->setup(sel_item); + row[i]->setup(thd, sel_item); } return FALSE; } @@ -5260,12 +5262,13 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list, Item *eq_cond; for (uint i= 0; i < subq_pred->left_expr->cols(); i++) { - eq_cond= new Item_func_eq(subq_pred->left_expr->element_index(i), + eq_cond= new Item_func_eq(join->thd, + subq_pred->left_expr->element_index(i), new_sink->row[i]); if (!eq_cond) DBUG_RETURN(1); - if (!((*join_where)= and_items(*join_where, eq_cond)) || + if (!((*join_where)= and_items(join->thd, *join_where, eq_cond)) || (*join_where)->fix_fields(join->thd, join_where)) DBUG_RETURN(1); } @@ -5304,7 +5307,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list, Item *sj_conds= hash_sj_engine->semi_join_conds; - (*join_where)= and_items(*join_where, sj_conds); + (*join_where)= and_items(join->thd, *join_where, sj_conds); if (!(*join_where)->fixed) (*join_where)->fix_fields(join->thd, join_where); } diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index f6e3b619f51..9f133b97683 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -529,7 +529,7 @@ bool check_func_dependency(JOIN *join, TABLE_LIST *oj_tbl, Item* cond); static -void build_eq_mods_for_cond(Dep_analysis_context *dac, +void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *dac, Dep_module_expr **eq_mod, uint *and_level, Item *cond); static @@ -846,7 +846,7 @@ bool check_func_dependency(JOIN *join, Dep_value_field objects for the used fields. */ uint and_level=0; - build_eq_mods_for_cond(&dac, &last_eq_mod, &and_level, cond); + build_eq_mods_for_cond(join->thd, &dac, &last_eq_mod, &and_level, cond); if (!(dac.n_equality_mods= last_eq_mod - dac.equality_mods)) return FALSE; /* No useful conditions */ @@ -1149,7 +1149,7 @@ int compare_field_values(Dep_value_field *a, Dep_value_field *b, void *unused) */ static -void build_eq_mods_for_cond(Dep_analysis_context *ctx, +void build_eq_mods_for_cond(THD *thd, Dep_analysis_context *ctx, Dep_module_expr **eq_mod, uint *and_level, Item *cond) { @@ -1163,7 +1163,7 @@ void build_eq_mods_for_cond(Dep_analysis_context *ctx, { Item *item; while ((item=li++)) - build_eq_mods_for_cond(ctx, eq_mod, and_level, item); + build_eq_mods_for_cond(thd, ctx, eq_mod, and_level, item); for (Dep_module_expr *mod_exp= ctx->equality_mods + orig_offset; mod_exp != *eq_mod ; mod_exp++) @@ -1175,12 +1175,12 @@ void build_eq_mods_for_cond(Dep_analysis_context *ctx, { Item *item; (*and_level)++; - build_eq_mods_for_cond(ctx, eq_mod, and_level, li++); + build_eq_mods_for_cond(thd, ctx, eq_mod, and_level, li++); while ((item=li++)) { Dep_module_expr *start_key_fields= *eq_mod; (*and_level)++; - build_eq_mods_for_cond(ctx, eq_mod, and_level, item); + build_eq_mods_for_cond(thd, ctx, eq_mod, and_level, item); *eq_mod= merge_eq_mods(ctx->equality_mods + orig_offset, start_key_fields, *eq_mod, ++(*and_level)); @@ -1217,7 +1217,7 @@ void build_eq_mods_for_cond(Dep_analysis_context *ctx, } case Item_func::ISNULL_FUNC: { - Item *tmp=new Item_null; + Item *tmp=new Item_null(thd); if (tmp) check_equality(ctx, eq_mod, *and_level, cond_func, args[0], tmp); break; diff --git a/sql/procedure.h b/sql/procedure.h index 6870b97de57..a46e8cfc137 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -38,7 +38,7 @@ class Item_proc :public Item { public: - Item_proc(const char *name_par): Item() + Item_proc(THD *thd, const char *name_par): Item(thd) { this->name=(char*) name_par; } @@ -63,7 +63,8 @@ class Item_proc_real :public Item_proc { double value; public: - Item_proc_real(const char *name_par,uint dec) : Item_proc(name_par) + Item_proc_real(THD *thd, const char *name_par, uint dec): + Item_proc(thd, name_par) { decimals=dec; max_length=float_length(dec); } @@ -92,7 +93,7 @@ class Item_proc_int :public Item_proc { longlong value; public: - Item_proc_int(const char *name_par) :Item_proc(name_par) + Item_proc_int(THD *thd, const char *name_par): Item_proc(thd, name_par) { max_length=11; } enum Item_result result_type () const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; } @@ -111,8 +112,8 @@ public: class Item_proc_string :public Item_proc { public: - Item_proc_string(const char *name_par,uint length) :Item_proc(name_par) - { this->max_length=length; } + Item_proc_string(THD *thd, const char *name_par, uint length): + Item_proc(thd, name_par) { this->max_length=length; } enum Item_result result_type () const { return STRING_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; } void set(double nr) { str_value.set_real(nr, 2, default_charset()); } @@ -156,7 +157,7 @@ public: virtual void add(void)=0; virtual void end_group(void)=0; virtual int send_row(List<Item> &fields)=0; - virtual bool change_columns(List<Item> &fields)=0; + virtual bool change_columns(THD *thd, List<Item> &fields)= 0; virtual void update_refs(void) {} virtual int end_of_records() { return 0; } }; diff --git a/sql/protocol.cc b/sql/protocol.cc index 05e970c01dc..542bdc2d4ea 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1248,7 +1248,7 @@ bool Protocol_text::send_out_parameters(List<Item_param> *sp_params) continue; // It's an IN-parameter. Item_func_set_user_var *suv= - new Item_func_set_user_var(*user_var_name, item_param); + new Item_func_set_user_var(thd, *user_var_name, item_param); /* Item_func_set_user_var is not fixed after construction, call fix_fields(). diff --git a/sql/protocol.h b/sql/protocol.h index 048db940804..329bb0f9c46 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -139,6 +139,10 @@ public: virtual enum enum_protocol_type type()= 0; void end_statement(); + + friend int send_answer_1(Protocol *protocol, String *s1, String *s2, + String *s3); + friend int send_header_2(Protocol *protocol, bool for_category); }; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 3c99becf304..1c7c8c013ea 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -232,16 +232,16 @@ bool show_slave_hosts(THD* thd) Protocol *protocol= thd->protocol; DBUG_ENTER("show_slave_hosts"); - field_list.push_back(new Item_return_int("Server_id", 10, + field_list.push_back(new Item_return_int(thd, "Server_id", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Host", 20)); + field_list.push_back(new Item_empty_string(thd, "Host", 20)); if (opt_show_slave_auth_info) { - field_list.push_back(new Item_empty_string("User",20)); - field_list.push_back(new Item_empty_string("Password",20)); + field_list.push_back(new Item_empty_string(thd, "User", 20)); + field_list.push_back(new Item_empty_string(thd, "Password", 20)); } - field_list.push_back(new Item_return_int("Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Master_id", 10, + field_list.push_back(new Item_return_int(thd, "Port", 7, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_return_int(thd, "Master_id", 10, MYSQL_TYPE_LONG)); if (protocol->send_result_set_metadata(&field_list, diff --git a/sql/set_var.cc b/sql/set_var.cc index 22922563802..53a7d2ad39a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -982,7 +982,7 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_ASSERT(tables->table->in_use == thd); - cond= make_cond_for_info_schema(cond, tables); + cond= make_cond_for_info_schema(thd, cond, tables); thd->count_cuted_fields= CHECK_FIELD_WARN; mysql_rwlock_rdlock(&LOCK_system_variables_hash); diff --git a/sql/set_var.h b/sql/set_var.h index 0215a452c07..e559f6bf810 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -285,7 +285,7 @@ public: } save_result; LEX_STRING base; /**< for structured variables, like keycache_name.variable_name */ - set_var(enum_var_type type_arg, sys_var *var_arg, + set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg, const LEX_STRING *base_name_arg, Item *value_arg) :var(var_arg), type(type_arg), base(*base_name_arg) { @@ -296,7 +296,8 @@ public: if (value_arg && value_arg->type() == Item::FIELD_ITEM) { Item_field *item= (Item_field*) value_arg; - if (!(value=new Item_string_sys(item->field_name))) // names are utf8 + // names are utf8 + if (!(value=new Item_string_sys(thd, item->field_name))) value=value_arg; /* Give error message later */ } else diff --git a/sql/slave.cc b/sql/slave.cc index 0fad20d77af..9b074f6488b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2519,102 +2519,109 @@ static bool send_show_master_info_header(THD *thd, bool full, if (full) { - field_list.push_back(new Item_empty_string("Connection_name", + field_list.push_back(new Item_empty_string(thd, "Connection_name", MAX_CONNECTION_NAME)); - field_list.push_back(new Item_empty_string("Slave_SQL_State", + field_list.push_back(new Item_empty_string(thd, "Slave_SQL_State", 30)); } - field_list.push_back(new Item_empty_string("Slave_IO_State", + field_list.push_back(new Item_empty_string(thd, "Slave_IO_State", 30)); - field_list.push_back(new Item_empty_string("Master_Host", + field_list.push_back(new Item_empty_string(thd, "Master_Host", sizeof(mi->host))); - field_list.push_back(new Item_empty_string("Master_User", + field_list.push_back(new Item_empty_string(thd, "Master_User", sizeof(mi->user))); - field_list.push_back(new Item_return_int("Master_Port", 7, + field_list.push_back(new Item_return_int(thd, "Master_Port", 7, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Connect_Retry", 10, + field_list.push_back(new Item_return_int(thd, "Connect_Retry", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Master_Log_File", + field_list.push_back(new Item_empty_string(thd, "Master_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Read_Master_Log_Pos", 10, + field_list.push_back(new Item_return_int(thd, "Read_Master_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Relay_Log_File", + field_list.push_back(new Item_empty_string(thd, "Relay_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Relay_Log_Pos", 10, + field_list.push_back(new Item_return_int(thd, "Relay_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Relay_Master_Log_File", + field_list.push_back(new Item_empty_string(thd, "Relay_Master_Log_File", FN_REFLEN)); - field_list.push_back(new Item_empty_string("Slave_IO_Running", 3)); - field_list.push_back(new Item_empty_string("Slave_SQL_Running", 3)); - field_list.push_back(new Item_empty_string("Replicate_Do_DB", 20)); - field_list.push_back(new Item_empty_string("Replicate_Ignore_DB", 20)); - field_list.push_back(new Item_empty_string("Replicate_Do_Table", 20)); - field_list.push_back(new Item_empty_string("Replicate_Ignore_Table", 23)); - field_list.push_back(new Item_empty_string("Replicate_Wild_Do_Table", 24)); - field_list.push_back(new Item_empty_string("Replicate_Wild_Ignore_Table", + field_list.push_back(new Item_empty_string(thd, "Slave_IO_Running", 3)); + field_list.push_back(new Item_empty_string(thd, "Slave_SQL_Running", 3)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Do_DB", 20)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_DB", 20)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Do_Table", 20)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Table", + 23)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Wild_Do_Table", + 24)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Wild_Ignore_Table", 28)); - field_list.push_back(new Item_return_int("Last_Errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_Error", 20)); - field_list.push_back(new Item_return_int("Skip_Counter", 10, + field_list.push_back(new Item_return_int(thd, "Last_Errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Exec_Master_Log_Pos", 10, + field_list.push_back(new Item_empty_string(thd, "Last_Error", 20)); + field_list.push_back(new Item_return_int(thd, "Skip_Counter", 10, + MYSQL_TYPE_LONG)); + field_list.push_back(new Item_return_int(thd, "Exec_Master_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_return_int("Relay_Log_Space", 10, + field_list.push_back(new Item_return_int(thd, "Relay_Log_Space", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Until_Condition", 6)); - field_list.push_back(new Item_empty_string("Until_Log_File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Until_Log_Pos", 10, + field_list.push_back(new Item_empty_string(thd, "Until_Condition", 6)); + field_list.push_back(new Item_empty_string(thd, "Until_Log_File", FN_REFLEN)); + field_list.push_back(new Item_return_int(thd, "Until_Log_Pos", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Master_SSL_Allowed", 7)); - field_list.push_back(new Item_empty_string("Master_SSL_CA_File", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Allowed", 7)); + field_list.push_back(new Item_empty_string(thd, "Master_SSL_CA_File", sizeof(mi->ssl_ca))); - field_list.push_back(new Item_empty_string("Master_SSL_CA_Path", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_CA_Path", sizeof(mi->ssl_capath))); - field_list.push_back(new Item_empty_string("Master_SSL_Cert", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Cert", sizeof(mi->ssl_cert))); - field_list.push_back(new Item_empty_string("Master_SSL_Cipher", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Cipher", sizeof(mi->ssl_cipher))); - field_list.push_back(new Item_empty_string("Master_SSL_Key", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Key", sizeof(mi->ssl_key))); - field_list.push_back(new Item_return_int("Seconds_Behind_Master", 10, + field_list.push_back(new Item_return_int(thd, "Seconds_Behind_Master", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Master_SSL_Verify_Server_Cert", + field_list.push_back(new Item_empty_string(thd, + "Master_SSL_Verify_Server_Cert", 3)); - field_list.push_back(new Item_return_int("Last_IO_Errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_IO_Error", 20)); - field_list.push_back(new Item_return_int("Last_SQL_Errno", 4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Last_SQL_Error", 20)); - field_list.push_back(new Item_empty_string("Replicate_Ignore_Server_Ids", + field_list.push_back(new Item_return_int(thd, "Last_IO_Errno", 4, + MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string(thd, "Last_IO_Error", 20)); + field_list.push_back(new Item_return_int(thd, "Last_SQL_Errno", 4, + MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string(thd, "Last_SQL_Error", 20)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Server_Ids", FN_REFLEN)); - field_list.push_back(new Item_return_int("Master_Server_Id", sizeof(ulong), + field_list.push_back(new Item_return_int(thd, "Master_Server_Id", + sizeof(ulong), MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Master_SSL_Crl", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Crl", sizeof(mi->ssl_crl))); - field_list.push_back(new Item_empty_string("Master_SSL_Crlpath", + field_list.push_back(new Item_empty_string(thd, "Master_SSL_Crlpath", sizeof(mi->ssl_crlpath))); - field_list.push_back(new Item_empty_string("Using_Gtid", + field_list.push_back(new Item_empty_string(thd, "Using_Gtid", sizeof("Current_Pos")-1)); - field_list.push_back(new Item_empty_string("Gtid_IO_Pos", 30)); - field_list.push_back(new Item_empty_string("Replicate_Do_Domain_Ids", + field_list.push_back(new Item_empty_string(thd, "Gtid_IO_Pos", 30)); + field_list.push_back(new Item_empty_string(thd, "Replicate_Do_Domain_Ids", FN_REFLEN)); - field_list.push_back(new Item_empty_string("Replicate_Ignore_Domain_Ids", + field_list.push_back(new Item_empty_string(thd, "Replicate_Ignore_Domain_Ids", FN_REFLEN)); - field_list.push_back(new Item_empty_string("Parallel_Mode", + field_list.push_back(new Item_empty_string(thd, "Parallel_Mode", sizeof("conservative")-1)); if (full) { - field_list.push_back(new Item_return_int("Retried_transactions", + field_list.push_back(new Item_return_int(thd, "Retried_transactions", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Max_relay_log_size", + field_list.push_back(new Item_return_int(thd, "Max_relay_log_size", 10, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_return_int("Executed_log_entries", + field_list.push_back(new Item_return_int(thd, "Executed_log_entries", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Slave_received_heartbeats", + field_list.push_back(new Item_return_int(thd, "Slave_received_heartbeats", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_float("Slave_heartbeat_period", + field_list.push_back(new Item_float(thd, "Slave_heartbeat_period", 0.0, 3, 10)); - field_list.push_back(new Item_empty_string("Gtid_Slave_Pos", + field_list.push_back(new Item_empty_string(thd, "Gtid_Slave_Pos", gtid_pos_length)); } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 667cac41d43..92e73774226 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2021,7 +2021,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (spvar->mode == sp_variable::MODE_OUT) { - Item_null *null_item= new Item_null(); + Item_null *null_item= new Item_null(thd); Item *tmp_item= null_item; if (!null_item || @@ -2575,8 +2575,8 @@ sp_head::show_create_routine(THD *thd, int type) /* Send header. */ - fields.push_back(new Item_empty_string(col1_caption, NAME_CHAR_LEN)); - fields.push_back(new Item_empty_string("sql_mode", sql_mode.length)); + fields.push_back(new Item_empty_string(thd, col1_caption, NAME_CHAR_LEN)); + fields.push_back(new Item_empty_string(thd, "sql_mode", sql_mode.length)); { /* @@ -2585,7 +2585,7 @@ sp_head::show_create_routine(THD *thd, int type) */ Item_empty_string *stmt_fld= - new Item_empty_string(col3_caption, + new Item_empty_string(thd, col3_caption, MY_MAX(m_defstr.length, 1024)); stmt_fld->maybe_null= TRUE; @@ -2593,13 +2593,13 @@ sp_head::show_create_routine(THD *thd, int type) fields.push_back(stmt_fld); } - fields.push_back(new Item_empty_string("character_set_client", + fields.push_back(new Item_empty_string(thd, "character_set_client", MY_CS_NAME_SIZE)); - fields.push_back(new Item_empty_string("collation_connection", + fields.push_back(new Item_empty_string(thd, "collation_connection", MY_CS_NAME_SIZE)); - fields.push_back(new Item_empty_string("Database Collation", + fields.push_back(new Item_empty_string(thd, "Database Collation", MY_CS_NAME_SIZE)); if (protocol->send_result_set_metadata(&fields, @@ -2783,9 +2783,9 @@ sp_head::show_routine_code(THD *thd) if (check_show_routine_access(thd, this, &full_access) || !full_access) DBUG_RETURN(1); - field_list.push_back(new Item_uint("Pos", 9)); + field_list.push_back(new Item_uint(thd, "Pos", 9)); // 1024 is for not to confuse old clients - field_list.push_back(new Item_empty_string("Instruction", + field_list.push_back(new Item_empty_string(thd, "Instruction", MY_MAX(buffer.length(), 1024))); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -3895,7 +3895,7 @@ sp_instr_set_case_expr::exec_core(THD *thd, uint *nextp) initialized. Set to NULL so we can continue. */ - Item *null_item= new Item_null(); + Item *null_item= new Item_null(thd); if (!null_item || thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item)) diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index b24da0ab239..3a5bc044253 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -137,7 +137,7 @@ bool sp_rcontext::init_var_items(THD *thd) for (uint idx = 0; idx < num_vars; ++idx) { - if (!(m_var_items[idx]= new Item_field(m_var_table->field[idx]))) + if (!(m_var_items[idx]= new Item_field(thd, m_var_table->field[idx]))) return true; } @@ -387,7 +387,7 @@ Item_cache *sp_rcontext::create_case_expr_holder(THD *thd, thd->set_n_backup_active_arena(thd->spcont->callers_arena, ¤t_arena); - holder= Item_cache::get_cache(item); + holder= Item_cache::get_cache(thd, item); thd->restore_active_arena(thd->spcont->callers_arena, ¤t_arena); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 92ea944df0c..457a6d3b0e8 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7788,7 +7788,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) } DBUG_ASSERT(rolename || username); - Item_string *field=new Item_string_ascii("", 0); + Item_string *field=new Item_string_ascii(thd, "", 0); List<Item> field_list; field->name=buff; field->max_length=1024; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index d917bd69f72..4f78b1785a5 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -326,13 +326,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, DBUG_ENTER("mysql_admin_table"); DBUG_PRINT("enter", ("extra_open_options: %u", extra_open_options)); - field_list.push_back(item = new Item_empty_string("Table", NAME_CHAR_LEN*2)); + field_list.push_back(item = new Item_empty_string(thd, "Table", + NAME_CHAR_LEN * 2)); item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Op", 10)); + field_list.push_back(item = new Item_empty_string(thd, "Op", 10)); item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_type", 10)); + field_list.push_back(item = new Item_empty_string(thd, "Msg_type", 10)); item->maybe_null = 1; - field_list.push_back(item = new Item_empty_string("Msg_text", + field_list.push_back(item = new Item_empty_string(thd, "Msg_text", SQL_ADMIN_MSG_TEXT_SIZE)); item->maybe_null = 1; if (protocol->send_result_set_metadata(&field_list, diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 32b447797cf..e9f43a50fce 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -1166,23 +1166,23 @@ int collect_ulonglong(ulonglong *element, } // collect_ulonglong -bool analyse::change_columns(List<Item> &field_list) +bool analyse::change_columns(THD *thd, List<Item> &field_list) { field_list.empty(); - func_items[0] = new Item_proc_string("Field_name", 255); - func_items[1] = new Item_proc_string("Min_value", 255); + func_items[0] = new Item_proc_string(thd, "Field_name", 255); + func_items[1] = new Item_proc_string(thd, "Min_value", 255); func_items[1]->maybe_null = 1; - func_items[2] = new Item_proc_string("Max_value", 255); + func_items[2] = new Item_proc_string(thd, "Max_value", 255); func_items[2]->maybe_null = 1; - func_items[3] = new Item_proc_int("Min_length"); - func_items[4] = new Item_proc_int("Max_length"); - func_items[5] = new Item_proc_int("Empties_or_zeros"); - func_items[6] = new Item_proc_int("Nulls"); - func_items[7] = new Item_proc_string("Avg_value_or_avg_length", 255); - func_items[8] = new Item_proc_string("Std", 255); + func_items[3] = new Item_proc_int(thd, "Min_length"); + func_items[4] = new Item_proc_int(thd, "Max_length"); + func_items[5] = new Item_proc_int(thd, "Empties_or_zeros"); + func_items[6] = new Item_proc_int(thd, "Nulls"); + func_items[7] = new Item_proc_string(thd, "Avg_value_or_avg_length", 255); + func_items[8] = new Item_proc_string(thd, "Std", 255); func_items[8]->maybe_null = 1; - func_items[9] = new Item_proc_string("Optimal_fieldtype", + func_items[9] = new Item_proc_string(thd, "Optimal_fieldtype", MY_MAX(64, output_str_length)); for (uint i = 0; i < array_elements(func_items); i++) diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 3d3662c3f4f..820877f2a69 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -356,7 +356,7 @@ public: } } virtual void add() {} - virtual bool change_columns(List<Item> &fields); + virtual bool change_columns(THD *thd, List<Item> &fields); virtual int send_row(List<Item> &field_list); virtual void end_group(void) {} virtual int end_of_records(void); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4fe9bc14c57..c6d96ee74f6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -7304,7 +7304,7 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2, set_new_item_local_context(thd, item_ident_2, nj_col_2->table_ref)) goto err; - if (!(eq_cond= new Item_func_eq(item_ident_1, item_ident_2))) + if (!(eq_cond= new Item_func_eq(thd, item_ident_1, item_ident_2))) goto err; /* Out of memory. */ if (field_1 && field_1->vcol_info) @@ -7317,8 +7317,8 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2, fix_fields() is applied to all ON conditions in setup_conds() so we don't do it here. */ - add_join_on((table_ref_1->outer_join & JOIN_TYPE_RIGHT ? - table_ref_1 : table_ref_2), + add_join_on(thd, (table_ref_1->outer_join & JOIN_TYPE_RIGHT ? + table_ref_1 : table_ref_2), eq_cond); nj_col_1->is_common= nj_col_2->is_common= TRUE; @@ -7651,7 +7651,7 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref, /* Add a TRUE condition to outer joins that have no common columns. */ if (table_ref_2->outer_join && !table_ref_1->on_expr && !table_ref_2->on_expr) - table_ref_2->on_expr= new Item_int((longlong) 1,1); /* Always true. */ + table_ref_2->on_expr= new Item_int(thd, (longlong) 1, 1); // Always true. /* Change this table reference to become a leaf for name resolution. */ if (left_neighbor) @@ -7816,7 +7816,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, Item_int do not need fix_fields() because it is basic constant. */ - it.replace(new Item_int("Not_used", (longlong) 1, + it.replace(new Item_int(thd, "Not_used", (longlong) 1, MY_INT64_NUM_DECIMAL_DIGITS)); } else if (insert_fields(thd, ((Item_field*) item)->context, @@ -8510,7 +8510,7 @@ void wrap_ident(THD *thd, Item **conds) DBUG_ASSERT((*conds)->type() == Item::FIELD_ITEM || (*conds)->type() == Item::REF_ITEM); Query_arena *arena, backup; arena= thd->activate_stmt_arena_if_needed(&backup); - if ((wrapper= new Item_direct_ref_to_ident((Item_ident *)(*conds)))) + if ((wrapper= new Item_direct_ref_to_ident(thd, (Item_ident *) (*conds)))) (*conds)= (Item*) wrapper; if (arena) thd->restore_active_arena(arena, &backup); @@ -9176,7 +9176,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX *select_lex, bool no_order) DBUG_PRINT("info",("Performing FULLTEXT search")); while ((ifm=li++)) - ifm->init_search(no_order); + ifm->init_search(thd, no_order); } return 0; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index bf161b274df..253d1cd67c1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2456,7 +2456,7 @@ int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is void THD::make_explain_json_field_list(List<Item> &field_list, bool is_analyze) { - Item *item= new Item_empty_string((is_analyze ? + Item *item= new Item_empty_string(this, (is_analyze ? "ANALYZE" : "EXPLAIN"), 78, system_charset_info); @@ -2477,55 +2477,59 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags, { Item *item; CHARSET_INFO *cs= system_charset_info; - field_list.push_back(item= new Item_return_int("id",3, MYSQL_TYPE_LONGLONG)); + field_list.push_back(item= new Item_return_int(this, "id", 3, + MYSQL_TYPE_LONGLONG)); item->maybe_null= 1; - field_list.push_back(new Item_empty_string("select_type", 19, cs)); - field_list.push_back(item= new Item_empty_string("table", NAME_CHAR_LEN, cs)); + field_list.push_back(new Item_empty_string(this, "select_type", 19, cs)); + field_list.push_back(item= new Item_empty_string(this, "table", NAME_CHAR_LEN, + cs)); item->maybe_null= 1; if (explain_flags & DESCRIBE_PARTITIONS) { /* Maximum length of string that make_used_partitions_str() can produce */ - item= new Item_empty_string("partitions", MAX_PARTITIONS * (1 + FN_LEN), - cs); + item= new Item_empty_string(this, "partitions", + MAX_PARTITIONS * (1 + FN_LEN), cs); field_list.push_back(item); item->maybe_null= 1; } - field_list.push_back(item= new Item_empty_string("type", 10, cs)); + field_list.push_back(item= new Item_empty_string(this, "type", 10, cs)); item->maybe_null= 1; - field_list.push_back(item=new Item_empty_string("possible_keys", + field_list.push_back(item=new Item_empty_string(this, "possible_keys", NAME_CHAR_LEN*MAX_KEY, cs)); item->maybe_null=1; - field_list.push_back(item=new Item_empty_string("key", NAME_CHAR_LEN, cs)); + field_list.push_back(item=new Item_empty_string(this, "key", NAME_CHAR_LEN, + cs)); item->maybe_null=1; - field_list.push_back(item=new Item_empty_string("key_len", + field_list.push_back(item=new Item_empty_string(this, "key_len", NAME_CHAR_LEN*MAX_KEY)); item->maybe_null=1; - field_list.push_back(item=new Item_empty_string("ref", + field_list.push_back(item=new Item_empty_string(this, "ref", NAME_CHAR_LEN*MAX_REF_PARTS, cs)); item->maybe_null=1; - field_list.push_back(item= new Item_return_int("rows", 10, + field_list.push_back(item= new Item_return_int(this, "rows", 10, MYSQL_TYPE_LONGLONG)); if (is_analyze) { - field_list.push_back(item= new Item_float("r_rows", 0.1234, 10, 4)); + field_list.push_back(item= new Item_float(this, "r_rows", 0.1234, 10, 4)); item->maybe_null=1; } if (is_analyze || (explain_flags & DESCRIBE_EXTENDED)) { - field_list.push_back(item= new Item_float("filtered", 0.1234, 2, 4)); + field_list.push_back(item= new Item_float(this, "filtered", 0.1234, 2, 4)); item->maybe_null=1; } if (is_analyze) { - field_list.push_back(item= new Item_float("r_filtered", 0.1234, 2, 4)); + field_list.push_back(item= new Item_float(this, "r_filtered", 0.1234, 2, + 4)); item->maybe_null=1; } item->maybe_null= 1; - field_list.push_back(new Item_empty_string("Extra", 255, cs)); + field_list.push_back(new Item_empty_string(this, "Extra", 255, cs)); } @@ -3346,7 +3350,7 @@ int select_max_min_finder_subselect::send_data(List<Item> &items) { if (!cache) { - cache= Item_cache::get_cache(val_item); + cache= Item_cache::get_cache(thd, val_item); switch (val_item->result_type()) { case REAL_RESULT: op= &select_max_min_finder_subselect::cmp_real; @@ -3803,7 +3807,7 @@ Statement_map::~Statement_map() bool my_var_user::set(THD *thd, Item *item) { - Item_func_set_user_var *suv= new Item_func_set_user_var(name, item); + Item_func_set_user_var *suv= new Item_func_set_user_var(thd, name, item); suv->save_item_result(item); return suv->fix_fields(thd, 0) || suv->update(); } diff --git a/sql/sql_class.h b/sql/sql_class.h index ae1d6418ffb..23e146c6750 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4088,6 +4088,8 @@ class JOIN; class select_result_sink: public Sql_alloc { public: + THD *thd; + select_result_sink(THD *thd_arg): thd(thd_arg) {} /* send_data returns 0 on ok, 1 on error and -1 if data was ignored, for example for a duplicate row entry written to a temp table. @@ -4112,7 +4114,6 @@ public: class select_result :public select_result_sink { protected: - THD *thd; /* All descendant classes have their send_data() skip the first unit->offset_limit_cnt rows sent. Select_materialize @@ -4121,7 +4122,7 @@ protected: SELECT_LEX_UNIT *unit; /* Something used only by the parser: */ public: - select_result(THD *thd_arg): thd(thd_arg) {} + select_result(THD *thd_arg): select_result_sink(thd_arg) {} virtual ~select_result() {}; /** Change wrapped select_result. @@ -4208,9 +4209,8 @@ class select_result_explain_buffer : public select_result_sink { public: select_result_explain_buffer(THD *thd_arg, TABLE *table_arg) : - thd(thd_arg), dst_table(table_arg) {}; + select_result_sink(thd_arg), dst_table(table_arg) {}; - THD *thd; TABLE *dst_table; /* table to write into */ /* The following is called in the child thread: */ @@ -4227,7 +4227,7 @@ public: class select_result_text_buffer : public select_result_sink { public: - select_result_text_buffer(THD *thd_arg) : thd(thd_arg) {} + select_result_text_buffer(THD *thd_arg): select_result_sink(thd_arg) {} int send_data(List<Item> &items); bool send_result_set_metadata(List<Item> &fields, uint flag); @@ -4235,7 +4235,6 @@ public: private: int append_row(List<Item> &items, bool send_names); - THD *thd; List<char*> rows; int n_columns; }; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 9dfabb3d2f8..67e7b6115a3 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -446,7 +446,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) if (derived->get_unit()->prepared) { Item *expr= derived->on_expr; - expr= and_conds(expr, dt_select->join ? dt_select->join->conds : 0); + expr= and_conds(thd, expr, dt_select->join ? dt_select->join->conds : 0); if (expr && (derived->prep_on_expr || expr != derived->on_expr)) { derived->on_expr= expr; diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 3e18b701031..e0776a661bc 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -818,9 +818,10 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show) DBUG_ASSERT(thd->get_stmt_da()->is_warning_info_read_only()); - field_list.push_back(new Item_empty_string("Level", 7)); - field_list.push_back(new Item_return_int("Code",4, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_empty_string("Message",MYSQL_ERRMSG_SIZE)); + field_list.push_back(new Item_empty_string(thd, "Level", 7)); + field_list.push_back(new Item_return_int(thd, "Code", 4, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string(thd, "Message", + MYSQL_ERRMSG_SIZE)); if (thd->protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 41d4268748c..64af808301c 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -227,7 +227,8 @@ void Explain_query::print_explain_json(select_result_sink *output, bool is_analy CHARSET_INFO *cs= system_charset_info; List<Item> item_list; String *buf= &writer.output; - item_list.push_back(new Item_string(buf->ptr(), buf->length(), cs)); + item_list.push_back(new Item_string(output->thd, buf->ptr(), buf->length(), + cs)); output->send_data(item_list); } @@ -257,19 +258,19 @@ bool Explain_query::print_explain_str(THD *thd, String *out_str, } -static void push_str(List<Item> *item_list, const char *str) +static void push_str(THD *thd, List<Item> *item_list, const char *str) { - item_list->push_back(new Item_string_sys(str)); + item_list->push_back(new Item_string_sys(thd, str)); } -static void push_string(List<Item> *item_list, String *str) +static void push_string(THD *thd, List<Item> *item_list, String *str) { - item_list->push_back(new Item_string_sys(str->ptr(), str->length())); + item_list->push_back(new Item_string_sys(thd, str->ptr(), str->length())); } -static void push_string_list(List<Item> *item_list, String_list &lines, - String *buf) +static void push_string_list(THD *thd, List<Item> *item_list, + String_list &lines, String *buf) { List_iterator_fast<char> it(lines); char *line; @@ -283,7 +284,7 @@ static void push_string_list(List<Item> *item_list, String_list &lines, buf->append(line); } - push_string(item_list, buf); + push_string(thd, item_list, buf); } @@ -316,51 +317,52 @@ int print_explain_row(select_result_sink *result, double r_filtered, const char *extra) { - Item *item_null= new Item_null(); + THD *thd= result->thd; + Item *item_null= new Item_null(thd); List<Item> item_list; Item *item; - item_list.push_back(new Item_int((int32) select_number)); - item_list.push_back(new Item_string_sys(select_type)); - item_list.push_back(new Item_string_sys(table_name)); + item_list.push_back(new Item_int(thd, (int32) select_number)); + item_list.push_back(new Item_string_sys(thd, select_type)); + item_list.push_back(new Item_string_sys(thd, table_name)); if (options & DESCRIBE_PARTITIONS) { if (partitions) { - item_list.push_back(new Item_string_sys(partitions)); + item_list.push_back(new Item_string_sys(thd, partitions)); } else item_list.push_back(item_null); } const char *jtype_str= join_type_str[jtype]; - item_list.push_back(new Item_string_sys(jtype_str)); + item_list.push_back(new Item_string_sys(thd, jtype_str)); /* 'possible_keys' */ if (possible_keys && !possible_keys->is_empty()) { StringBuffer<64> possible_keys_buf; - push_string_list(&item_list, *possible_keys, &possible_keys_buf); + push_string_list(thd, &item_list, *possible_keys, &possible_keys_buf); } else item_list.push_back(item_null); /* 'index */ - item= index ? new Item_string_sys(index) : item_null; + item= index ? new Item_string_sys(thd, index) : item_null; item_list.push_back(item); /* 'key_len */ - item= key_len ? new Item_string_sys(key_len) : item_null; + item= key_len ? new Item_string_sys(thd, key_len) : item_null; item_list.push_back(item); /* 'ref' */ - item= ref ? new Item_string_sys(ref) : item_null; + item= ref ? new Item_string_sys(thd, ref) : item_null; item_list.push_back(item); /* 'rows' */ if (rows) { - item_list.push_back(new Item_int(*rows, + item_list.push_back(new Item_int(thd, *rows, MY_INT64_NUM_DECIMAL_DIGITS)); } else @@ -370,7 +372,7 @@ int print_explain_row(select_result_sink *result, if (is_analyze) { if (r_rows) - item_list.push_back(new Item_float(*r_rows, 2)); + item_list.push_back(new Item_float(thd, *r_rows, 2)); else item_list.push_back(item_null); } @@ -378,15 +380,15 @@ int print_explain_row(select_result_sink *result, /* 'filtered' */ const double filtered=100.0; if (options & DESCRIBE_EXTENDED || is_analyze) - item_list.push_back(new Item_float(filtered, 2)); + item_list.push_back(new Item_float(thd, filtered, 2)); /* 'r_filtered' */ if (is_analyze) - item_list.push_back(new Item_float(r_filtered, 2)); + item_list.push_back(new Item_float(thd, r_filtered, 2)); /* 'Extra' */ if (extra) - item_list.push_back(new Item_string_sys(extra)); + item_list.push_back(new Item_string_sys(thd, extra)); else item_list.push_back(item_null); @@ -431,6 +433,7 @@ int Explain_union::print_explain(Explain_query *query, uint8 explain_flags, bool is_analyze) { + THD *thd= output->thd; //CHARSET_INFO *cs= system_charset_info; char table_name_buffer[SAFE_NAME_LEN]; @@ -446,24 +449,24 @@ int Explain_union::print_explain(Explain_query *query, /* Print a line with "UNION RESULT" */ List<Item> item_list; - Item *item_null= new Item_null(); + Item *item_null= new Item_null(thd); /* `id` column */ item_list.push_back(item_null); /* `select_type` column */ - push_str(&item_list, fake_select_type); + push_str(thd, &item_list, fake_select_type); /* `table` column: something like "<union1,2>" */ uint len= make_union_table_name(table_name_buffer); - item_list.push_back(new Item_string_sys(table_name_buffer, len)); + item_list.push_back(new Item_string_sys(thd, table_name_buffer, len)); /* `partitions` column */ if (explain_flags & DESCRIBE_PARTITIONS) item_list.push_back(item_null); /* `type` column */ - push_str(&item_list, join_type_str[JT_ALL]); + push_str(thd, &item_list, join_type_str[JT_ALL]); /* `possible_keys` column */ item_list.push_back(item_null); @@ -484,7 +487,7 @@ int Explain_union::print_explain(Explain_query *query, if (is_analyze) { double avg_rows= fake_select_lex_tracker.get_avg_rows(); - item_list.push_back(new Item_float(avg_rows, 2)); + item_list.push_back(new Item_float(thd, avg_rows, 2)); } /* `filtered` */ @@ -501,7 +504,8 @@ int Explain_union::print_explain(Explain_query *query, { extra_buf.append(STRING_WITH_LEN("Using filesort")); } - item_list.push_back(new Item_string_sys(extra_buf.ptr(), extra_buf.length())); + item_list.push_back(new Item_string_sys(thd, extra_buf.ptr(), + extra_buf.length())); //output->unit.offset_limit_cnt= 0; if (output->send_data(item_list)) @@ -696,13 +700,14 @@ int Explain_select::print_explain(Explain_query *query, select_result_sink *output, uint8 explain_flags, bool is_analyze) { + THD *thd= output->thd; if (message) { List<Item> item_list; - Item *item_null= new Item_null(); + Item *item_null= new Item_null(thd); - item_list.push_back(new Item_int((int32) select_id)); - item_list.push_back(new Item_string_sys(select_type)); + item_list.push_back(new Item_int(thd, (int32) select_id)); + item_list.push_back(new Item_string_sys(thd, select_type)); for (uint i=0 ; i < 7; i++) item_list.push_back(item_null); if (explain_flags & DESCRIBE_PARTITIONS) @@ -719,7 +724,7 @@ int Explain_select::print_explain(Explain_query *query, item_list.push_back(item_null); } - item_list.push_back(new Item_string_sys(message)); + item_list.push_back(new Item_string_sys(thd, message)); if (output->send_data(item_list)) return 1; @@ -1106,47 +1111,48 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai uint select_id, const char *select_type, bool using_temporary, bool using_filesort) { + THD *thd= output->thd; //CHARSET_INFO *cs= system_charset_info; List<Item> item_list; - Item *item_null= new Item_null(); + Item *item_null= new Item_null(thd); /* `id` column */ - item_list.push_back(new Item_int((int32) select_id)); + item_list.push_back(new Item_int(thd, (int32) select_id)); /* `select_type` column */ - push_str(&item_list, select_type); + push_str(thd, &item_list, select_type); /* `table` column */ - push_string(&item_list, &table_name); + push_string(thd, &item_list, &table_name); /* `partitions` column */ if (explain_flags & DESCRIBE_PARTITIONS) { if (used_partitions_set) { - push_string(&item_list, &used_partitions); + push_string(thd, &item_list, &used_partitions); } else item_list.push_back(item_null); } /* `type` column */ - push_str(&item_list, join_type_str[type]); + push_str(thd, &item_list, join_type_str[type]); /* `possible_keys` column */ StringBuffer<64> possible_keys_buf; if (possible_keys.is_empty()) item_list.push_back(item_null); else - push_string_list(&item_list, possible_keys, &possible_keys_buf); + push_string_list(thd, &item_list, possible_keys, &possible_keys_buf); /* `key` */ StringBuffer<64> key_str; fill_key_str(&key_str, false); if (key_str.length() > 0) - push_string(&item_list, &key_str); + push_string(thd, &item_list, &key_str); else item_list.push_back(item_null); @@ -1155,7 +1161,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai fill_key_len_str(&key_len_str); if (key_len_str.length() > 0) - push_string(&item_list, &key_len_str); + push_string(thd, &item_list, &key_len_str); else item_list.push_back(item_null); @@ -1166,18 +1172,18 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai if (type == JT_FT) { /* Traditionally, EXPLAIN lines with type=fulltext have ref='' */ - push_str(&item_list, ""); + push_str(thd, &item_list, ""); } else item_list.push_back(item_null); } else - push_string_list(&item_list, ref_list, &ref_list_buf); + push_string_list(thd, &item_list, ref_list, &ref_list_buf); /* `rows` */ if (rows_set) { - item_list.push_back(new Item_int((longlong) (ulonglong) rows, + item_list.push_back(new Item_int(thd, (longlong) (ulonglong) rows, MY_INT64_NUM_DECIMAL_DIGITS)); } else @@ -1193,7 +1199,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai else { double avg_rows= tracker.get_avg_rows(); - item_list.push_back(new Item_float(avg_rows, 2)); + item_list.push_back(new Item_float(thd, avg_rows, 2)); } } @@ -1202,7 +1208,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai { if (filtered_set) { - item_list.push_back(new Item_float(filtered, 2)); + item_list.push_back(new Item_float(thd, filtered, 2)); } else item_list.push_back(item_null); @@ -1220,7 +1226,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai double r_filtered= tracker.get_filtered_after_where(); if (bka_type.is_using_jbuf()) r_filtered *= jbuf_tracker.get_filtered_after_where(); - item_list.push_back(new Item_float(r_filtered*100.0, 2)); + item_list.push_back(new Item_float(thd, r_filtered * 100.0, 2)); } } @@ -1254,7 +1260,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai extra_buf.append(STRING_WITH_LEN("Using filesort")); } - item_list.push_back(new Item_string_sys(extra_buf.ptr(), extra_buf.length())); + item_list.push_back(new Item_string_sys(thd, extra_buf.ptr(), + extra_buf.length())); if (output->send_data(item_list)) return 1; diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc index cc922c3bcfe..f9d2f599804 100644 --- a/sql/sql_expression_cache.cc +++ b/sql/sql_expression_cache.cc @@ -161,7 +161,7 @@ void Expression_cache_tmptable::init() goto error; } - if (!(cached_result= new Item_field(cache_table->field[0]))) + if (!(cached_result= new Item_field(table_thd, cache_table->field[0]))) { DBUG_PRINT("error", ("Creating Item_field failed")); goto error; diff --git a/sql/sql_get_diagnostics.cc b/sql/sql_get_diagnostics.cc index 8b0d86aa7d1..b6c215d29b1 100644 --- a/sql/sql_get_diagnostics.cc +++ b/sql/sql_get_diagnostics.cc @@ -174,7 +174,7 @@ Statement_information_item::get_value(THD *thd, const Diagnostics_area *da) case NUMBER: { ulong count= da->cond_count(); - value= new (thd->mem_root) Item_uint(count); + value= new (thd->mem_root) Item_uint(thd, count); break; } /* @@ -183,7 +183,7 @@ Statement_information_item::get_value(THD *thd, const Diagnostics_area *da) REPLACE, LOAD). */ case ROW_COUNT: - value= new (thd->mem_root) Item_int(thd->get_row_count_func()); + value= new (thd->mem_root) Item_int(thd, thd->get_row_count_func()); break; } @@ -270,7 +270,7 @@ Condition_information_item::make_utf8_string_item(THD *thd, const String *str) String tmp(str->ptr(), str->length(), from_cs); /* If necessary, convert the string (ignoring errors), then copy it over. */ uint conv_errors; - return new Item_string(&tmp, to_cs, &conv_errors, + return new Item_string(thd, &tmp, to_cs, &conv_errors, DERIVATION_COERCIBLE, MY_REPERTOIRE_UNICODE30); } @@ -329,7 +329,7 @@ Condition_information_item::get_value(THD *thd, const Sql_condition *cond) value= make_utf8_string_item(thd, &(cond->m_message_text)); break; case MYSQL_ERRNO: - value= new (thd->mem_root) Item_uint(cond->m_sql_errno); + value= new (thd->mem_root) Item_uint(thd, cond->m_sql_errno); break; case RETURNED_SQLSTATE: str.set_ascii(cond->get_sqlstate(), strlen(cond->get_sqlstate())); diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 50ce8a51f01..0c74f3385eb 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -449,11 +449,12 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname, int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) { + THD *thd= protocol->thd; DBUG_ENTER("send_answer_1"); List<Item> field_list; - field_list.push_back(new Item_empty_string("name",64)); - field_list.push_back(new Item_empty_string("description",1000)); - field_list.push_back(new Item_empty_string("example",1000)); + field_list.push_back(new Item_empty_string(thd, "name", 64)); + field_list.push_back(new Item_empty_string(thd, "description", 1000)); + field_list.push_back(new Item_empty_string(thd, "example", 1000)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -492,12 +493,14 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) int send_header_2(Protocol *protocol, bool for_category) { + THD *thd= protocol->thd; DBUG_ENTER("send_header_2"); List<Item> field_list; if (for_category) - field_list.push_back(new Item_empty_string("source_category_name",64)); - field_list.push_back(new Item_empty_string("name",64)); - field_list.push_back(new Item_empty_string("is_it_category",1)); + field_list.push_back(new Item_empty_string(thd, "source_category_name", + 64)); + field_list.push_back(new Item_empty_string(thd, "name", 64)); + field_list.push_back(new Item_empty_string(thd, "is_it_category", 1)); DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)); } @@ -625,9 +628,10 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, uint mlen, TABLE_LIST *tables, TABLE *table, Field *pfname, int *error) { - Item *cond= new Item_func_like(new Item_field(pfname), - new Item_string(mask,mlen,pfname->charset()), - new Item_string_ascii("\\"), + Item *cond= new Item_func_like(thd, new Item_field(thd, pfname), + new Item_string(thd, mask, mlen, + pfname->charset()), + new Item_string_ascii(thd, "\\"), FALSE); if (thd->is_fatal_error) return 0; // OOM @@ -763,11 +767,11 @@ bool mysqld_help(THD *thd, const char *mask) { Field *topic_cat_id= used_fields[help_topic_help_category_id].field; Item *cond_topic_by_cat= - new Item_func_equal(new Item_field(topic_cat_id), - new Item_int((int32)category_id)); + new Item_func_equal(thd, new Item_field(thd, topic_cat_id), + new Item_int(thd, (int32) category_id)); Item *cond_cat_by_cat= - new Item_func_equal(new Item_field(cat_cat_id), - new Item_int((int32)category_id)); + new Item_func_equal(thd, new Item_field(thd, cat_cat_id), + new Item_int(thd, (int32) category_id)); if (!(select= prepare_simple_select(thd, cond_topic_by_cat, tables[0].table, &error))) goto error; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 08215980534..420a4101c8e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3482,7 +3482,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) while ((item= li++)) { - item->transform(&Item::update_value_transformer, + item->transform(thd, &Item::update_value_transformer, (uchar*)lex->current_select); } } @@ -3950,9 +3950,10 @@ static TABLE *create_table_from_items(THD *thd, (Item ***) 0, &tmp_field, &def_field, 0, 0, 0, 0, 0); if (!field || - !(cr_field=new Create_field(field,(item->type() == Item::FIELD_ITEM ? - ((Item_field *)item)->field : - (Field*) 0)))) + !(cr_field=new Create_field(thd, field, + (item->type() == Item::FIELD_ITEM ? + ((Item_field *) item)->field : + (Field *) 0)))) DBUG_RETURN(0); if (item->maybe_null) cr_field->flags &= ~NOT_NULL_FLAG; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5e58ceb9621..a86465f73b0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2685,7 +2685,7 @@ mysql_execute_command(THD *thd) goto error; } if (v->var->session_is_default(thd)) - o= new set_var(v->type, v->var, &v->base, NULL); + o= new set_var(thd,v->type, v->var, &v->base, NULL); else { switch (v->var->option.var_type & GET_TYPE_MASK) @@ -2697,10 +2697,10 @@ mysql_execute_command(THD *thd) { bool null_value; longlong val= v->var->val_int(&null_value, thd, v->type, &v->base); - o= new set_var(v->type, v->var, &v->base, + o= new set_var(thd, v->type, v->var, &v->base, (null_value ? - (Item *)new Item_null() : - (Item *)new Item_int(val))); + (Item *) new Item_null(thd) : + (Item *) new Item_int(thd, val))); } break; case GET_UINT: @@ -2709,20 +2709,20 @@ mysql_execute_command(THD *thd) { bool null_value; ulonglong val= v->var->val_int(&null_value, thd, v->type, &v->base); - o= new set_var(v->type, v->var, &v->base, + o= new set_var(thd, v->type, v->var, &v->base, (null_value ? - (Item *)new Item_null() : - (Item *)new Item_uint(val))); + (Item *) new Item_null(thd) : + (Item *) new Item_uint(thd, val))); } break; case GET_DOUBLE: { bool null_value; double val= v->var->val_real(&null_value, thd, v->type, &v->base); - o= new set_var(v->type, v->var, &v->base, + o= new set_var(thd, v->type, v->var, &v->base, (null_value ? - (Item *)new Item_null() : - (Item *)new Item_float(val, 1))); + (Item *) new Item_null(thd) : + (Item *) new Item_float(thd, val, 1))); } break; default: @@ -2741,12 +2741,13 @@ mysql_execute_command(THD *thd) val= v->var->val_str(&tmp, thd, v->type, &v->base); if (val) { - Item_string *str= new Item_string(v->var->charset(thd), + Item_string *str= new Item_string(thd, v->var->charset(thd), val->ptr(), val->length()); - o= new set_var(v->type, v->var, &v->base, str); + o= new set_var(thd, v->type, v->var, &v->base, str); } else - o= new set_var(v->type, v->var, &v->base, new Item_null()); + o= new set_var(thd, v->type, v->var, &v->base, + new Item_null(thd)); } break; } @@ -3002,7 +3003,7 @@ mysql_execute_command(THD *thd) my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE"); goto error; } - it= new Item_func_unix_timestamp(it); + it= new Item_func_unix_timestamp(thd, it); it->fix_fields(thd, &it); res = purge_master_logs_before_date(thd, (ulong)it->val_int()); break; @@ -4087,7 +4088,7 @@ end_with_restore_list: /* condition will be TRUE on SP re-excuting */ if (select_lex->item_list.elements != 0) select_lex->item_list.empty(); - if (add_item_to_list(thd, new Item_null())) + if (add_item_to_list(thd, new Item_null(thd))) goto error; THD_STAGE_INFO(thd, stage_init); @@ -5745,7 +5746,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) SELECT_LEX *param= lex->unit.global_parameters(); if (!param->explicit_limit) param->select_limit= - new (thd->mem_root) Item_int((ulonglong) thd->variables.select_limit); + new (thd->mem_root) Item_int(thd, + (ulonglong) thd->variables.select_limit); } if (!(res= open_and_lock_tables(thd, all_tables, TRUE, 0))) { @@ -7867,14 +7869,14 @@ push_new_name_resolution_context(THD *thd, @return fixed condition */ -Item *normalize_cond(Item *cond) +Item *normalize_cond(THD *thd, Item *cond) { if (cond) { Item::Type type= cond->type(); if (type == Item::FIELD_ITEM || type == Item::REF_ITEM) { - cond= new Item_func_ne(cond, new Item_int(0)); + cond= new Item_func_ne(thd, cond, new Item_int(thd, 0)); } } return cond; @@ -7895,11 +7897,11 @@ Item *normalize_cond(Item *cond) TRUE if all is OK */ -void add_join_on(TABLE_LIST *b, Item *expr) +void add_join_on(THD *thd, TABLE_LIST *b, Item *expr) { if (expr) { - expr= normalize_cond(expr); + expr= normalize_cond(thd, expr); if (!b->on_expr) b->on_expr= expr; else @@ -7909,7 +7911,7 @@ void add_join_on(TABLE_LIST *b, Item *expr) right and left join. If called later, it happens if we add more than one condition to the ON clause. */ - b->on_expr= new Item_cond_and(b->on_expr,expr); + b->on_expr= new Item_cond_and(thd, b->on_expr,expr); } b->on_expr->top_level_item(); } @@ -8279,16 +8281,17 @@ Item * all_any_subquery_creator(THD *thd, Item *left_expr, return new (thd->mem_root) Item_in_subselect(thd, left_expr, select_lex); if ((cmp == &comp_ne_creator) && all) // <> ALL <=> NOT IN - return new (thd->mem_root) Item_func_not( + return new (thd->mem_root) Item_func_not(thd, new (thd->mem_root) Item_in_subselect(thd, left_expr, select_lex)); Item_allany_subselect *it= new (thd->mem_root) Item_allany_subselect(thd, left_expr, cmp, select_lex, all); - if (all) - return it->upper_item= new (thd->mem_root) Item_func_not_all(it); /* ALL */ + if (all) /* ALL */ + return it->upper_item= new (thd->mem_root) Item_func_not_all(thd, it); - return it->upper_item= new (thd->mem_root) Item_func_nop_all(it); /* ANY/SOME */ + /* ANY/SOME */ + return it->upper_item= new (thd->mem_root) Item_func_nop_all(thd, it); } @@ -8816,12 +8819,12 @@ Item *negate_expression(THD *thd, Item *expr) if it is not boolean function then we have to emulate value of not(not(a)), it will be a != 0 */ - return new Item_func_ne(arg, new Item_int((char*) "0", 0, 1)); + return new Item_func_ne(thd, arg, new Item_int(thd, (char*) "0", 0, 1)); } if ((negated= expr->neg_transformer(thd)) != 0) return negated; - return new Item_func_not(expr); + return new Item_func_not(thd, expr); } /** diff --git a/sql/sql_parse.h b/sql/sql_parse.h index d85bb87a4fb..c3c47567cf5 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -108,7 +108,7 @@ bool append_file_to_dir(THD *thd, const char **filename_ptr, void execute_init_command(THD *thd, LEX_STRING *init_command, mysql_rwlock_t *var_lock); bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group, bool asc); -void add_join_on(TABLE_LIST *b,Item *expr); +void add_join_on(THD *thd, TABLE_LIST *b, Item *expr); void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields, SELECT_LEX *lex); bool add_proc_to_list(THD *thd, Item *item); @@ -118,7 +118,7 @@ bool push_new_name_resolution_context(THD *thd, void store_position_for_column(const char *name); void init_update_queries(void); bool check_simple_select(); -Item *normalize_cond(Item *cond); +Item *normalize_cond(THD *thd, Item *cond); Item *negate_expression(THD *thd, Item *expr); bool check_stack_overrun(THD *thd, long margin, uchar *dummy); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d0212163ffe..5474d2f1b80 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -202,7 +202,7 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs) TABLE_LIST *save_list= context->table_list; const char *save_where= thd->where; - item= item->safe_charset_converter(cs); + item= item->safe_charset_converter(thd, cs); context->table_list= NULL; thd->where= "convert character set partition constant"; if (!item || item->fix_fields(thd, (Item**)NULL)) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9c0cce9e575..57a8582644d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1542,7 +1542,7 @@ static int mysql_test_select(Prepared_statement *stmt, List<Item> fields(lex->select_lex.item_list); /* Change columns if a procedure like analyse() */ - if (unit->last_procedure && unit->last_procedure->change_columns(fields)) + if (unit->last_procedure && unit->last_procedure->change_columns(thd, fields)) goto error; /* @@ -1898,7 +1898,7 @@ static bool mysql_test_multidelete(Prepared_statement *stmt, TABLE_LIST *tables) { stmt->thd->lex->current_select= &stmt->thd->lex->select_lex; - if (add_item_to_list(stmt->thd, new Item_null())) + if (add_item_to_list(stmt->thd, new Item_null(stmt->thd))) { my_error(ER_OUTOFMEMORY, MYF(ME_FATALERROR), 0); goto error; diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index a21cca5449a..0f29add7079 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -390,11 +390,12 @@ bool PROFILING::show_profiles() QUERY_PROFILE *prof; List<Item> field_list; - field_list.push_back(new Item_return_int("Query_ID", 10, + field_list.push_back(new Item_return_int(thd, "Query_ID", 10, MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Duration", TIME_FLOAT_DIGITS-1, + field_list.push_back(new Item_return_int(thd, "Duration", + TIME_FLOAT_DIGITS - 1, MYSQL_TYPE_DOUBLE)); - field_list.push_back(new Item_empty_string("Query", 40)); + field_list.push_back(new Item_empty_string(thd, "Query", 40)); if (thd->protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index f6f444c4b60..263a982db30 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3816,7 +3816,7 @@ bool mysql_show_binlog_events(THD* thd) DBUG_ENTER("mysql_show_binlog_events"); - Log_event::init_show_field_list(&field_list); + Log_event::init_show_field_list(thd, &field_list); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); @@ -4002,11 +4002,11 @@ bool show_binlog_info(THD* thd) Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlog_info"); List<Item> field_list; - field_list.push_back(new Item_empty_string("File", FN_REFLEN)); - field_list.push_back(new Item_return_int("Position",20, + field_list.push_back(new Item_empty_string(thd, "File", FN_REFLEN)); + field_list.push_back(new Item_return_int(thd, "Position", 20, MYSQL_TYPE_LONGLONG)); - field_list.push_back(new Item_empty_string("Binlog_Do_DB",255)); - field_list.push_back(new Item_empty_string("Binlog_Ignore_DB",255)); + field_list.push_back(new Item_empty_string(thd, "Binlog_Do_DB", 255)); + field_list.push_back(new Item_empty_string(thd, "Binlog_Ignore_DB", 255)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -4057,8 +4057,8 @@ bool show_binlogs(THD* thd) DBUG_RETURN(TRUE); } - field_list.push_back(new Item_empty_string("Log_name", 255)); - field_list.push_back(new Item_return_int("File_size", 20, + field_list.push_back(new Item_empty_string(thd, "Log_name", 255)); + field_list.push_back(new Item_return_int(thd, "File_size", 20, MYSQL_TYPE_LONGLONG)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 026377d7b46..c887e67bdf6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -116,7 +116,7 @@ static store_key *get_store_key(THD *thd, uint maybe_null); static bool make_outerjoin_info(JOIN *join); static Item* -make_cond_after_sjm(Item *root_cond, Item *cond, table_map tables, +make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables, table_map sjm_tables, bool inside_or_clause); static bool make_join_select(JOIN *join,SQL_SELECT *select,COND *item); static void revise_cache_usage(JOIN_TAB *join_tab); @@ -137,7 +137,7 @@ static COND *build_equal_items(JOIN *join, COND *cond, bool ignore_on_conds, COND_EQUAL **cond_equal_ref, bool link_equal_fields= FALSE); -static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, +static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, COND *cond, COND_EQUAL *cond_equal, void *table_join_idx); @@ -512,9 +512,9 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, direct_ref= TRUE; new_ref= direct_ref ? - new Item_direct_ref(ref->context, item_ref, ref->table_name, + new Item_direct_ref(thd, ref->context, item_ref, ref->table_name, ref->field_name, ref->alias_name_used) : - new Item_ref(ref->context, item_ref, ref->table_name, + new Item_ref(thd, ref->context, item_ref, ref->table_name, ref->field_name, ref->alias_name_used); if (!new_ref) return TRUE; @@ -1408,7 +1408,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S if (!conds && outer_join) { /* Handle the case where we have an OUTER JOIN without a WHERE */ - conds=new Item_int((longlong) 1,1); // Always true + conds= new Item_int(thd, (longlong) 1,1); // Always true } if (impossible_where) @@ -1442,7 +1442,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S */ if (conds) { - conds= substitute_for_best_equal_field(NO_PARTICULAR_TAB, conds, + conds= substitute_for_best_equal_field(thd, NO_PARTICULAR_TAB, conds, cond_equal, map2table); if (thd->is_error()) { @@ -1466,7 +1466,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S { if (*tab->on_expr_ref) { - *tab->on_expr_ref= substitute_for_best_equal_field(NO_PARTICULAR_TAB, + *tab->on_expr_ref= substitute_for_best_equal_field(thd, NO_PARTICULAR_TAB, *tab->on_expr_ref, tab->cond_equal, map2table); @@ -1498,7 +1498,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S JOIN_TAB *first_inner= tab->first_inner; while (equals) { - ref_item= substitute_for_best_equal_field(tab, ref_item, + ref_item= substitute_for_best_equal_field(thd, tab, ref_item, equals, map2table); if (first_inner) { @@ -1544,7 +1544,7 @@ TODO: make view to decide if it is possible to write to WHERE directly or make S if (conds && const_table_map != found_const_table_map && (select_options & SELECT_DESCRIBE)) { - conds=new Item_int((longlong) 0,1); // Always false + conds=new Item_int(thd, (longlong) 0, 1); // Always false } /* Cache constant expressions in WHERE, HAVING, ON clauses. */ @@ -2116,32 +2116,32 @@ bool JOIN::setup_subquery_caches() select_lex->expr_cache_may_be_used[NO_MATTER]) { if (conds) - conds= conds->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + conds= conds->transform(thd, &Item::expr_cache_insert_transformer, + NULL); JOIN_TAB *tab; for (tab= first_linear_tab(this, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES); tab; tab= next_linear_tab(this, tab, WITH_BUSH_ROOTS)) { if (tab->select_cond) tab->select_cond= - tab->select_cond->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + tab->select_cond->transform(thd, &Item::expr_cache_insert_transformer, + NULL); if (tab->cache_select && tab->cache_select->cond) tab->cache_select->cond= tab->cache_select-> - cond->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + cond->transform(thd, &Item::expr_cache_insert_transformer, + NULL); } if (having) - having= having->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + having= having->transform(thd, &Item::expr_cache_insert_transformer, + NULL); if (tmp_having) { DBUG_ASSERT(having == NULL); - tmp_having= tmp_having->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + tmp_having= tmp_having->transform(thd, &Item::expr_cache_insert_transformer, + NULL); } } if (select_lex->expr_cache_may_be_used[SELECT_LIST] || @@ -2153,7 +2153,8 @@ bool JOIN::setup_subquery_caches() while ((item= li++)) { Item *new_item= - item->transform(&Item::expr_cache_insert_transformer, (uchar*) thd); + item->transform(thd, &Item::expr_cache_insert_transformer, + NULL); if (new_item != item) { thd->change_item_tree(li.ref(), new_item); @@ -2162,8 +2163,8 @@ bool JOIN::setup_subquery_caches() for (ORDER *tmp_group= group_list; tmp_group ; tmp_group= tmp_group->next) { *tmp_group->item= - (*tmp_group->item)->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + (*tmp_group->item)->transform(thd, &Item::expr_cache_insert_transformer, + NULL); } } if (select_lex->expr_cache_may_be_used[NO_MATTER]) @@ -2171,8 +2172,8 @@ bool JOIN::setup_subquery_caches() for (ORDER *ord= order; ord; ord= ord->next) { *ord->item= - (*ord->item)->transform(&Item::expr_cache_insert_transformer, - (uchar*) thd); + (*ord->item)->transform(thd, &Item::expr_cache_insert_transformer, + NULL); } } DBUG_RETURN(FALSE); @@ -2440,7 +2441,7 @@ void JOIN::exec_inner() if (procedure) { procedure_fields_list= fields_list; - if (procedure->change_columns(procedure_fields_list) || + if (procedure->change_columns(thd, procedure_fields_list) || result->prepare(procedure_fields_list, unit)) { thd->set_examined_row_count(0); @@ -2975,8 +2976,8 @@ void JOIN::exec_inner() else { if (!(curr_table->select->cond= - new Item_cond_and(curr_table->select->cond, - sort_table_cond))) + new Item_cond_and(thd, curr_table->select->cond, + sort_table_cond))) DBUG_VOID_RETURN; } if (curr_table->pre_idx_push_select_cond) @@ -2984,7 +2985,7 @@ void JOIN::exec_inner() if (sort_table_cond->type() == Item::COND_ITEM) sort_table_cond= sort_table_cond->copy_andor_structure(thd); if (!(curr_table->pre_idx_push_select_cond= - new Item_cond_and(curr_table->pre_idx_push_select_cond, + new Item_cond_and(thd, curr_table->pre_idx_push_select_cond, sort_table_cond))) DBUG_VOID_RETURN; } @@ -3887,7 +3888,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, if (join->cond_value == Item::COND_FALSE) { join->impossible_where= true; - conds=new Item_int((longlong) 0,1); + conds= new Item_int(join->thd, (longlong) 0, 1); } join->cond_equal= NULL; @@ -4837,7 +4838,7 @@ Item_func_null_predicate::add_key_fields(JOIN *join, KEY_FIELD **key_fields, /* column_name IS [NOT] NULL */ if (is_local_field(args[0]) && !(used_tables() & OUTER_REF_TABLE_BIT)) { - Item *tmp= new Item_null; + Item *tmp= new Item_null(join->thd); if (unlikely(!tmp)) // Should never be true return; add_key_equal_fields(join, key_fields, *and_level, this, @@ -9155,7 +9156,7 @@ inline void add_cond_and_fix(THD *thd, Item **e1, Item *e2) if (!e2) return; Item *res; - if ((res= new Item_cond_and(*e1, e2))) + if ((res= new Item_cond_and(thd, *e1, e2))) { res->fix_fields(thd, 0); res->update_used_tables(); @@ -9256,7 +9257,7 @@ static void add_not_null_conds(JOIN *join) */ if (!referred_tab) continue; - if (!(notnull= new Item_func_isnotnull(not_null_item))) + if (!(notnull= new Item_func_isnotnull(join->thd, not_null_item))) DBUG_VOID_RETURN; /* We need to do full fix_fields() call here in order to have correct @@ -9312,14 +9313,15 @@ static void add_not_null_conds(JOIN *join) */ static COND* -add_found_match_trig_cond(JOIN_TAB *tab, COND *cond, JOIN_TAB *root_tab) +add_found_match_trig_cond(THD *thd, JOIN_TAB *tab, COND *cond, + JOIN_TAB *root_tab) { COND *tmp; DBUG_ASSERT(cond != 0); if (tab == root_tab) return cond; - if ((tmp= add_found_match_trig_cond(tab->first_upper, cond, root_tab))) - tmp= new Item_func_trig_cond(tmp, &tab->found); + if ((tmp= add_found_match_trig_cond(thd, tab->first_upper, cond, root_tab))) + tmp= new Item_func_trig_cond(thd, tmp, &tab->found); if (tmp) { tmp->quick_fix_field(); @@ -9626,8 +9628,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (tab->bush_children) { // Reached the materialization tab - tmp= make_cond_after_sjm(cond, cond, save_used_tables, used_tables, - /*inside_or_clause=*/FALSE); + tmp= make_cond_after_sjm(thd, cond, cond, save_used_tables, + used_tables, /*inside_or_clause=*/FALSE); used_tables= save_used_tables | used_tables; save_used_tables= 0; } @@ -9671,7 +9673,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) below to check if we should use 'quick' instead. */ DBUG_PRINT("info", ("Item_int")); - tmp= new Item_int((longlong) 1,1); // Always true + tmp= new Item_int(thd, (longlong) 1, 1); // Always true } } @@ -9699,7 +9701,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) a cond, so neutralize the hack above. */ COND *tmp_cond; - if (!(tmp_cond= add_found_match_trig_cond(first_inner_tab, tmp, 0))) + if (!(tmp_cond= add_found_match_trig_cond(thd, first_inner_tab, tmp, + 0))) DBUG_RETURN(1); sel->cond= tmp_cond; tab->set_select_cond(tmp_cond, __LINE__); @@ -9784,7 +9787,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { /* Join with outer join condition */ COND *orig_cond=sel->cond; - sel->cond= and_conds(sel->cond, *tab->on_expr_ref); + sel->cond= and_conds(thd, sel->cond, *tab->on_expr_ref); /* We can't call sel->cond->fix_fields, @@ -9903,13 +9906,14 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) (table_map) 0, -1, FALSE, FALSE); if (!tmp_cond) continue; - tmp_cond= new Item_func_trig_cond(tmp_cond, &cond_tab->not_null_compl); + tmp_cond= new Item_func_trig_cond(thd, tmp_cond, + &cond_tab->not_null_compl); if (!tmp_cond) DBUG_RETURN(1); tmp_cond->quick_fix_field(); cond_tab->select_cond= !cond_tab->select_cond ? tmp_cond : - new Item_cond_and(cond_tab->select_cond, - tmp_cond); + new Item_cond_and(thd, cond_tab->select_cond, + tmp_cond); if (!cond_tab->select_cond) DBUG_RETURN(1); cond_tab->select_cond->quick_fix_field(); @@ -9999,7 +10003,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) First add the guards for match variables of all embedding outer join operations. */ - if (!(tmp_cond= add_found_match_trig_cond(cond_tab->first_inner, + if (!(tmp_cond= add_found_match_trig_cond(thd, + cond_tab->first_inner, tmp_cond, first_inner_tab))) DBUG_RETURN(1); @@ -10008,7 +10013,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) the null complemented row. */ DBUG_PRINT("info", ("Item_func_trig_cond")); - tmp_cond= new Item_func_trig_cond(tmp_cond, + tmp_cond= new Item_func_trig_cond(thd, tmp_cond, &first_inner_tab-> not_null_compl); DBUG_PRINT("info", ("Item_func_trig_cond 0x%lx", @@ -10019,7 +10024,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) DBUG_PRINT("info", ("Item_cond_and")); *sel_cond_ref= !(*sel_cond_ref) ? tmp_cond : - new Item_cond_and(*sel_cond_ref, tmp_cond); + new Item_cond_and(thd, *sel_cond_ref, tmp_cond); DBUG_PRINT("info", ("Item_cond_and 0x%lx", (ulong)(*sel_cond_ref))); if (!(*sel_cond_ref)) @@ -11007,7 +11012,7 @@ void JOIN_TAB::remove_redundant_bnl_scan_conds() { List_iterator<Item> pushed_cond_li(*((Item_cond*) select_cond)->argument_list()); Item *pushed_item; - Item_cond_and *reduced_select_cond= new Item_cond_and; + Item_cond_and *reduced_select_cond= new Item_cond_and(join->thd); if (is_cond_and(cache_select->cond)) { @@ -12639,7 +12644,7 @@ static bool check_simple_equality(THD *thd, Item *left_item, Item *right_item, if (!item) { Item_func_eq *eq_item; - if (!(eq_item= new (thd->mem_root) Item_func_eq(orig_left_item, + if (!(eq_item= new (thd->mem_root) Item_func_eq(thd, orig_left_item, orig_right_item)) || eq_item->set_cmp_func_and_arg_cmp_context()) return FALSE; @@ -12734,7 +12739,7 @@ static bool check_row_equality(THD *thd, Item *left_row, Item_row *right_row, if (!is_converted) { Item_func_eq *eq_item; - if (!(eq_item= new Item_func_eq(left_item, right_item)) || + if (!(eq_item= new Item_func_eq(thd, left_item, right_item)) || eq_item->set_cmp_func_and_arg_cmp_context()) return FALSE; eq_item->quick_fix_field(); @@ -12901,7 +12906,7 @@ COND *Item_cond_and::build_equal_items(THD *thd, if (!cond_args->elements && !cond_equal.current_level.elements && !eq_list.elements) - return new (thd->mem_root) Item_int((longlong) 1, 1); + return new (thd->mem_root) Item_int(thd, (longlong) 1, 1); List_iterator_fast<Item_equal> it(cond_equal.current_level); while ((item_equal= it++)) @@ -13008,7 +13013,7 @@ COND *Item_func_eq::build_equal_items(THD *thd, Item_equal *item_equal; int n= cond_equal.current_level.elements + eq_list.elements; if (n == 0) - return new (thd->mem_root) Item_int((longlong) 1,1); + return new (thd->mem_root) Item_int(thd, (longlong) 1, 1); else if (n == 1) { if ((item_equal= cond_equal.current_level.pop())) @@ -13034,7 +13039,7 @@ COND *Item_func_eq::build_equal_items(THD *thd, Here a new AND level must be created. It can happen only when a row equality is processed as a standalone predicate. */ - Item_cond_and *and_cond= new Item_cond_and(eq_list); + Item_cond_and *and_cond= new Item_cond_and(thd, eq_list); and_cond->quick_fix_field(); List<Item> *cond_args= and_cond->argument_list(); List_iterator_fast<Item_equal> it(cond_equal.current_level); @@ -13070,7 +13075,7 @@ COND *Item_func::build_equal_items(THD *thd, COND_EQUAL *inherited, an argument of a comparison predicate. */ uchar* is_subst_valid= (uchar *) Item::ANY_SUBST; - COND *cond= compile(&Item::subst_argument_checker, + COND *cond= compile(thd, &Item::subst_argument_checker, &is_subst_valid, &Item::equal_fields_propagator, (uchar *) inherited); @@ -13387,13 +13392,13 @@ static TABLE_LIST* embedding_sjm(Item *item) - 0, otherwise. */ -Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, +Item *eliminate_item_equal(THD *thd, COND *cond, COND_EQUAL *upper_levels, Item_equal *item_equal) { List<Item> eq_list; Item_func_eq *eq_item= 0; if (((Item *) item_equal)->const_item() && !item_equal->val_int()) - return new Item_int((longlong) 0,1); + return new Item_int(thd, (longlong) 0, 1); Item *item_const= item_equal->get_const(); Item_equal_fields_iterator it(*item_equal); Item *head; @@ -13458,7 +13463,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, Upper item also has "field_item=const". Don't produce equality if const is equal to item_const. */ - Item_func_eq *func= new Item_func_eq(item_const, upper_const); + Item_func_eq *func= new Item_func_eq(thd, item_const, upper_const); func->set_cmp_func(); func->quick_fix_field(); if (func->val_int()) @@ -13507,7 +13512,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, if (head_real_item->type() == Item::FIELD_ITEM) head_item= head_real_item; - eq_item= new Item_func_eq(field_item->real_item(), head_item); + eq_item= new Item_func_eq(thd, field_item->real_item(), head_item); if (!eq_item || eq_item->set_cmp_func()) return 0; @@ -13540,7 +13545,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, switch (eq_list.elements) { case 0: - res= cond ? cond : new Item_int((longlong) 1, 1); + res= cond ? cond : new Item_int(thd, (longlong) 1, 1); break; case 1: if (!cond || cond->type() == Item::INT_ITEM) @@ -13563,7 +13568,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, } } if (!res) - res= new Item_cond_and(eq_list); + res= new Item_cond_and(thd, eq_list); if (res) { res->quick_fix_field(); @@ -13630,7 +13635,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, The transformed condition, or NULL in case of error */ -static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, +static COND* substitute_for_best_equal_field(THD *thd, JOIN_TAB *context_tab, COND *cond, COND_EQUAL *cond_equal, void *table_join_idx) @@ -13660,7 +13665,7 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, Item *item; while ((item= li++)) { - Item *new_item= substitute_for_best_equal_field(context_tab, + Item *new_item= substitute_for_best_equal_field(thd, context_tab, item, cond_equal, table_join_idx); /* @@ -13678,8 +13683,8 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, bool false_eq_cond= FALSE; while ((item_equal= it++)) { - eq_cond= eliminate_item_equal(eq_cond, cond_equal->upper_levels, - item_equal); + eq_cond= eliminate_item_equal(thd, eq_cond, cond_equal->upper_levels, + item_equal); if (!eq_cond) { eq_cond= 0; @@ -13735,7 +13740,7 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, cond_equal= item_equal->upper_levels; if (cond_equal && cond_equal->current_level.head() == item_equal) cond_equal= cond_equal->upper_levels; - cond= eliminate_item_equal(0, cond_equal, item_equal); + cond= eliminate_item_equal(thd, 0, cond_equal, item_equal); return cond ? cond : org_cond; } else @@ -13746,7 +13751,7 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, while((item_equal= it++)) { REPLACE_EQUAL_FIELD_ARG arg= {item_equal, context_tab}; - cond= cond->transform(&Item::replace_equal_field, (uchar *) &arg); + cond= cond->transform(thd, &Item::replace_equal_field, (uchar *) &arg); } cond_equal= cond_equal->upper_levels; } @@ -13929,7 +13934,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list, if (can_change_cond_ref_to_const(func, right_item, left_item, field_value_owner, field, value)) { - Item *tmp=value->clone_item(); + Item *tmp=value->clone_item(thd); if (tmp) { tmp->collation.set(right_item->collation); @@ -13958,7 +13963,7 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list, else if (can_change_cond_ref_to_const(func, left_item, right_item, field_value_owner, field, value)) { - Item *tmp= value->clone_item(); + Item *tmp= value->clone_item(thd); if (tmp) { tmp->collation.set(left_item->collation); @@ -14251,7 +14256,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top, /* Add ON expression to the WHERE or upper-level ON condition. */ if (conds) { - conds= and_conds(conds, table->on_expr); + conds= and_conds(join->thd, conds, table->on_expr); conds->top_level_item(); /* conds is always a new item as both cond and on_expr existed */ DBUG_ASSERT(!conds->fixed); @@ -14899,7 +14904,7 @@ void propagate_new_equalities(THD *thd, Item *cond, else { uchar* is_subst_valid= (uchar *) Item::ANY_SUBST; - cond= cond->compile(&Item::subst_argument_checker, + cond= cond->compile(thd, &Item::subst_argument_checker, &is_subst_valid, &Item::equal_fields_propagator, (uchar *) inherited); @@ -15339,8 +15344,8 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, */ - Item *item0= new(thd->mem_root) Item_int((longlong)0, 1); - Item *eq_cond= new(thd->mem_root) Item_func_eq(args[0], item0); + Item *item0= new(thd->mem_root) Item_int(thd, (longlong) 0, 1); + Item *eq_cond= new(thd->mem_root) Item_func_eq(thd, args[0], item0); if (!eq_cond) return this; @@ -15348,7 +15353,7 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, if (field->table->pos_in_table_list->is_inner_table_of_outer_join()) { // outer join: transform "col IS NULL" to "col IS NULL or col=0" - Item *or_cond= new(thd->mem_root) Item_cond_or(eq_cond, this); + Item *or_cond= new(thd->mem_root) Item_cond_or(thd, eq_cond, this); if (!or_cond) return this; cond= or_cond; @@ -15400,8 +15405,8 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, query_cache_abort(&thd->query_cache_tls); #endif COND *new_cond, *cond= this; - if ((new_cond= new Item_func_eq(args[0], - new Item_int("last_insert_id()", + if ((new_cond= new Item_func_eq(thd, args[0], + new Item_int(thd, "last_insert_id()", thd->read_first_successful_insert_id_in_prev_stmt(), MY_INT64_NUM_DECIMAL_DIGITS)))) { @@ -16260,7 +16265,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, string_total_length+= new_field->pack_length(); } thd->mem_root= mem_root_save; - arg= sum_item->set_arg(i, thd, new Item_field(new_field)); + arg= sum_item->set_arg(i, thd, new Item_field(thd, new_field)); thd->mem_root= &table->mem_root; if (param->force_not_null_cols) { @@ -19844,7 +19849,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) { /* Create new top level AND item */ - Item_cond_and *new_cond=new Item_cond_and; + Item_cond_and *new_cond=new Item_cond_and(thd); if (!new_cond) return (COND*) 0; // OOM /* purecov: inspected */ List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); @@ -19879,7 +19884,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, } else { // Or list - Item_cond_or *new_cond=new Item_cond_or; + Item_cond_or *new_cond=new Item_cond_or(thd); if (!new_cond) return (COND*) 0; // OOM /* purecov: inspected */ List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); @@ -19956,7 +19961,7 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, */ static COND * -make_cond_after_sjm(Item *root_cond, Item *cond, table_map tables, +make_cond_after_sjm(THD *thd, Item *root_cond, Item *cond, table_map tables, table_map sjm_tables, bool inside_or_clause) { /* @@ -19974,14 +19979,14 @@ make_cond_after_sjm(Item *root_cond, Item *cond, table_map tables, if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) { /* Create new top level AND item */ - Item_cond_and *new_cond=new Item_cond_and; + Item_cond_and *new_cond= new Item_cond_and(thd); if (!new_cond) return (COND*) 0; // OOM /* purecov: inspected */ List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix=make_cond_after_sjm(root_cond, item, tables, sjm_tables, + Item *fix=make_cond_after_sjm(thd, root_cond, item, tables, sjm_tables, inside_or_clause); if (fix) new_cond->argument_list()->push_back(fix); @@ -20005,14 +20010,14 @@ make_cond_after_sjm(Item *root_cond, Item *cond, table_map tables, } else { // Or list - Item_cond_or *new_cond=new Item_cond_or; + Item_cond_or *new_cond= new Item_cond_or(thd); if (!new_cond) return (COND*) 0; // OOM /* purecov: inspected */ List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_after_sjm(root_cond, item, tables, sjm_tables, + Item *fix= make_cond_after_sjm(thd, root_cond, item, tables, sjm_tables, /*inside_or_clause= */TRUE); if (!fix) return (COND*) 0; // Always true @@ -22453,7 +22458,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, pos= item; if (item->field->flags & BLOB_FLAG) { - if (!(pos= new Item_copy_string(pos))) + if (!(pos= new Item_copy_string(thd, pos))) goto err; /* Item_copy_string::copy for function can call @@ -22508,7 +22513,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, on how the value is to be used: In some cases this may be an argument in a group function, like: IF(ISNULL(col),0,COUNT(*)) */ - if (!(pos=new Item_copy_string(pos))) + if (!(pos=new Item_copy_string(thd, pos))) goto err; if (i < border) // HAVING, ORDER and GROUP BY { @@ -22722,7 +22727,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, */ Item_func_set_user_var* suv= new Item_func_set_user_var(thd, (Item_func_set_user_var*) item); - Item_field *new_field= new Item_field(field); + Item_field *new_field= new Item_field(thd, field); if (!suv || !new_field) DBUG_RETURN(true); // Fatal error /* @@ -22743,9 +22748,9 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, else if ((field= item->get_tmp_table_field())) { if (item->type() == Item::SUM_FUNC_ITEM && field->table->group) - item_field= ((Item_sum*) item)->result_item(field); + item_field= ((Item_sum*) item)->result_item(thd, field); else - item_field= (Item*) new Item_field(field); + item_field= (Item *) new Item_field(thd, field); if (!item_field) DBUG_RETURN(true); // Fatal error @@ -22985,7 +22990,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) if (!join_tab->ref.key_parts) DBUG_RETURN(FALSE); - Item_cond_and *cond=new Item_cond_and(); + Item_cond_and *cond= new Item_cond_and(thd); TABLE *table=join_tab->table; int error= 0; if (!cond) @@ -22996,7 +23001,7 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) Field *field=table->field[table->key_info[join_tab->ref.key].key_part[i]. fieldnr-1]; Item *value=join_tab->ref.items[i]; - cond->add(new Item_func_equal(new Item_field(field), value)); + cond->add(new Item_func_equal(thd, new Item_field(thd, field), value)); } if (thd->is_fatal_error) DBUG_RETURN(TRUE); @@ -23016,7 +23021,8 @@ static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab) join_tab->select->cond= cond; if (join_tab->select->pre_idx_push_select_cond) { - Item *new_cond= and_conds(cond_copy, join_tab->select->pre_idx_push_select_cond); + Item *new_cond= and_conds(thd, cond_copy, + join_tab->select->pre_idx_push_select_cond); if (!new_cond->fixed && new_cond->fix_fields(thd, &new_cond)) error= 1; join_tab->pre_idx_push_select_cond= @@ -23112,8 +23118,8 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, if (item->eq(*group_tmp->item,0)) { Item *new_item; - if (!(new_item= new Item_ref(context, group_tmp->item, 0, - item->name))) + if (!(new_item= new Item_ref(thd, context, group_tmp->item, 0, + item->name))) return 1; // fatal_error is set thd->change_item_tree(arg, new_item); arg_changed= TRUE; @@ -23170,7 +23176,7 @@ bool JOIN::rollup_init() */ for (i= 0 ; i < send_group_parts ; i++) { - rollup.null_items[i]= new (thd->mem_root) Item_null_result(); + rollup.null_items[i]= new (thd->mem_root) Item_null_result(thd); List<Item> *rollup_fields= &rollup.fields[i]; rollup_fields->empty(); rollup.ref_pointer_arrays[i]= ref_array; @@ -23250,7 +23256,7 @@ bool JOIN::rollup_process_const_fields() { if (*group_tmp->item == item) { - Item* new_item= new Item_func_rollup_const(item); + Item* new_item= new Item_func_rollup_const(thd, item); if (!new_item) return 1; new_item->fix_fields(thd, (Item **) 0); @@ -23375,7 +23381,7 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, This is an element that is used by the GROUP BY and should be set to NULL in this level */ - Item_null_result *null_item= new (thd->mem_root) Item_null_result(); + Item_null_result *null_item= new (thd->mem_root) Item_null_result(thd); if (!null_item) return 1; item->maybe_null= 1; // Value will be null sometimes @@ -23528,11 +23534,12 @@ int print_explain_message_line(select_result_sink *result, ha_rows *rows, const char *message) { - Item *item_null= new Item_null(); + THD *thd= result->thd; + Item *item_null= new Item_null(thd); List<Item> item_list; - item_list.push_back(new Item_int((int32) select_number)); - item_list.push_back(new Item_string_sys(select_type)); + item_list.push_back(new Item_int(thd, (int32) select_number)); + item_list.push_back(new Item_string_sys(thd, select_type)); /* `table` */ item_list.push_back(item_null); @@ -23547,7 +23554,7 @@ int print_explain_message_line(select_result_sink *result, /* `rows` */ if (rows) { - item_list.push_back(new Item_int(*rows, + item_list.push_back(new Item_int(thd, *rows, MY_INT64_NUM_DECIMAL_DIGITS)); } else @@ -23567,7 +23574,7 @@ int print_explain_message_line(select_result_sink *result, /* `Extra` */ if (message) - item_list.push_back(new Item_string_sys(message)); + item_list.push_back(new Item_string_sys(thd, message)); else item_list.push_back(item_null); @@ -25051,11 +25058,11 @@ void JOIN::cache_const_exprs() return; if (conds) - conds->compile(&Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, + conds->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); cache_flag= FALSE; if (having) - having->compile(&Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, + having->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); for (JOIN_TAB *tab= first_depth_first_tab(this); tab; @@ -25064,7 +25071,7 @@ void JOIN::cache_const_exprs() if (*tab->on_expr_ref) { cache_flag= FALSE; - (*tab->on_expr_ref)->compile(&Item::cache_const_expr_analyzer, + (*tab->on_expr_ref)->compile(thd, &Item::cache_const_expr_analyzer, (uchar **)&analyzer_arg, &Item::cache_const_expr_transformer, (uchar *)&cache_flag); diff --git a/sql/sql_select.h b/sql/sql_select.h index 57b8658bdf1..71233af9845 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1850,9 +1850,9 @@ int test_if_item_cache_changed(List<Cached_item> &list); int join_init_read_record(JOIN_TAB *tab); int join_read_record_no_init(JOIN_TAB *tab); void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key); -inline Item * and_items(Item* cond, Item *item) +inline Item * and_items(THD *thd, Item* cond, Item *item) { - return (cond? (new Item_cond_and(cond, item)) : item); + return (cond ? (new Item_cond_and(thd, cond, item)) : item); } bool choose_plan(JOIN *join, table_map join_tables); void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 73a5b662fbd..53535a7a017 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -453,9 +453,9 @@ bool mysqld_show_authors(THD *thd) Protocol *protocol= thd->protocol; DBUG_ENTER("mysqld_show_authors"); - field_list.push_back(new Item_empty_string("Name",40)); - field_list.push_back(new Item_empty_string("Location",40)); - field_list.push_back(new Item_empty_string("Comment",512)); + field_list.push_back(new Item_empty_string(thd, "Name", 40)); + field_list.push_back(new Item_empty_string(thd, "Location", 40)); + field_list.push_back(new Item_empty_string(thd, "Comment", 512)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -487,9 +487,9 @@ bool mysqld_show_contributors(THD *thd) Protocol *protocol= thd->protocol; DBUG_ENTER("mysqld_show_contributors"); - field_list.push_back(new Item_empty_string("Name",40)); - field_list.push_back(new Item_empty_string("Location",40)); - field_list.push_back(new Item_empty_string("Comment", 512)); + field_list.push_back(new Item_empty_string(thd, "Name", 40)); + field_list.push_back(new Item_empty_string(thd, "Location", 40)); + field_list.push_back(new Item_empty_string(thd, "Comment", 512)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -564,9 +564,9 @@ bool mysqld_show_privileges(THD *thd) Protocol *protocol= thd->protocol; DBUG_ENTER("mysqld_show_privileges"); - field_list.push_back(new Item_empty_string("Privilege",10)); - field_list.push_back(new Item_empty_string("Context",15)); - field_list.push_back(new Item_empty_string("Comment",NAME_CHAR_LEN)); + field_list.push_back(new Item_empty_string(thd, "Privilege", 10)); + field_list.push_back(new Item_empty_string(thd, "Context", 15)); + field_list.push_back(new Item_empty_string(thd, "Comment", NAME_CHAR_LEN)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -1144,19 +1144,19 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) if (table_list->view) { - field_list.push_back(new Item_empty_string("View",NAME_CHAR_LEN)); - field_list.push_back(new Item_empty_string("Create View", + field_list.push_back(new Item_empty_string(thd, "View", NAME_CHAR_LEN)); + field_list.push_back(new Item_empty_string(thd, "Create View", MY_MAX(buffer.length(),1024))); - field_list.push_back(new Item_empty_string("character_set_client", + field_list.push_back(new Item_empty_string(thd, "character_set_client", MY_CS_NAME_SIZE)); - field_list.push_back(new Item_empty_string("collation_connection", + field_list.push_back(new Item_empty_string(thd, "collation_connection", MY_CS_NAME_SIZE)); } else { - field_list.push_back(new Item_empty_string("Table",NAME_CHAR_LEN)); + field_list.push_back(new Item_empty_string(thd, "Table", NAME_CHAR_LEN)); // 1024 is for not to confuse old clients - field_list.push_back(new Item_empty_string("Create Table", + field_list.push_back(new Item_empty_string(thd, "Create Table", MY_MAX(buffer.length(),1024))); } @@ -1249,8 +1249,8 @@ bool mysqld_show_create_db(THD *thd, LEX_STRING *dbname, load_db_opt_by_name(thd, dbname->str, &create); } List<Item> field_list; - field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN)); - field_list.push_back(new Item_empty_string("Create Database",1024)); + field_list.push_back(new Item_empty_string(thd, "Database", NAME_CHAR_LEN)); + field_list.push_back(new Item_empty_string(thd, "Create Database", 1024)); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) @@ -1313,11 +1313,11 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) !wild_case_compare(system_charset_info, field->field_name,wild)) { if (table_list->view) - field_list.push_back(new Item_ident_for_show(field, + field_list.push_back(new Item_ident_for_show(thd, field, table_list->view_db.str, table_list->view_name.str)); else - field_list.push_back(new Item_field(field)); + field_list.push_back(new Item_field(thd, field)); } } restore_record(table, s->default_values); // Get empty record @@ -2343,22 +2343,26 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) Protocol *protocol= thd->protocol; DBUG_ENTER("mysqld_list_processes"); - field_list.push_back(new Item_int("Id", 0, MY_INT32_NUM_DECIMAL_DIGITS)); - field_list.push_back(new Item_empty_string("User", USERNAME_CHAR_LENGTH)); - field_list.push_back(new Item_empty_string("Host",LIST_PROCESS_HOST_LEN)); - field_list.push_back(field=new Item_empty_string("db",NAME_CHAR_LEN)); + field_list.push_back(new Item_int(thd, "Id", 0, MY_INT32_NUM_DECIMAL_DIGITS)); + field_list.push_back(new Item_empty_string(thd, "User", + USERNAME_CHAR_LENGTH)); + field_list.push_back(new Item_empty_string(thd, "Host", + LIST_PROCESS_HOST_LEN)); + field_list.push_back(field=new Item_empty_string(thd, "db", NAME_CHAR_LEN)); field->maybe_null=1; - field_list.push_back(new Item_empty_string("Command",16)); - field_list.push_back(field= new Item_return_int("Time",7, MYSQL_TYPE_LONG)); + field_list.push_back(new Item_empty_string(thd, "Command", 16)); + field_list.push_back(field= new Item_return_int(thd, "Time", 7, + MYSQL_TYPE_LONG)); field->unsigned_flag= 0; - field_list.push_back(field=new Item_empty_string("State",30)); + field_list.push_back(field=new Item_empty_string(thd, "State", 30)); field->maybe_null=1; - field_list.push_back(field=new Item_empty_string("Info",max_query_length)); + field_list.push_back(field=new Item_empty_string(thd, "Info", + max_query_length)); field->maybe_null=1; if (!thd->variables.old_mode && !(thd->variables.old_behavior & OLD_MODE_NO_PROGRESS_INFO)) { - field_list.push_back(field= new Item_float("Progress", 0.0, 3, 7)); + field_list.push_back(field= new Item_float(thd, "Progress", 0.0, 3, 7)); field->maybe_null= 0; } if (protocol->send_result_set_metadata(&field_list, @@ -3528,7 +3532,7 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table) } -COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table) +COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table) { if (!cond) return (COND*) 0; @@ -3537,14 +3541,14 @@ COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table) if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC) { /* Create new top level AND item */ - Item_cond_and *new_cond=new Item_cond_and; + Item_cond_and *new_cond=new Item_cond_and(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix= make_cond_for_info_schema(item, table); + Item *fix= make_cond_for_info_schema(thd, item, table); if (fix) new_cond->argument_list()->push_back(fix); } @@ -3560,14 +3564,14 @@ COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table) } else { // Or list - Item_cond_or *new_cond=new Item_cond_or; + Item_cond_or *new_cond= new Item_cond_or(thd); if (!new_cond) return (COND*) 0; List_iterator<Item> li(*((Item_cond*) cond)->argument_list()); Item *item; while ((item=li++)) { - Item *fix=make_cond_for_info_schema(item, table); + Item *fix=make_cond_for_info_schema(thd, item, table); if (!fix) return (COND*) 0; new_cond->argument_list()->push_back(fix); @@ -7058,7 +7062,7 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) schema_table_idx == SCH_GLOBAL_VARIABLES) scope= OPT_GLOBAL; - COND *partial_cond= make_cond_for_info_schema(cond, tables); + COND *partial_cond= make_cond_for_info_schema(thd, cond, tables); mysql_rwlock_rdlock(&LOCK_system_variables_hash); res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars, scope), @@ -7100,7 +7104,7 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) tmp1= &thd->status_var; } - COND *partial_cond= make_cond_for_info_schema(cond, tables); + COND *partial_cond= make_cond_for_info_schema(thd, cond, tables); // Evaluate and cache const subqueries now, before the mutex. if (partial_cond) partial_cond->val_int(); @@ -7323,7 +7327,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_INT24: - if (!(item= new Item_return_int(fields_info->field_name, + if (!(item= new Item_return_int(thd, fields_info->field_name, fields_info->field_length, fields_info->field_type, fields_info->value))) @@ -7333,33 +7337,34 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) item->unsigned_flag= (fields_info->field_flags & MY_I_S_UNSIGNED); break; case MYSQL_TYPE_DATE: - if (!(item=new Item_return_date_time(fields_info->field_name, + if (!(item=new Item_return_date_time(thd, fields_info->field_name, strlen(fields_info->field_name), fields_info->field_type))) DBUG_RETURN(0); break; case MYSQL_TYPE_TIME: - if (!(item=new Item_return_date_time(fields_info->field_name, + if (!(item=new Item_return_date_time(thd, fields_info->field_name, strlen(fields_info->field_name), fields_info->field_type))) DBUG_RETURN(0); break; case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: - if (!(item=new Item_return_date_time(fields_info->field_name, + if (!(item=new Item_return_date_time(thd, fields_info->field_name, strlen(fields_info->field_name), fields_info->field_type))) DBUG_RETURN(0); break; case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: - if ((item= new Item_float(fields_info->field_name, 0.0, NOT_FIXED_DEC, - fields_info->field_length)) == NULL) + if ((item= new Item_float(thd, fields_info->field_name, 0.0, + NOT_FIXED_DEC, + fields_info->field_length)) == NULL) DBUG_RETURN(NULL); break; case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: - if (!(item= new Item_decimal((longlong) fields_info->value, false))) + if (!(item= new Item_decimal(thd, (longlong) fields_info->value, false))) { DBUG_RETURN(0); } @@ -7383,7 +7388,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: - if (!(item= new Item_blob(fields_info->field_name, + if (!(item= new Item_blob(thd, fields_info->field_name, fields_info->field_length))) { DBUG_RETURN(0); @@ -7393,7 +7398,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) /* Don't let unimplemented types pass through. Could be a grave error. */ DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING); - if (!(item= new Item_empty_string("", fields_info->field_length, cs))) + if (!(item= new Item_empty_string(thd, "", fields_info->field_length, cs))) { DBUG_RETURN(0); } @@ -7815,7 +7820,7 @@ static bool optimize_for_get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond if (plan->has_db_lookup_value() && plan->has_table_lookup_value()) plan->partial_cond= 0; else - plan->partial_cond= make_cond_for_info_schema(cond, tables); + plan->partial_cond= make_cond_for_info_schema(thd, cond, tables); end: DBUG_RETURN(0); @@ -9152,8 +9157,9 @@ static bool show_create_trigger_impl(THD *thd, /* Send header. */ - fields.push_back(new Item_empty_string("Trigger", NAME_LEN)); - fields.push_back(new Item_empty_string("sql_mode", trg_sql_mode_str.length)); + fields.push_back(new Item_empty_string(thd, "Trigger", NAME_LEN)); + fields.push_back(new Item_empty_string(thd, "sql_mode", + trg_sql_mode_str.length)); { /* @@ -9162,7 +9168,7 @@ static bool show_create_trigger_impl(THD *thd, */ Item_empty_string *stmt_fld= - new Item_empty_string("SQL Original Statement", + new Item_empty_string(thd, "SQL Original Statement", MY_MAX(trg_sql_original_stmt.length, 1024)); stmt_fld->maybe_null= TRUE; @@ -9170,13 +9176,13 @@ static bool show_create_trigger_impl(THD *thd, fields.push_back(stmt_fld); } - fields.push_back(new Item_empty_string("character_set_client", + fields.push_back(new Item_empty_string(thd, "character_set_client", MY_CS_NAME_SIZE)); - fields.push_back(new Item_empty_string("collation_connection", + fields.push_back(new Item_empty_string(thd, "collation_connection", MY_CS_NAME_SIZE)); - fields.push_back(new Item_empty_string("Database Collation", + fields.push_back(new Item_empty_string(thd, "Database Collation", MY_CS_NAME_SIZE)); if (p->send_result_set_metadata(&fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/sql_show.h b/sql/sql_show.h index 4bdfe95701b..029249f4129 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -112,7 +112,7 @@ void view_store_options(THD *thd, TABLE_LIST *table, String *buff); void init_fill_schema_files_row(TABLE* table); bool schema_table_store_record(THD *thd, TABLE *table); void initialize_information_schema_acl(); -COND *make_cond_for_info_schema(COND *cond, TABLE_LIST *table); +COND *make_cond_for_info_schema(THD *thd, COND *cond, TABLE_LIST *table); ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 091dc0cb761..453239e3bf9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3268,7 +3268,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, pointer in the parsed tree of a prepared statement or a stored procedure statement. */ - sql_field->def= sql_field->def->safe_charset_converter(save_cs); + sql_field->def= sql_field->def->safe_charset_converter(thd, save_cs); if (sql_field->def == NULL) { @@ -7414,7 +7414,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, This field was not dropped and not changed, add it to the list for the new table. */ - def= new Create_field(field, field); + def= new Create_field(thd, field, field); new_create_list.push_back(def); alter_it.rewind(); // Change default if ALTER Alter_column *alter; @@ -9626,9 +9626,9 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, */ DBUG_ASSERT(! thd->in_sub_stmt); - field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2)); + field_list.push_back(item = new Item_empty_string(thd, "Table", NAME_LEN*2)); item->maybe_null= 1; - field_list.push_back(item= new Item_int("Checksum", + field_list.push_back(item= new Item_int(thd, "Checksum", (longlong) 1, MY_INT64_NUM_DECIMAL_DIGITS)); item->maybe_null= 1; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index e889ce0b669..ce211eca0e6 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1978,7 +1978,7 @@ loop_end: table to be updated was created by mysql 4.1. Deny this. */ field->can_alter_field_type= 0; - Item_field *ifield= new Item_field((Field *) field); + Item_field *ifield= new Item_field(join->thd, (Field *) field); if (!ifield) DBUG_RETURN(1); ifield->maybe_null= 0; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 811ee4f97d5..c006a5fbdf0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -310,7 +310,7 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple) if (simple) { - var= new Item_case_expr(ctx->get_current_case_expr_id()); + var= new Item_case_expr(lex->thd, ctx->get_current_case_expr_id()); #ifndef DBUG_OFF if (var) @@ -319,7 +319,7 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple) } #endif - expr= new Item_func_eq(var, when); + expr= new Item_func_eq(lex->thd, var, when); i= new sp_instr_jump_if_not(ip, ctx, expr, lex); } else @@ -332,7 +332,7 @@ int case_stmt_action_when(LEX *lex, Item *when, bool simple) */ return !MY_TEST(i) || - sp->push_backpatch(i, ctx->push_label(current_thd, empty_lex_str, 0)) || + sp->push_backpatch(i, ctx->push_label(lex->thd, empty_lex_str, 0)) || sp->add_cont_backpatch(i) || sp->add_instr(i); } @@ -411,7 +411,7 @@ set_system_variable(THD *thd, struct sys_var_with_base *tmp, return TRUE; } - if (! (var= new set_var(var_type, tmp->var, &tmp->base_name, val))) + if (! (var= new set_var(thd, var_type, tmp->var, &tmp->base_name, val))) return TRUE; return lex->var_list.push_back(var); @@ -442,7 +442,7 @@ set_local_variable(THD *thd, sp_variable *spv, Item *val) it= spv->default_value; else { - it= new (thd->mem_root) Item_null(); + it= new (thd->mem_root) Item_null(thd); if (it == NULL) return TRUE; } @@ -474,7 +474,7 @@ set_trigger_new_row(THD *thd, LEX_STRING *name, Item *val) /* QQ: Shouldn't this be field's default value ? */ if (! val) - val= new Item_null(); + val= new Item_null(thd); DBUG_ASSERT(lex->trg_chistics.action_time == TRG_ACTION_BEFORE && (lex->trg_chistics.event == TRG_EVENT_INSERT || @@ -545,7 +545,7 @@ create_item_for_sp_var(THD *thd, LEX_STRING name, sp_variable *spvar, len_in_q= end_in_q - start_in_q; item= new (thd->mem_root) - Item_splocal(name, spvar->offset, spvar->type, pos_in_q, len_in_q); + Item_splocal(thd, name, spvar->offset, spvar->type, pos_in_q, len_in_q); #ifndef DBUG_OFF if (item) @@ -623,9 +623,9 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal, } if (equal) - result= new (thd->mem_root) Item_func_eq(left, expr); + result= new (thd->mem_root) Item_func_eq(thd, left, expr); else - result= new (thd->mem_root) Item_func_ne(left, expr); + result= new (thd->mem_root) Item_func_ne(thd, left, expr); DBUG_RETURN(result); } @@ -2680,7 +2680,7 @@ opt_ev_status: ev_starts: /* empty */ { - Item *item= new (thd->mem_root) Item_func_now_local(0); + Item *item= new (thd->mem_root) Item_func_now_local(thd, 0); if (item == NULL) MYSQL_YYABORT; Lex->event_parse_data->item_starts= item; @@ -3034,7 +3034,7 @@ sp_decl: if (!dflt_value_item) { - dflt_value_item= new (thd->mem_root) Item_null(); + dflt_value_item= new (thd->mem_root) Item_null(thd); if (dflt_value_item == NULL) MYSQL_YYABORT; /* QQ Set to the var_type with null_value? */ @@ -3539,7 +3539,7 @@ simple_target_specification: } | '@' ident_or_text { - $$= new (thd->mem_root) Item_func_get_user_var($2); + $$= new (thd->mem_root) Item_func_get_user_var(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } @@ -6527,7 +6527,7 @@ attribute: | DEFAULT now_or_signed_literal { Lex->last_field->def= $2; } | ON UPDATE_SYM NOW_SYM opt_default_time_precision { - Item *item= new (thd->mem_root) Item_func_now_local($4); + Item *item= new (thd->mem_root) Item_func_now_local(thd, $4); if (item == NULL) MYSQL_YYABORT; Lex->last_field->on_update= item; @@ -6615,7 +6615,7 @@ type_with_opt_collate: now_or_signed_literal: NOW_SYM opt_default_time_precision { - $$= new (thd->mem_root) Item_func_now_local($2); + $$= new (thd->mem_root) Item_func_now_local(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } @@ -8684,7 +8684,7 @@ expr: else { /* X OR Y */ - $$ = new (thd->mem_root) Item_cond_or($1, $3); + $$ = new (thd->mem_root) Item_cond_or(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8692,7 +8692,7 @@ expr: | expr XOR expr %prec XOR { /* XOR is a proprietary extension */ - $$ = new (thd->mem_root) Item_func_xor($1, $3); + $$ = new (thd->mem_root) Item_func_xor(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8734,7 +8734,7 @@ expr: else { /* X AND Y */ - $$ = new (thd->mem_root) Item_cond_and($1, $3); + $$ = new (thd->mem_root) Item_cond_and(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8747,37 +8747,37 @@ expr: } | bool_pri IS TRUE_SYM %prec IS { - $$= new (thd->mem_root) Item_func_istrue($1); + $$= new (thd->mem_root) Item_func_istrue(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not TRUE_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnottrue($1); + $$= new (thd->mem_root) Item_func_isnottrue(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS FALSE_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isfalse($1); + $$= new (thd->mem_root) Item_func_isfalse(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not FALSE_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnotfalse($1); + $$= new (thd->mem_root) Item_func_isnotfalse(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS UNKNOWN_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnull($1); + $$= new (thd->mem_root) Item_func_isnull(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not UNKNOWN_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnotnull($1); + $$= new (thd->mem_root) Item_func_isnotnull(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } @@ -8787,25 +8787,25 @@ expr: bool_pri: bool_pri IS NULL_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnull($1); + $$= new (thd->mem_root) Item_func_isnull(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri IS not NULL_SYM %prec IS { - $$= new (thd->mem_root) Item_func_isnotnull($1); + $$= new (thd->mem_root) Item_func_isnotnull(thd, $1); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri EQUAL_SYM predicate %prec EQUAL_SYM { - $$= new (thd->mem_root) Item_func_equal($1,$3); + $$= new (thd->mem_root) Item_func_equal(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bool_pri comp_op predicate %prec EQ { - $$= (*$2)(0)->create(thd->mem_root, $1, $3); + $$= (*$2)(0)->create(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -8844,7 +8844,7 @@ predicate: { $6->push_front($4); $6->push_front($1); - $$= new (thd->mem_root) Item_func_in(*$6); + $$= new (thd->mem_root) Item_func_in(thd, *$6); if ($$ == NULL) MYSQL_YYABORT; } @@ -8858,7 +8858,7 @@ predicate: { $7->push_front($5); $7->push_front($1); - Item_func_in *item = new (thd->mem_root) Item_func_in(*$7); + Item_func_in *item = new (thd->mem_root) Item_func_in(thd, *$7); if (item == NULL) MYSQL_YYABORT; item->negate(); @@ -8866,14 +8866,14 @@ predicate: } | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate { - $$= new (thd->mem_root) Item_func_between($1,$3,$5); + $$= new (thd->mem_root) Item_func_between(thd, $1, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate { Item_func_between *item; - item= new (thd->mem_root) Item_func_between($1,$4,$6); + item= new (thd->mem_root) Item_func_between(thd, $1, $4, $6); if (item == NULL) MYSQL_YYABORT; item->negate(); @@ -8881,39 +8881,40 @@ predicate: } | bit_expr SOUNDS_SYM LIKE bit_expr { - Item *item1= new (thd->mem_root) Item_func_soundex($1); - Item *item4= new (thd->mem_root) Item_func_soundex($4); + Item *item1= new (thd->mem_root) Item_func_soundex(thd, $1); + Item *item4= new (thd->mem_root) Item_func_soundex(thd, $4); if ((item1 == NULL) || (item4 == NULL)) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_func_eq(item1, item4); + $$= new (thd->mem_root) Item_func_eq(thd, item1, item4); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr LIKE simple_expr opt_escape { - $$= new (thd->mem_root) Item_func_like($1,$3,$4,Lex->escape_used); + $$= new (thd->mem_root) Item_func_like(thd, $1, $3, $4, + Lex->escape_used); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not LIKE simple_expr opt_escape { - Item *item= new (thd->mem_root) Item_func_like($1,$4,$5, + Item *item= new (thd->mem_root) Item_func_like(thd, $1, $4, $5, Lex->escape_used); if (item == NULL) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_func_not(item); + $$= new (thd->mem_root) Item_func_not(thd, item); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr REGEXP bit_expr { - $$= new (thd->mem_root) Item_func_regex($1,$3); + $$= new (thd->mem_root) Item_func_regex(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr not REGEXP bit_expr { - Item *item= new (thd->mem_root) Item_func_regex($1,$4); + Item *item= new (thd->mem_root) Item_func_regex(thd, $1, $4); if (item == NULL) MYSQL_YYABORT; $$= negate_expression(thd, item); @@ -8926,85 +8927,85 @@ predicate: bit_expr: bit_expr '|' bit_expr %prec '|' { - $$= new (thd->mem_root) Item_func_bit_or($1,$3); + $$= new (thd->mem_root) Item_func_bit_or(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '&' bit_expr %prec '&' { - $$= new (thd->mem_root) Item_func_bit_and($1,$3); + $$= new (thd->mem_root) Item_func_bit_and(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr SHIFT_LEFT bit_expr %prec SHIFT_LEFT { - $$= new (thd->mem_root) Item_func_shift_left($1,$3); + $$= new (thd->mem_root) Item_func_shift_left(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr SHIFT_RIGHT bit_expr %prec SHIFT_RIGHT { - $$= new (thd->mem_root) Item_func_shift_right($1,$3); + $$= new (thd->mem_root) Item_func_shift_right(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '+' bit_expr %prec '+' { - $$= new (thd->mem_root) Item_func_plus($1,$3); + $$= new (thd->mem_root) Item_func_plus(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '-' bit_expr %prec '-' { - $$= new (thd->mem_root) Item_func_minus($1,$3); + $$= new (thd->mem_root) Item_func_minus(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '+' INTERVAL_SYM expr interval %prec '+' { - $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,0); + $$= new (thd->mem_root) Item_date_add_interval(thd, $1, $4, $5, 0); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '-' INTERVAL_SYM expr interval %prec '-' { - $$= new (thd->mem_root) Item_date_add_interval($1,$4,$5,1); + $$= new (thd->mem_root) Item_date_add_interval(thd, $1, $4, $5, 1); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '*' bit_expr %prec '*' { - $$= new (thd->mem_root) Item_func_mul($1,$3); + $$= new (thd->mem_root) Item_func_mul(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '/' bit_expr %prec '/' { - $$= new (thd->mem_root) Item_func_div($1,$3); + $$= new (thd->mem_root) Item_func_div(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '%' bit_expr %prec '%' { - $$= new (thd->mem_root) Item_func_mod($1,$3); + $$= new (thd->mem_root) Item_func_mod(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr DIV_SYM bit_expr %prec DIV_SYM { - $$= new (thd->mem_root) Item_func_int_div($1,$3); + $$= new (thd->mem_root) Item_func_int_div(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr MOD_SYM bit_expr %prec MOD_SYM { - $$= new (thd->mem_root) Item_func_mod($1,$3); + $$= new (thd->mem_root) Item_func_mod(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } | bit_expr '^' bit_expr { - $$= new (thd->mem_root) Item_func_bit_xor($1,$3); + $$= new (thd->mem_root) Item_func_bit_xor(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -9182,12 +9183,12 @@ simple_expr: | function_call_conflict | simple_expr COLLATE_SYM ident_or_text %prec NEG { - Item *i1= new (thd->mem_root) Item_string($3.str, + Item *i1= new (thd->mem_root) Item_string(thd, $3.str, $3.length, thd->charset()); if (i1 == NULL) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_func_set_collation($1, i1); + $$= new (thd->mem_root) Item_func_set_collation(thd, $1, i1); if ($$ == NULL) MYSQL_YYABORT; } @@ -9197,7 +9198,7 @@ simple_expr: | sum_expr | simple_expr OR_OR_SYM simple_expr { - $$= new (thd->mem_root) Item_func_concat($1, $3); + $$= new (thd->mem_root) Item_func_concat(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -9207,13 +9208,13 @@ simple_expr: } | '-' simple_expr %prec NEG { - $$= new (thd->mem_root) Item_func_neg($2); + $$= new (thd->mem_root) Item_func_neg(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } | '~' simple_expr %prec NEG { - $$= new (thd->mem_root) Item_func_bit_neg($2); + $$= new (thd->mem_root) Item_func_bit_neg(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } @@ -9234,14 +9235,14 @@ simple_expr: | '(' expr ',' expr_list ')' { $4->push_front($2); - $$= new (thd->mem_root) Item_row(*$4); + $$= new (thd->mem_root) Item_row(thd, *$4); if ($$ == NULL) MYSQL_YYABORT; } | ROW_SYM '(' expr ',' expr_list ')' { $5->push_front($3); - $$= new (thd->mem_root) Item_row(*$5); + $$= new (thd->mem_root) Item_row(thd, *$5); if ($$ == NULL) MYSQL_YYABORT; } @@ -9278,7 +9279,8 @@ simple_expr: | MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')' { $2->push_front($5); - Item_func_match *i1= new (thd->mem_root) Item_func_match(*$2, $6); + Item_func_match *i1= new (thd->mem_root) Item_func_match(thd, *$2, + $6); if (i1 == NULL) MYSQL_YYABORT; Select->add_ftfunc_to_list(i1); @@ -9301,7 +9303,7 @@ simple_expr: } | CASE_SYM opt_expr when_list opt_else END { - $$= new (thd->mem_root) Item_func_case(* $3, $2, $4 ); + $$= new (thd->mem_root) Item_func_case(thd, *$3, $2, $4); if ($$ == NULL) MYSQL_YYABORT; } @@ -9314,7 +9316,7 @@ simple_expr: } | CONVERT_SYM '(' expr USING charset_name ')' { - $$= new (thd->mem_root) Item_func_conv_charset($3,$5); + $$= new (thd->mem_root) Item_func_conv_charset(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } @@ -9342,7 +9344,7 @@ simple_expr: | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM /* we cannot put interval before - */ { - $$= new (thd->mem_root) Item_date_add_interval($5,$2,$3,0); + $$= new (thd->mem_root) Item_date_add_interval(thd, $5, $2, $3, 0); if ($$ == NULL) MYSQL_YYABORT; } @@ -9357,19 +9359,20 @@ simple_expr: function_call_keyword: CHAR_SYM '(' expr_list ')' { - $$= new (thd->mem_root) Item_func_char(*$3); + $$= new (thd->mem_root) Item_func_char(thd, *$3); if ($$ == NULL) MYSQL_YYABORT; } | CHAR_SYM '(' expr_list USING charset_name ')' { - $$= new (thd->mem_root) Item_func_char(*$3, $5); + $$= new (thd->mem_root) Item_func_char(thd, *$3, $5); if ($$ == NULL) MYSQL_YYABORT; } | CURRENT_USER optional_braces { - $$= new (thd->mem_root) Item_func_current_user(Lex->current_context()); + $$= new (thd->mem_root) Item_func_current_user(thd, + Lex->current_context()); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -9377,7 +9380,8 @@ function_call_keyword: } | CURRENT_ROLE optional_braces { - $$= new (thd->mem_root) Item_func_current_role(Lex->current_context()); + $$= new (thd->mem_root) Item_func_current_role(thd, + Lex->current_context()); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -9385,25 +9389,25 @@ function_call_keyword: } | DATE_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_date_typecast($3); + $$= new (thd->mem_root) Item_date_typecast(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | DAY_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_dayofmonth($3); + $$= new (thd->mem_root) Item_func_dayofmonth(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | HOUR_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_hour($3); + $$= new (thd->mem_root) Item_func_hour(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | INSERT '(' expr ',' expr ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_insert($3,$5,$7,$9); + $$= new (thd->mem_root) Item_func_insert(thd, $3, $5, $7, $9); if ($$ == NULL) MYSQL_YYABORT; } @@ -9414,10 +9418,10 @@ function_call_keyword: MYSQL_YYABORT; list->push_front($5); list->push_front($3); - Item_row *item= new (thd->mem_root) Item_row(*list); + Item_row *item= new (thd->mem_root) Item_row(thd, *list); if (item == NULL) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_func_interval(item); + $$= new (thd->mem_root) Item_func_interval(thd, item); if ($$ == NULL) MYSQL_YYABORT; } @@ -9425,112 +9429,114 @@ function_call_keyword: { $7->push_front($5); $7->push_front($3); - Item_row *item= new (thd->mem_root) Item_row(*$7); + Item_row *item= new (thd->mem_root) Item_row(thd, *$7); if (item == NULL) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_func_interval(item); + $$= new (thd->mem_root) Item_func_interval(thd, item); if ($$ == NULL) MYSQL_YYABORT; } | LEFT '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_left($3,$5); + $$= new (thd->mem_root) Item_func_left(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | MINUTE_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_minute($3); + $$= new (thd->mem_root) Item_func_minute(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | MONTH_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_month($3); + $$= new (thd->mem_root) Item_func_month(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | RIGHT '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_right($3,$5); + $$= new (thd->mem_root) Item_func_right(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | SECOND_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_second($3); + $$= new (thd->mem_root) Item_func_second(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | TIME_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_time_typecast($3, AUTO_SEC_PART_DIGITS); + $$= new (thd->mem_root) Item_time_typecast(thd, $3, + AUTO_SEC_PART_DIGITS); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP '(' expr ')' { - $$= new (thd->mem_root) Item_datetime_typecast($3, AUTO_SEC_PART_DIGITS); + $$= new (thd->mem_root) Item_datetime_typecast(thd, $3, + AUTO_SEC_PART_DIGITS); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_add_time($3, $5, 1, 0); + $$= new (thd->mem_root) Item_func_add_time(thd, $3, $5, 1, 0); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' expr ')' { - $$= new (thd->mem_root) Item_func_trim($3); + $$= new (thd->mem_root) Item_func_trim(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' LEADING expr FROM expr ')' { - $$= new (thd->mem_root) Item_func_ltrim($6,$4); + $$= new (thd->mem_root) Item_func_ltrim(thd, $6, $4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' TRAILING expr FROM expr ')' { - $$= new (thd->mem_root) Item_func_rtrim($6,$4); + $$= new (thd->mem_root) Item_func_rtrim(thd, $6, $4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' BOTH expr FROM expr ')' { - $$= new (thd->mem_root) Item_func_trim($6,$4); + $$= new (thd->mem_root) Item_func_trim(thd, $6, $4); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' LEADING FROM expr ')' { - $$= new (thd->mem_root) Item_func_ltrim($5); + $$= new (thd->mem_root) Item_func_ltrim(thd, $5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' TRAILING FROM expr ')' { - $$= new (thd->mem_root) Item_func_rtrim($5); + $$= new (thd->mem_root) Item_func_rtrim(thd, $5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' BOTH FROM expr ')' { - $$= new (thd->mem_root) Item_func_trim($5); + $$= new (thd->mem_root) Item_func_trim(thd, $5); if ($$ == NULL) MYSQL_YYABORT; } | TRIM '(' expr FROM expr ')' { - $$= new (thd->mem_root) Item_func_trim($5,$3); + $$= new (thd->mem_root) Item_func_trim(thd, $5, $3); if ($$ == NULL) MYSQL_YYABORT; } | USER '(' ')' { - $$= new (thd->mem_root) Item_func_user(); + $$= new (thd->mem_root) Item_func_user(thd); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -9538,7 +9544,7 @@ function_call_keyword: } | YEAR_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_year($3); + $$= new (thd->mem_root) Item_func_year(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -9559,27 +9565,27 @@ function_call_keyword: function_call_nonkeyword: ADDDATE_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_date_add_interval($3, $5, + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 0); if ($$ == NULL) MYSQL_YYABORT; } | ADDDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { - $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 0); + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 0); if ($$ == NULL) MYSQL_YYABORT; } | CURDATE optional_braces { - $$= new (thd->mem_root) Item_func_curdate_local(); + $$= new (thd->mem_root) Item_func_curdate_local(thd); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | CURTIME opt_time_precision { - $$= new (thd->mem_root) Item_func_curtime_local($2); + $$= new (thd->mem_root) Item_func_curtime_local(thd, $2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; @@ -9587,76 +9593,76 @@ function_call_nonkeyword: | DATE_ADD_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM { - $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,0); + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 0); if ($$ == NULL) MYSQL_YYABORT; } | DATE_SUB_INTERVAL '(' expr ',' INTERVAL_SYM expr interval ')' %prec INTERVAL_SYM { - $$= new (thd->mem_root) Item_date_add_interval($3,$6,$7,1); + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 1); if ($$ == NULL) MYSQL_YYABORT; } | EXTRACT_SYM '(' interval FROM expr ')' { - $$=new (thd->mem_root) Item_extract( $3, $5); + $$=new (thd->mem_root) Item_extract(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | GET_FORMAT '(' date_time_type ',' expr ')' { - $$= new (thd->mem_root) Item_func_get_format($3, $5); + $$= new (thd->mem_root) Item_func_get_format(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | NOW_SYM opt_time_precision { - $$= new (thd->mem_root) Item_func_now_local($2); + $$= new (thd->mem_root) Item_func_now_local(thd, $2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | POSITION_SYM '(' bit_expr IN_SYM expr ')' { - $$ = new (thd->mem_root) Item_func_locate($5,$3); + $$ = new (thd->mem_root) Item_func_locate(thd, $5, $3); if ($$ == NULL) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_date_add_interval($3, $5, + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUBDATE_SYM '(' expr ',' INTERVAL_SYM expr interval ')' { - $$= new (thd->mem_root) Item_date_add_interval($3, $6, $7, 1); + $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $6, $7, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_substr($3,$5,$7); + $$= new (thd->mem_root) Item_func_substr(thd, $3, $5, $7); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_substr($3,$5); + $$= new (thd->mem_root) Item_func_substr(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr FOR_SYM expr ')' { - $$= new (thd->mem_root) Item_func_substr($3,$5,$7); + $$= new (thd->mem_root) Item_func_substr(thd, $3, $5, $7); if ($$ == NULL) MYSQL_YYABORT; } | SUBSTRING '(' expr FROM expr ')' { - $$= new (thd->mem_root) Item_func_substr($3,$5); + $$= new (thd->mem_root) Item_func_substr(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } @@ -9671,42 +9677,42 @@ function_call_nonkeyword: */ Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); if (global_system_variables.sysdate_is_now == 0) - $$= new (thd->mem_root) Item_func_sysdate_local($2); + $$= new (thd->mem_root) Item_func_sysdate_local(thd, $2); else - $$= new (thd->mem_root) Item_func_now_local($2); + $$= new (thd->mem_root) Item_func_now_local(thd, $2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_date_add_interval($7,$5,$3,0); + $$= new (thd->mem_root) Item_date_add_interval(thd, $7, $5, $3, 0); if ($$ == NULL) MYSQL_YYABORT; } | TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_timestamp_diff($5,$7,$3); + $$= new (thd->mem_root) Item_func_timestamp_diff(thd, $5, $7, $3); if ($$ == NULL) MYSQL_YYABORT; } | UTC_DATE_SYM optional_braces { - $$= new (thd->mem_root) Item_func_curdate_utc(); + $$= new (thd->mem_root) Item_func_curdate_utc(thd); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | UTC_TIME_SYM opt_time_precision { - $$= new (thd->mem_root) Item_func_curtime_utc($2); + $$= new (thd->mem_root) Item_func_curtime_utc(thd, $2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | UTC_TIMESTAMP_SYM opt_time_precision { - $$= new (thd->mem_root) Item_func_now_utc($2); + $$= new (thd->mem_root) Item_func_now_utc(thd, $2); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; @@ -9728,7 +9734,7 @@ function_call_nonkeyword: | COLUMN_CHECK_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_dyncol_check($3); + $$= new (thd->mem_root) Item_func_dyncol_check(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -9759,113 +9765,113 @@ function_call_nonkeyword: function_call_conflict: ASCII_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_ascii($3); + $$= new (thd->mem_root) Item_func_ascii(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | CHARSET '(' expr ')' { - $$= new (thd->mem_root) Item_func_charset($3); + $$= new (thd->mem_root) Item_func_charset(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | COALESCE '(' expr_list ')' { - $$= new (thd->mem_root) Item_func_coalesce(* $3); + $$= new (thd->mem_root) Item_func_coalesce(thd, *$3); if ($$ == NULL) MYSQL_YYABORT; } | COLLATION_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_collation($3); + $$= new (thd->mem_root) Item_func_collation(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | DATABASE '(' ')' { - $$= new (thd->mem_root) Item_func_database(); + $$= new (thd->mem_root) Item_func_database(thd); if ($$ == NULL) MYSQL_YYABORT; Lex->safe_to_cache_query=0; } | IF_SYM '(' expr ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_if($3,$5,$7); + $$= new (thd->mem_root) Item_func_if(thd, $3, $5, $7); if ($$ == NULL) MYSQL_YYABORT; } | FORMAT_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_format($3, $5); + $$= new (thd->mem_root) Item_func_format(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | FORMAT_SYM '(' expr ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_format($3, $5, $7); + $$= new (thd->mem_root) Item_func_format(thd, $3, $5, $7); if ($$ == NULL) MYSQL_YYABORT; } | LAST_VALUE '(' expr_list ')' { - $$= new (thd->mem_root) Item_func_last_value(* $3); + $$= new (thd->mem_root) Item_func_last_value(thd, *$3); if ($$ == NULL) MYSQL_YYABORT; } | MICROSECOND_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_microsecond($3); + $$= new (thd->mem_root) Item_func_microsecond(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | MOD_SYM '(' expr ',' expr ')' { - $$ = new (thd->mem_root) Item_func_mod($3, $5); + $$ = new (thd->mem_root) Item_func_mod(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | OLD_PASSWORD_SYM '(' expr ')' { $$= new (thd->mem_root) - Item_func_password($3, Item_func_password::OLD); + Item_func_password(thd, $3, Item_func_password::OLD); if ($$ == NULL) MYSQL_YYABORT; } | PASSWORD_SYM '(' expr ')' { Item* i1; - i1= new (thd->mem_root) Item_func_password($3); + i1= new (thd->mem_root) Item_func_password(thd, $3); if (i1 == NULL) MYSQL_YYABORT; $$= i1; } | QUARTER_SYM '(' expr ')' { - $$ = new (thd->mem_root) Item_func_quarter($3); + $$ = new (thd->mem_root) Item_func_quarter(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | REPEAT_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_repeat($3,$5); + $$= new (thd->mem_root) Item_func_repeat(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | REPLACE '(' expr ',' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_replace($3,$5,$7); + $$= new (thd->mem_root) Item_func_replace(thd, $3, $5, $7); if ($$ == NULL) MYSQL_YYABORT; } | REVERSE_SYM '(' expr ')' { - $$= new (thd->mem_root) Item_func_reverse($3); + $$= new (thd->mem_root) Item_func_reverse(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | ROW_COUNT_SYM '(' ')' { - $$= new (thd->mem_root) Item_func_row_count(); + $$= new (thd->mem_root) Item_func_row_count(thd); if ($$ == NULL) MYSQL_YYABORT; Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); @@ -9873,7 +9879,7 @@ function_call_conflict: } | TRUNCATE_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_round($3,$5,1); + $$= new (thd->mem_root) Item_func_round(thd, $3, $5, 1); if ($$ == NULL) MYSQL_YYABORT; } @@ -9887,43 +9893,46 @@ function_call_conflict: i1->set_name((const char *) STRING_WITH_LEN("@@default_week_format"), system_charset_info); - $$= new (thd->mem_root) Item_func_week($3, i1); + $$= new (thd->mem_root) Item_func_week(thd, $3, i1); if ($$ == NULL) MYSQL_YYABORT; } | WEEK_SYM '(' expr ',' expr ')' { - $$= new (thd->mem_root) Item_func_week($3,$5); + $$= new (thd->mem_root) Item_func_week(thd, $3, $5); if ($$ == NULL) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr opt_ws_levels ')' { - $$= new (thd->mem_root) Item_func_weight_string($3, 0, 0, $4); + $$= new (thd->mem_root) Item_func_weight_string(thd, $3, 0, 0, $4); if ($$ == NULL) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr AS CHAR_SYM ws_nweights opt_ws_levels ')' { $$= new (thd->mem_root) - Item_func_weight_string($3, 0, $6, + Item_func_weight_string(thd, $3, 0, $6, $7 | MY_STRXFRM_PAD_WITH_SPACE); if ($$ == NULL) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr AS BINARY ws_nweights ')' { - Item *item= new (thd->mem_root) Item_char_typecast($3, $6, &my_charset_bin); + Item *item= new (thd->mem_root) Item_char_typecast(thd, $3, $6, + &my_charset_bin); if (item == NULL) MYSQL_YYABORT; $$= new (thd->mem_root) - Item_func_weight_string(item, 0, $6, MY_STRXFRM_PAD_WITH_SPACE); + Item_func_weight_string(thd, item, 0, $6, + MY_STRXFRM_PAD_WITH_SPACE); if ($$ == NULL) MYSQL_YYABORT; } | WEIGHT_STRING_SYM '(' expr ',' ulong_num ',' ulong_num ',' ulong_num ')' { - $$= new (thd->mem_root) Item_func_weight_string($3, $5, $7, $9); + $$= new (thd->mem_root) Item_func_weight_string(thd, $3, $5, $7, + $9); if ($$ == NULL) MYSQL_YYABORT; } @@ -9946,52 +9955,52 @@ geometry_function: CONTAINS_SYM '(' expr ',' expr ')' { $$= GEOM_NEW(thd, - Item_func_spatial_precise_rel($3, $5, + Item_func_spatial_precise_rel(thd, $3, $5, Item_func::SP_CONTAINS_FUNC)); } | GEOMETRYCOLLECTION '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_geometrycollection, Geometry::wkb_point)); } | LINESTRING '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_linestring, Geometry::wkb_point)); } | MULTILINESTRING '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_multilinestring, Geometry::wkb_linestring)); } | MULTIPOINT '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_multipoint, Geometry::wkb_point)); } | MULTIPOLYGON '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_multipolygon, Geometry::wkb_polygon)); } | POINT_SYM '(' expr ',' expr ')' { - $$= GEOM_NEW(thd, Item_func_point($3,$5)); + $$= GEOM_NEW(thd, Item_func_point(thd, $3, $5)); } | POLYGON '(' expr_list ')' { $$= GEOM_NEW(thd, - Item_func_spatial_collection(* $3, + Item_func_spatial_collection(thd, *$3, Geometry::wkb_polygon, Geometry::wkb_linestring)); } @@ -10186,46 +10195,46 @@ udf_expr: sum_expr: AVG_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_avg($3, FALSE); + $$= new (thd->mem_root) Item_sum_avg(thd, $3, FALSE); if ($$ == NULL) MYSQL_YYABORT; } | AVG_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_avg($4, TRUE); + $$= new (thd->mem_root) Item_sum_avg(thd, $4, TRUE); if ($$ == NULL) MYSQL_YYABORT; } | BIT_AND '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_and($3); + $$= new (thd->mem_root) Item_sum_and(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | BIT_OR '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_or($3); + $$= new (thd->mem_root) Item_sum_or(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | BIT_XOR '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_xor($3); + $$= new (thd->mem_root) Item_sum_xor(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | COUNT_SYM '(' opt_all '*' ')' { - Item *item= new (thd->mem_root) Item_int((int32) 0L,1); + Item *item= new (thd->mem_root) Item_int(thd, (int32) 0L, 1); if (item == NULL) MYSQL_YYABORT; - $$= new (thd->mem_root) Item_sum_count(item); + $$= new (thd->mem_root) Item_sum_count(thd, item); if ($$ == NULL) MYSQL_YYABORT; } | COUNT_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_count($3); + $$= new (thd->mem_root) Item_sum_count(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -10235,13 +10244,13 @@ sum_expr: { Select->in_sum_expr--; } ')' { - $$= new (thd->mem_root) Item_sum_count(* $5); + $$= new (thd->mem_root) Item_sum_count(thd, *$5); if ($$ == NULL) MYSQL_YYABORT; } | MIN_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_min($3); + $$= new (thd->mem_root) Item_sum_min(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } @@ -10252,55 +10261,55 @@ sum_expr: */ | MIN_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_min($4); + $$= new (thd->mem_root) Item_sum_min(thd, $4); if ($$ == NULL) MYSQL_YYABORT; } | MAX_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_max($3); + $$= new (thd->mem_root) Item_sum_max(thd, $3); if ($$ == NULL) MYSQL_YYABORT; } | MAX_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_max($4); + $$= new (thd->mem_root) Item_sum_max(thd, $4); if ($$ == NULL) MYSQL_YYABORT; } | STD_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_std($3, 0); + $$= new (thd->mem_root) Item_sum_std(thd, $3, 0); if ($$ == NULL) MYSQL_YYABORT; } | VARIANCE_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_variance($3, 0); + $$= new (thd->mem_root) Item_sum_variance(thd, $3, 0); if ($$ == NULL) MYSQL_YYABORT; } | STDDEV_SAMP_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_std($3, 1); + $$= new (thd->mem_root) Item_sum_std(thd, $3, 1); if ($$ == NULL) MYSQL_YYABORT; } | VAR_SAMP_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_variance($3, 1); + $$= new (thd->mem_root) Item_sum_variance(thd, $3, 1); if ($$ == NULL) MYSQL_YYABORT; } | SUM_SYM '(' in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_sum($3, FALSE); + $$= new (thd->mem_root) Item_sum_sum(thd, $3, FALSE); if ($$ == NULL) MYSQL_YYABORT; } | SUM_SYM '(' DISTINCT in_sum_expr ')' { - $$= new (thd->mem_root) Item_sum_sum($4, TRUE); + $$= new (thd->mem_root) Item_sum_sum(thd, $4, TRUE); if ($$ == NULL) MYSQL_YYABORT; } @@ -10313,7 +10322,7 @@ sum_expr: SELECT_LEX *sel= Select; sel->in_sum_expr--; $$= new (thd->mem_root) - Item_func_group_concat(Lex->current_context(), $3, $5, + Item_func_group_concat(thd, Lex->current_context(), $3, $5, sel->gorder_list, $7); if ($$ == NULL) MYSQL_YYABORT; @@ -10341,7 +10350,7 @@ variable_aux: ident_or_text SET_VAR expr { Item_func_set_user_var *item; - $$= item= new (thd->mem_root) Item_func_set_user_var($1, $3); + $$= item= new (thd->mem_root) Item_func_set_user_var(thd, $1, $3); if ($$ == NULL) MYSQL_YYABORT; LEX *lex= Lex; @@ -10350,7 +10359,7 @@ variable_aux: } | ident_or_text { - $$= new (thd->mem_root) Item_func_get_user_var($1); + $$= new (thd->mem_root) Item_func_get_user_var(thd, $1); if ($$ == NULL) MYSQL_YYABORT; LEX *lex= Lex; @@ -10604,7 +10613,7 @@ join_table: expr { $3->straight=$2; - add_join_on($3,$6); + add_join_on(thd, $3, $6); Lex->pop_context(); Select->parsing_place= NO_MATTER; } @@ -10638,7 +10647,7 @@ join_table: } expr { - add_join_on($5,$8); + add_join_on(thd, $5, $8); Lex->pop_context(); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; @@ -10677,7 +10686,7 @@ join_table: LEX *lex= Lex; if (!($$= lex->current_select->convert_right_join())) MYSQL_YYABORT; - add_join_on($$, $8); + add_join_on(thd, $$, $8); Lex->pop_context(); Select->parsing_place= NO_MATTER; } @@ -11166,7 +11175,7 @@ where_clause: expr { SELECT_LEX *select= Select; - select->where= normalize_cond($3); + select->where= normalize_cond(thd, $3); select->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -11182,7 +11191,7 @@ having_clause: expr { SELECT_LEX *sel= Select; - sel->having= normalize_cond($3); + sel->having= normalize_cond(thd, $3); sel->parsing_place= NO_MATTER; if ($3) $3->top_level_item(); @@ -11199,8 +11208,8 @@ opt_escape: { Lex->escape_used= FALSE; $$= ((thd->variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES) ? - new (thd->mem_root) Item_string_ascii("", 0) : - new (thd->mem_root) Item_string_ascii("\\", 1)); + new (thd->mem_root) Item_string_ascii(thd, "", 0) : + new (thd->mem_root) Item_string_ascii(thd, "\\", 1)); if ($$ == NULL) MYSQL_YYABORT; } @@ -11449,7 +11458,7 @@ limit_option: if (spc && (spv = spc->find_variable($1, false))) { splocal= new (thd->mem_root) - Item_splocal($1, spv->offset, spv->type, + Item_splocal(thd, $1, spv->offset, spv->type, lip->get_tok_start() - lex->sphead->m_tmp_query, lip->get_ptr() - lip->get_tok_start()); if (splocal == NULL) @@ -11478,19 +11487,19 @@ limit_option: } | ULONGLONG_NUM { - $$= new (thd->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | LONG_NUM { - $$= new (thd->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | NUM { - $$= new (thd->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } @@ -12788,7 +12797,7 @@ wild_and_where: } | WHERE remember_tok_start expr { - Select->where= normalize_cond($3); + Select->where= normalize_cond(thd, $3); if ($3) $3->top_level_item(); $$= $2; @@ -13314,7 +13323,7 @@ field_or_var: simple_ident_nospvar {$$= $1;} | '@' ident_or_text { - $$= new (thd->mem_root) Item_user_var_as_out_param($2); + $$= new (thd->mem_root) Item_user_var_as_out_param(thd, $2); if ($$ == NULL) MYSQL_YYABORT; } @@ -13361,7 +13370,8 @@ text_literal: if (thd->convert_string(&tmp, cs_con, $1.str, $1.length, cs_cli)) MYSQL_YYABORT; } - $$= new (thd->mem_root) Item_string(tmp.str, tmp.length, cs_con, + $$= new (thd->mem_root) Item_string(thd, tmp.str, tmp.length, + cs_con, DERIVATION_COERCIBLE, repertoire); if ($$ == NULL) @@ -13372,7 +13382,7 @@ text_literal: uint repertoire= Lex->text_string_is_7bit ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30; DBUG_ASSERT(my_charset_is_ascii_based(national_charset_info)); - $$= new (thd->mem_root) Item_string($1.str, $1.length, + $$= new (thd->mem_root) Item_string(thd, $1.str, $1.length, national_charset_info, DERIVATION_COERCIBLE, repertoire); @@ -13381,7 +13391,7 @@ text_literal: } | UNDERSCORE_CHARSET TEXT_STRING { - $$= new (thd->mem_root) Item_string_with_introducer($2.str, + $$= new (thd->mem_root) Item_string_with_introducer(thd, $2.str, $2.length, $1); if ($$ == NULL) MYSQL_YYABORT; @@ -13420,7 +13430,8 @@ text_string: hex_or_bin_String: HEX_NUM { - Item *tmp= new (thd->mem_root) Item_hex_hybrid($1.str, $1.length); + Item *tmp= new (thd->mem_root) Item_hex_hybrid(thd, $1.str, + $1.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -13432,7 +13443,8 @@ hex_or_bin_String: } | HEX_STRING { - Item *tmp= new (thd->mem_root) Item_hex_string($1.str, $1.length); + Item *tmp= new (thd->mem_root) Item_hex_string(thd, $1.str, + $1.length); if (tmp == NULL) MYSQL_YYABORT; tmp->quick_fix_field(); @@ -13440,7 +13452,8 @@ hex_or_bin_String: } | BIN_NUM { - Item *tmp= new (thd->mem_root) Item_bin_string($1.str, $1.length); + Item *tmp= new (thd->mem_root) Item_bin_string(thd, $1.str, + $1.length); if (tmp == NULL) MYSQL_YYABORT; /* @@ -13465,7 +13478,8 @@ param_marker: } const char *query_start= lex->sphead ? lex->sphead->m_tmp_query : thd->query(); - item= new (thd->mem_root) Item_param(lip->get_tok_start() - query_start); + item= new (thd->mem_root) Item_param(thd, lip->get_tok_start() - + query_start); if (!($$= item) || lex->param_list.push_back(item)) { my_message(ER_OUT_OF_RESOURCES, ER_THD(thd, ER_OUT_OF_RESOURCES), MYF(0)); @@ -13480,7 +13494,7 @@ signed_literal: | '-' NUM_literal { $2->max_length++; - $$= $2->neg(); + $$= $2->neg(thd); } ; @@ -13497,38 +13511,38 @@ literal: TOK_GENERIC_VALUE := NULL_SYM */ YYLIP->reduce_digest_token(TOK_GENERIC_VALUE, NULL_SYM); - $$ = new (thd->mem_root) Item_null(); + $$ = new (thd->mem_root) Item_null(thd); if ($$ == NULL) MYSQL_YYABORT; YYLIP->next_state= MY_LEX_OPERATOR_OR_IDENT; } | FALSE_SYM { - $$= new (thd->mem_root) Item_int((char*) "FALSE",0,1); + $$= new (thd->mem_root) Item_int(thd, (char*) "FALSE",0,1); if ($$ == NULL) MYSQL_YYABORT; } | TRUE_SYM { - $$= new (thd->mem_root) Item_int((char*) "TRUE",1,1); + $$= new (thd->mem_root) Item_int(thd, (char*) "TRUE",1,1); if ($$ == NULL) MYSQL_YYABORT; } | HEX_NUM { - $$ = new (thd->mem_root) Item_hex_hybrid($1.str, $1.length); + $$ = new (thd->mem_root) Item_hex_hybrid(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | HEX_STRING { - $$ = new (thd->mem_root) Item_hex_string($1.str, $1.length); + $$ = new (thd->mem_root) Item_hex_string(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | BIN_NUM { - $$= new (thd->mem_root) Item_bin_string($1.str, $1.length); + $$= new (thd->mem_root) Item_bin_string(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } @@ -13540,7 +13554,8 @@ literal: will include the introducer and the original hex/bin notation. */ item_str= new (thd->mem_root) - Item_string_with_introducer(NULL, $2->ptr(), $2->length(), $1); + Item_string_with_introducer(thd, NULL, $2->ptr(), $2->length(), + $1); if (!item_str || !item_str->check_well_formed_result(true)) MYSQL_YYABORT; @@ -13553,7 +13568,7 @@ NUM_literal: { int error; $$= new (thd->mem_root) - Item_int($1.str, + Item_int(thd, $1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); if ($$ == NULL) @@ -13563,7 +13578,7 @@ NUM_literal: { int error; $$= new (thd->mem_root) - Item_int($1.str, + Item_int(thd, $1.str, (longlong) my_strtoll10($1.str, NULL, &error), $1.length); if ($$ == NULL) @@ -13571,13 +13586,13 @@ NUM_literal: } | ULONGLONG_NUM { - $$= new (thd->mem_root) Item_uint($1.str, $1.length); + $$= new (thd->mem_root) Item_uint(thd, $1.str, $1.length); if ($$ == NULL) MYSQL_YYABORT; } | DECIMAL_NUM { - $$= new (thd->mem_root) Item_decimal($1.str, $1.length, + $$= new (thd->mem_root) Item_decimal(thd, $1.str, $1.length, thd->charset()); if (($$ == NULL) || (thd->is_error())) { @@ -13586,7 +13601,7 @@ NUM_literal: } | FLOAT_NUM { - $$= new (thd->mem_root) Item_float($1.str, $1.length); + $$= new (thd->mem_root) Item_float(thd, $1.str, $1.length); if (($$ == NULL) || (thd->is_error())) { MYSQL_YYABORT; @@ -13674,7 +13689,7 @@ simple_ident: Item_splocal *splocal; splocal= new (thd->mem_root) - Item_splocal($1, spv->offset, spv->type, + Item_splocal(thd, $1, spv->offset, spv->type, lip->get_tok_start_prev() - lex->sphead->m_tmp_query, lip->get_tok_end() - lip->get_tok_start_prev()); if (splocal == NULL) @@ -13696,7 +13711,7 @@ simple_ident: } else { - $$= new (thd->mem_root) Item_ref(Lex->current_context(), + $$= new (thd->mem_root) Item_ref(thd, Lex->current_context(), NullS, NullS, $1.str); } if ($$ == NULL) @@ -13718,7 +13733,7 @@ simple_ident_nospvar: } else { - $$= new (thd->mem_root) Item_ref(Lex->current_context(), + $$= new (thd->mem_root) Item_ref(thd, Lex->current_context(), NullS, NullS, $1.str); } if ($$ == NULL) @@ -13799,7 +13814,7 @@ simple_ident_q: } else { - $$= new (thd->mem_root) Item_ref(Lex->current_context(), + $$= new (thd->mem_root) Item_ref(thd, Lex->current_context(), NullS, $1.str, $3.str); } if ($$ == NULL) @@ -13824,7 +13839,7 @@ simple_ident_q: } else { - $$= new (thd->mem_root) Item_ref(Lex->current_context(), + $$= new (thd->mem_root) Item_ref(thd, Lex->current_context(), NullS, $2.str, $4.str); } if ($$ == NULL) @@ -13850,7 +13865,7 @@ simple_ident_q: } else { - $$= new (thd->mem_root) Item_ref(Lex->current_context(), + $$= new (thd->mem_root) Item_ref(thd, Lex->current_context(), schema, $3.str, $5.str); } @@ -14696,7 +14711,7 @@ option_value_no_option_type: | '@' ident_or_text equal expr { Item_func_set_user_var *item; - item= new (thd->mem_root) Item_func_set_user_var($2, $4); + item= new (thd->mem_root) Item_func_set_user_var(thd, $2, $4); if (item == NULL) MYSQL_YYABORT; set_var_user *var= new set_var_user(item); @@ -14906,10 +14921,10 @@ transaction_access_mode: transaction_access_mode_types { LEX *lex=Lex; - Item *item= new (thd->mem_root) Item_int((int32) $1); + Item *item= new (thd->mem_root) Item_int(thd, (int32) $1); if (item == NULL) MYSQL_YYABORT; - set_var *var= new set_var(lex->option_type, + set_var *var= new set_var(thd, lex->option_type, find_sys_var(thd, "tx_read_only"), &null_lex_str, item); @@ -14923,10 +14938,10 @@ isolation_level: ISOLATION LEVEL_SYM isolation_types { LEX *lex=Lex; - Item *item= new (thd->mem_root) Item_int((int32) $3); + Item *item= new (thd->mem_root) Item_int(thd, (int32) $3); if (item == NULL) MYSQL_YYABORT; - set_var *var= new set_var(lex->option_type, + set_var *var= new set_var(thd, lex->option_type, find_sys_var(thd, "tx_isolation"), &null_lex_str, item); @@ -14986,19 +15001,19 @@ set_expr_or_default: | DEFAULT { $$=0; } | ON { - $$=new (thd->mem_root) Item_string_sys("ON", 2); + $$=new (thd->mem_root) Item_string_sys(thd, "ON", 2); if ($$ == NULL) MYSQL_YYABORT; } | ALL { - $$=new (thd->mem_root) Item_string_sys("ALL", 3); + $$=new (thd->mem_root) Item_string_sys(thd, "ALL", 3); if ($$ == NULL) MYSQL_YYABORT; } | BINARY { - $$=new (thd->mem_root) Item_string_sys("binary", 6); + $$=new (thd->mem_root) Item_string_sys(thd, "binary", 6); if ($$ == NULL) MYSQL_YYABORT; } @@ -15115,7 +15130,7 @@ handler: lex->expr_allows_subselect= FALSE; lex->sql_command = SQLCOM_HA_READ; lex->ha_rkey_mode= HA_READ_KEY_EXACT; /* Avoid purify warnings */ - Item *one= new (thd->mem_root) Item_int((int32) 1); + Item *one= new (thd->mem_root) Item_int(thd, (int32) 1); if (one == NULL) MYSQL_YYABORT; lex->current_select->select_limit= one; diff --git a/sql/table.cc b/sql/table.cc index 92ecb517aeb..9beada2667f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -4142,7 +4142,7 @@ bool TABLE::fill_item_list(List<Item> *item_list) const */ for (Field **ptr= field; *ptr; ptr++) { - Item_field *item= new Item_field(*ptr); + Item_field *item= new Item_field(in_use, *ptr); if (!item || item_list->push_back(item)) return TRUE; } @@ -4390,7 +4390,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, this expression will not be moved to WHERE condition (i.e. will be clean correctly for PS/SP) */ - tbl->on_expr= and_conds(tbl->on_expr, + tbl->on_expr= and_conds(thd, tbl->on_expr, where->copy_andor_structure(thd)); break; } @@ -4400,7 +4400,7 @@ bool TABLE_LIST::prep_where(THD *thd, Item **conds, if (*conds && !(*conds)->fixed) res= (*conds)->fix_fields(thd, conds); if (!res) - *conds= and_conds(*conds, where->copy_andor_structure(thd)); + *conds= and_conds(thd, *conds, where->copy_andor_structure(thd)); if (*conds && !(*conds)->fixed && !res) res= (*conds)->fix_fields(thd, conds); } @@ -4472,7 +4472,7 @@ merge_on_conds(THD *thd, TABLE_LIST *table, bool is_cascaded) { if (tbl->view && !is_cascaded) continue; - cond= and_conds(cond, merge_on_conds(thd, tbl, is_cascaded)); + cond= and_conds(thd, cond, merge_on_conds(thd, tbl, is_cascaded)); } DBUG_RETURN(cond); } @@ -4532,10 +4532,10 @@ bool TABLE_LIST::prep_check_option(THD *thd, uint8 check_opt_type) for (TABLE_LIST *tbl= merge_underlying_list; tbl; tbl= tbl->next_local) { if (tbl->check_option) - check_option= and_conds(check_option, tbl->check_option); + check_option= and_conds(thd, check_option, tbl->check_option); } } - check_option= and_conds(check_option, + check_option= and_conds(thd, check_option, merge_on_conds(thd, this, is_cascaded)); if (arena) @@ -5354,7 +5354,7 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref, { DBUG_RETURN(field); } - Item *item= new Item_direct_view_ref(&view->view->select_lex.context, + Item *item= new Item_direct_view_ref(thd, &view->view->select_lex.context, field_ref, view->alias, name, view); /* @@ -7328,7 +7328,7 @@ bool TABLE_LIST::change_refs_to_fields() DBUG_ASSERT(!field_it.end_of_fields()); if (!materialized_items[idx]) { - materialized_items[idx]= new Item_field(table->field[idx]); + materialized_items[idx]= new Item_field(thd, table->field[idx]); if (!materialized_items[idx]) return TRUE; } |