mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01: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:
parent
b0379ea4b3
commit
9e457cbe50
5 changed files with 98 additions and 10 deletions
|
@ -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
|
||||
#
|
||||
|
|
|
@ -232,5 +232,33 @@ show create table t1;
|
|||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo # MDEV-32439 INSERT IGNORE VALUES (one row) errors on constraint
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
|
||||
INSERT IGNORE INTO t1 VALUES (1,1);
|
||||
SHOW WARNINGS;
|
||||
INSERT IGNORE INTO t1 VALUES (1,2),(2,2);
|
||||
SHOW WARNINGS;
|
||||
INSERT IGNORE INTO t1 VALUES (3,3),(4,4);
|
||||
SHOW WARNINGS;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-32439 INSERT IGNORE VALUES (one row) errors on constraint
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (v1 varchar(10), v2 varchar(10), constraint unequal check (v1 != v2));
|
||||
INSERT IGNORE INTO t1 VALUES (1,1);
|
||||
SHOW WARNINGS;
|
||||
INSERT IGNORE INTO t1 VALUES (1,2),(2,2);
|
||||
SHOW WARNINGS;
|
||||
INSERT IGNORE INTO t1 VALUES (3,3),(4,4);
|
||||
SHOW WARNINGS;
|
||||
SELECT * FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 11.4 tests
|
||||
--echo #
|
||||
|
|
|
@ -1228,10 +1228,17 @@ drop table t1;
|
|||
create table t1 (s1 int);
|
||||
create view v1 as select * from t1 where s1 < 5 with check option;
|
||||
insert ignore into v1 values (6);
|
||||
ERROR 44000: CHECK OPTION failed `test`.`v1`
|
||||
Warnings:
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
insert ignore into v1 values (6),(3);
|
||||
Warnings:
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Warning 1369 CHECK OPTION failed `test`.`v1`
|
||||
select * from t1;
|
||||
s1
|
||||
3
|
||||
|
|
|
@ -1126,15 +1126,16 @@ drop view v2, v1;
|
|||
drop table t1;
|
||||
|
||||
#
|
||||
# inserting single value with check option failed always get error
|
||||
# inserting single value with check option warns like 2 values
|
||||
#
|
||||
create table t1 (s1 int);
|
||||
create view v1 as select * from t1 where s1 < 5 with check option;
|
||||
#single value
|
||||
-- error ER_VIEW_CHECK_FAILED
|
||||
insert ignore into v1 values (6);
|
||||
SHOW WARNINGS;
|
||||
#several values
|
||||
insert ignore into v1 values (6),(3);
|
||||
SHOW WARNINGS;
|
||||
select * from t1;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
|
|
@ -1129,11 +1129,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list,
|
|||
}
|
||||
}
|
||||
|
||||
if ((res= table_list->view_check_option(thd,
|
||||
(values_list.elements == 1 ?
|
||||
0 :
|
||||
ignore))) ==
|
||||
VIEW_CHECK_SKIP)
|
||||
if ((res= table_list->view_check_option(thd, ignore)) == VIEW_CHECK_SKIP)
|
||||
continue;
|
||||
else if (res == VIEW_CHECK_ERROR)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue