summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/invisible_field.result17
-rw-r--r--mysql-test/main/invisible_field.test13
-rw-r--r--sql/sql_base.cc5
3 files changed, 33 insertions, 2 deletions
diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result
index ee45567d212..cd1bb77be71 100644
--- a/mysql-test/main/invisible_field.result
+++ b/mysql-test/main/invisible_field.result
@@ -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;
diff --git a/mysql-test/main/invisible_field.test b/mysql-test/main/invisible_field.test
index 7a48347ec29..558ca7aa3a2 100644
--- a/mysql-test/main/invisible_field.test
+++ b/mysql-test/main/invisible_field.test
@@ -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;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index b65737bfb02..a1f3f6116b9 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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;