Commit 1e70b287 authored by Aleksey Midenkov's avatar Aleksey Midenkov

MDEV-25891 Computed default for INVISIBLE column is ignored in INSERT

There are two fill_record() functions (lines 8343 and 8618). First one
is used when there are some explicit values, the second one is used
for all implicit values. First one does update_default_fields(), the
second one did not. Added update_default_fields() call to the implicit
version of fill_record().
parent d31f9537
......@@ -538,7 +538,7 @@ a b
insert into t2 values(1);
select a,b from t2;
a b
NULL 1
12 1
drop table t1,t2;
create table t1 (a int invisible, b int, c int);
create table t2 (a int, b int, d int);
......@@ -623,3 +623,18 @@ drop table t1;
create table t1 (a int, b int invisible);
insert delayed into t1 values (1);
drop table t1;
#
# MDEV-25891 Computed default for INVISIBLE column is ignored in INSERT
#
create table t1(
a int,
x int default (a),
y int default (a) invisible,
z int default (33) invisible);
insert into t1 values (1, default);
insert into t1 (a) values (2);
select a, x, y, z from t1;
a x y z
1 1 1 33
2 2 2 33
drop table t1;
......@@ -279,3 +279,16 @@ create table t1 (a int, b int invisible);
insert delayed into t1 values (1);
# cleanup
drop table t1;
--echo #
--echo # MDEV-25891 Computed default for INVISIBLE column is ignored in INSERT
--echo #
create table t1(
a int,
x int default (a),
y int default (a) invisible,
z int default (33) invisible);
insert into t1 values (1, default);
insert into t1 (a) values (2);
select a, x, y, z from t1;
drop table t1;
......@@ -8699,8 +8699,11 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
goto err;
field->set_has_explicit_value();
}
/* Update virtual fields */
thd->abort_on_warning= FALSE;
if (table->default_field &&
table->update_default_fields(ignore_errors))
goto err;
/* Update virtual fields */
if (table->vfield &&
table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_WRITE))
goto err;
......
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