~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/update.test

pandora-build v0.100 - Fixes several bugs found by cb1kenobi. Add several thoughts from folks at LCA.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
CREATE TABLE t1
26
26
 (
27
 
 place_id int unsigned NOT NULL,
28
 
 shows int unsigned DEFAULT '0' NOT NULL,
29
 
 ishows int unsigned DEFAULT '0' NOT NULL,
30
 
 ushows int unsigned DEFAULT '0' NOT NULL,
31
 
 clicks int unsigned DEFAULT '0' NOT NULL,
32
 
 iclicks int unsigned DEFAULT '0' NOT NULL,
33
 
 uclicks int unsigned DEFAULT '0' NOT NULL,
 
27
 place_id int NOT NULL,
 
28
 shows int DEFAULT '0' NOT NULL,
 
29
 ishows int DEFAULT '0' NOT NULL,
 
30
 ushows int DEFAULT '0' NOT NULL,
 
31
 clicks int DEFAULT '0' NOT NULL,
 
32
 iclicks int DEFAULT '0' NOT NULL,
 
33
 uclicks int DEFAULT '0' NOT NULL,
34
34
 ts timestamp,
35
35
 PRIMARY KEY (place_id,ts)
36
36
 );
45
45
# Test bug with update reported by Jan Legenhausen
46
46
#
47
47
 
48
 
CREATE TABLE t1 (
49
 
  lfdnr int unsigned NOT NULL default '0',
50
 
  ticket int unsigned NOT NULL default '0',
 
48
CREATE TEMPORARY TABLE t1 (
 
49
  lfdnr int NOT NULL default '0',
 
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 int unsigned 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 '',
58
 
  assignment int unsigned NOT NULL default '0',
59
 
  fupcount int unsigned NOT NULL default '0',
60
 
  parent int unsigned NOT NULL default '0',
61
 
  activity int unsigned NOT NULL default '0',
62
 
  priority tinyint unsigned NOT NULL default '1',
 
58
  assignment int NOT NULL default '0',
 
59
  fupcount int NOT NULL default '0',
 
60
  parent int NOT NULL default '0',
 
61
  activity int NOT NULL default '0',
 
62
  priority int NOT NULL default '1',
63
63
  cc varchar(255) NOT NULL default '',
64
64
  bcc varchar(255) NOT NULL default '',
65
65
  body text NOT NULL,
75
75
 
76
76
INSERT INTO t1 VALUES (773,773,'','','',980257344,20010318180652,0,'Open',10,0,0,0,1,'','','','','');
77
77
 
78
 
alter table t1 change lfdnr lfdnr int unsigned not null auto_increment;
 
78
alter table t1 change lfdnr lfdnr int not null auto_increment;
79
79
update t1 set status=1 where type='Open';
80
80
select status from t1;
81
81
drop table t1;
102
102
# Test with limit (Bug #393)
103
103
#
104
104
 
105
 
CREATE TABLE t1 (
106
 
   `id_param` smallint unsigned NOT NULL default '0',
 
105
CREATE TEMPORARY TABLE t1 (
 
106
   `id_param` int NOT NULL default '0',
107
107
   `nom_option` char(40) NOT NULL default '',
108
 
   `valid` tinyint NOT NULL default '0',
 
108
   `valid` int NOT NULL default '0',
109
109
   KEY `id_param` (`id_param`,`nom_option`)
110
110
 ) ENGINE=MyISAM;
111
111
 
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
 
#
143
119
# Bug #8057
144
120
#
145
121
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
158
134
select * from t1;
159
135
drop table t1;
160
136
 
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
 
 
173
137
#
174
138
# Bug #11868 Update with subquery with ref built with a key from the updated
175
139
#            table crashes server
222
186
delete from t1 order by a limit 1;
223
187
show status like 'handler_read%';
224
188
 
 
189
# PBXT: this select returns a different result to
 
190
# innodb because the 2 updates above change different rows
225
191
select * from t1;
226
192
update t1 set a=a+10,b=1 order by a limit 3;
227
193
update t1 set a=a+11,b=2 order by a limit 3;
233
199
#
234
200
# Bug#14186 select datefield is null not updated
235
201
#
236
 
create table t1 (f1 date not null);
237
 
insert into t1 values('2000-01-01'),('0000-00-00');
 
202
create table t1 (f1 date NULL);
 
203
insert into t1 values('2000-01-01'),(NULL);
238
204
update t1 set f1='2002-02-02' where f1 is null;
239
205
select * from t1;
240
206
drop table t1;
241
207
 
242
 
#
243
 
# Bug#15028 Multitable update returns different numbers of matched rows
244
 
#           depending on table order
245
 
create table t1 (f1 int);
246
 
create table t2 (f2 int);
247
 
insert into t1 values(1),(2);
248
 
insert into t2 values(1),(1);
249
 
--enable_info
250
 
update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1;
251
 
--disable_info
252
 
update t2 set f2=1;
253
 
update t1 set f1=1 where f1=3;
254
 
--enable_info
255
 
update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1;
256
 
--disable_info
257
 
drop table t1,t2;
258
 
 
259
 
 
260
208
# BUG#15935
261
209
create table t1 (a int);
262
210
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
289
237
#
290
238
 
291
239
CREATE TABLE t1 (
292
 
  request_id int unsigned NOT NULL auto_increment,
 
240
  request_id int NOT NULL auto_increment,
293
241
  user_id varchar(12) default NULL,
294
 
  time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
 
242
  time_stamp datetime,
295
243
  ip_address varchar(15) default NULL,
296
244
  PRIMARY KEY (request_id),
297
245
  KEY user_id_2 (user_id,time_stamp)
356
304
 
357
305
# Create the test tables
358
306
create table t1 (id int, a int, key idx(a));
359
 
create table t2 (id int unsigned not null auto_increment primary key, a int);
 
307
create table t2 (id int not null auto_increment primary key, a int);
360
308
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
361
309
insert into t2(a) select a from t2; 
362
310
insert into t2(a) select a from t2;
364
312
update t2 set a=id;
365
313
insert into t1 select * from t2;
366
314
 
 
315
# PBXT: Rows changed are different here between InnoDB and PBXT
 
316
# because PBXT does not update the rows that are not modified!
 
317
# InnoDB seems to do this....
367
318
# Check that the number of matched rows is correct when the temporary
368
319
# table is small enough to not be converted to MyISAM
369
320
select count(*) from t1 join t2 on (t1.a=t2.a);
370
 
--enable_info
371
 
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
372
 
--disable_info
373
321
 
374
322
# Increase table sizes
375
323
insert into t2(a) select a from t2; 
380
328
# Check that the number of matched rows is correct when the temporary
381
329
# table has to be converted to MyISAM
382
330
select count(*) from t1 join t2 on (t1.a=t2.a);
383
 
--enable_info
384
 
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
385
 
--disable_info
386
331
 
387
332
# Check that the number of matched rows is correct when there are duplicate
388
333
# key errors
389
334
update t1 set a=1;
390
335
update t2 set a=1;
391
336
select count(*) from t1 join t2 on (t1.a=t2.a);
392
 
--enable_info
393
 
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
394
 
--disable_info
395
337
 
396
338
drop table t1,t2;
397
339
 
 
340
#
 
341
# Bug #439719: Drizzle crash when running random query generator
 
342
#
 
343
CREATE TABLE t1(col1 enum('a','b') NOT NULL, col2 enum('a','b') DEFAULT NULL, KEY col2 (col2));
 
344
UPDATE t1 SET col1 = "crash" WHERE col2 = now() ;
 
345
 
398
346
connection default;
399
347
disconnect con1;
400
348