Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.4.31, 10.11.4
-
MySQL version: 10.11.4-MariaDB-1:10.11.4+maria~ubu2204 through PHP extension MySQLi
Description
The following INSERT IGNORE emits an error instead of a warning:
DROP TABLE IF EXISTS `my_table`;
CREATE TABLE `my_table` (
`first_col` char(63),
`second_col` char(63),
constraint `my_const` check (`first_col` != `second_col`)
);INSERT IGNORE INTO `my_table` VALUES ('a', 'a');
Attachments
Issue Links
- relates to
-
MDEV-31985 IGNORE in INSERT and LOAD are being ignored in InnoDB bulk insert
-
- Confirmed
-
I checked some earlier versions https://dbfiddle.uk/H9aZj6Y9 and it seems it was always causing an error, so I don't think its a regression.
It seems the KB document https://mariadb.com/kb/en/insert-ignore/ inconsistent as looking at documentation this only applies to this list of errors is ignored.
error generated
ERROR 4025 (23000): CONSTRAINT `my_const` failed for `test`.`my_table`
It does seem rather inconsistent to not insert on a FK constraint, but error on a local constraint.
I tested a fix:
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1129,10 +1129,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
}
}
- (values_list.elements == 1 ?
- 0 :
VIEW_CHECK_SKIP)
The reason for this check was added in 2aad30394d33eef23545d717f4b92eb280c2b19d around views with WITH CHECK OPTION.
mysql_load and mysql_updates (from LOAD DATA and UPDATE) just pass with lex.ignore to view_check_option.
Sanja, why is the insert behaviour different?
Why does it error rather than warn if one value provided, by two will ignore?