1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-32439 INSERT IGNORE on constraints result in ERROR rather than warning

INSERT IGNORE had a pecular undocumented case that when one row was
inserted, there was an error rather than a warning.

As LOAD DATA IGNORE, UPDATE IGNORE, INSERT IGNORE SELECT, and INSERT
IGNORE VALUES (single row, for foreign key violation) all behave the same
way with a warning lets keep the behaviour normalized.

In compatibility, previously a error was generated, now a warning is
generated.

This behaviour is now consistent with MySQL-8.0 too.
This commit is contained in:
Daniel Black
2023-10-12 12:53:55 +11:00
parent b0379ea4b3
commit 9e457cbe50
5 changed files with 98 additions and 10 deletions

View File

@ -308,5 +308,61 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
#
# End of 10.4 tests
# MDEV-32439 INSERT IGNORE VALUES (one row) errors on constraint
#
CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
INSERT IGNORE INTO t1 VALUES (1,1);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
INSERT IGNORE INTO t1 VALUES (1,2),(2,2);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
INSERT IGNORE INTO t1 VALUES (3,3),(4,4);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SELECT * FROM t1;
v1 v2
1 2
DROP TABLE t1;
#
# MDEV-32439 INSERT IGNORE VALUES (one row) errors on constraint
#
CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
INSERT IGNORE INTO t1 VALUES (1,1);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
INSERT IGNORE INTO t1 VALUES (1,2),(2,2);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
INSERT IGNORE INTO t1 VALUES (3,3),(4,4);
Warnings:
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SHOW WARNINGS;
Level Code Message
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
Warning 4025 CONSTRAINT `unequal` failed for `test`.`t1`
SELECT * FROM t1;
v1 v2
1 2
DROP TABLE t1;
#
# End of 11.4 tests
#