~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/warnings.test

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
show count(*) errors;
13
13
show errors;
14
14
show warnings;
15
 
--error 1115
16
 
create table t2(a int) default charset qwerty;
17
 
show count(*) errors;
18
 
show errors;
19
15
--error 1064
20
16
create table t (i);
21
17
show count(*) errors;
22
18
show errors;
23
19
insert into t1 values (1);
 
20
--error 1366
24
21
insert into t1 values ("hej");
 
22
--error 1366
25
23
insert into t1 values ("hej"),("d�");
26
24
set SQL_WARNINGS=1;
 
25
--error 1366
27
26
insert into t1 values ("hej");
 
27
--error 1366
28
28
insert into t1 values ("hej"),("d�");
29
29
drop table t1;
30
30
set SQL_WARNINGS=0;
46
46
drop table t1;
47
47
 
48
48
#
49
 
# Test warnings for LOAD DATA INFILE
 
49
# Test error for LOAD DATA INFILE
50
50
#
51
51
 
52
52
create table t1(a int, b int not null, c date, d char(5));
 
53
--error 1263
53
54
load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
54
55
# PS doesn't work good with @@warning_count
55
56
--disable_ps_protocol
58
59
drop table t1;
59
60
 
60
61
#
61
 
# Warnings from basic INSERT, UPDATE and ALTER commands
 
62
# Errors and Warnings from basic INSERT, UPDATE and ALTER commands
62
63
#
63
64
 
64
65
create table t1(a int NOT NULL, b int, c char(5));
65
 
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
 
66
 
 
67
# Error data to big for character field
 
68
--error 1406
 
69
insert into t1 values(-1,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
 
70
insert into t1 values(-1,100,'mysql'),(10,-1,'dri '),(500,256,'zzle'),(20,NULL,'test');
 
71
 
 
72
# Error as changing width truncates data
 
73
--error 1265  
66
74
alter table t1 modify c char(4);
67
75
alter table t1 add d char(2);
 
76
 
 
77
# Error trying to insert NULL data into NOT NULL field
68
78
--error 1048
69
79
update t1 set a=NULL where a=10;
70
 
update t1 set c='mysql ab' where c='test';
 
80
 
 
81
# Error data to big for character field
 
82
--error 1406
 
83
update t1 set c='drizzle' where c='test';
 
84
 
 
85
# Error data to big for character field
 
86
--error 1406
71
87
update t1 set d=c;
 
88
 
72
89
create table t2(a int NOT NULL, b char(3));
 
90
 
 
91
# Error data to big for character field
 
92
--error 1406
73
93
insert into t2 select b,c from t1;
 
94
 
 
95
# Error 'a' doesn't have a default value
 
96
--error 1364
74
97
insert into t2(b) values('mysqlab');
 
98
insert into t2(a) values(1);
 
99
 
75
100
set sql_warnings=1;
76
 
insert into t2(b) values('mysqlab');
 
101
 
 
102
# Error data to big for character field
 
103
--error 1406
 
104
insert into t2(a,b) values(1,'mysqlab');
 
105
insert into t2(a,b) values(1,'mys');
 
106
 
77
107
set sql_warnings=0;
78
108
drop table t1, t2;
79
109
 
84
114
create table t1(a char(10));
85
115
let $1=50;
86
116
disable_query_log;
 
117
begin;
87
118
while ($1)
88
119
{
89
 
  eval insert into t1 values('mysql ab');
 
120
  eval insert into t1 values('drizzle ab');
90
121
  dec $1;
91
122
}
 
123
commit;
92
124
enable_query_log;
93
125
alter table t1 add b char;
94
126
set max_error_count=10;
 
127
 
 
128
# Error data to big for character field
 
129
--error 1406
 
130
update t1 set b=a;
 
131
 
 
132
alter table t1 modify b char(10);
95
133
update t1 set b=a;
96
134
--disable_ps_protocol
97
135
select @@warning_count;
113
151
drop table t1;
114
152
 
115
153
#
116
 
# Tests for show warnings limit a, b
 
154
# Tests for show errors and warnings limit a, b
117
155
#
118
156
create table t1 (a int);
119
157
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
120
 
# should generate 10 warnings
 
158
# Incorrect integer value abc for column a
 
159
--error 1366
121
160
update t1 set a='abc';
122
161
show warnings limit 2, 1;
123
162
show warnings limit 0, 10;
136
175
 
137
176
--echo End of 4.1 tests
138
177
 
139
 
#
140
 
# Bug#20778: strange characters in warning message 1366 when called in SP
141
 
#
142
 
 
143
 
CREATE TABLE t1( f1 CHAR(20) );
144
 
CREATE TABLE t2( f1 CHAR(20), f2 CHAR(25) );
145
 
CREATE TABLE t3( f1 CHAR(20), f2 CHAR(25), f3 DATE );
146
 
 
147
 
INSERT INTO t1 VALUES ( 'a`' );
148
 
INSERT INTO t2 VALUES ( 'a`', 'a`' );
149
 
INSERT INTO t3 VALUES ( 'a`', 'a`', '1000-01-1' );
150
 
 
151
 
DROP PROCEDURE IF EXISTS sp1;
152
 
DROP PROCEDURE IF EXISTS sp2;
153
 
DROP PROCEDURE IF EXISTS sp3;
154
 
delimiter //;
155
 
CREATE PROCEDURE sp1()
156
 
BEGIN
157
 
   DECLARE x NUMERIC ZEROFILL;
158
 
   SELECT f1 INTO x FROM t1 LIMIT 1;
159
 
END//
160
 
CREATE PROCEDURE sp2()
161
 
BEGIN
162
 
   DECLARE x NUMERIC ZEROFILL;
163
 
   SELECT f1 INTO x FROM t2 LIMIT 1;
164
 
END//
165
 
CREATE PROCEDURE sp3()
166
 
BEGIN
167
 
   DECLARE x NUMERIC ZEROFILL;
168
 
   SELECT f1 INTO x FROM t3 LIMIT 1;
169
 
END//
170
 
delimiter ;//
171
 
CALL sp1();
172
 
CALL sp2();
173
 
CALL sp3();
174
 
 
175
 
DROP PROCEDURE IF EXISTS sp1;
176
 
delimiter //;
177
 
CREATE PROCEDURE sp1()
178
 
BEGIN
179
 
declare x numeric zerofill;
180
 
SELECT f1 into x from t2 limit 1;
181
 
END//
182
 
delimiter ;//
183
 
CALL sp1();
184
 
DROP TABLE t1;
185
 
DROP TABLE t2;
186
 
DROP TABLE t3;
187
 
DROP PROCEDURE sp1;
188
 
DROP PROCEDURE sp2;
189
 
DROP PROCEDURE sp3;
190
 
 
191
 
 
192
 
#
193
 
# Bug#30059: End-space truncation warnings are inconsistent or incorrect
194
 
#
195
 
 
196
 
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext tinytext);
197
 
create table t2 (c_tinyblob tinyblob); # not affected by bug, for regression testing
 
178
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext blob);
198
179
set @c = repeat(' ', 256);
199
180
set @q = repeat('q', 256);
200
181
 
201
 
set sql_mode = '';
202
 
 
203
 
insert into t1 values(@c, @c, @c);
204
 
insert into t2 values(@c);
205
 
insert into t1 values(@q, @q, @q);
206
 
insert into t2 values(@q);
207
 
 
208
 
set sql_mode = 'traditional';
209
 
 
210
 
insert into t1 values(@c, @c, @c);
211
 
--error 1406
212
 
insert into t2 values(@c);
 
182
# BUG, 309791 currently only gives a warning but should give error
 
183
insert into t1 values(@c, @c, @c);
 
184
show warnings;
213
185
--error 1406
214
186
insert into t1 values(@q, NULL, NULL);
215
187
--error 1406
216
188
insert into t1 values(NULL, @q, NULL);
217
 
--error 1406
218
189
insert into t1 values(NULL, NULL, @q);
219
 
--error 1406
220
 
insert into t2 values(@q);
221
 
 
222
 
drop table t1, t2;
223
 
 
224
 
--echo End of 5.0 tests
 
190
 
 
191
drop table t1;
 
192
 
 
193
--echo End of Drizzle tests