diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-05-15 20:16:58 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-05-15 20:21:54 +0400 |
commit | 3df297271a02ef13babae6ff6a7e47a6bdb7d538 (patch) | |
tree | 101f5a15e1119ebb4e2d412b137e32574ec9b501 /sql/sql_base.cc | |
parent | efd68f5e3184c54e04045a1350a1ff37dc313348 (diff) | |
download | mariadb-git-3df297271a02ef13babae6ff6a7e47a6bdb7d538.tar.gz |
MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
The code erroneously allowed both:
INSERT INTO t1 (vcol) VALUES (DEFAULT);
INSERT INTO t1 (vcol) VALUES (DEFAULT(non_virtual_column));
The former is OK, but the latter is not.
Adding a new virtual method in Item:
virtual bool vcol_assignment_allowed_value() const { return false; }
Item_null, Item_param and Item_default_value override it.
Item_default_value overrides it in the way to:
- allow DEFAULT
- disallow DEFAULT(col)
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c092faa986b..3533c241fbc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8889,8 +8889,7 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values, rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; if (rfield->vcol_info && - value->type() != Item::DEFAULT_VALUE_ITEM && - value->type() != Item::NULL_ITEM && + !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, @@ -9098,8 +9097,7 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values, if (field->field_index == autoinc_index) table->auto_increment_field_not_null= TRUE; if (field->vcol_info && - value->type() != Item::DEFAULT_VALUE_ITEM && - value->type() != Item::NULL_ITEM && + !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, |