~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/warnings.test

Merged vcol stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
SET SQL_WARNINGS=1;
8
8
 
9
9
create table t1 (a int);
10
 
--error ER_TABLE_EXISTS_ERROR
 
10
--error 1050
11
11
create table t1 (a int);
12
12
show count(*) errors;
13
13
show errors;
14
14
show warnings;
15
 
--error ER_PARSE_ERROR
 
15
--error 1115
 
16
create table t2(a int) default charset qwerty;
 
17
show count(*) errors;
 
18
show errors;
 
19
--error 1064
16
20
create table t (i);
17
21
show count(*) errors;
18
22
show errors;
19
23
insert into t1 values (1);
20
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
21
24
insert into t1 values ("hej");
22
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
23
25
insert into t1 values ("hej"),("d�");
24
26
set SQL_WARNINGS=1;
25
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
26
27
insert into t1 values ("hej");
27
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
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 error for LOAD DATA INFILE
 
49
# Test warnings 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
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
54
 
--error ER_WARN_NULL_TO_NOTNULL
55
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
 
53
load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
56
54
# PS doesn't work good with @@warning_count
57
55
--disable_ps_protocol
58
56
select @@warning_count;
60
58
drop table t1;
61
59
 
62
60
#
63
 
# Errors and Warnings from basic INSERT, UPDATE and ALTER commands
 
61
# Warnings from basic INSERT, UPDATE and ALTER commands
64
62
#
65
63
 
66
64
create table t1(a int NOT NULL, b int, c char(5));
67
 
 
68
 
# Error data to big for character field
69
 
--error ER_DATA_TOO_LONG
70
 
insert into t1 values(-1,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
71
 
insert into t1 values(-1,100,'mysql'),(10,-1,'dri '),(500,256,'zzle'),(20,NULL,'test');
72
 
 
73
 
# Error as changing width truncates data
74
 
--error ER_WARN_DATA_TRUNCATED  
 
65
insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
75
66
alter table t1 modify c char(4);
76
67
alter table t1 add d char(2);
77
 
 
78
 
# Error trying to insert NULL data into NOT NULL field
79
 
--error ER_BAD_NULL_ERROR
 
68
--error 1048
80
69
update t1 set a=NULL where a=10;
81
 
 
82
 
# Error data to big for character field
83
 
--error ER_DATA_TOO_LONG
84
 
update t1 set c='drizzle' where c='test';
85
 
 
86
 
# Error data to big for character field
87
 
--error ER_DATA_TOO_LONG
 
70
update t1 set c='mysql ab' where c='test';
88
71
update t1 set d=c;
89
 
 
90
72
create table t2(a int NOT NULL, b char(3));
91
 
 
92
 
# Error data to big for character field
93
 
--error ER_DATA_TOO_LONG
94
73
insert into t2 select b,c from t1;
95
 
 
96
 
# Error 'a' doesn't have a default value
97
 
--error ER_NO_DEFAULT_FOR_FIELD
98
74
insert into t2(b) values('mysqlab');
99
 
insert into t2(a) values(1);
100
 
 
101
75
set sql_warnings=1;
102
 
 
103
 
# Error data to big for character field
104
 
--error ER_DATA_TOO_LONG
105
 
insert into t2(a,b) values(1,'mysqlab');
106
 
insert into t2(a,b) values(1,'mys');
107
 
 
 
76
insert into t2(b) values('mysqlab');
108
77
set sql_warnings=0;
109
78
drop table t1, t2;
110
79
 
115
84
create table t1(a char(10));
116
85
let $1=50;
117
86
disable_query_log;
118
 
begin;
119
87
while ($1)
120
88
{
121
 
  eval insert into t1 values('drizzle ab');
 
89
  eval insert into t1 values('mysql ab');
122
90
  dec $1;
123
91
}
124
 
commit;
125
92
enable_query_log;
126
93
alter table t1 add b char;
127
94
set max_error_count=10;
128
 
 
129
 
# Error data to big for character field
130
 
--error ER_DATA_TOO_LONG
131
 
update t1 set b=a;
132
 
 
133
 
alter table t1 modify b char(10);
134
95
update t1 set b=a;
135
96
--disable_ps_protocol
136
97
select @@warning_count;
152
113
drop table t1;
153
114
 
154
115
#
155
 
# Tests for show errors and warnings limit a, b
 
116
# Tests for show warnings limit a, b
156
117
#
157
118
create table t1 (a int);
158
119
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
159
 
# Incorrect integer value abc for column a
160
 
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
 
120
# should generate 10 warnings
161
121
update t1 set a='abc';
162
122
show warnings limit 2, 1;
163
123
show warnings limit 0, 10;
176
136
 
177
137
--echo End of 4.1 tests
178
138
 
179
 
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext blob);
 
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
180
198
set @c = repeat(' ', 256);
181
199
set @q = repeat('q', 256);
182
200
 
183
 
# BUG, 309791 currently only gives a warning but should give error
184
 
--error ER_DATA_TOO_LONG
185
 
insert into t1 values(@c, @c, @c);
186
 
show warnings;
187
 
--error ER_DATA_TOO_LONG
 
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);
 
213
--error 1406
188
214
insert into t1 values(@q, NULL, NULL);
189
 
--error ER_DATA_TOO_LONG
 
215
--error 1406
190
216
insert into t1 values(NULL, @q, NULL);
 
217
--error 1406
191
218
insert into t1 values(NULL, NULL, @q);
192
 
 
193
 
drop table t1;
194
 
 
195
 
--echo End of Drizzle tests
 
219
--error 1406
 
220
insert into t2 values(@q);
 
221
 
 
222
drop table t1, t2;
 
223
 
 
224
--echo End of 5.0 tests