Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mysql-test/main/func_math.result
Original file line number Diff line number Diff line change
Expand Up @@ -3645,3 +3645,11 @@ cast(1 as unsigned) - cast(2 as unsigned)
-1
set sql_mode=default;
# End of 10.5 tests
#
# MDEV-31284: SIGSEGV in VDec2_lazy::VDec2_lazy | Item_func_plus::decimal_op
#
CREATE TABLE t (t INT KEY);
INSERT INTO t (t) VALUES (t +0+t + t+t +0+t + t -0+t +-0+-0+t + t +-0+t +-0+t + t+t +0+t + t+t + t +0+t + t +-0+t +-0+-0+t + t +-0+t +-0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0+t + t+t +0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+t + t +0.0+0+t + t+t +0.0+t + t +-0+0+t +0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +0.0+0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0+t + t+t +0+t + t+t +-0+0.0+t +0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t+t +0.0+0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t );
ERROR HY000: Thread stack overrun: #### bytes used of a #### byte stack, and #### bytes needed. Consider increasing the thread_stack system variable.
DROP TABLE t;
# End of 10.6 tests
13 changes: 13 additions & 0 deletions mysql-test/main/func_math.test
Original file line number Diff line number Diff line change
Expand Up @@ -1947,3 +1947,16 @@ select cast(1 as unsigned) - cast(2 as unsigned);
set sql_mode=default;

--echo # End of 10.5 tests

--echo #
--echo # MDEV-31284: SIGSEGV in VDec2_lazy::VDec2_lazy | Item_func_plus::decimal_op
--echo #

CREATE TABLE t (t INT KEY);
--replace_regex /[0-9]+ byte/#### byte/
--error ER_STACK_OVERRUN_NEED_MORE
INSERT INTO t (t) VALUES (t +0+t + t+t +0+t + t -0+t +-0+-0+t + t +-0+t +-0+t + t+t +0+t + t+t + t +0+t + t +-0+t +-0+-0+t + t +-0+t +-0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0+t + t+t +0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+t + t +0.0+0+t + t+t +0.0+t + t +-0+0+t +0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +0.0+0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0+t + t+t +0+t + t+t +-0+0.0+t +0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t+t +0.0+0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t + t+t +0+t + t+t + t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+t +-0+0+t +-0+0.0+t + t +-0+0.0+0.0+0+t +-0+0.0+-0+0.0+0.0+0+t +-0+0.0+0+0.0+0+t +-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0.0+0+t + t+t +0.0+t + t +-0+0+t +-0+0.0+-0+t + t +-0+0.0+0.0+0+t +-0+0.0+0+t );

DROP TABLE t;

--echo # End of 10.6 tests
51 changes: 51 additions & 0 deletions sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,57 @@ bool Item_func_plus::fix_length_and_dec(void)
DBUG_RETURN(FALSE);
}

double Item_func_hybrid_field_type::val_real()
{
DBUG_ASSERT(fixed());
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
{
null_value= true;
return 0.0;
}
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_real(this);
}

longlong Item_func_hybrid_field_type::val_int()
{
DBUG_ASSERT(!is_cond());
DBUG_ASSERT(fixed());
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
{
null_value= true;
return 0;
}
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_int(this);
}

my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *dec)
{
uchar buff[STACK_BUFF_ALLOC];
DBUG_ASSERT(fixed());
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, buff))
{
null_value= true;
return NULL;
}
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_decimal(this, dec);
}

String *Item_func_hybrid_field_type::val_str(String*str)
{
DBUG_ASSERT(fixed());
if (check_stack_overrun(current_thd, STACK_MIN_SIZE, NULL))
{
null_value= true;
return NULL;
}
String *res= Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_str(this, str);
DBUG_ASSERT(null_value == (res == NULL));
return res;
}

String *Item_func_hybrid_field_type::val_str_from_int_op(String *str)
{
Expand Down
32 changes: 5 additions & 27 deletions sql/item_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,33 +966,11 @@ class Item_func_hybrid_field_type: public Item_hybrid_func
Item_hybrid_func(thd, list)
{ collation= DTCollation_numeric(); }

double val_real() override
{
DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_real(this);
}
longlong val_int() override
{
DBUG_ASSERT(!is_cond());
DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_int(this);
}
my_decimal *val_decimal(my_decimal *dec) override
{
DBUG_ASSERT(fixed());
return Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_decimal(this, dec);
}
String *val_str(String*str) override
{
DBUG_ASSERT(fixed());
String *res= Item_func_hybrid_field_type::type_handler()->
Item_func_hybrid_field_type_val_str(this, str);
DBUG_ASSERT(null_value == (res == NULL));
return res;
}
double val_real() override;
longlong val_int() override;
my_decimal *val_decimal(my_decimal *dec) override;
String *val_str(String*str) override;

bool get_date(THD *thd, MYSQL_TIME *to, date_mode_t mode) override
{
DBUG_ASSERT(fixed());
Expand Down