~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#
# Test some warnings
#
--disable_warnings
drop table if exists t1, t2;
--enable_warnings
SET SQL_WARNINGS=1;

create table t1 (a int);
--error ER_TABLE_EXISTS_ERROR
create table t1 (a int);
show count(*) errors;
show errors;
show warnings;
--error ER_PARSE_ERROR
create table t (i);
show count(*) errors;
show errors;
insert into t1 values (1);
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
insert into t1 values ("hej");
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
insert into t1 values ("hej"),("då");
set SQL_WARNINGS=1;
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
insert into t1 values ("hej");
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
insert into t1 values ("hej"),("då");
drop table t1;
set SQL_WARNINGS=0;

#
# Test other warnings
#

drop temporary table if exists not_exists;
drop table if exists not_exists_table;
show warnings limit 1;
drop database if exists not_exists_db;
show count(*) warnings;
create table t1(id int);
create table if not exists t1(id int);
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol
drop table t1;

#
# Test error for LOAD DATA INFILE
#

create table t1(a int, b int not null, c date, d char(5));
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
--error ER_WARN_NULL_TO_NOTNULL
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
# PS doesn't work good with @@warning_count
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol
drop table t1;

#
# Errors and Warnings from basic INSERT, UPDATE and ALTER commands
#

create table t1(a int NOT NULL, b int, c char(5));

# Error data to big for character field
--error ER_DATA_TOO_LONG
insert into t1 values(-1,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
insert into t1 values(-1,100,'mysql'),(10,-1,'dri '),(500,256,'zzle'),(20,NULL,'test');

# Error as changing width truncates data
--error ER_WARN_DATA_TRUNCATED  
alter table t1 modify c char(4);
alter table t1 add d char(2);

# Error trying to insert NULL data into NOT NULL field
--error ER_BAD_NULL_ERROR
update t1 set a=NULL where a=10;

# Error data to big for character field
--error ER_DATA_TOO_LONG
update t1 set c='drizzle' where c='test';

# Error data to big for character field
--error ER_DATA_TOO_LONG
update t1 set d=c;

create table t2(a int NOT NULL, b char(3));

# Error data to big for character field
--error ER_DATA_TOO_LONG
insert into t2 select b,c from t1;

# Error 'a' doesn't have a default value
--error ER_NO_DEFAULT_FOR_FIELD
insert into t2(b) values('mysqlab');
insert into t2(a) values(1);

set sql_warnings=1;

# Error data to big for character field
--error ER_DATA_TOO_LONG
insert into t2(a,b) values(1,'mysqlab');
insert into t2(a,b) values(1,'mys');

set sql_warnings=0;
drop table t1, t2;

#
# Test for max_error_count
#

create table t1(a char(10));
let $1=50;
disable_query_log;
begin;
while ($1)
{
  eval insert into t1 values('drizzle ab');
  dec $1;
}
commit;
enable_query_log;
alter table t1 add b char;
set max_error_count=10;

# Error data to big for character field
--error ER_DATA_TOO_LONG
update t1 set b=a;

alter table t1 modify b char(10);
update t1 set b=a;
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol

# Bug#9072
set max_error_count=0;
show variables like 'max_error_count';
update t1 set b='hi';
--disable_ps_protocol
select @@warning_count;
--enable_ps_protocol
show warnings;
set max_error_count=65535;
show variables like 'max_error_count';
set max_error_count=10;
show variables like 'max_error_count';

drop table t1;

#
# Tests for show errors and warnings limit a, b
#
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
# Incorrect integer value abc for column a
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
update t1 set a='abc';
show warnings limit 2, 1;
show warnings limit 0, 10;
show warnings limit 9, 1;
show warnings limit 10, 1;
show warnings limit 9, 2;
show warnings limit 0, 0;
show warnings limit 1;
show warnings limit 0;
show warnings limit 1, 0;
# make sure behaviour is consistent with select ... limit
select * from t1 limit 0;
select * from t1 limit 1, 0;
select * from t1 limit 0, 0;
drop table t1;

--echo End of 4.1 tests

create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext blob);
set @c = repeat(' ', 256);
set @q = repeat('q', 256);

# BUG, 309791 currently only gives a warning but should give error
--error ER_DATA_TOO_LONG
insert into t1 values(@c, @c, @c);
show warnings;
--error ER_DATA_TOO_LONG
insert into t1 values(@q, NULL, NULL);
--error ER_DATA_TOO_LONG
insert into t1 values(NULL, @q, NULL);
insert into t1 values(NULL, NULL, @q);

drop table t1;

--echo End of Drizzle tests