Debian Codegraph @

mysql-test/suite/group_replication/r/gr_foreign_checks_disabled.result

raw
1 include/group_replication.inc
2 Warnings:
3 Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
4 Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information.
5 [connection server1]
6 #########################################################################
7 # 1. Disable foreign key checks
8 SET foreign_key_checks=0;
9 #########################################################################
10 # 2.1. Should be able to create a table with a foreign key
11 # which refers a table which does not exist.
12 CREATE TABLE child_table (c1 INT PRIMARY KEY,
13 FOREIGN KEY (c1) REFERENCES parent_table(c1));
14 #########################################################################
15 # 2.2. Should be able to insert a value in child table even
16 # when the parent table does not exists because foreign
17 # key checks are disabled.
18 INSERT INTO child_table VALUES(1);
19 #########################################################################
20 # 3. Create parent table.
21 CREATE TABLE parent_table (c1 INT PRIMARY KEY);
22 #########################################################################
23 # 4. Should be able to insert a value into child table even
24 # when that value is not there in the parent table
25 # because foreign key checks are disabled.
26 INSERT INTO child_table VALUES(2);
27 #########################################################################
28 # 5. Enable foreign_key_checks
29 SET foreign_key_checks=1;
30 #########################################################################
31 # 6.1. Foreign key checks are enabled. Now inserting a value into
32 # child table that does not exists in parent table should
33 # throw error.
34 INSERT INTO child_table VALUES(3);
35 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child_table`, CONSTRAINT `child_table_ibfk_1` FOREIGN KEY (`c1`) REFERENCES `parent_table` (`c1`))
36 #########################################################################
37 # 6.2. Insert a tuple into parent_table. Inserting that value
38 # into child table should be allowed now.
39 INSERT INTO parent_table VALUES(3);
40 INSERT INTO child_table VALUES(3);
41 #########################################################################
42 # 7. Clean up.
43 DROP TABLE child_table;
44 DROP TABLE parent_table;
45 include/group_replication_end.inc