MDEV-31112 vcol circular references lead to stack overflow

This commit is contained in:
Sergei Golubchik 2023-10-21 17:33:29 +02:00
parent 547dfc0e01
commit 082aea7742
3 changed files with 28 additions and 3 deletions

View file

@ -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
#

View file

@ -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 #

View file

@ -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)
{