Skip to content

Commit 57bb3ed

Browse files
committed
WL#6614 : Define and reimplement IGNORE
WL#6891 : Define and reimplement STRICT MODE IGNORE Reimplementation : This worklog reimplements IGNORE. In the previous implementation, errors were downgraded to warnings inside THD::raise_condition() based on SELECT_LEX::no_error. This patch changes it to use an Internal_error_handler activated just for statements which support IGNORE keyword to downgrade specific errors to warnings. Bugs Fixed by this worklog : - Bug#11744960 : INSERT IGNORE SHOULD RETURN WARNINGS - Bug#11752648 : MULTI-DELETE IGNORE DOES NOT REPORT WARNINGS - Bug#16522924 : UPDATE TRIGGER INVOKED WHEN UPDATE IGNORE MEANS THAT NO UPDATE IS PERFORMED - Bug#16860715 : ASSERT IN PROTOCOL::END_STATEMENT DURING DELETE IGNORE - Bug#16860829 : ASSERT IN DIAGNOSTICS_AREA::SET_ERROR_STATUS - Bug#17550423 : DELETE IGNORE GIVES INCORRECT RESULT WITH FOREIGN KEY FOR PARENT TABLE STRICT Mode Reimplementation : This worklog reimplements STRICT mode. In the previous implementation When STRICT MODE was enabled, warning were upgraded to errors inside THD::raise_condition() based on THD::abort_on_warning flag. This patch uses an Internal_error_handler activated just for STRICT MODE to do the upgrade of specific warnings to errors. Bugs Fixed by this worklog : - BUG#11751889: TRIGGERS OVERRIDE STRICT SQL_MODE - Bug#16976939: FIX ERROR MESSAGE ON DUPLICATE INDEX CREATION AND STRICT MODE - BUG#18526888: STRICT MODE DOES NOT APPLY TO MULTI DELETE STATEMENT
1 parent 7656a23 commit 57bb3ed

File tree

127 files changed

+3077
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+3077
-610
lines changed

mysql-test/r/commit_1innodb.result

+2
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ SUCCESS
529529
# 13. Read-write statement: INSERT IGNORE, change 0 rows.
530530
#
531531
insert ignore t1 set a=2;
532+
Warnings:
533+
Warning 1062 Duplicate entry '2' for key 'a'
532534
call p_verify_status_increment(2, 2, 1, 0);
533535
SUCCESS
534536

mysql-test/r/create.result

+2
Original file line numberDiff line numberDiff line change
@@ -1787,6 +1787,8 @@ a b
17871787
drop table t1;
17881788
create table if not exists t1 (a int unique, b int)
17891789
ignore select 1 as a, 1 as b union select 1 as a, 2 as b;
1790+
Warnings:
1791+
Warning 1062 Duplicate entry '1' for key 'a'
17901792
select * from t1;
17911793
a b
17921794
1 1

mysql-test/r/delete.result

+52-7
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ a b
126126
2 12
127127
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
128128
Warnings:
129-
Error 1242 Subquery returns more than 1 row
130-
Error 1242 Subquery returns more than 1 row
129+
Warning 1242 Subquery returns more than 1 row
130+
Warning 1242 Subquery returns more than 1 row
131131
select * from t11;
132132
a b
133133
0 10
@@ -146,8 +146,8 @@ a b
146146
2 12
147147
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
148148
Warnings:
149-
Error 1242 Subquery returns more than 1 row
150-
Error 1242 Subquery returns more than 1 row
149+
Warning 1242 Subquery returns more than 1 row
150+
Warning 1242 Subquery returns more than 1 row
151151
select * from t11;
152152
a b
153153
0 10
@@ -547,15 +547,15 @@ INSERT INTO t1 VALUES (1);
547547
INSERT INTO t2 VALUES (1);
548548
DELETE IGNORE FROM t1 WHERE i = 1;
549549
Warnings:
550-
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
550+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
551551
CREATE PROCEDURE p1() DELETE IGNORE FROM t1 WHERE i = 1;
552552
CALL p1();
553553
Warnings:
554-
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
554+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
555555
PREPARE stm FROM 'CALL p1()';
556556
EXECUTE stm;
557557
Warnings:
558-
Error 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
558+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`i`) REFERENCES `t1` (`i`) ON DELETE NO ACTION)
559559
DEALLOCATE PREPARE stm;
560560
DROP TABLE t2, t1;
561561
DROP PROCEDURE p1;
@@ -570,3 +570,48 @@ DELETE z FROM (SELECT 1) AS x, z;
570570
ERROR HY000: Can not delete from join view 'test.z'
571571
DROP VIEW z, x, y;
572572
DROP TABLE b;
573+
# Bug#11752648 : MULTI-DELETE IGNORE DOES NOT REPORT WARNINGS
574+
#
575+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
576+
INSERT INTO t1 (a) VALUES (1);
577+
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
578+
INSERT INTO t2 (a) VALUES (1);
579+
CREATE TABLE t3 (a INT, b INT, CONSTRAINT c_a FOREIGN KEY (a)
580+
REFERENCES t1 (a), CONSTRAINT c_b FOREIGN KEY (b) REFERENCES t2 (a)) ENGINE=InnoDB;
581+
INSERT INTO t3 (a, b) VALUES (1, 1);
582+
DELETE IGNORE FROM t1;
583+
Warnings:
584+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
585+
DELETE IGNORE t1,t2 FROM t1,t2;
586+
Warnings:
587+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_a` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
588+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t3`, CONSTRAINT `c_b` FOREIGN KEY (`b`) REFERENCES `t2` (`a`))
589+
SELECT * FROM t1;
590+
a
591+
1
592+
SELECT * FROM t2;
593+
a
594+
1
595+
DROP TABLE t3,t2,t1;
596+
#
597+
# Bug#17550423 : DELETE IGNORE GIVES INCORRECT RESULT WITH FOREIGN KEY
598+
# FOR PARENT TABLE
599+
#
600+
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
601+
CREATE TABLE t2 (b INT) ENGINE=InnoDB;
602+
INSERT INTO t1 VALUES (1), (2), (5);
603+
INSERT INTO t2 VALUES (1), (5);
604+
ALTER TABLE t2 ADD CONSTRAINT FOREIGN KEY(b) REFERENCES t1(a);
605+
SELECT * FROM t2;
606+
b
607+
1
608+
5
609+
DELETE IGNORE FROM t1;
610+
Warnings:
611+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`))
612+
Warning 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`a`))
613+
SELECT * FROM t1;
614+
a
615+
1
616+
5
617+
DROP TABLE t2,t1;

0 commit comments

Comments
 (0)