diff --git a/mysql-test/r/check_constraint.result b/mysql-test/r/check_constraint.result index 3511af841666a..988e49b274da6 100644 --- a/mysql-test/r/check_constraint.result +++ b/mysql-test/r/check_constraint.result @@ -235,3 +235,18 @@ a b insert t1 (b) values (1); ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` drop table t1; +# +# MDEV-26061 MariaDB server crash at Field::set_default +# +create table t1 (v2 date check (v1 like default (v1)), v1 date default (from_days ('x'))); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'x' +insert ignore into t1 values ( 'x' , 'x' ) ; +Warnings: +Warning 1265 Data truncated for column 'v2' at row 1 +Warning 1265 Data truncated for column 'v1' at row 1 +Warning 1292 Truncated incorrect INTEGER value: 'x' +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/t/check_constraint.test b/mysql-test/t/check_constraint.test index 93538fd166635..05145d9d43486 100644 --- a/mysql-test/t/check_constraint.test +++ b/mysql-test/t/check_constraint.test @@ -176,3 +176,20 @@ select * from t1 where a is null; --error ER_CONSTRAINT_FAILED insert t1 (b) values (1); drop table t1; + +--echo # +--echo # MDEV-26061 MariaDB server crash at Field::set_default +--echo # + +create table t1 (v2 date check (v1 like default (v1)), v1 date default (from_days ('x'))); +insert ignore into t1 values ( 'x' , 'x' ) ; +drop table t1; + +--echo # +--echo # End of 10.2 tests +--echo # + +# 10.3 test +#create table t1 (d timestamp check (default (d) is true)) as select 1; +#show create table t1; +#drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 6e5d2ee45a280..cf824039b5634 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8976,6 +8976,12 @@ bool Item_default_value::eq(const Item *item, bool binary_cmp) const } +bool Item_default_value::check_field_expression_processor(void *) +{ + field->default_value= ((Item_field *)(arg->real_item()))->field->default_value; + return 0; +} + bool Item_default_value::fix_fields(THD *thd, Item **items) { Item *real_arg; diff --git a/sql/item.h b/sql/item.h index 290ff11a0f8c0..0823f064af88c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5507,6 +5507,7 @@ class Item_default_value : public Item_field Item *get_tmp_table_item(THD *thd) { return this; } Item_field *field_for_view_update() { return 0; } bool update_vcol_processor(void *arg) { return 0; } + bool check_field_expression_processor(void *arg); bool check_func_default_processor(void *arg) { return true; } bool enchant_default_with_arg_processor(void *arg);