diff options
-rw-r--r-- | mysql-test/main/long_unique_bugs.result | 9 | ||||
-rw-r--r-- | mysql-test/main/long_unique_bugs.test | 13 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 |
3 files changed, 24 insertions, 2 deletions
diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index b3a1076804b..a96cac09bc1 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -186,3 +186,12 @@ c varchar(5000), UNIQUE(c,b(64)) ) ENGINE=InnoDB; drop table t1; +CREATE TABLE t1 (data VARCHAR(4), unique(data) using hash) with system versioning; +INSERT INTO t1 VALUES ('A'); +SELECT * INTO OUTFILE 'load.data' from t1; +LOAD DATA INFILE 'load.data' INTO TABLE t1; +ERROR 23000: Duplicate entry 'A' for key 'data' +select * from t1; +data +A +DROP TABLE t1; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 6257111b3fb..910e1e8b436 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -215,3 +215,16 @@ CREATE TABLE t1 ( UNIQUE(c,b(64)) ) ENGINE=InnoDB; drop table t1; + +# +# MDEV-18967 Load data in system version with long unique does not work +# +CREATE TABLE t1 (data VARCHAR(4), unique(data) using hash) with system versioning; +INSERT INTO t1 VALUES ('A'); +SELECT * INTO OUTFILE 'load.data' from t1; +--error ER_DUP_ENTRY +LOAD DATA INFILE 'load.data' INTO TABLE t1; +select * from t1; +DROP TABLE t1; +--let $datadir= `select @@datadir` +--remove_file $datadir/test/load.data diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5de8bcc6df6..a7debea0076 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8439,12 +8439,12 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values, if (!update && table_arg->default_field && table_arg->update_default_fields(0, ignore_errors)) goto err; + if (table_arg->versioned() && !only_unvers_fields) + table_arg->vers_update_fields(); /* Update virtual fields */ if (table_arg->vfield && table_arg->update_virtual_fields(table_arg->file, VCOL_UPDATE_FOR_WRITE)) goto err; - if (table_arg->versioned() && !only_unvers_fields) - table_arg->vers_update_fields(); thd->abort_on_warning= save_abort_on_warning; thd->no_errors= save_no_errors; DBUG_RETURN(thd->is_error()); |