mariadb/mysql-test/suite/galera/t/galera_var_fkchecks.test
2014-09-30 18:06:15 -04:00

40 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;