Debian Codegraph @

mysql-test/suite/ndb/t/ndb_metadata_upgrade_80_minor_fk.test

raw
1 --source include/have_multi_ndb.inc
2 --source suite/ndb/include/backup_restore_setup.inc
3 --source suite/ndb/include/have_little_endian.inc
4
5 #
6 # The backup being restored was created using the following commands in 8.0.18:
7 #
8 # CREATE TABLE parent (
9 # c1 int PRIMARY KEY,
10 # c2 int,
11 # UNIQUE p_ukc2(c2)
12 # ) ENGINE NDB;
13 #
14 # INSERT INTO parent VALUES(1, 10),(2, 20);
15 #
16 # CREATE TABLE child (
17 # c1 int,
18 # c2 int,
19 # INDEX c_xc1 (c1),
20 # INDEX c_xc2 (c2),
21 # CONSTRAINT c_fk1
22 # FOREIGN KEY (c1)
23 # REFERENCES parent(c1),
24 # CONSTRAINT c_fk2
25 # FOREIGN KEY (c2)
26 # REFERENCES parent(c2)
27 # ) ENGINE NDB;
28 #
29 # INSERT INTO child
30 # VALUES (1, 10), (2, 20), (1, 20), (2, 10);
31 #
32 # CREATE TABLE self_ref (
33 # c1 int NOT NULL,
34 # c2 int,
35 # UNIQUE sr_ukc1(c1),
36 # CONSTRAINT sr_fk1
37 # FOREIGN KEY (c2)
38 # REFERENCES self_ref(c1)
39 # ON DELETE CASCADE
40 # ON UPDATE SET DEFAULT
41 # ) ENGINE NDB;
42 #
43 # INSERT INTO self_ref VALUES(1,1), (2,1);
44 #
45
46 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m -r --backup-path=$NDB_SAVED_BACKUPS/metadata_upgrade_80_minor_fk >> $NDB_TOOLS_OUTPUT
47 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 2 -r --backup-path=$NDB_SAVED_BACKUPS/metadata_upgrade_80_minor_fk >> $NDB_TOOLS_OUTPUT
48
49 --echo Backup restored
50
51 # Test upgrade of the metadata during schema synchronization
52 --echo Restart server 1 to trigger schema synchronization
53 let $mysqld_name=mysqld.1.1;
54 --source include/restart_mysqld.inc
55
56 # Check if the tables have been synced
57 SHOW TABLES;
58
59 # Check table definitions, data, and constraints
60 SHOW CREATE TABLE parent;
61 --sorted_result
62 SELECT * FROM parent;
63 SHOW CREATE TABLE child;
64 --sorted_result
65 SELECT * FROM child;
66 --echo # Check foreign key constraints
67 INSERT INTO parent VALUES (3, 30);
68 --error ER_ROW_IS_REFERENCED_2
69 DELETE FROM parent WHERE c1 = 1;
70 --sorted_result
71 SELECT * FROM parent;
72 INSERT INTO child VALUES (3, 30);
73 --error ER_NO_REFERENCED_ROW_2
74 INSERT INTO child VALUES (4, 40);
75 --sorted_result
76 SELECT * FROM child;
77 SHOW CREATE TABLE self_ref;
78 --sorted_result
79 SELECT * FROM self_ref;
80 INSERT INTO self_ref VALUES (3, 2);
81 --error ER_NO_REFERENCED_ROW_2
82 INSERT INTO self_ref VALUES (4, 5);
83 DELETE FROM self_ref WHERE c1 = 1;
84 --sorted_result
85 SELECT * FROM self_ref;
86
87 # Clean-up
88 DROP TABLE child;
89 DROP TABLE parent;
90 DROP TABLE self_ref;
91 --remove_file $NDB_TOOLS_OUTPUT