mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
38 lines
864 B
Text
38 lines
864 B
Text
#
|
|
# Test the operation where the definition of the FK is different from the one of the underlying key
|
|
#
|
|
|
|
--source include/galera_cluster.inc
|
|
--source include/have_innodb.inc
|
|
|
|
CREATE TABLE parent (
|
|
id1 INT,
|
|
id2 INT,
|
|
PRIMARY KEY (id1, id2) /* Multipart PK */
|
|
) ENGINE=InnoDB;
|
|
|
|
CREATE TABLE child (
|
|
id INT PRIMARY KEY,
|
|
parent_id1 INT,
|
|
FOREIGN KEY (parent_id1)
|
|
REFERENCES parent(id1) /* FK is subset of PK above */
|
|
ON UPDATE CASCADE
|
|
ON DELETE CASCADE
|
|
) ENGINE=InnoDB;
|
|
|
|
INSERT INTO parent VALUES (1, 2);
|
|
INSERT INTO child VALUES (1, 1);
|
|
|
|
--connection node_2
|
|
UPDATE parent SET id1 = 3 WHERE id1 = 1;
|
|
|
|
--connection node_1
|
|
SELECT COUNT(*) = 1 FROM child WHERE parent_id1 = 3;
|
|
|
|
DELETE FROM parent WHERE id1 = 3;
|
|
|
|
--connection node_2
|
|
SELECT COUNT(*) = 0 FROM child WHERE parent_id1 = 3;
|
|
|
|
DROP TABLE child;
|
|
DROP TABLE parent;
|