summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/innodb/t/innodb-get-fk.test
blob: b4b170b89f93fd3524649e5cccc970dd30a6096e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--source include/have_innodb.inc
--source include/default_charset.inc
# need to restart server
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc

CREATE SCHEMA `repro`;

CREATE TABLE `repro`.`crew` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `code` (`code`)
) ENGINE=InnoDB;

CREATE TABLE `repro`.`pilot` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `code` (`code`)
) ENGINE=InnoDB;

CREATE TABLE `repro`.`crew_role_assigned` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`crew_id` int(11) NOT NULL,
`role_code` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_crewRoleAssigned_roleCode` (`role_code`),
CONSTRAINT `fk_crewRoleAssigned_crewId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`crew` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_crewRoleAssigned_pilotId` FOREIGN KEY (`crew_id`) REFERENCES `repro`.`pilot` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB COMMENT="This is a comment about tables";

-- let $restart_parameters=--innodb-read-only
-- source include/restart_mysqld.inc

--error ER_OPEN_AS_READONLY
ALTER TABLE `repro`.`crew_role_assigned` COMMENT = 'innodb_read_only';
SHOW CREATE TABLE `repro`.`crew_role_assigned`;

# These should be ignored in innodb_read_only mode.
SET GLOBAL innodb_buffer_pool_load_now = ON;
SET GLOBAL innodb_buffer_pool_dump_now = ON;
SET GLOBAL innodb_buffer_pool_load_abort = ON;

-- let $restart_parameters=
-- source include/restart_mysqld.inc

ALTER TABLE `repro`.`crew_role_assigned` COMMENT = "This is a new comment about tables";
SHOW CREATE TABLE `repro`.`crew_role_assigned`;

-- let $restart_parameters=--innodb-read-only
-- source include/restart_mysqld.inc

#
# Below create table should contain also fk definitions
#
SHOW CREATE TABLE `repro`.`crew_role_assigned`;

-- let $restart_parameters=
-- source include/restart_mysqld.inc

DROP TABLE `repro`.`crew_role_assigned`;
DROP TABLE `repro`.`pilot`;
DROP TABLE `repro`.`crew`;
DROP SCHEMA `repro`;