summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2023-04-28 11:25:31 +0200
committerSergei Golubchik <serg@mariadb.org>2023-04-28 14:11:59 +0200
commitbc970573b38e87a3087c8d7b2252c42e87b7cebb (patch)
treed7949fee84ec2d7d87503f359c423d9afaa94012
parentadbad5e36f99f64eedbcc43f98215f5e52f10cad (diff)
downloadmariadb-git-bc970573b38e87a3087c8d7b2252c42e87b7cebb.tar.gz
MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value
exclude generated columns from the "has default value" check
-rw-r--r--mysql-test/main/long_unique_bugs.result6
-rw-r--r--mysql-test/main/long_unique_bugs.test7
-rw-r--r--sql/sql_insert.cc2
3 files changed, 14 insertions, 1 deletions
diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result
index 0071beb7a24..eb60f79ac67 100644
--- a/mysql-test/main/long_unique_bugs.result
+++ b/mysql-test/main/long_unique_bugs.result
@@ -448,5 +448,11 @@ a b
1 xxx
drop table t1;
#
+# MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value
+#
+create table t1 (f text not null, unique (f));
+insert into t1 (f) select 'f';
+drop table t1;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test
index f594038c375..c6cfd5f006a 100644
--- a/mysql-test/main/long_unique_bugs.test
+++ b/mysql-test/main/long_unique_bugs.test
@@ -443,5 +443,12 @@ select * from t1;
drop table t1;
--echo #
+--echo # MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value
+--echo #
+create table t1 (f text not null, unique (f));
+insert into t1 (f) select 'f';
+drop table t1;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9a760614f6a..424296efcf5 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2134,7 +2134,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry, TABLE_LIST *t
for (Field **field=entry->field ; *field ; field++)
{
if (!bitmap_is_set(write_set, (*field)->field_index) &&
- !(*field)->vers_sys_field() &&
+ !(*field)->vers_sys_field() && !(*field)->vcol_info &&
has_no_default_value(thd, *field, table_list) &&
((*field)->real_type() != MYSQL_TYPE_ENUM))
err=1;