~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1, t2;
2
SET SQL_WARNINGS=1;
3
create table t1 (a int);
4
create table t1 (a int);
5
ERROR 42S01: Table 't1' already exists
6
show count(*) errors;
7
@@session.error_count
8
1
9
show errors;
10
Level	Code	Message
11
Error	1050	Table 't1' already exists
12
show warnings;
13
Level	Code	Message
14
Error	1050	Table 't1' already exists
15
create table t2(a int) default charset qwerty;
16
ERROR 42000: Unknown character set: 'qwerty'
17
show count(*) errors;
18
@@session.error_count
19
1
20
show errors;
21
Level	Code	Message
22
Error	1115	Unknown character set: 'qwerty'
23
create table t (i);
24
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
25
show count(*) errors;
26
@@session.error_count
27
1
28
show errors;
29
Level	Code	Message
30
Error	1064	You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
31
insert into t1 values (1);
32
insert into t1 values ("hej");
33
Warnings:
34
Warning	1366	Incorrect integer value: 'hej' for column 'a' at row 1
35
insert into t1 values ("hej"),("då");
36
Warnings:
37
Warning	1366	Incorrect integer value: 'hej' for column 'a' at row 1
38
Warning	1366	Incorrect integer value: 'd?' for column 'a' at row 2
39
set SQL_WARNINGS=1;
40
insert into t1 values ("hej");
41
Warnings:
42
Warning	1366	Incorrect integer value: 'hej' for column 'a' at row 1
43
insert into t1 values ("hej"),("då");
44
Warnings:
45
Warning	1366	Incorrect integer value: 'hej' for column 'a' at row 1
46
Warning	1366	Incorrect integer value: 'd?' for column 'a' at row 2
47
drop table t1;
48
set SQL_WARNINGS=0;
49
drop temporary table if exists not_exists;
50
Warnings:
51
Note	1051	Unknown table 'not_exists'
52
drop table if exists not_exists_table;
53
Warnings:
54
Note	1051	Unknown table 'not_exists_table'
55
show warnings limit 1;
56
Level	Code	Message
57
Note	1051	Unknown table 'not_exists_table'
58
drop database if exists not_exists_db;
59
Warnings:
60
Note	1008	Can't drop database 'not_exists_db'; database doesn't exist
61
show count(*) warnings;
62
@@session.warning_count
63
1
64
create table t1(id int);
65
create table if not exists t1(id int);
66
Warnings:
67
Note	1050	Table 't1' already exists
68
select @@warning_count;
69
@@warning_count
70
1
71
drop table t1;
72
create table t1(a tinyint, b int not null, c date, d char(5));
73
load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
74
Warnings:
75
Warning	1263	Column set to default value; NULL supplied to NOT NULL column 'b' at row 2
76
Warning	1265	Data truncated for column 'd' at row 3
77
Warning	1265	Data truncated for column 'c' at row 4
78
Warning	1261	Row 5 doesn't contain data for all columns
79
Warning	1265	Data truncated for column 'b' at row 6
80
Warning	1262	Row 7 was truncated; it contained more data than there were input columns
81
Warning	1264	Out of range value for column 'a' at row 8
82
select @@warning_count;
83
@@warning_count
84
7
85
drop table t1;
86
create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
87
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
88
Warnings:
89
Warning	1048	Column 'a' cannot be null
90
Warning	1264	Out of range value for column 'b' at row 2
91
Warning	1265	Data truncated for column 'c' at row 2
92
Warning	1264	Out of range value for column 'a' at row 3
93
Warning	1264	Out of range value for column 'b' at row 3
94
Warning	1265	Data truncated for column 'c' at row 3
95
alter table t1 modify c char(4);
96
Warnings:
97
Warning	1265	Data truncated for column 'c' at row 1
98
Warning	1265	Data truncated for column 'c' at row 2
99
alter table t1 add d char(2);
100
update t1 set a=NULL where a=10;
101
ERROR 23000: Column 'a' cannot be null
102
update t1 set c='mysql ab' where c='test';
103
Warnings:
104
Warning	1265	Data truncated for column 'c' at row 4
105
update t1 set d=c;
106
Warnings:
107
Warning	1265	Data truncated for column 'd' at row 1
108
Warning	1265	Data truncated for column 'd' at row 2
109
Warning	1265	Data truncated for column 'd' at row 3
110
Warning	1265	Data truncated for column 'd' at row 4
111
create table t2(a tinyint NOT NULL, b char(3));
112
insert into t2 select b,c from t1;
113
Warnings:
114
Warning	1265	Data truncated for column 'b' at row 1
115
Warning	1265	Data truncated for column 'b' at row 2
116
Warning	1265	Data truncated for column 'b' at row 3
117
Warning	1048	Column 'a' cannot be null
118
Warning	1265	Data truncated for column 'b' at row 4
119
insert into t2(b) values('mysqlab');
120
Warnings:
121
Warning	1364	Field 'a' doesn't have a default value
122
Warning	1265	Data truncated for column 'b' at row 1
123
set sql_warnings=1;
124
insert into t2(b) values('mysqlab');
125
Warnings:
126
Warning	1364	Field 'a' doesn't have a default value
127
Warning	1265	Data truncated for column 'b' at row 1
128
set sql_warnings=0;
129
drop table t1, t2;
130
create table t1(a char(10));
131
alter table t1 add b char;
132
set max_error_count=10;
133
update t1 set b=a;
134
Warnings:
135
Warning	1265	Data truncated for column 'b' at row 1
136
Warning	1265	Data truncated for column 'b' at row 2
137
Warning	1265	Data truncated for column 'b' at row 3
138
Warning	1265	Data truncated for column 'b' at row 4
139
Warning	1265	Data truncated for column 'b' at row 5
140
Warning	1265	Data truncated for column 'b' at row 6
141
Warning	1265	Data truncated for column 'b' at row 7
142
Warning	1265	Data truncated for column 'b' at row 8
143
Warning	1265	Data truncated for column 'b' at row 9
144
Warning	1265	Data truncated for column 'b' at row 10
145
select @@warning_count;
146
@@warning_count
147
50
148
set max_error_count=0;
149
show variables like 'max_error_count';
150
Variable_name	Value
151
max_error_count	0
152
update t1 set b='hi';
153
Warnings:
154
select @@warning_count;
155
@@warning_count
156
50
157
show warnings;
158
Level	Code	Message
159
set max_error_count=65535;
160
show variables like 'max_error_count';
161
Variable_name	Value
162
max_error_count	65535
163
set max_error_count=10;
164
show variables like 'max_error_count';
165
Variable_name	Value
166
max_error_count	10
167
drop table t1;
168
create table t1 (a int);
169
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
170
update t1 set a='abc';
171
Warnings:
172
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 1
173
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 2
174
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 3
175
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 4
176
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 5
177
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 6
178
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 7
179
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 8
180
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 9
181
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 10
182
show warnings limit 2, 1;
183
Level	Code	Message
184
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 3
185
show warnings limit 0, 10;
186
Level	Code	Message
187
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 1
188
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 2
189
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 3
190
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 4
191
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 5
192
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 6
193
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 7
194
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 8
195
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 9
196
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 10
197
show warnings limit 9, 1;
198
Level	Code	Message
199
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 10
200
show warnings limit 10, 1;
201
Level	Code	Message
202
show warnings limit 9, 2;
203
Level	Code	Message
204
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 10
205
show warnings limit 0, 0;
206
Level	Code	Message
207
show warnings limit 1;
208
Level	Code	Message
209
Warning	1366	Incorrect integer value: 'abc' for column 'a' at row 1
210
show warnings limit 0;
211
Level	Code	Message
212
show warnings limit 1, 0;
213
Level	Code	Message
214
select * from t1 limit 0;
215
a
216
select * from t1 limit 1, 0;
217
a
218
select * from t1 limit 0, 0;
219
a
220
drop table t1;
221
End of 4.1 tests
222
CREATE TABLE t1( f1 CHAR(20) );
223
CREATE TABLE t2( f1 CHAR(20), f2 CHAR(25) );
224
CREATE TABLE t3( f1 CHAR(20), f2 CHAR(25), f3 DATE );
225
INSERT INTO t1 VALUES ( 'a`' );
226
INSERT INTO t2 VALUES ( 'a`', 'a`' );
227
INSERT INTO t3 VALUES ( 'a`', 'a`', '1000-01-1' );
228
DROP PROCEDURE IF EXISTS sp1;
229
Warnings:
230
Note	1305	PROCEDURE sp1 does not exist
231
DROP PROCEDURE IF EXISTS sp2;
232
Warnings:
233
Note	1305	PROCEDURE sp2 does not exist
234
DROP PROCEDURE IF EXISTS sp3;
235
Warnings:
236
Note	1305	PROCEDURE sp3 does not exist
237
CREATE PROCEDURE sp1()
238
BEGIN
239
DECLARE x NUMERIC ZEROFILL;
240
SELECT f1 INTO x FROM t1 LIMIT 1;
241
END//
242
CREATE PROCEDURE sp2()
243
BEGIN
244
DECLARE x NUMERIC ZEROFILL;
245
SELECT f1 INTO x FROM t2 LIMIT 1;
246
END//
247
CREATE PROCEDURE sp3()
248
BEGIN
249
DECLARE x NUMERIC ZEROFILL;
250
SELECT f1 INTO x FROM t3 LIMIT 1;
251
END//
252
CALL sp1();
253
Warnings:
254
Warning	1366	Incorrect decimal value: 'a`' for column 'x' at row 1
255
CALL sp2();
256
Warnings:
257
Warning	1366	Incorrect decimal value: 'a`' for column 'x' at row 1
258
CALL sp3();
259
Warnings:
260
Warning	1366	Incorrect decimal value: 'a`' for column 'x' at row 1
261
DROP PROCEDURE IF EXISTS sp1;
262
CREATE PROCEDURE sp1()
263
BEGIN
264
declare x numeric unsigned zerofill;
265
SELECT f1 into x from t2 limit 1;
266
END//
267
CALL sp1();
268
Warnings:
269
Warning	1366	Incorrect decimal value: 'a`' for column 'x' at row 1
270
DROP TABLE t1;
271
DROP TABLE t2;
272
DROP TABLE t3;
273
DROP PROCEDURE sp1;
274
DROP PROCEDURE sp2;
275
DROP PROCEDURE sp3;
276
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext tinytext);
277
create table t2 (c_tinyblob tinyblob);
278
set @c = repeat(' ', 256);
279
set @q = repeat('q', 256);
280
set sql_mode = '';
281
insert into t1 values(@c, @c, @c);
282
Warnings:
283
Note	1265	Data truncated for column 'c_char' at row 1
284
Note	1265	Data truncated for column 'c_varchar' at row 1
285
Note	1265	Data truncated for column 'c_tinytext' at row 1
286
insert into t2 values(@c);
287
Warnings:
288
Warning	1265	Data truncated for column 'c_tinyblob' at row 1
289
insert into t1 values(@q, @q, @q);
290
Warnings:
291
Warning	1265	Data truncated for column 'c_char' at row 1
292
Warning	1265	Data truncated for column 'c_varchar' at row 1
293
Warning	1265	Data truncated for column 'c_tinytext' at row 1
294
insert into t2 values(@q);
295
Warnings:
296
Warning	1265	Data truncated for column 'c_tinyblob' at row 1
297
set sql_mode = 'traditional';
298
insert into t1 values(@c, @c, @c);
299
Warnings:
300
Note	1265	Data truncated for column 'c_char' at row 1
301
Note	1265	Data truncated for column 'c_varchar' at row 1
302
Note	1265	Data truncated for column 'c_tinytext' at row 1
303
insert into t2 values(@c);
304
ERROR 22001: Data too long for column 'c_tinyblob' at row 1
305
insert into t1 values(@q, NULL, NULL);
306
ERROR 22001: Data too long for column 'c_char' at row 1
307
insert into t1 values(NULL, @q, NULL);
308
ERROR 22001: Data too long for column 'c_varchar' at row 1
309
insert into t1 values(NULL, NULL, @q);
310
ERROR 22001: Data too long for column 'c_tinytext' at row 1
311
insert into t2 values(@q);
312
ERROR 22001: Data too long for column 'c_tinyblob' at row 1
313
drop table t1, t2;
314
End of 5.0 tests