~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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 = innodb;
 
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
 
 
69
Testcase x.x.x.1:
 
70
-----------------
 
71
DROP TABLE IF EXISTS t0, t1, t2;
 
72
CREATE TABLE t0 (col1 char(50)) ENGINE=innodb;
 
73
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
 
74
PRIMARY KEY (id)) ENGINE=innodb;
 
75
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=innodb;
 
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       NULL    Emp 1
 
98
2       NULL    Emp 2
 
99
3       NULL    Emp 3
 
100
drop trigger trig;
 
101
drop table t2, t1;
 
102
 
 
103
Testcase x.x.x.2:
 
104
-----------------
 
105
DROP TABLE IF EXISTS t1, t2;
 
106
CREATE TABLE t1 (id INT NOT NULL, col1 char(50),
 
107
PRIMARY KEY (id)) ENGINE=innodb;
 
108
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=innodb;
 
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
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)
 
119
create trigger tr_t2 before insert on t2 for each row
 
120
insert into t1 values(new.f_id, concat('New Department ', new.f_id));
 
121
lock tables t1 write, t2 write;
 
122
insert into t2 values (3,4,'Emp 3');
 
123
unlock tables;
 
124
select * from t1;
 
125
id      col1
 
126
1       Department A
 
127
2       Department B
 
128
3       Department C
 
129
4       New Department 4
 
130
select * from t2;
 
131
id      f_id    col1
 
132
1       2       Emp 1
 
133
2       3       Emp 2
 
134
3       4       Emp 3
 
135
drop trigger tr_t2;
 
136
drop table t2, t1, t0;
 
137
 
 
138
Foreign Key tests disabled (bug 11472 - stored in trig_frkey2.test)
 
139
-------------------------------------------------------------------
 
140
DROP TABLE test.tb3;