Skip to content

Commit

Permalink
MDEV-31112 vcol circular references lead to stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Oct 23, 2023
1 parent 547dfc0 commit 082aea7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/vcol/r/vcol_misc.result
Expand Up @@ -569,3 +569,14 @@ drop table t1;
#
# End of 10.3 tests
#
#
# MDEV-31112 vcol circular references lead to stack overflow
#
create table t (a int, c int as (a));
alter table t alter column c drop default;
alter table t modify column a int as (c) stored;
ERROR 01000: Expression for field `a` is referring to uninitialized field `c`
drop table t;
#
# End of 10.4 tests
#
13 changes: 13 additions & 0 deletions mysql-test/suite/vcol/t/vcol_misc.test
Expand Up @@ -536,3 +536,16 @@ drop table t1;
--echo #
--echo # End of 10.3 tests
--echo #

--echo #
--echo # MDEV-31112 vcol circular references lead to stack overflow
--echo #
create table t (a int, c int as (a));
alter table t alter column c drop default;
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
alter table t modify column a int as (c) stored;
drop table t;

--echo #
--echo # End of 10.4 tests
--echo #
7 changes: 4 additions & 3 deletions sql/item.cc
Expand Up @@ -908,14 +908,15 @@ bool Item_field::register_field_in_write_map(void *arg)
This is used by fix_vcol_expr() when a table is opened
We don't have to check fields that are marked as NO_DEFAULT_VALUE
as the upper level will ensure that all these will be given a value.
We don't have to check non-virtual fields that are marked as
NO_DEFAULT_VALUE as the upper level will ensure that all these
will be given a value.
*/

bool Item_field::check_field_expression_processor(void *arg)
{
Field *org_field= (Field*) arg;
if (field->flags & NO_DEFAULT_VALUE_FLAG)
if (field->flags & NO_DEFAULT_VALUE_FLAG && !field->vcol_info)
return 0;
if ((field->default_value && field->default_value->flags) || field->vcol_info)
{
Expand Down

0 comments on commit 082aea7

Please sign in to comment.