mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
41 lines
761 B
Text
41 lines
761 B
Text
|
#
|
||
|
# Test the operation on the foreign_key_checks variable
|
||
|
#
|
||
|
|
||
|
--source include/galera_cluster.inc
|
||
|
--source include/have_innodb.inc
|
||
|
|
||
|
CREATE TABLE parent (
|
||
|
id INT PRIMARY KEY,
|
||
|
KEY (id)
|
||
|
) ENGINE=InnoDB;
|
||
|
|
||
|
CREATE TABLE child (
|
||
|
id INT PRIMARY KEY,
|
||
|
parent_id INT,
|
||
|
FOREIGN KEY (parent_id)
|
||
|
REFERENCES parent(id)
|
||
|
) ENGINE=InnoDB;
|
||
|
|
||
|
INSERT INTO parent VALUES (1);
|
||
|
INSERT INTO child VALUES (1,1);
|
||
|
|
||
|
SET SESSION foreign_key_checks = 0;
|
||
|
|
||
|
INSERT INTO child VALUES (2,2);
|
||
|
|
||
|
--connection node_2
|
||
|
SELECT COUNT(*) = 1 FROM child WHERE id = 2;
|
||
|
|
||
|
--error ER_NO_REFERENCED_ROW_2
|
||
|
INSERT INTO child VALUES (3,3);
|
||
|
|
||
|
SET SESSION foreign_key_checks = 0;
|
||
|
DELETE FROM parent;
|
||
|
|
||
|
--connection node_1
|
||
|
SELECT COUNT(*) = 0 FROM parent;
|
||
|
|
||
|
DROP TABLE child;
|
||
|
DROP TABLE parent;
|