mirror of
https://github.com/MariaDB/server.git
synced 2025-12-19 22:42:44 +03:00
Apply InnoDB-specific parts of the fix for bug #9680, wrong error from
cascading update.
This commit is contained in:
@@ -3213,3 +3213,21 @@ drop trigger t2t;
|
||||
drop trigger t3t;
|
||||
drop trigger t4t;
|
||||
drop table t1, t2, t3, t4, t5;
|
||||
CREATE TABLE t1 (
|
||||
field1 varchar(8) NOT NULL DEFAULT '',
|
||||
field2 varchar(8) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (field1, field2)
|
||||
) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (
|
||||
field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
|
||||
FOREIGN KEY (field1) REFERENCES t1 (field1)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES ('old', 'somevalu');
|
||||
INSERT INTO t1 VALUES ('other', 'anyvalue');
|
||||
INSERT INTO t2 VALUES ('old');
|
||||
INSERT INTO t2 VALUES ('other');
|
||||
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
|
||||
ERROR 23000: Upholding foreign key constraints for table 't1', entry 'other-somevalu', key 1 would lead to a duplicate entry
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -2106,3 +2106,32 @@ drop trigger t4t;
|
||||
drop table t1, t2, t3, t4, t5;
|
||||
disconnect a;
|
||||
disconnect b;
|
||||
|
||||
#
|
||||
# Test that cascading updates leading to duplicate keys give the correct
|
||||
# error message (bug #9680)
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (
|
||||
field1 varchar(8) NOT NULL DEFAULT '',
|
||||
field2 varchar(8) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (field1, field2)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
field1 varchar(8) NOT NULL DEFAULT '' PRIMARY KEY,
|
||||
FOREIGN KEY (field1) REFERENCES t1 (field1)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO t1 VALUES ('old', 'somevalu');
|
||||
INSERT INTO t1 VALUES ('other', 'anyvalue');
|
||||
|
||||
INSERT INTO t2 VALUES ('old');
|
||||
INSERT INTO t2 VALUES ('other');
|
||||
|
||||
--error ER_FOREIGN_DUPLICATE_KEY
|
||||
UPDATE t1 SET field1 = 'other' WHERE field2 = 'somevalu';
|
||||
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
Reference in New Issue
Block a user