~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/falcon_trig_frkey.result

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
USE test;
2
 
drop table if exists tb3 ;
3
 
create table tb3 (
4
 
f118 char not null DEFAULT 'a', 
5
 
f119 char binary not null DEFAULT b'101', 
6
 
f120 char ascii not null DEFAULT b'101', 
7
 
f121 tinytext, 
8
 
f122 text, 
9
 
f123 mediumtext, 
10
 
f124 longtext unicode, 
11
 
f125 tinyblob, 
12
 
f126 blob, 
13
 
f127 mediumblob, 
14
 
f128 longblob, 
15
 
f129 binary not null DEFAULT b'101', 
16
 
f130 tinyint not null DEFAULT 99, 
17
 
f131 tinyint unsigned not null DEFAULT 99, 
18
 
f132 tinyint zerofill not null DEFAULT 99, 
19
 
f133 tinyint unsigned zerofill not null DEFAULT 99, 
20
 
f134 smallint not null DEFAULT 999, 
21
 
f135 smallint unsigned not null DEFAULT 999, 
22
 
f136 smallint zerofill not null DEFAULT 999,  
23
 
f137 smallint unsigned zerofill not null DEFAULT 999, 
24
 
f138 mediumint not null DEFAULT 9999, 
25
 
f139 mediumint unsigned not null DEFAULT 9999, 
26
 
f140 mediumint zerofill not null DEFAULT 9999, 
27
 
f141 mediumint unsigned zerofill not null DEFAULT 9999, 
28
 
f142 int not null DEFAULT 99999, 
29
 
f143 int unsigned not null DEFAULT 99999, 
30
 
f144 int zerofill not null DEFAULT 99999, 
31
 
f145 int unsigned zerofill not null DEFAULT 99999, 
32
 
f146 bigint not null DEFAULT 999999, 
33
 
f147 bigint unsigned not null DEFAULT 999999, 
34
 
f148 bigint zerofill not null DEFAULT 999999, 
35
 
f149 bigint unsigned zerofill not null DEFAULT 999999, 
36
 
f150 decimal not null DEFAULT 999.999, 
37
 
f151 decimal unsigned not null DEFAULT 999.17, 
38
 
f152 decimal zerofill not null DEFAULT 999.999, 
39
 
f153 decimal unsigned zerofill, 
40
 
f154 decimal (0), 
41
 
f155 decimal (64), 
42
 
f156 decimal (0) unsigned, 
43
 
f157 decimal (64) unsigned, 
44
 
f158 decimal (0) zerofill, 
45
 
f159 decimal (64) zerofill, 
46
 
f160 decimal (0) unsigned zerofill, 
47
 
f161 decimal (64) unsigned zerofill, 
48
 
f162 decimal (0,0), 
49
 
f163 decimal (63,30), 
50
 
f164 decimal (0,0) unsigned, 
51
 
f165 decimal (63,30) unsigned, 
52
 
f166 decimal (0,0) zerofill, 
53
 
f167 decimal (63,30) zerofill, 
54
 
f168 decimal (0,0) unsigned zerofill, 
55
 
f169 decimal (63,30) unsigned zerofill, 
56
 
f170 numeric, 
57
 
f171 numeric unsigned, 
58
 
f172 numeric zerofill, 
59
 
f173 numeric unsigned zerofill, 
60
 
f174 numeric (0), 
61
 
f175 numeric (64) 
62
 
) engine = falcon;
63
 
Warnings:
64
 
Note    1265    Data truncated for column 'f150' at row 1
65
 
Note    1265    Data truncated for column 'f151' at row 1
66
 
Note    1265    Data truncated for column 'f152' at row 1
67
 
load data infile 'MYSQL_TEST_DIR/suite/funcs_1/data/innodb_tb3.txt' into table tb3 ;
68
1
 
69
2
Testcase x.x.x.1:
70
3
-----------------
71
4
DROP TABLE IF EXISTS t0, t1, t2;
72
 
CREATE TABLE t0 (col1 char(50)) ENGINE=falcon;
73
 
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
74
 
PRIMARY KEY (id)) ENGINE=falcon;
 
5
CREATE TABLE t0 (col1 CHAR(50))
 
6
ENGINE = <engine_to_be_tested>;
 
7
CREATE TABLE t1 (id INT NOT NULL, col1 CHAR(50), PRIMARY KEY (id))
 
8
ENGINE = <engine_to_be_tested>;
75
9
CREATE TABLE t2 (id INT PRIMARY KEY, f_id INT,
76
 
INDEX par_ind (f_id), col1 char(50),
77
 
FOREIGN KEY (f_id) REFERENCES t1(id)
78
 
ON DELETE SET NULL) ENGINE=falcon;
79
 
insert into t1 values (1,'Department A');
80
 
insert into t1 values (2,'Department B');
81
 
insert into t1 values (3,'Department C');
82
 
insert into t2 values (1,2,'Emp 1');
83
 
insert into t2 values (2,2,'Emp 2');
84
 
insert into t2 values (3,2,'Emp 3');
85
 
create trigger trig after insert on t0 for each row
86
 
delete from t1 where col1=new.col1;
87
 
select * from t2;
88
 
id      f_id    col1
89
 
1       2       Emp 1
90
 
2       2       Emp 2
91
 
3       2       Emp 3
92
 
lock tables t0 write, t1 write;
93
 
insert into t0 values ('Department B');
94
 
unlock tables;
95
 
select * from t2;
96
 
id      f_id    col1
97
 
1       2       Emp 1
98
 
2       2       Emp 2
99
 
3       2       Emp 3
100
 
drop trigger trig;
101
 
drop table t2, t1;
 
10
INDEX par_ind (f_id), col1 CHAR(50),
 
11
FOREIGN KEY (f_id) REFERENCES t1(id) ON DELETE SET NULL)
 
12
ENGINE = <engine_to_be_tested>;
 
13
INSERT INTO t1 VALUES (1,'Department A');
 
14
INSERT INTO t1 VALUES (2,'Department B');
 
15
INSERT INTO t1 VALUES (3,'Department C');
 
16
INSERT INTO t2 VALUES (1,2,'Emp 1');
 
17
INSERT INTO t2 VALUES (2,2,'Emp 2');
 
18
INSERT INTO t2 VALUES (3,2,'Emp 3');
 
19
CREATE TRIGGER trig AFTER INSERT ON t0 FOR EACH ROW
 
20
DELETE FROM t1 WHERE col1 = new.col1;
 
21
SELECT * FROM t2;
 
22
id      f_id    col1
 
23
1       2       Emp 1
 
24
2       2       Emp 2
 
25
3       2       Emp 3
 
26
LOCK TABLES t0 WRITE, t1 WRITE;
 
27
INSERT INTO t0 VALUES ('Department B');
 
28
UNLOCK TABLES;
 
29
SELECT * FROM t2;
 
30
id      f_id    col1
 
31
1       NULL    Emp 1
 
32
2       NULL    Emp 2
 
33
3       NULL    Emp 3
 
34
DROP TRIGGER trig;
 
35
DROP TABLE t2, t1;
102
36
 
103
37
Testcase x.x.x.2:
104
38
-----------------
105
39
DROP TABLE IF EXISTS t1, t2;
106
 
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
107
 
PRIMARY KEY (id)) ENGINE=falcon;
 
40
CREATE TABLE t1 (id INT NOT NULL, col1 CHAR(50), PRIMARY KEY (id))
 
41
ENGINE = <engine_to_be_tested>;
108
42
CREATE TABLE t2 (id INT PRIMARY KEY, f_id INT,
109
 
INDEX par_ind (f_id), col1 char(50),
110
 
FOREIGN KEY (f_id) REFERENCES t1(id)
111
 
ON UPDATE CASCADE) ENGINE=falcon;
112
 
insert into t1 values (1,'Department A');
113
 
insert into t1 values (2,'Department B');
114
 
insert into t1 values (3,'Department C');
115
 
insert into t2 values (1,2,'Emp 1');
116
 
insert into t2 values (2,3,'Emp 2');
117
 
insert into t2 values (3,4,'Emp 3');
118
 
create trigger tr_t2 before insert on t2 for each row
119
 
insert into t1 values(new.f_id, concat('New Department ', new.f_id));
120
 
lock tables t1 write, t2 write;
121
 
insert into t2 values (3,4,'Emp 3');
122
 
ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
123
 
unlock tables;
124
 
select * from t1;
 
43
INDEX par_ind (f_id), col1 CHAR(50),
 
44
FOREIGN KEY (f_id) REFERENCES t1(id) ON UPDATE CASCADE)
 
45
ENGINE = <engine_to_be_tested>;
 
46
INSERT INTO t1 VALUES (1,'Department A');
 
47
INSERT INTO t1 VALUES (2,'Department B');
 
48
INSERT INTO t1 VALUES (3,'Department C');
 
49
INSERT INTO t2 VALUES (1,2,'Emp 1');
 
50
INSERT INTO t2 VALUES (2,3,'Emp 2');
 
51
insert into t2 VALUES (3,4,'Emp 3');
 
52
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `t1` (`id`) ON UPDATE CASCADE)
 
53
CREATE TRIGGER tr_t2 BEFORE INSERT ON t2 FOR EACH ROW
 
54
INSERT INTO t1 VALUES(new.f_id, CONCAT('New Department ', new.f_id));
 
55
LOCK TABLES t1 WRITE, t2 WRITE;
 
56
INSERT INTO t2 VALUES (3,4,'Emp 3');
 
57
UNLOCK TABLES;
 
58
SELECT * FROM t1;
125
59
id      col1
126
60
1       Department A
127
61
2       Department B
128
62
3       Department C
129
 
select * from t2;
 
63
4       New Department 4
 
64
SELECT * FROM t2;
130
65
id      f_id    col1
131
66
1       2       Emp 1
132
67
2       3       Emp 2
133
68
3       4       Emp 3
134
 
drop trigger tr_t2;
135
 
drop table t2, t1, t0;
 
69
DROP TRIGGER tr_t2;
 
70
DROP TABLE t2, t1, t0;
136
71
 
137
72
Foreign Key tests disabled (bug 11472 - stored in trig_frkey2.test)
138
73
-------------------------------------------------------------------
139
 
DROP TABLE test.tb3;