~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/update.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-07 20:12:20 UTC
  • mto: (934.3.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 938.
  • Revision ID: osullivan.padraig@gmail.com-20090307201220-u9r93y0knyyb8ggy
Cleaning up my function object a little bit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
# Some strange updates to test some otherwise unused code
15
15
update t1 set a=a+100 where a=1 and a=2;
16
 
--error ER_BAD_FIELD_ERROR
 
16
--error 1054
17
17
update t1 set a=b+100 where a=1 and a=2; 
18
 
--error ER_BAD_FIELD_ERROR
 
18
--error 1054
19
19
update t1 set a=b+100 where c=1 and a=2; 
20
 
--error ER_BAD_FIELD_ERROR
 
20
--error 1054
21
21
update t1 set d=a+100 where a=1;
22
22
select * from t1;
23
23
drop table t1;
45
45
# Test bug with update reported by Jan Legenhausen
46
46
#
47
47
 
48
 
CREATE TEMPORARY TABLE t1 (
 
48
CREATE TABLE t1 (
49
49
  lfdnr int NOT NULL default '0',
50
50
  ticket int NOT NULL default '0',
51
51
  client varchar(255) NOT NULL default '',
52
52
  replyto varchar(255) NOT NULL default '',
53
53
  subject varchar(100) NOT NULL default '',
54
 
  timestamp_arg int NOT NULL default '0',
 
54
  timestamp int NOT NULL default '0',
55
55
  tstamp timestamp NOT NULL,
56
56
  status int NOT NULL default '0',
57
57
  type varchar(15) NOT NULL default '',
66
66
  comment text,
67
67
  header text,
68
68
  PRIMARY KEY  (lfdnr),
69
 
  KEY k1 (timestamp_arg),
 
69
  KEY k1 (timestamp),
70
70
  KEY k2 (type),
71
71
  KEY k3 (parent),
72
72
  KEY k4 (assignment),
102
102
# Test with limit (Bug #393)
103
103
#
104
104
 
105
 
CREATE TEMPORARY TABLE t1 (
 
105
CREATE TABLE t1 (
106
106
   `id_param` int NOT NULL default '0',
107
107
   `nom_option` char(40) NOT NULL default '',
108
108
   `valid` int NOT NULL default '0',
116
116
drop table t1;
117
117
 
118
118
#
 
119
# Multi table update test from bugs
 
120
#
 
121
 
 
122
create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid));
 
123
 
 
124
insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6),
 
125
('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2),
 
126
('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4),
 
127
('2','2','0',1,7);
 
128
delete from m1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3);
 
129
select * from t1;
 
130
drop table t1;
 
131
 
 
132
#
 
133
# Bug #6054 
 
134
#
 
135
create table t1 (c1 int, c2 char(6), c3 int);
 
136
create table t2 (c1 int, c2 char(6));
 
137
insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
 
138
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
 
139
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
 
140
drop table t1, t2;
 
141
 
 
142
#
119
143
# Bug #8057
120
144
#
121
145
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
134
158
select * from t1;
135
159
drop table t1;
136
160
 
 
161
# BUG#9103 "Erroneous data truncation warnings on multi-table updates"
 
162
create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam;
 
163
create table t2 (a int, b varchar(10)) engine=myisam;
 
164
insert into t1 values ( 1, 'abcd1e');
 
165
insert into t1 values ( 2, 'abcd2e');
 
166
insert into t2 values ( 1, 'abcd1e');
 
167
insert into t2 values ( 2, 'abcd2e');
 
168
analyze table t1,t2;
 
169
update t1, t2 set t1.a = t2.a where t2.b = t1.b;
 
170
show warnings;
 
171
drop table t1, t2;
 
172
 
137
173
#
138
174
# Bug #11868 Update with subquery with ref built with a key from the updated
139
175
#            table crashes server
152
188
#
153
189
create table t1(f1 int);
154
190
select DATABASE();
155
 
--error ER_INVALID_GROUP_FUNC_USE
 
191
--error 1111
156
192
update t1 set f1=1 where count(*)=1;
157
193
select DATABASE();
158
 
--error ER_INVALID_GROUP_FUNC_USE
 
194
--error 1111
159
195
delete from t1 where count(*)=1;
160
196
drop table t1;
161
197
 
165
201
 
166
202
flush status;
167
203
select a from t1 order by a limit 1;
168
 
--replace_column 2 #
169
204
show status like 'handler_read%';
170
205
 
171
206
flush status;
172
207
update t1 set a=9999 order by a limit 1;
173
208
update t1 set b=9999 order by a limit 1;
174
 
--replace_column 2 #
175
209
show status like 'handler_read%';
176
210
 
177
211
flush status;
178
212
delete from t1 order by a limit 1;
179
 
--replace_column 2 #
180
213
show status like 'handler_read%';
181
214
 
182
215
flush status;
183
216
delete from t1 order by a desc limit 1;
184
 
--replace_column 2 #
185
217
show status like 'handler_read%';
186
218
 
187
219
alter table t1 disable keys;
188
220
 
189
221
flush status;
190
222
delete from t1 order by a limit 1;
191
 
--replace_column 2 #
192
223
show status like 'handler_read%';
193
224
 
194
225
# PBXT: this select returns a different result to
210
241
select * from t1;
211
242
drop table t1;
212
243
 
 
244
#
 
245
# Bug#15028 Multitable update returns different numbers of matched rows
 
246
#           depending on table order
 
247
create table t1 (f1 int);
 
248
create table t2 (f2 int);
 
249
insert into t1 values(1),(2);
 
250
insert into t2 values(1),(1);
 
251
--enable_info
 
252
update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1;
 
253
--disable_info
 
254
update t2 set f2=1;
 
255
update t1 set f1=1 where f1=3;
 
256
--enable_info
 
257
update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1;
 
258
--disable_info
 
259
drop table t1,t2;
 
260
 
 
261
 
213
262
# BUG#15935
214
263
create table t1 (a int);
215
264
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
216
265
create table t2 (a int, filler1 char(200), filler2 char(200), key(a));
217
 
insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A CROSS JOIN t1 B;
 
266
insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B;
218
267
flush status;
219
268
update t2 set a=3 where a=2;
220
 
--replace_column 2 #
221
269
show status like 'handler_read%';
222
270
drop table t1, t2;
223
271
 
233
281
# Bug#25126: Wrongly resolved field leads to a crash
234
282
#
235
283
create table t1(f1 int);
236
 
--error ER_BAD_FIELD_ERROR
 
284
--error 1054
237
285
update t1 set f2=1 order by f2;
238
286
drop table t1;
239
287
# End of 4.1 tests
263
311
 
264
312
flush status;
265
313
SELECT user_id FROM t1 WHERE request_id=9999999999999; 
266
 
--replace_column 2 #
267
314
show status like '%Handler_read%';
268
315
SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999; 
269
 
--replace_column 2 #
270
316
show status like '%Handler_read%';
271
317
UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
272
 
--replace_column 2 #
273
318
show status like '%Handler_read%';
274
319
UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
275
 
--replace_column 2 #
276
320
show status like '%Handler_read%';
277
321
 
278
322
DROP TABLE t1;
328
372
# Check that the number of matched rows is correct when the temporary
329
373
# table is small enough to not be converted to MyISAM
330
374
select count(*) from t1 join t2 on (t1.a=t2.a);
 
375
--enable_info
 
376
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
377
--disable_info
331
378
 
332
379
# Increase table sizes
333
380
insert into t2(a) select a from t2; 
338
385
# Check that the number of matched rows is correct when the temporary
339
386
# table has to be converted to MyISAM
340
387
select count(*) from t1 join t2 on (t1.a=t2.a);
 
388
--enable_info
 
389
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
390
--disable_info
341
391
 
342
392
# Check that the number of matched rows is correct when there are duplicate
343
393
# key errors
344
394
update t1 set a=1;
345
395
update t2 set a=1;
346
396
select count(*) from t1 join t2 on (t1.a=t2.a);
 
397
--enable_info
 
398
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
399
--disable_info
347
400
 
348
401
drop table t1,t2;
349
402
 
350
 
#
351
 
# Bug #439719: Drizzle crash when running random query generator
352
 
#
353
 
CREATE TABLE t1(col1 enum('a','b') NOT NULL, col2 enum('a','b') DEFAULT NULL, KEY col2 (col2));
354
 
UPDATE t1 SET col1 = "crash" WHERE col2 = now() ;
355
 
 
356
403
connection default;
357
404
disconnect con1;
358
405
 
359
 
drop table t1;
360
406
--echo End of 5.0 tests