mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Part 2 of the fix for bug mdev-504.
Any Field object should use current_thd instead of table->in_use when THD is needed if table == NULL. This patch fixes the crash of test case from mdev-504.test.
This commit is contained in:
@@ -1319,7 +1319,7 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
|
||||
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
||||
uchar null_bit_arg,
|
||||
utype unireg_check_arg, const char *field_name_arg)
|
||||
:ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0), thd(0),
|
||||
:ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
|
||||
table_name(0), field_name(field_name_arg), option_list(0),
|
||||
option_struct(0), key_start(0), part_of_key(0),
|
||||
part_of_key_not_clustered(0), part_of_sortkey(0),
|
||||
@@ -1874,12 +1874,11 @@ Field *Field::clone(MEM_ROOT *root, TABLE *new_table, my_ptrdiff_t diff,
|
||||
}
|
||||
|
||||
|
||||
Field *Field::clone(THD *thd_arg, MEM_ROOT *root, my_ptrdiff_t diff)
|
||||
Field *Field::clone(MEM_ROOT *root, my_ptrdiff_t diff)
|
||||
{
|
||||
Field *tmp;
|
||||
if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
|
||||
{
|
||||
tmp->thd= thd_arg;
|
||||
tmp->move_field_offset(diff);
|
||||
}
|
||||
return tmp;
|
||||
@@ -2780,7 +2779,7 @@ int Field_new_decimal::store(longlong nr, bool unsigned_val)
|
||||
}
|
||||
if (store_value(&decimal_value))
|
||||
err= 1;
|
||||
else if (err && !thd->got_warning)
|
||||
else if (err && !get_thd()->got_warning)
|
||||
err= warn_if_overflow(err);
|
||||
return err;
|
||||
}
|
||||
|
@@ -175,7 +175,6 @@ public:
|
||||
*/
|
||||
TABLE *table; // Pointer for table
|
||||
TABLE *orig_table; // Pointer to original table
|
||||
THD *thd; // Used when table == NULL
|
||||
const char * const *table_name;
|
||||
const char *field_name;
|
||||
/** reference to the list of options or NULL */
|
||||
@@ -452,7 +451,7 @@ public:
|
||||
*/
|
||||
inline bool real_maybe_null(void) { return null_ptr != 0; }
|
||||
|
||||
inline THD *get_thd() { return table ? table->in_use : thd; }
|
||||
inline THD *get_thd() { return table ? table->in_use : current_thd; }
|
||||
|
||||
enum {
|
||||
LAST_NULL_BYTE_UNDEF= 0
|
||||
@@ -492,7 +491,7 @@ public:
|
||||
Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
|
||||
Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff,
|
||||
bool stat_flag= FALSE);
|
||||
Field *clone(THD *thd_arg, MEM_ROOT *mem_root, my_ptrdiff_t diff);
|
||||
Field *clone(MEM_ROOT *mem_root, my_ptrdiff_t diff);
|
||||
inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
|
||||
{
|
||||
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
|
||||
|
@@ -1586,7 +1586,7 @@ void create_min_max_stistical_fields_for_table_share(THD *thd,
|
||||
Field *fld;
|
||||
table_field= *field_ptr;
|
||||
my_ptrdiff_t diff= record - table_share->default_values;
|
||||
if (!(fld= table_field->clone(thd, &table_share->mem_root, diff)))
|
||||
if (!(fld= table_field->clone(&table_share->mem_root, diff)))
|
||||
continue;
|
||||
store_address_if_first(i == 0 ?
|
||||
(void **) &table_field->read_stats->min_value :
|
||||
|
Reference in New Issue
Block a user