Commit d2f84ab9 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-10352 Server crashes in Field::set_default on CREATE TABLE

fix Item_default_value not to pretend being const_item
if the field's default_value expression isn't parsed yet
parent b6a3917b
...@@ -3362,4 +3362,6 @@ a b t ...@@ -3362,4 +3362,6 @@ a b t
4 5 4 also expression DEFAULT(0)+0 4 5 4 also expression DEFAULT(0)+0
4 5 5 the value of the DEFAULT(a), that is b 4 5 5 the value of the DEFAULT(a), that is b
drop table t1; drop table t1;
create table t1 (col1 int default(-(default(col1))));
ERROR 01000: Expression for field `col1` is refering to uninitialized field `col1`
# end of 10.2 test # end of 10.2 test
...@@ -2069,4 +2069,10 @@ insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); ...@@ -2069,4 +2069,10 @@ insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is b');
select * from t1 order by t; select * from t1 order by t;
drop table t1; drop table t1;
#
# MDEV-10352 Server crashes in Field::set_default on CREATE TABLE
#
--error ER_EXPRESSION_REFERS_TO_UNINIT_FIELD
create table t1 (col1 int default(-(default(col1))));
--echo # end of 10.2 test --echo # end of 10.2 test
...@@ -8853,9 +8853,11 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) ...@@ -8853,9 +8853,11 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
table_map Item_default_value::used_tables() const table_map Item_default_value::used_tables() const
{ {
if (field && field->default_value && field->default_value->flags) if (!field || !field->default_value)
return field->default_value->expr->used_tables(); return static_cast<table_map>(0);
return static_cast<table_map>(0); if (!field->default_value->expr) // not fully parsed field
return static_cast<table_map>(RAND_TABLE_BIT);
return field->default_value->expr->used_tables();
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment