diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/event_scheduler.cc | 2 | ||||
-rw-r--r-- | sql/field.cc | 243 | ||||
-rw-r--r-- | sql/field.h | 40 | ||||
-rw-r--r-- | sql/ha_partition.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 103 | ||||
-rw-r--r-- | sql/item.h | 4 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 | ||||
-rw-r--r-- | sql/item_create.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 20 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 12 | ||||
-rw-r--r-- | sql/item_sum.cc | 46 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 | ||||
-rw-r--r-- | sql/net_serv.cc | 17 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 1 | ||||
-rw-r--r-- | sql/sql_acl.cc | 38 | ||||
-rw-r--r-- | sql/sql_cache.cc | 36 | ||||
-rw-r--r-- | sql/sql_cache.h | 10 | ||||
-rw-r--r-- | sql/sql_class.cc | 30 | ||||
-rw-r--r-- | sql/sql_insert.cc | 10 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 29 | ||||
-rw-r--r-- | sql/sql_show.cc | 17 | ||||
-rw-r--r-- | sql/sql_signal.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 2 | ||||
-rw-r--r-- | sql/unireg.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 2 |
27 files changed, 387 insertions, 297 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index e369904cbe5..95c5f6d9047 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -186,7 +186,7 @@ pre_init_event_thread(THD* thd) thd->security_ctx->master_access= 0; thd->security_ctx->db_access= 0; thd->security_ctx->host_or_ip= (char*)my_localhost; - my_net_init(&thd->net, NULL, MYF(MY_THREAD_SPECIFIC)); + my_net_init(&thd->net, NULL, thd, MYF(MY_THREAD_SPECIFIC)); thd->security_ctx->set_user((char*)"event_scheduler"); thd->net.read_timeout= slave_net_timeout; thd->variables.option_bits|= OPTION_AUTO_IS_NULL; diff --git a/sql/field.cc b/sql/field.cc index f48eb46657b..76b917859d1 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2736,7 +2736,7 @@ Field_new_decimal::Field_new_decimal(uint32 len_arg, } -Field *Field_new_decimal::create_from_item (Item *item) +Field *Field_new_decimal::create_from_item(MEM_ROOT *mem_root, Item *item) { uint8 dec= item->decimals; uint8 intg= item->decimal_precision() - dec; @@ -2775,8 +2775,9 @@ Field *Field_new_decimal::create_from_item (Item *item) /* Corrected value fits. */ len= required_length; } - return new Field_new_decimal(len, item->maybe_null, item->name, - dec, item->unsigned_flag); + return new (mem_root) + Field_new_decimal(len, item->maybe_null, item->name, + dec, item->unsigned_flag); } @@ -2875,14 +2876,13 @@ int Field_new_decimal::store(const char *from, uint length, ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED; int err; my_decimal decimal_value; - THD *thd= get_thd(); DBUG_ENTER("Field_new_decimal::store(char*)"); if ((err= str2my_decimal(E_DEC_FATAL_ERROR & ~(E_DEC_OVERFLOW | E_DEC_BAD_NUM), from, length, charset_arg, &decimal_value)) && - thd->abort_on_warning) + get_thd()->abort_on_warning) { ErrConvString errmsg(from, length, charset_arg); set_warning_truncated_wrong_value("decimal", errmsg.ptr()); @@ -4929,9 +4929,8 @@ void Field_timestamp::sql_type(String &res) const int Field_timestamp::set_time() { - THD *thd= get_thd(); set_notnull(); - store_TIME(thd->query_start(), 0); + store_TIME(get_thd()->query_start(), 0); return 0; } @@ -5092,8 +5091,8 @@ int Field_timestamp::store_decimal(const my_decimal *d) } else tmp= number_to_datetime(nr, sec_part, <ime, TIME_NO_ZERO_IN_DATE | - (thd->variables.sql_mode & - MODE_NO_ZERO_DATE), &error); + (thd->variables.sql_mode & + MODE_NO_ZERO_DATE), &error); return store_TIME_with_warning(thd, <ime, &str, error, tmp != -1); } @@ -5294,16 +5293,16 @@ int Field_temporal_with_date::store_time_dec(MYSQL_TIME *ltime, uint dec) */ have_smth_to_conv= false; error= MYSQL_TIME_WARN_OUT_OF_RANGE; - goto store; } - - /* - We don't perform range checking here since values stored in TIME - structure always fit into DATETIME range. - */ - have_smth_to_conv= !check_date(&l_time, pack_time(&l_time) != 0, - sql_mode_for_dates(current_thd), &error); -store: + else + { + /* + We don't perform range checking here since values stored in TIME + structure always fit into DATETIME range. + */ + have_smth_to_conv= !check_date(&l_time, pack_time(&l_time) != 0, + sql_mode_for_dates(get_thd()), &error); + } return store_TIME_with_warning(&l_time, &str, error, have_smth_to_conv); } @@ -6928,8 +6927,9 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table, Field *field; if (type() != MYSQL_TYPE_VAR_STRING || keep_type) field= Field::make_new_field(root, new_table, keep_type); - else if ((field= new Field_varstring(field_length, maybe_null(), field_name, - new_table->s, charset()))) + else if ((field= new (root) Field_varstring(field_length, maybe_null(), + field_name, + new_table->s, charset()))) { /* Old VARCHAR field which should be modified to a VARCHAR on copy @@ -7035,7 +7035,7 @@ double Field_varstring::val_real(void) (error || (length != (uint)(end - (char*)ptr+length_bytes) && !check_if_only_end_space(cs, end, (char*)ptr+length_bytes+length)))) { - push_numerical_conversion_warning(current_thd, (char*)ptr+length_bytes, + push_numerical_conversion_warning(get_thd(), (char*)ptr+length_bytes, length, cs,"DOUBLE", ER_TRUNCATED_WRONG_VALUE); } @@ -7058,7 +7058,7 @@ longlong Field_varstring::val_int(void) (error || (length != (uint)(end - (char*)ptr+length_bytes) && !check_if_only_end_space(cs, end, (char*)ptr+length_bytes+length)))) { - push_numerical_conversion_warning(current_thd, (char*)ptr+length_bytes, + push_numerical_conversion_warning(get_thd(), (char*)ptr+length_bytes, length, cs, "INTEGER", ER_TRUNCATED_WRONG_VALUE); } @@ -7085,7 +7085,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value) if (!get_thd()->no_errors && error) { - push_numerical_conversion_warning(current_thd, (char*)ptr+length_bytes, + push_numerical_conversion_warning(get_thd(), (char*)ptr+length_bytes, length, cs, "DECIMAL", ER_TRUNCATED_WRONG_VALUE); } @@ -7764,7 +7764,7 @@ int Field_blob::do_save_field_metadata(uchar *metadata_ptr) uint32 Field_blob::sort_length() const { - return (uint32) (current_thd->variables.max_sort_length + + return (uint32) (get_thd()->variables.max_sort_length + (field_charset == &my_charset_bin ? 0 : packlength)); } @@ -9817,7 +9817,9 @@ uint pack_length_to_packflag(uint type) } -Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, +Field *make_field(TABLE_SHARE *share, + MEM_ROOT *mem_root, + uchar *ptr, uint32 field_length, uchar *null_pos, uchar null_bit, uint pack_flag, enum_field_types field_type, @@ -9829,6 +9831,7 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, { uchar *UNINIT_VAR(bit_ptr); uchar UNINIT_VAR(bit_offset); + if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag)) { bit_ptr= null_pos; @@ -9865,16 +9868,18 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, if (field_type == MYSQL_TYPE_STRING || field_type == MYSQL_TYPE_DECIMAL || // 3.23 or 4.0 string field_type == MYSQL_TYPE_VAR_STRING) - return new Field_string(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - field_charset); + return new (mem_root) + Field_string(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + field_charset); if (field_type == MYSQL_TYPE_VARCHAR) - return new Field_varstring(ptr,field_length, - HA_VARCHAR_PACKLENGTH(field_length), - null_pos,null_bit, - unireg_check, field_name, - share, - field_charset); + return new (mem_root) + Field_varstring(ptr,field_length, + HA_VARCHAR_PACKLENGTH(field_length), + null_pos,null_bit, + unireg_check, field_name, + share, + field_charset); return 0; // Error } @@ -9886,138 +9891,160 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, if (f_is_geom(pack_flag)) { status_var_increment(current_thd->status_var.feature_gis); - return new Field_geom(ptr,null_pos,null_bit, - unireg_check, field_name, share, - pack_length, geom_type, srid); + return new (mem_root) + Field_geom(ptr,null_pos,null_bit, + unireg_check, field_name, share, + pack_length, geom_type, srid); } #endif if (f_is_blob(pack_flag)) - return new Field_blob(ptr,null_pos,null_bit, - unireg_check, field_name, share, - pack_length, field_charset); + return new (mem_root) + Field_blob(ptr,null_pos,null_bit, + unireg_check, field_name, share, + pack_length, field_charset); if (interval) { if (f_is_enum(pack_flag)) - return new Field_enum(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - pack_length, interval, field_charset); + return new (mem_root) + Field_enum(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + pack_length, interval, field_charset); else - return new Field_set(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - pack_length, interval, field_charset); + return new (mem_root) + Field_set(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + pack_length, interval, field_charset); } } switch (field_type) { case MYSQL_TYPE_DECIMAL: - return new Field_decimal(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_decimals(pack_flag), - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_decimal(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_decimals(pack_flag), + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_NEWDECIMAL: - return new Field_new_decimal(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_decimals(pack_flag), - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_new_decimal(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_decimals(pack_flag), + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_FLOAT: - return new Field_float(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_decimals(pack_flag), - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag)== 0); + return new (mem_root) + Field_float(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_decimals(pack_flag), + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag)== 0); case MYSQL_TYPE_DOUBLE: - return new Field_double(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_decimals(pack_flag), - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag)== 0); + return new (mem_root) + Field_double(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_decimals(pack_flag), + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag)== 0); case MYSQL_TYPE_TINY: - return new Field_tiny(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_tiny(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_SHORT: - return new Field_short(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_short(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_INT24: - return new Field_medium(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_medium(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_LONG: - return new Field_long(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_long(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_LONGLONG: - return new Field_longlong(ptr,field_length,null_pos,null_bit, - unireg_check, field_name, - f_is_zerofill(pack_flag) != 0, - f_is_dec(pack_flag) == 0); + return new (mem_root) + Field_longlong(ptr,field_length,null_pos,null_bit, + unireg_check, field_name, + f_is_zerofill(pack_flag) != 0, + f_is_dec(pack_flag) == 0); case MYSQL_TYPE_TIMESTAMP: { uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; - return new_Field_timestamp(ptr, null_pos, null_bit, unireg_check, + return new_Field_timestamp(mem_root, ptr, null_pos, null_bit, unireg_check, field_name, share, dec); } case MYSQL_TYPE_TIMESTAMP2: { uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; - return new Field_timestampf(ptr, null_pos, null_bit, unireg_check, - field_name, share, dec); + return new (mem_root) + Field_timestampf(ptr, null_pos, null_bit, unireg_check, + field_name, share, dec); } case MYSQL_TYPE_YEAR: - return new Field_year(ptr,field_length,null_pos,null_bit, - unireg_check, field_name); + return new (mem_root) + Field_year(ptr,field_length,null_pos,null_bit, + unireg_check, field_name); case MYSQL_TYPE_DATE: - return new Field_date(ptr,null_pos,null_bit, - unireg_check, field_name); + return new (mem_root) + Field_date(ptr,null_pos,null_bit, + unireg_check, field_name); case MYSQL_TYPE_NEWDATE: - return new Field_newdate(ptr,null_pos,null_bit, - unireg_check, field_name); + return new (mem_root) + Field_newdate(ptr,null_pos,null_bit, + unireg_check, field_name); case MYSQL_TYPE_TIME: { uint dec= field_length > MIN_TIME_WIDTH ? field_length - MIN_TIME_WIDTH - 1: 0; - return new_Field_time(ptr, null_pos, null_bit, unireg_check, + return new_Field_time(mem_root, ptr, null_pos, null_bit, unireg_check, field_name, dec); } case MYSQL_TYPE_TIME2: { uint dec= field_length > MIN_TIME_WIDTH ? field_length - MIN_TIME_WIDTH - 1: 0; - return new Field_timef(ptr, null_pos, null_bit, unireg_check, - field_name, dec); + return new (mem_root) + Field_timef(ptr, null_pos, null_bit, unireg_check, + field_name, dec); } case MYSQL_TYPE_DATETIME: { uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; - return new_Field_datetime(ptr, null_pos, null_bit, unireg_check, + return new_Field_datetime(mem_root, ptr, null_pos, null_bit, unireg_check, field_name, dec); } case MYSQL_TYPE_DATETIME2: { uint dec= field_length > MAX_DATETIME_WIDTH ? field_length - MAX_DATETIME_WIDTH - 1: 0; - return new Field_datetimef(ptr, null_pos, null_bit, unireg_check, - field_name, dec); + return new (mem_root) + Field_datetimef(ptr, null_pos, null_bit, unireg_check, + field_name, dec); } case MYSQL_TYPE_NULL: - return new Field_null(ptr, field_length, unireg_check, field_name, - field_charset); + return new (mem_root) + Field_null(ptr, field_length, unireg_check, field_name, + field_charset); case MYSQL_TYPE_BIT: - return f_bit_as_char(pack_flag) ? - new Field_bit_as_char(ptr, field_length, null_pos, null_bit, - unireg_check, field_name) : - new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, - bit_offset, unireg_check, field_name); + return (f_bit_as_char(pack_flag) ? + new (mem_root) + Field_bit_as_char(ptr, field_length, null_pos, null_bit, + unireg_check, field_name) : + new (mem_root) + Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr, + bit_offset, unireg_check, field_name)); default: // Impossible (Wrong version) break; diff --git a/sql/field.h b/sql/field.h index de9a6cd2a96..392041dcf67 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1350,7 +1350,7 @@ public: uint16 mflags, int *order_var); uint is_equal(Create_field *new_field); virtual const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end, uint param_data); - static Field *create_from_item (Item *); + static Field *create_from_item(MEM_ROOT *root, Item *); }; @@ -2329,45 +2329,50 @@ public: static inline Field_timestamp * -new_Field_timestamp(uchar *ptr, uchar *null_ptr, uchar null_bit, +new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, const char *field_name, TABLE_SHARE *share, uint dec) { if (dec==0) - return new Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name, share); + return new (root) + Field_timestamp(ptr, MAX_DATETIME_WIDTH, null_ptr, + null_bit, unireg_check, field_name, share); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; - return new Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check, - field_name, share, dec); + return new (root) + Field_timestamp_hires(ptr, null_ptr, null_bit, unireg_check, + field_name, share, dec); } static inline Field_time * -new_Field_time(uchar *ptr, uchar *null_ptr, uchar null_bit, +new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, const char *field_name, uint dec) { if (dec == 0) - return new Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name); + return new (root) + Field_time(ptr, MIN_TIME_WIDTH, null_ptr, null_bit, unireg_check, + field_name); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; - return new Field_time_hires(ptr, null_ptr, null_bit, - unireg_check, field_name, dec); + return new (root) + Field_time_hires(ptr, null_ptr, null_bit, unireg_check, field_name, dec); } static inline Field_datetime * -new_Field_datetime(uchar *ptr, uchar *null_ptr, uchar null_bit, +new_Field_datetime(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit, enum Field::utype unireg_check, const char *field_name, uint dec) { if (dec == 0) - return new Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit, - unireg_check, field_name); + return new (root) + Field_datetime(ptr, MAX_DATETIME_WIDTH, null_ptr, null_bit, + unireg_check, field_name); if (dec == NOT_FIXED_DEC) dec= MAX_DATETIME_PRECISION; - return new Field_datetime_hires(ptr, null_ptr, null_bit, - unireg_check, field_name, dec); + return new (root) + Field_datetime_hires(ptr, null_ptr, null_bit, + unireg_check, field_name, dec); } class Field_string :public Field_longstr { @@ -3178,7 +3183,8 @@ public: }; -Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, +Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root, + uchar *ptr, uint32 field_length, uchar *null_pos, uchar null_bit, uint pack_flag, enum_field_types field_type, CHARSET_INFO *cs, diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index f85cdc73650..043f7fb280b 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2400,7 +2400,7 @@ reg_query_cache_dependant_table(THD *thd, DBUG_RETURN(TRUE); } (++(*block_table))->n= ++(*n); - if (!cache->insert_table(cache_key_len, + if (!cache->insert_table(thd, cache_key_len, cache_key, (*block_table), table_share->db.length, (uint8) (cache_key_len - diff --git a/sql/item.cc b/sql/item.cc index cf646f591de..255e6080727 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -111,6 +111,8 @@ bool Item::val_bool() */ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate) { + THD *thd= current_thd; + /* Some TIME type items return error when trying to do get_date() without TIME_TIME_ONLY set (e.g. Item_field for Field_time). @@ -119,7 +121,7 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate) and leave it to get_date() to check date. */ ulonglong time_flag= (field_type() == MYSQL_TYPE_TIME && - !(current_thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST)) ? + !(thd->variables.old_behavior & OLD_MODE_ZERO_DATE_TIME_CAST)) ? TIME_TIME_ONLY : 0; if (get_date(ltime, fuzzydate | time_flag)) return true; @@ -127,7 +129,7 @@ bool Item::get_date_with_conversion(MYSQL_TIME *ltime, ulonglong fuzzydate) !(fuzzydate & TIME_TIME_ONLY)) { MYSQL_TIME tmp; - if (time_to_datetime_with_warn(current_thd, ltime, &tmp, fuzzydate)) + if (time_to_datetime_with_warn(thd, ltime, &tmp, fuzzydate)) return null_value= true; *ltime= tmp; } @@ -3033,17 +3035,17 @@ longlong_from_string_with_check(CHARSET_INFO *cs, const char *cptr, int err; longlong tmp; char *end_of_num= (char*) end; + THD *thd= current_thd; tmp= (*(cs->cset->strtoll10))(cs, cptr, &end_of_num, &err); /* TODO: Give error if we wanted a signed integer and we got an unsigned one */ - if (!current_thd->no_errors && + if (!thd->no_errors && (err > 0 || (end != end_of_num && !check_if_only_end_space(cs, end_of_num, end)))) { - THD *thd= current_thd; ErrConvString err_str(cptr, end - cptr, cs); push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, @@ -5730,22 +5732,26 @@ bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs) Field *Item::make_string_field(TABLE *table) { Field *field; + MEM_ROOT *mem_root= table->in_use->mem_root; + DBUG_ASSERT(collation.collation); /* Note: the following check is repeated in subquery_types_allow_materialization(): */ if (too_big_for_varchar()) - field= new Field_blob(max_length, maybe_null, name, - collation.collation, TRUE); + field= new (mem_root) + Field_blob(max_length, maybe_null, name, + collation.collation, TRUE); /* Item_type_holder holds the exact type, do not change it */ else if (max_length > 0 && (type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING)) - field= new Field_varstring(max_length, maybe_null, name, table->s, - collation.collation); + field= new (mem_root) + Field_varstring(max_length, maybe_null, name, table->s, + collation.collation); else - field= new Field_string(max_length, maybe_null, name, - collation.collation); + field= new (mem_root) + Field_string(max_length, maybe_null, name, collation.collation); if (field) field->init(table); return field; @@ -5771,63 +5777,74 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) */ uchar *null_ptr= maybe_null ? (uchar*) "" : 0; Field *field; + MEM_ROOT *mem_root= table->in_use->mem_root; switch (field_type()) { case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: - field= Field_new_decimal::create_from_item(this); + field= Field_new_decimal::create_from_item(mem_root, this); break; case MYSQL_TYPE_TINY: - field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, 0, unsigned_flag); + field= new (mem_root) + Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, 0, unsigned_flag); break; case MYSQL_TYPE_SHORT: - field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, 0, unsigned_flag); + field= new (mem_root) + Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, 0, unsigned_flag); break; case MYSQL_TYPE_LONG: - field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, 0, unsigned_flag); + field= new (mem_root) + Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, 0, unsigned_flag); break; #ifdef HAVE_LONG_LONG case MYSQL_TYPE_LONGLONG: - field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, 0, unsigned_flag); + field= new (mem_root) + Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, 0, unsigned_flag); break; #endif case MYSQL_TYPE_FLOAT: - field= new Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, decimals, 0, unsigned_flag); + field= new (mem_root) + Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, decimals, 0, unsigned_flag); break; case MYSQL_TYPE_DOUBLE: - field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, decimals, 0, unsigned_flag); + field= new (mem_root) + Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, decimals, 0, unsigned_flag); break; case MYSQL_TYPE_INT24: - field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name, 0, unsigned_flag); + field= new (mem_root) + Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE, + name, 0, unsigned_flag); break; case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_DATE: - field= new Field_newdate(0, null_ptr, 0, Field::NONE, name); + field= new (mem_root) + Field_newdate(0, null_ptr, 0, Field::NONE, name); break; case MYSQL_TYPE_TIME: - field= new_Field_time(0, null_ptr, 0, Field::NONE, name, decimals); + field= new_Field_time(mem_root, 0, null_ptr, 0, Field::NONE, name, + decimals); break; case MYSQL_TYPE_TIMESTAMP: - field= new_Field_timestamp(0, null_ptr, 0, + field= new_Field_timestamp(mem_root, 0, null_ptr, 0, Field::NONE, name, 0, decimals); break; case MYSQL_TYPE_DATETIME: - field= new_Field_datetime(0, null_ptr, 0, Field::NONE, name, decimals); + field= new_Field_datetime(mem_root, 0, null_ptr, 0, Field::NONE, name, + decimals); break; case MYSQL_TYPE_YEAR: - field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE, - name); + field= new (mem_root) + Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name); break; case MYSQL_TYPE_BIT: - field= new Field_bit_as_char(NULL, max_length, null_ptr, 0, - Field::NONE, name); + field= new (mem_root) + Field_bit_as_char(NULL, max_length, null_ptr, 0, Field::NONE, name); break; default: /* This case should never be chosen */ @@ -5837,8 +5854,8 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) case MYSQL_TYPE_STRING: if (fixed_length && !too_big_for_varchar()) { - field= new Field_string(max_length, maybe_null, name, - collation.collation); + field= new (mem_root) + Field_string(max_length, maybe_null, name, collation.collation); break; } /* Fall through to make_string_field() */ @@ -5852,15 +5869,16 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: if (this->type() == Item::TYPE_HOLDER) - field= new Field_blob(max_length, maybe_null, name, collation.collation, - 1); + field= new (mem_root) + Field_blob(max_length, maybe_null, name, collation.collation, 1); else - field= new Field_blob(max_length, maybe_null, name, collation.collation); + field= new (mem_root) + Field_blob(max_length, maybe_null, name, collation.collation); break; // Blob handled outside of case #ifdef HAVE_SPATIAL case MYSQL_TYPE_GEOMETRY: - field= new Field_geom(max_length, maybe_null, - name, table->s, get_geometry_type()); + field= new (mem_root) + Field_geom(max_length, maybe_null, name, table->s, get_geometry_type()); #endif /* HAVE_SPATIAL */ } if (field) @@ -9288,10 +9306,9 @@ int Item_cache_str::save_in_field(Field *field, bool no_conversions) } -bool Item_cache_row::allocate(uint num) +bool Item_cache_row::allocate(THD *thd, uint num) { item_count= num; - THD *thd= current_thd; return (!(values= (Item_cache **) thd->calloc(sizeof(Item_cache *)*item_count))); } @@ -9300,7 +9317,7 @@ bool Item_cache_row::allocate(uint num) bool Item_cache_row::setup(THD *thd, Item *item) { example= item; - if (!values && allocate(item->cols())) + if (!values && allocate(thd, item->cols())) return 1; for (uint i= 0; i < item_count; i++) { diff --git a/sql/item.h b/sql/item.h index 127f1cf138f..8faba4ddcb5 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4769,7 +4769,7 @@ public: null_value= 1; } - virtual bool allocate(uint i) { return 0; } + virtual bool allocate(THD *thd, uint i) { return 0; } virtual bool setup(THD *thd, Item *item) { example= item; @@ -4950,7 +4950,7 @@ public: 'allocate' used only in row transformer, to preallocate space for row cache. */ - bool allocate(uint num); + bool allocate(THD *thd, uint num); /* 'setup' is needed only by row => it not called by simple row subselect (only by IN subselect (in subselect optimizer)) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ae1e003e871..619180a2c8e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1849,7 +1849,7 @@ Item *Item_in_optimizer::transform(THD *thd, Item_transformer transformer, Item_subselect::ANY_SUBS)); Item_in_subselect *in_arg= (Item_in_subselect*)args[1]; - current_thd->change_item_tree(&in_arg->left_expr, args[0]); + thd->change_item_tree(&in_arg->left_expr, args[0]); } return (this->*transformer)(thd, argument); } diff --git a/sql/item_create.cc b/sql/item_create.cc index 3d7c4eede93..82f6bbd3173 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -6312,7 +6312,7 @@ Item *create_temporal_literal(THD *thd, if (status.warnings) // e.g. a note on nanosecond truncation { ErrConvString err(str, length, cs); - make_truncated_value_warning(current_thd, + make_truncated_value_warning(thd, Sql_condition::time_warn_level(status.warnings), &err, ltime.time_type, 0); } diff --git a/sql/item_func.cc b/sql/item_func.cc index 78a6f914e5b..79fed505d2d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -521,23 +521,27 @@ bool Item_func::eq(const Item *item, bool binary_cmp) const Field *Item_func::tmp_table_field(TABLE *table) { Field *field= NULL; + MEM_ROOT *mem_root= table->in_use->mem_root; switch (result_type()) { case INT_RESULT: if (max_char_length() > MY_INT32_NUM_DECIMAL_DIGITS) - field= new Field_longlong(max_char_length(), maybe_null, name, - unsigned_flag); + field= new (mem_root) + Field_longlong(max_char_length(), maybe_null, name, + unsigned_flag); else - field= new Field_long(max_char_length(), maybe_null, name, - unsigned_flag); + field= new (mem_root) + Field_long(max_char_length(), maybe_null, name, + unsigned_flag); break; case REAL_RESULT: - field= new Field_double(max_char_length(), maybe_null, name, decimals); + field= new (mem_root) + Field_double(max_char_length(), maybe_null, name, decimals); break; case STRING_RESULT: return make_string_field(table); case DECIMAL_RESULT: - field= Field_new_decimal::create_from_item(this); + field= Field_new_decimal::create_from_item(mem_root, this); break; case ROW_RESULT: case TIME_RESULT: @@ -6507,7 +6511,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg, 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); + m_name->init_qname(thd); dummy_table= (TABLE*) thd->calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); dummy_table->s= (TABLE_SHARE*) (dummy_table+1); } @@ -6519,7 +6523,7 @@ Item_func_sp::Item_func_sp(THD *thd, Name_resolution_context *context_arg, sp_result_field(NULL) { maybe_null= 1; - m_name->init_qname(current_thd); + m_name->init_qname(thd); dummy_table= (TABLE*) thd->calloc(sizeof(TABLE)+ sizeof(TABLE_SHARE)); dummy_table->s= (TABLE_SHARE*) (dummy_table+1); } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 387e349300e..0be51de16d8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1011,8 +1011,10 @@ String *Item_func_concat_ws::val_str(String *str) if (!(res2= args[i]->val_str(use_as_buff))) continue; // Skip NULL + if (!thd) + thd= current_thd; if (res->length() + sep_str->length() + res2->length() > - (thd ? thd : (thd= current_thd))->variables.max_allowed_packet) + thd->variables.max_allowed_packet) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_ALLOWED_PACKET_OVERFLOWED, @@ -1273,8 +1275,12 @@ redo: while (j != search_end) if (*i++ != *j++) goto skip; offset= (int) (ptr-res->ptr()); + + if (!thd) + thd= current_thd; + if (res->length()-from_length + to_length > - (thd ? thd : (thd= current_thd))->variables.max_allowed_packet) + thd->variables.max_allowed_packet) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_ALLOWED_PACKET_OVERFLOWED, @@ -1301,7 +1307,7 @@ redo: else #endif /* USE_MB */ { - THD *thd= current_thd; + thd= current_thd; do { if (res->length()-from_length + to_length > diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b67986f0fb0..c56c4c217fb 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -502,23 +502,27 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table, uint convert_blob_length) { Field *UNINIT_VAR(field); + MEM_ROOT *mem_root= table->in_use->mem_root; + switch (result_type()) { case REAL_RESULT: - field= new Field_double(max_length, maybe_null, name, decimals, TRUE); + field= new (mem_root) + Field_double(max_length, maybe_null, name, decimals, TRUE); break; case INT_RESULT: - field= new Field_longlong(max_length, maybe_null, name, unsigned_flag); + field= new (mem_root) + Field_longlong(max_length, maybe_null, name, unsigned_flag); break; case STRING_RESULT: if (max_length/collation.collation->mbmaxlen <= 255 || convert_blob_length > Field_varstring::MAX_SIZE || !convert_blob_length) return make_string_field(table); - field= new Field_varstring(convert_blob_length, maybe_null, - name, table->s, collation.collation); + field= new (mem_root) Field_varstring(convert_blob_length, maybe_null, + name, table->s, collation.collation); break; case DECIMAL_RESULT: - field= Field_new_decimal::create_from_item(this); + field= Field_new_decimal::create_from_item(mem_root, this); break; case ROW_RESULT: case TIME_RESULT: @@ -1266,33 +1270,37 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table, uint convert_blob_length) { Field *field; + MEM_ROOT *mem_root; + if (args[0]->type() == Item::FIELD_ITEM) { field= ((Item_field*) args[0])->field; - if ((field= create_tmp_field_from_field(current_thd, field, name, table, + if ((field= create_tmp_field_from_field(table->in_use, field, name, table, NULL, convert_blob_length))) field->flags&= ~NOT_NULL_FLAG; return field; } + /* DATE/TIME fields have STRING_RESULT result types. In order to preserve field type, it's needed to handle DATE/TIME fields creations separately. */ + mem_root= table->in_use->mem_root; switch (args[0]->field_type()) { case MYSQL_TYPE_DATE: - field= new Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name); + field= new (mem_root) + Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, name); break; case MYSQL_TYPE_TIME: - field= new_Field_time(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name, decimals); + field= new_Field_time(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0, + Field::NONE, name, decimals); break; case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: - field= new_Field_datetime(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, - name, decimals); + field= new_Field_datetime(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0, + Field::NONE, name, decimals); break; default: return Item_sum::create_tmp_field(group, table, convert_blob_length); @@ -1657,6 +1665,8 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table, uint convert_blob_len) { Field *field; + MEM_ROOT *mem_root= table->in_use->mem_root; + if (group) { /* @@ -1664,14 +1674,16 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table, The easiest way is to do this is to store both value in a string and unpack on access. */ - field= new Field_string(((hybrid_type == DECIMAL_RESULT) ? - dec_bin_size : sizeof(double)) + sizeof(longlong), - 0, name, &my_charset_bin); + field= new (mem_root) + Field_string(((hybrid_type == DECIMAL_RESULT) ? + dec_bin_size : sizeof(double)) + sizeof(longlong), + 0, name, &my_charset_bin); } else if (hybrid_type == DECIMAL_RESULT) - field= Field_new_decimal::create_from_item(this); + field= Field_new_decimal::create_from_item(mem_root, this); else - field= new Field_double(max_length, maybe_null, name, decimals, TRUE); + field= new (mem_root) Field_double(max_length, maybe_null, name, decimals, + TRUE); if (field) field->init(table); return field; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9a71407730c..0586f1b9bf5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6165,7 +6165,7 @@ static void bootstrap(MYSQL_FILE *file) thd->variables.wsrep_on= 0; #endif thd->bootstrap=1; - my_net_init(&thd->net,(st_vio*) 0, MYF(0)); + my_net_init(&thd->net,(st_vio*) 0, (void*) 0, MYF(0)); thd->max_client_packet_length= thd->net.max_packet; thd->security_ctx->master_access= ~(ulong)0; thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; @@ -6634,7 +6634,7 @@ void handle_connections_sockets() mysql_socket_vio_new(new_sock, is_unix_sock ? VIO_TYPE_SOCKET : VIO_TYPE_TCPIP, is_unix_sock ? VIO_LOCALHOST: 0)) || - my_net_init(&thd->net, vio_tmp, MYF(MY_THREAD_SPECIFIC))) + my_net_init(&thd->net, vio_tmp, thd, MYF(MY_THREAD_SPECIFIC))) { /* Only delete the temporary vio if we didn't already attach it to the @@ -6759,7 +6759,7 @@ pthread_handler_t handle_connections_namedpipes(void *arg) } set_current_thd(thd); if (!(thd->net.vio= vio_new_win32pipe(hConnectedPipe)) || - my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC))) + my_net_init(&thd->net, thd->net.vio, thd, MYF(MY_THREAD_SPECIFIC))) { close_connection(thd, ER_OUT_OF_RESOURCES); delete thd; @@ -6956,7 +6956,7 @@ pthread_handler_t handle_connections_shared_memory(void *arg) event_server_wrote, event_server_read, event_conn_closed)) || - my_net_init(&thd->net, thd->net.vio, MYF(MY_THREAD_SPECIFIC))) + my_net_init(&thd->net, thd->net.vio, thd, MYF(MY_THREAD_SPECIFIC))) { close_connection(thd, ER_OUT_OF_RESOURCES); errmsg= 0; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 0ce0fa93f99..b6da7933bb1 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -103,7 +103,7 @@ extern uint test_flags; extern ulong bytes_sent, bytes_received, net_big_packet_count; #ifdef HAVE_QUERY_CACHE #define USE_QUERY_CACHE -extern void query_cache_insert(const char *packet, ulong length, +extern void query_cache_insert(void *thd, const char *packet, ulong length, unsigned pkt_nr); #endif // HAVE_QUERY_CACHE #define update_statistics(A) A @@ -123,7 +123,7 @@ static my_bool net_write_buff(NET *, const uchar *, ulong); /** Init with packet info. */ -my_bool my_net_init(NET *net, Vio* vio, uint my_flags) +my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) { DBUG_ENTER("my_net_init"); DBUG_PRINT("enter", ("my_flags: %u", my_flags)); @@ -142,10 +142,11 @@ my_bool my_net_init(NET *net, Vio* vio, uint my_flags) net->where_b = net->remain_in_buf=0; net->net_skip_rest_factor= 0; net->last_errno=0; - net->unused= 0; net->thread_specific_malloc= MY_TEST(my_flags & MY_THREAD_SPECIFIC); + net->thd= 0; #ifdef MYSQL_SERVER net->extension= NULL; + net->thd= thd; #endif if (vio) @@ -602,7 +603,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) DBUG_ENTER("net_real_write"); #if defined(MYSQL_SERVER) && defined(USE_QUERY_CACHE) - query_cache_insert((char*) packet, len, net->pkt_nr); + query_cache_insert(net->thd, (char*) packet, len, net->pkt_nr); #endif if (net->error == 2) @@ -705,7 +706,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) break; } pos+=length; - update_statistics(thd_increment_bytes_sent(length)); + update_statistics(thd_increment_bytes_sent(net->thd, length)); } #ifndef __WIN__ end: @@ -778,7 +779,7 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed, DBUG_PRINT("enter",("bytes_to_skip: %u", (uint) remain)); /* The following is good for debugging */ - update_statistics(thd_increment_net_big_packet_count(1)); + update_statistics(thd_increment_net_big_packet_count(net->thd, 1)); if (!thr_alarm_in_use(alarmed)) { @@ -794,7 +795,7 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed, size_t length= MY_MIN(remain, net->max_packet); if (net_safe_read(net, net->buff, length, alarmed)) DBUG_RETURN(1); - update_statistics(thd_increment_bytes_received(length)); + update_statistics(thd_increment_bytes_received(net->thd, length)); remain -= (uint32) length; limit-= length; if (limit < 0) @@ -935,7 +936,7 @@ my_real_read(NET *net, size_t *complen, } remain -= (uint32) length; pos+= length; - update_statistics(thd_increment_bytes_received(length)); + update_statistics(thd_increment_bytes_received(net->thd, length)); } if (i == 0) { /* First parts is packet length */ diff --git a/sql/slave.cc b/sql/slave.cc index 3f9a7fb6ee1..07b0dbacc82 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3061,7 +3061,7 @@ static int init_slave_thread(THD* thd, Master_info *mi, simulate_error|= (1 << SLAVE_THD_SQL);); /* We must call store_globals() before doing my_net_init() */ if (init_thr_lock() || thd->store_globals() || - my_net_init(&thd->net, 0, MYF(MY_THREAD_SPECIFIC)) || + my_net_init(&thd->net, 0, thd, MYF(MY_THREAD_SPECIFIC)) || IF_DBUG(simulate_error & (1<< thd_type), 0)) { thd->cleanup(); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index d165cb8d883..a11796391d7 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -872,6 +872,7 @@ sp_head::create_result_field(uint field_max_length, const char *field_name, field_max_length : m_return_field_def.length; field= ::make_field(table->s, /* TABLE_SHARE ptr */ + table->in_use->mem_root, (uchar*) 0, /* field ptr */ field_length, /* field [max] length */ (uchar*) "", /* null ptr */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index bcb2a36280d..061a227004f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8575,7 +8575,7 @@ static int handle_roles_mappings_table(TABLE *table, bool drop, int error; int result= 0; - THD *thd= current_thd; + THD *thd= table->in_use; const char *host, *user, *role; Field *host_field= table->field[0]; Field *user_field= table->field[1]; @@ -8668,7 +8668,7 @@ static int handle_roles_mappings_table(TABLE *table, bool drop, < 0 Error. */ -static int handle_grant_table(TABLE_LIST *tables, +static int handle_grant_table(THD *thd, TABLE_LIST *tables, enum enum_acl_tables table_no, bool drop, LEX_USER *user_from, LEX_USER *user_to) { @@ -8685,7 +8685,6 @@ static int handle_grant_table(TABLE_LIST *tables, uchar user_key[MAX_KEY_LENGTH]; uint key_prefix_length; DBUG_ENTER("handle_grant_table"); - THD *thd= current_thd; if (table_no == ROLES_MAPPING_TABLE) { @@ -9189,7 +9188,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop, < 0 Error. */ -static int handle_grant_data(TABLE_LIST *tables, bool drop, +static int handle_grant_data(THD *thd, TABLE_LIST *tables, bool drop, LEX_USER *user_from, LEX_USER *user_to) { int result= 0; @@ -9212,7 +9211,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle db table. */ - if ((found= handle_grant_table(tables, DB_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, DB_TABLE, drop, user_from, + user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9232,7 +9232,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle stored routines table. */ - if ((found= handle_grant_table(tables, PROCS_PRIV_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, PROCS_PRIV_TABLE, drop, + user_from, user_to)) < 0) { /* Handle of table failed, don't touch in-memory array. */ result= -1; @@ -9260,7 +9261,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle tables table. */ - if ((found= handle_grant_table(tables, TABLES_PRIV_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, TABLES_PRIV_TABLE, drop, + user_from, user_to)) < 0) { /* Handle of table failed, don't touch columns and in-memory array. */ result= -1; @@ -9276,7 +9278,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle columns table. */ - if ((found= handle_grant_table(tables, COLUMNS_PRIV_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, COLUMNS_PRIV_TABLE, drop, + user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9295,7 +9298,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, /* Handle proxies_priv table. */ if (tables[PROXIES_PRIV_TABLE].table) { - if ((found= handle_grant_table(tables, PROXIES_PRIV_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, PROXIES_PRIV_TABLE, drop, + user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9314,7 +9318,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, /* Handle roles_mapping table. */ if (tables[ROLES_MAPPING_TABLE].table) { - if ((found= handle_grant_table(tables, ROLES_MAPPING_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, ROLES_MAPPING_TABLE, drop, + user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9331,7 +9336,8 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle user table. */ - if ((found= handle_grant_table(tables, USER_TABLE, drop, user_from, user_to)) < 0) + if ((found= handle_grant_table(thd, tables, USER_TABLE, drop, user_from, + user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ result= -1; @@ -9425,12 +9431,12 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) Search all in-memory structures and grant tables for a mention of the new user/role name. */ - if (handle_grant_data(tables, 0, user_name, NULL)) + if (handle_grant_data(thd, tables, 0, user_name, NULL)) { if (thd->lex->create_info.or_replace()) { // Drop the existing user - if (handle_grant_data(tables, 1, user_name, NULL) <= 0) + if (handle_grant_data(thd, tables, 1, user_name, NULL) <= 0) { // DROP failed append_user(thd, &wrong_users, user_name); @@ -9573,7 +9579,7 @@ bool mysql_drop_user(THD *thd, List <LEX_USER> &list, bool handle_as_role) continue; } - if ((rc= handle_grant_data(tables, 1, user_name, NULL)) > 0) + if ((rc= handle_grant_data(thd, tables, 1, user_name, NULL)) > 0) { // The user or role was successfully deleted binlog= true; @@ -9686,8 +9692,8 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list) Search all in-memory structures and grant tables for a mention of the new user name. */ - if (handle_grant_data(tables, 0, user_to, NULL) || - handle_grant_data(tables, 0, user_from, user_to) <= 0) + if (handle_grant_data(thd, tables, 0, user_to, NULL) || + handle_grant_data(thd, tables, 0, user_from, user_to) <= 0) { /* NOTE TODO renaming roles is not yet implemented */ append_user(thd, &wrong_users, user_from); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index e1efb1e85d6..2dd8976d51e 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -397,9 +397,9 @@ const uchar *query_state_map; #if defined(ENABLED_DEBUG_SYNC) #define QC_DEBUG_SYNC(name) \ do { \ - THD *thd= current_thd; \ - if (thd) \ - DEBUG_SYNC(thd, name); \ + THD *thd_tmp= current_thd; \ + if (thd_tmp) \ + DEBUG_SYNC(thd_tmp, name); \ } while (0) #else #define QC_DEBUG_SYNC(name) @@ -1037,10 +1037,10 @@ uchar *query_cache_query_get_key(const uchar *record, size_t *length, /** libmysql convenience wrapper to insert data into query cache. */ -void query_cache_insert(const char *packet, ulong length, +void query_cache_insert(void *thd_arg, const char *packet, ulong length, unsigned pkt_nr) { - THD *thd= current_thd; + THD *thd= (THD*) thd_arg; /* Current_thd can be NULL when a new connection is immediately ended @@ -1052,7 +1052,7 @@ void query_cache_insert(const char *packet, ulong length, if (!thd) return; - query_cache.insert(&thd->query_cache_tls, + query_cache.insert(thd, &thd->query_cache_tls, packet, length, pkt_nr); } @@ -1063,7 +1063,7 @@ void query_cache_insert(const char *packet, ulong length, */ void -Query_cache::insert(Query_cache_tls *query_cache_tls, +Query_cache::insert(THD *thd, Query_cache_tls *query_cache_tls, const char *packet, ulong length, unsigned pkt_nr) { @@ -1073,15 +1073,13 @@ Query_cache::insert(Query_cache_tls *query_cache_tls, if (is_disabled() || query_cache_tls->first_query_block == NULL) DBUG_VOID_RETURN; - DBUG_ASSERT(current_thd); - QC_DEBUG_SYNC("wait_in_query_cache_insert"); /* Lock the cache with try_lock(). try_lock() will fail if cache was disabled between the above test and lock. */ - if (try_lock(current_thd, Query_cache::WAIT)) + if (try_lock(thd, Query_cache::WAIT)) DBUG_VOID_RETURN; Query_cache_block *query_block = query_cache_tls->first_query_block; @@ -1130,16 +1128,15 @@ Query_cache::insert(Query_cache_tls *query_cache_tls, void -Query_cache::abort(Query_cache_tls *query_cache_tls) +Query_cache::abort(THD *thd, Query_cache_tls *query_cache_tls) { - THD *thd; DBUG_ENTER("query_cache_abort"); /* See the comment on double-check locking usage above. */ if (is_disabled() || query_cache_tls->first_query_block == NULL) DBUG_VOID_RETURN; - if (try_lock(current_thd, Query_cache::WAIT)) + if (try_lock(thd, Query_cache::WAIT)) DBUG_VOID_RETURN; /* @@ -1149,7 +1146,6 @@ Query_cache::abort(Query_cache_tls *query_cache_tls) Query_cache_block *query_block= query_cache_tls->first_query_block; if (query_block) { - thd= current_thd; THD_STAGE_INFO(thd, stage_storing_result_in_query_cache); DUMP(this); BLOCK_LOCK_WR(query_block); @@ -1181,12 +1177,12 @@ void Query_cache::end_of_result(THD *thd) if (thd->killed) { - query_cache_abort(&thd->query_cache_tls); + query_cache_abort(thd, &thd->query_cache_tls); DBUG_VOID_RETURN; } #ifdef EMBEDDED_LIBRARY - insert(query_cache_tls, (char*)thd, + insert(thd, query_cache_tls, (char*)thd, emb_count_querycache_size(thd), 0); #endif @@ -3338,7 +3334,7 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, /* There are not callback function for for VIEWs */ - if (!insert_table(key_length, key, (*block_table), + if (!insert_table(thd, key_length, key, (*block_table), tables_used->view_db.length, 0, HA_CACHE_TBL_NONTRANSACT, 0, 0, TRUE)) DBUG_RETURN(0); @@ -3357,7 +3353,7 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, (ulong) tables_used->table->s->table_cache_key.length, (ulong) tables_used->table->s->table_cache_key.str)); - if (!insert_table(tables_used->table->s->table_cache_key.length, + if (!insert_table(thd, tables_used->table->s->table_cache_key.length, tables_used->table->s->table_cache_key.str, (*block_table), tables_used->db_length, 0, @@ -3423,7 +3419,7 @@ my_bool Query_cache::register_all_tables(THD *thd, */ my_bool -Query_cache::insert_table(uint key_len, const char *key, +Query_cache::insert_table(THD *thd, uint key_len, const char *key, Query_cache_block_table *node, uint32 db_length, uint8 suffix_length_arg, uint8 cache_type, @@ -3435,8 +3431,6 @@ Query_cache::insert_table(uint key_len, const char *key, DBUG_PRINT("qcache", ("insert table node 0x%lx, len %d", (ulong)node, key_len)); - THD *thd= current_thd; - Query_cache_block *table_block= (hash ? (Query_cache_block *) my_hash_search(&tables, (uchar*) key, key_len) : diff --git a/sql/sql_cache.h b/sql/sql_cache.h index 69520d668ac..00ba9bf59d8 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -487,11 +487,11 @@ protected: void destroy(); - void insert(Query_cache_tls *query_cache_tls, + void insert(THD *thd, Query_cache_tls *query_cache_tls, const char *packet, ulong length, unsigned pkt_nr); - my_bool insert_table(uint key_len, const char *key, + my_bool insert_table(THD *thd, uint key_len, const char *key, Query_cache_block_table *node, uint32 db_length, uint8 suffix_length_arg, uint8 cache_type, @@ -500,7 +500,7 @@ protected: my_bool hash); void end_of_result(THD *thd); - void abort(Query_cache_tls *query_cache_tls); + void abort(THD *thd, Query_cache_tls *query_cache_tls); /* The following functions are only used when debugging @@ -558,7 +558,7 @@ struct Query_cache_query_flags #define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags) #define QUERY_CACHE_DB_LENGTH_SIZE 2 #include "sql_cache.h" -#define query_cache_abort(A) query_cache.abort(A) +#define query_cache_abort(A,B) query_cache.abort(A,B) #define query_cache_end_of_result(A) query_cache.end_of_result(A) #define query_cache_store_query(A, B) query_cache.store_query(A, B) #define query_cache_destroy() query_cache.destroy() @@ -590,7 +590,7 @@ struct Query_cache_query_flags #define query_cache_send_result_to_client(A, B, C) 0 #define query_cache_invalidate_by_MyISAM_filename_ref NULL -#define query_cache_abort(A) do { } while(0) +#define query_cache_abort(A,B) do { } while(0) #define query_cache_end_of_result(A) do { } while(0) #define query_cache_maybe_disabled(T) 1 #define query_cache_is_cacheable_query(L) 0 diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e77aa0d3d39..a367e0b44df 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1286,7 +1286,7 @@ Sql_condition* THD::raise_condition(uint sql_errno, } } - query_cache_abort(&query_cache_tls); + query_cache_abort(this, &query_cache_tls); /* Avoid pushing a condition for fatal out of memory errors as this will @@ -1939,6 +1939,7 @@ void THD::disconnect() /* Disconnect even if a active vio is not associated. */ if (net.vio != vio) vio_close(net.vio); + net.thd= 0; // Don't collect statistics mysql_mutex_unlock(&LOCK_thd_data); } @@ -2065,7 +2066,11 @@ bool THD::store_globals() real_id= pthread_self(); // For debugging mysys_var->stack_ends_here= thread_stack + // for consistency, see libevent_thread_proc STACK_DIRECTION * (long)my_thread_stack_size; - vio_set_thread_id(net.vio, real_id); + if (net.vio) + { + vio_set_thread_id(net.vio, real_id); + net.thd= this; + } /* We have to call thr_lock_info_init() again here as THD may have been created in another thread @@ -2090,7 +2095,7 @@ void THD::reset_globals() /* Undocking the thread specific data. */ set_current_thd(0); my_pthread_setspecific_ptr(THR_MALLOC, NULL); - + net.thd= 0; } /* @@ -3998,26 +4003,29 @@ void TMP_TABLE_PARAM::init() } -void thd_increment_bytes_sent(ulong length) +void thd_increment_bytes_sent(void *thd, ulong length) { - THD *thd=current_thd; + /* thd == 0 when close_connection() calls net_send_error() */ if (likely(thd != 0)) { - /* current_thd == 0 when close_connection() calls net_send_error() */ - thd->status_var.bytes_sent+= length; + ((THD*) thd)->status_var.bytes_sent+= length; } } -void thd_increment_bytes_received(ulong length) +void thd_increment_bytes_received(void *thd, ulong length) { - current_thd->status_var.bytes_received+= length; + if (unlikely(!thd)) // Called from federatedx + thd= current_thd; + ((THD*) thd)->status_var.bytes_received+= length; } -void thd_increment_net_big_packet_count(ulong length) +void thd_increment_net_big_packet_count(void *thd, ulong length) { - current_thd->status_var.net_big_packet_count+= length; + if (unlikely(!thd)) // Called from federatedx + thd= current_thd; + ((THD*) thd)->status_var.net_big_packet_count+= length; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 004b9c3cfd9..c4f7be2c500 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3931,6 +3931,7 @@ static TABLE *create_table_from_items(THD *thd, tmp_table.s->db_create_options=0; tmp_table.null_row= 0; tmp_table.maybe_null= 0; + tmp_table.in_use= thd; promote_first_timestamp_column(&alter_info->create_list); @@ -3950,10 +3951,11 @@ 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(thd, field, - (item->type() == Item::FIELD_ITEM ? - ((Item_field *) item)->field : - (Field *) 0)))) + !(cr_field= (new (thd->mem_root) + 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 94daad42c39..d3e99e17275 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7220,7 +7220,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length, DBUG_PRINT("info",("Command aborted. Fatal_error: %d", thd->is_fatal_error)); - query_cache_abort(&thd->query_cache_tls); + query_cache_abort(thd, &thd->query_cache_tls); } THD_STAGE_INFO(thd, stage_freeing_items); sp_cache_enforce_limit(thd->sp_proc_cache, stored_program_cache_size); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3e60120aaf6..a15dd56fa75 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15406,7 +15406,7 @@ Item_func_isnull::remove_eq_conds(THD *thd, Item::cond_result *cond_value, thd->substitute_null_with_insert_id)) { #ifdef HAVE_QUERY_CACHE - query_cache_abort(&thd->query_cache_tls); + query_cache_abort(thd, &thd->query_cache_tls); #endif COND *new_cond, *cond= this; if ((new_cond= new (thd->mem_root) Item_func_eq(thd, args[0], @@ -15674,11 +15674,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, { bool maybe_null= item->maybe_null; Field *UNINIT_VAR(new_field); + MEM_ROOT *mem_root= thd->mem_root; switch (item->result_type()) { case REAL_RESULT: - new_field= new Field_double(item->max_length, maybe_null, - item->name, item->decimals, TRUE); + new_field= new (mem_root) + Field_double(item->max_length, maybe_null, + item->name, item->decimals, TRUE); break; case INT_RESULT: /* @@ -15688,11 +15690,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, Field_long : make them Field_longlong. */ if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1)) - new_field=new Field_longlong(item->max_length, maybe_null, - item->name, item->unsigned_flag); + new_field=new (mem_root) + Field_longlong(item->max_length, maybe_null, + item->name, item->unsigned_flag); else - new_field=new Field_long(item->max_length, maybe_null, - item->name, item->unsigned_flag); + new_field=new (mem_root) + Field_long(item->max_length, maybe_null, item->name, + item->unsigned_flag); break; case STRING_RESULT: DBUG_ASSERT(item->collation.collation); @@ -15711,15 +15715,16 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, else if (item->max_length/item->collation.collation->mbmaxlen > 255 && convert_blob_length <= Field_varstring::MAX_SIZE && convert_blob_length) - new_field= new Field_varstring(convert_blob_length, maybe_null, - item->name, table->s, - item->collation.collation); + new_field= new (mem_root) + Field_varstring(convert_blob_length, maybe_null, + item->name, table->s, + item->collation.collation); else new_field= item->make_string_field(table); new_field->set_derivation(item->collation.derivation); break; case DECIMAL_RESULT: - new_field= Field_new_decimal::create_from_item(item); + new_field= Field_new_decimal::create_from_item(mem_root, item); break; case ROW_RESULT: default: @@ -16930,7 +16935,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list) List_iterator_fast<Create_field> it(field_list); while ((cdef= it++)) { - *field= make_field(share, 0, cdef->length, + *field= make_field(share, thd->mem_root, 0, cdef->length, (uchar*) (f_maybe_null(cdef->pack_flag) ? "" : 0), f_maybe_null(cdef->pack_flag) ? 1 : 0, cdef->pack_flag, cdef->sql_type, cdef->charset, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6c400bcdd31..ddad6096bd8 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5588,6 +5588,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, sp_head *sp; stored_procedure_type routine_type; bool free_sp_head; + bool error= 0; DBUG_ENTER("store_schema_params"); bzero((char*) &tbl, sizeof(TABLE)); @@ -5638,7 +5639,8 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, &tmp_string); table->field[15]->store(tmp_string.ptr(), tmp_string.length(), cs); field_def= &sp->m_return_field_def; - field= make_field(&share, (uchar*) 0, field_def->length, + field= make_field(&share, thd->mem_root, + (uchar*) 0, field_def->length, (uchar*) "", 0, field_def->pack_flag, field_def->sql_type, field_def->charset, field_def->geom_type, field_def->srid, Field::NONE, @@ -5691,7 +5693,7 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, &tmp_string); table->field[15]->store(tmp_string.ptr(), tmp_string.length(), cs); - field= make_field(&share, (uchar*) 0, field_def->length, + field= make_field(&share, thd->mem_root, (uchar*) 0, field_def->length, (uchar*) "", 0, field_def->pack_flag, field_def->sql_type, field_def->charset, field_def->geom_type, field_def->srid, Field::NONE, @@ -5702,17 +5704,15 @@ bool store_schema_params(THD *thd, TABLE *table, TABLE *proc_table, store_column_type(table, field, cs, 6); if (schema_table_store_record(thd, table)) { - free_table_share(&share); - if (free_sp_head) - delete sp; - DBUG_RETURN(1); + error= 1; + break; } } if (free_sp_head) delete sp; } free_table_share(&share); - DBUG_RETURN(0); + DBUG_RETURN(error); } @@ -5790,7 +5790,8 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table, bzero((char*) &tbl, sizeof(TABLE)); (void) build_table_filename(path, sizeof(path), "", "", "", 0); init_tmp_table_share(thd, &share, "", 0, "", path); - field= make_field(&share, (uchar*) 0, field_def->length, + field= make_field(&share, thd->mem_root, (uchar*) 0, + field_def->length, (uchar*) "", 0, field_def->pack_flag, field_def->sql_type, field_def->charset, field_def->geom_type, field_def->srid, Field::NONE, diff --git a/sql/sql_signal.cc b/sql/sql_signal.cc index e3cf3f74318..5f4862f173c 100644 --- a/sql/sql_signal.cc +++ b/sql/sql_signal.cc @@ -506,7 +506,7 @@ bool Sql_cmd_resignal::execute(THD *thd) if (m_cond) { - query_cache_abort(&thd->query_cache_tls); + query_cache_abort(thd, &thd->query_cache_tls); /* Keep handled conditions. */ da->unmark_sql_conditions_from_removal(); diff --git a/sql/table.cc b/sql/table.cc index 33b74ccb1a5..f233fd19860 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1657,7 +1657,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, #endif *field_ptr= reg_field= - make_field(share, record+recpos, + make_field(share, &share->mem_root, record+recpos, (uint32) field_length, null_pos, null_bit_pos, pack_flag, diff --git a/sql/unireg.cc b/sql/unireg.cc index 49503794c38..66959f400d9 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -924,7 +924,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options, /* regfield don't have to be deleted as it's allocated with sql_alloc() */ - Field *regfield= make_field(&share, + Field *regfield= make_field(&share, thd->mem_root, buff+field->offset + data_offset, field->length, null_pos + null_count / 8, diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 057a4d448ba..93de43b246f 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1737,7 +1737,7 @@ pthread_handler_t start_wsrep_THD(void *arg) thread_created++; threads.append(thd); - my_net_init(&thd->net,(st_vio*) 0, MYF(0)); + my_net_init(&thd->net,(st_vio*) 0, thd, MYF(0)); DBUG_PRINT("wsrep",(("creating thread %lld"), (long long)thd->thread_id)); thd->prior_thr_create_utime= thd->start_utime= microsecond_interval_timer(); |