~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/r/update.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2;
 
2
create table t1 (a int auto_increment , primary key (a));
 
3
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
 
4
update t1 set a=a+10 where a > 34;
 
5
update t1 set a=a+100 where a > 0;
 
6
update t1 set a=a+100 where a=1 and a=2;
 
7
update t1 set a=b+100 where a=1 and a=2;
 
8
ERROR 42S22: Unknown column 'b' in 'field list'
 
9
update t1 set a=b+100 where c=1 and a=2;
 
10
ERROR 42S22: Unknown column 'c' in 'where clause'
 
11
update t1 set d=a+100 where a=1;
 
12
ERROR 42S22: Unknown column 'd' in 'field list'
 
13
select * from t1;
 
14
a
 
15
101
 
16
102
 
17
103
 
18
104
 
19
105
 
20
106
 
21
107
 
22
108
 
23
109
 
24
110
 
25
111
 
26
112
 
27
113
 
28
114
 
29
115
 
30
116
 
31
117
 
32
118
 
33
119
 
34
120
 
35
121
 
36
122
 
37
123
 
38
124
 
39
125
 
40
126
 
41
127
 
42
128
 
43
129
 
44
130
 
45
131
 
46
132
 
47
133
 
48
134
 
49
145
 
50
146
 
51
drop table t1;
 
52
CREATE TABLE t1
 
53
(
 
54
place_id int (10) unsigned NOT NULL,
 
55
shows int(10) unsigned DEFAULT '0' NOT NULL,
 
56
ishows int(10) unsigned DEFAULT '0' NOT NULL,
 
57
ushows int(10) unsigned DEFAULT '0' NOT NULL,
 
58
clicks int(10) unsigned DEFAULT '0' NOT NULL,
 
59
iclicks int(10) unsigned DEFAULT '0' NOT NULL,
 
60
uclicks int(10) unsigned DEFAULT '0' NOT NULL,
 
61
ts timestamp,
 
62
PRIMARY KEY (place_id,ts)
 
63
);
 
64
INSERT INTO t1 (place_id,shows,ishows,ushows,clicks,iclicks,uclicks,ts)
 
65
VALUES (1,0,0,0,0,0,0,20000928174434);
 
66
UPDATE t1 SET shows=shows+1,ishows=ishows+1,ushows=ushows+1,clicks=clicks+1,iclicks=iclicks+1,uclicks=uclicks+1 WHERE place_id=1 AND ts>="2000-09-28 00:00:00";
 
67
select place_id,shows from t1;
 
68
place_id        shows
 
69
1       1
 
70
drop table t1;
 
71
CREATE TABLE t1 (
 
72
lfdnr int(10) unsigned NOT NULL default '0',
 
73
ticket int(10) unsigned NOT NULL default '0',
 
74
client varchar(255) NOT NULL default '',
 
75
replyto varchar(255) NOT NULL default '',
 
76
subject varchar(100) NOT NULL default '',
 
77
timestamp int(10) unsigned NOT NULL default '0',
 
78
tstamp timestamp NOT NULL,
 
79
status int(3) NOT NULL default '0',
 
80
type varchar(15) NOT NULL default '',
 
81
assignment int(10) unsigned NOT NULL default '0',
 
82
fupcount int(4) unsigned NOT NULL default '0',
 
83
parent int(10) unsigned NOT NULL default '0',
 
84
activity int(10) unsigned NOT NULL default '0',
 
85
priority tinyint(1) unsigned NOT NULL default '1',
 
86
cc varchar(255) NOT NULL default '',
 
87
bcc varchar(255) NOT NULL default '',
 
88
body text NOT NULL,
 
89
comment text,
 
90
header text,
 
91
PRIMARY KEY  (lfdnr),
 
92
KEY k1 (timestamp),
 
93
KEY k2 (type),
 
94
KEY k3 (parent),
 
95
KEY k4 (assignment),
 
96
KEY ticket (ticket)
 
97
) ENGINE=MyISAM;
 
98
INSERT INTO t1 VALUES (773,773,'','','',980257344,20010318180652,0,'Open',10,0,0,0,1,'','','','','');
 
99
alter table t1 change lfdnr lfdnr int(10) unsigned not null auto_increment;
 
100
update t1 set status=1 where type='Open';
 
101
select status from t1;
 
102
status
 
103
1
 
104
drop table t1;
 
105
create table t1 (a int not null, b int not null, key (a));
 
106
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
 
107
SET @tmp=0;
 
108
update t1 set b=(@tmp:=@tmp+1) order by a;
 
109
update t1 set b=99 where a=1 order by b asc limit 1;
 
110
select * from t1 order by a,b;
 
111
a       b
 
112
1       2
 
113
1       3
 
114
1       99
 
115
2       4
 
116
2       5
 
117
2       6
 
118
3       7
 
119
3       8
 
120
3       9
 
121
3       10
 
122
3       11
 
123
3       12
 
124
update t1 set b=100 where a=1 order by b desc limit 2;
 
125
update t1 set a=a+10+b where a=1 order by b;
 
126
select * from t1 order by a,b;
 
127
a       b
 
128
2       4
 
129
2       5
 
130
2       6
 
131
3       7
 
132
3       8
 
133
3       9
 
134
3       10
 
135
3       11
 
136
3       12
 
137
13      2
 
138
111     100
 
139
111     100
 
140
create table t2 (a int not null, b int not null);
 
141
insert into t2 values (1,1),(1,2),(1,3);
 
142
update t1 set b=(select distinct 1 from (select * from t2) a);
 
143
drop table t1,t2;
 
144
CREATE TABLE t1 (
 
145
`id_param` smallint(3) unsigned NOT NULL default '0',
 
146
`nom_option` char(40) NOT NULL default '',
 
147
`valid` tinyint(1) NOT NULL default '0',
 
148
KEY `id_param` (`id_param`,`nom_option`)
 
149
) ENGINE=MyISAM;
 
150
INSERT INTO t1 (id_param,nom_option,valid) VALUES (185,'600x1200',1);
 
151
UPDATE t1 SET nom_option='test' WHERE id_param=185 AND nom_option='600x1200' AND valid=1 LIMIT 1;
 
152
select * from t1;
 
153
id_param        nom_option      valid
 
154
185     test    1
 
155
drop table t1;
 
156
create table t1 (F1 VARCHAR(30), F2 VARCHAR(30), F3 VARCHAR(30), cnt int, groupid int, KEY groupid_index (groupid));
 
157
insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6),
 
158
('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2),
 
159
('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4),
 
160
('2','2','0',1,7);
 
161
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);
 
162
select * from t1;
 
163
F1      F2      F3      cnt     groupid
 
164
0       0       0       1       6
 
165
0       1       2       1       5
 
166
0       2       0       1       3
 
167
1       0       1       1       2
 
168
1       2       1       1       1
 
169
2       0       1       2       4
 
170
2       2       0       1       7
 
171
drop table t1;
 
172
CREATE TABLE t1 ( 
 
173
`colA` int(10) unsigned NOT NULL auto_increment,
 
174
`colB` int(11) NOT NULL default '0',
 
175
PRIMARY KEY  (`colA`)
 
176
);
 
177
INSERT INTO t1 VALUES (4433,5424);
 
178
CREATE TABLE t2 (
 
179
`colC` int(10) unsigned NOT NULL default '0',
 
180
`colA` int(10) unsigned NOT NULL default '0',
 
181
`colD` int(10) unsigned NOT NULL default '0',
 
182
`colE` int(10) unsigned NOT NULL default '0',
 
183
`colF` int(10) unsigned NOT NULL default '0',
 
184
PRIMARY KEY  (`colC`,`colA`,`colD`,`colE`)
 
185
);
 
186
INSERT INTO t2 VALUES (3,4433,10005,495,500);
 
187
INSERT INTO t2 VALUES (3,4433,10005,496,500);
 
188
INSERT INTO t2 VALUES (3,4433,10009,494,500);
 
189
INSERT INTO t2 VALUES (3,4433,10011,494,500);
 
190
INSERT INTO t2 VALUES (3,4433,10005,497,500);
 
191
INSERT INTO t2 VALUES (3,4433,10013,489,500);
 
192
INSERT INTO t2 VALUES (3,4433,10005,494,500);
 
193
INSERT INTO t2 VALUES (3,4433,10005,493,500);
 
194
INSERT INTO t2 VALUES (3,4433,10005,492,500);
 
195
UPDATE IGNORE t2,t1 set t2.colE = t2.colE + 1,colF=0 WHERE t1.colA = t2.colA AND (t1.colB & 4096) > 0 AND (colE + 1) < colF;
 
196
SELECT * FROM t2;
 
197
colC    colA    colD    colE    colF
 
198
3       4433    10005   495     500
 
199
3       4433    10005   496     500
 
200
3       4433    10009   495     0
 
201
3       4433    10011   495     0
 
202
3       4433    10005   498     0
 
203
3       4433    10013   490     0
 
204
3       4433    10005   494     500
 
205
3       4433    10005   493     500
 
206
3       4433    10005   492     500
 
207
DROP TABLE t1;
 
208
DROP TABLE t2;
 
209
create table t1 (c1 int, c2 char(6), c3 int);
 
210
create table t2 (c1 int, c2 char(6));
 
211
insert into t1 values (1, "t1c2-1", 10), (2, "t1c2-2", 20);
 
212
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1";
 
213
update t1 left join t2 on t1.c1 = t2.c1 set t2.c2 = "t2c2-1" where t1.c3 = 10;
 
214
drop table t1, t2;
 
215
create table t1 (id int not null auto_increment primary key, id_str varchar(32));
 
216
insert into t1 (id_str) values ("test");
 
217
update t1 set id_str = concat(id_str, id) where id = last_insert_id();
 
218
select * from t1;
 
219
id      id_str
 
220
1       test1
 
221
drop table t1;
 
222
create table t1 (a int, b char(255), key(a, b(20)));
 
223
insert into t1 values (0, '1');
 
224
update t1 set b = b + 1 where a = 0;
 
225
select * from t1;
 
226
a       b
 
227
0       2
 
228
drop table t1;
 
229
create table t1 (a int, b varchar(10), key b(b(5))) engine=myisam;
 
230
create table t2 (a int, b varchar(10)) engine=myisam;
 
231
insert into t1 values ( 1, 'abcd1e');
 
232
insert into t1 values ( 2, 'abcd2e');
 
233
insert into t2 values ( 1, 'abcd1e');
 
234
insert into t2 values ( 2, 'abcd2e');
 
235
analyze table t1,t2;
 
236
Table   Op      Msg_type        Msg_text
 
237
test.t1 analyze status  OK
 
238
test.t2 analyze status  OK
 
239
update t1, t2 set t1.a = t2.a where t2.b = t1.b;
 
240
show warnings;
 
241
Level   Code    Message
 
242
drop table t1, t2;
 
243
create table t1(f1 int, f2 int);
 
244
create table t2(f3 int, f4 int);
 
245
create index idx on t2(f3);
 
246
insert into t1 values(1,0),(2,0);
 
247
insert into t2 values(1,1),(2,2);
 
248
UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
 
249
select * from t1;
 
250
f1      f2
 
251
1       1
 
252
2       2
 
253
drop table t1,t2;
 
254
create table t1(f1 int);
 
255
select DATABASE();
 
256
DATABASE()
 
257
test
 
258
update t1 set f1=1 where count(*)=1;
 
259
ERROR HY000: Invalid use of group function
 
260
select DATABASE();
 
261
DATABASE()
 
262
test
 
263
delete from t1 where count(*)=1;
 
264
ERROR HY000: Invalid use of group function
 
265
drop table t1;
 
266
create table t1 ( a int, b int default 0, index (a) );
 
267
insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0);
 
268
flush status;
 
269
select a from t1 order by a limit 1;
 
270
a
 
271
0
 
272
show status like 'handler_read%';
 
273
Variable_name   Value
 
274
Handler_read_first      1
 
275
Handler_read_key        0
 
276
Handler_read_next       0
 
277
Handler_read_prev       0
 
278
Handler_read_rnd        0
 
279
Handler_read_rnd_next   0
 
280
flush status;
 
281
update t1 set a=9999 order by a limit 1;
 
282
update t1 set b=9999 order by a limit 1;
 
283
show status like 'handler_read%';
 
284
Variable_name   Value
 
285
Handler_read_first      1
 
286
Handler_read_key        0
 
287
Handler_read_next       0
 
288
Handler_read_prev       0
 
289
Handler_read_rnd        2
 
290
Handler_read_rnd_next   9
 
291
flush status;
 
292
delete from t1 order by a limit 1;
 
293
show status like 'handler_read%';
 
294
Variable_name   Value
 
295
Handler_read_first      1
 
296
Handler_read_key        0
 
297
Handler_read_next       0
 
298
Handler_read_prev       0
 
299
Handler_read_rnd        0
 
300
Handler_read_rnd_next   0
 
301
flush status;
 
302
delete from t1 order by a desc limit 1;
 
303
show status like 'handler_read%';
 
304
Variable_name   Value
 
305
Handler_read_first      0
 
306
Handler_read_key        0
 
307
Handler_read_next       0
 
308
Handler_read_prev       0
 
309
Handler_read_rnd        1
 
310
Handler_read_rnd_next   9
 
311
alter table t1 disable keys;
 
312
flush status;
 
313
delete from t1 order by a limit 1;
 
314
show status like 'handler_read%';
 
315
Variable_name   Value
 
316
Handler_read_first      0
 
317
Handler_read_key        0
 
318
Handler_read_next       0
 
319
Handler_read_prev       0
 
320
Handler_read_rnd        1
 
321
Handler_read_rnd_next   9
 
322
select * from t1;
 
323
a       b
 
324
0       0
 
325
0       0
 
326
0       0
 
327
0       0
 
328
0       0
 
329
update t1 set a=a+10,b=1 order by a limit 3;
 
330
update t1 set a=a+11,b=2 order by a limit 3;
 
331
update t1 set a=a+12,b=3 order by a limit 3;
 
332
select * from t1 order by a;
 
333
a       b
 
334
11      2
 
335
21      2
 
336
22      3
 
337
22      3
 
338
23      3
 
339
drop table t1;
 
340
create table t1 (f1 date not null);
 
341
insert into t1 values('2000-01-01'),('0000-00-00');
 
342
update t1 set f1='2002-02-02' where f1 is null;
 
343
select * from t1;
 
344
f1
 
345
2000-01-01
 
346
2002-02-02
 
347
drop table t1;
 
348
create table t1 (f1 int);
 
349
create table t2 (f2 int);
 
350
insert into t1 values(1),(2);
 
351
insert into t2 values(1),(1);
 
352
update t1,t2 set f1=3,f2=3 where f1=f2 and f1=1;
 
353
affected rows: 3
 
354
info: Rows matched: 3  Changed: 3  Warnings: 0
 
355
update t2 set f2=1;
 
356
update t1 set f1=1 where f1=3;
 
357
update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1;
 
358
affected rows: 3
 
359
info: Rows matched: 3  Changed: 3  Warnings: 0
 
360
drop table t1,t2;
 
361
create table t1 (a int);
 
362
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
363
create table t2 (a int, filler1 char(200), filler2 char(200), key(a));
 
364
insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B;
 
365
flush status;
 
366
update t2 set a=3 where a=2;
 
367
show status like 'handler_read%';
 
368
Variable_name   Value
 
369
Handler_read_first      0
 
370
Handler_read_key        1
 
371
Handler_read_next       1
 
372
Handler_read_prev       0
 
373
Handler_read_rnd        1
 
374
Handler_read_rnd_next   0
 
375
drop table t1, t2;
 
376
create table t1(f1 int, `*f2` int);
 
377
insert into t1 values (1,1);
 
378
update t1 set `*f2`=1;
 
379
drop table t1;
 
380
create table t1(f1 int);
 
381
update t1 set f2=1 order by f2;
 
382
ERROR 42S22: Unknown column 'f2' in 'order clause'
 
383
drop table t1;
 
384
CREATE TABLE t1 (
 
385
request_id int unsigned NOT NULL auto_increment,
 
386
user_id varchar(12) default NULL,
 
387
time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
 
388
ip_address varchar(15) default NULL,
 
389
PRIMARY KEY (request_id),
 
390
KEY user_id_2 (user_id,time_stamp)
 
391
);
 
392
INSERT INTO t1 (user_id) VALUES ('user1');
 
393
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
394
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
395
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
396
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
397
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
398
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
399
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
400
INSERT INTO t1(user_id) SELECT user_id FROM t1;
 
401
flush status;
 
402
SELECT user_id FROM t1 WHERE request_id=9999999999999;
 
403
user_id
 
404
show status like '%Handler_read%';
 
405
Variable_name   Value
 
406
Handler_read_first      0
 
407
Handler_read_key        1
 
408
Handler_read_next       0
 
409
Handler_read_prev       0
 
410
Handler_read_rnd        0
 
411
Handler_read_rnd_next   0
 
412
SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999;
 
413
user_id
 
414
show status like '%Handler_read%';
 
415
Variable_name   Value
 
416
Handler_read_first      0
 
417
Handler_read_key        2
 
418
Handler_read_next       0
 
419
Handler_read_prev       0
 
420
Handler_read_rnd        0
 
421
Handler_read_rnd_next   0
 
422
UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
 
423
show status like '%Handler_read%';
 
424
Variable_name   Value
 
425
Handler_read_first      0
 
426
Handler_read_key        3
 
427
Handler_read_next       0
 
428
Handler_read_prev       0
 
429
Handler_read_rnd        0
 
430
Handler_read_rnd_next   0
 
431
UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
 
432
show status like '%Handler_read%';
 
433
Variable_name   Value
 
434
Handler_read_first      0
 
435
Handler_read_key        3
 
436
Handler_read_next       0
 
437
Handler_read_prev       0
 
438
Handler_read_rnd        0
 
439
Handler_read_rnd_next   0
 
440
DROP TABLE t1;
 
441
CREATE TABLE t1 (
 
442
a INT(11),
 
443
quux decimal( 31, 30 ),
 
444
UNIQUE KEY bar (a),
 
445
KEY quux (quux)
 
446
);
 
447
INSERT INTO
 
448
t1 ( a, quux )
 
449
VALUES
 
450
( 1,    1 ),
 
451
( 2,  0.1 );
 
452
INSERT INTO t1( a )
 
453
SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1;
 
454
SELECT * FROM t1;
 
455
a       quux
 
456
1       1.000000000000000000000000000000
 
457
2       0.100000000000000000000000000000
 
458
3       NULL
 
459
DROP TABLE t1;
 
460
set tmp_table_size=1024;
 
461
create table t1 (id int, a int, key idx(a));
 
462
create table t2 (id int unsigned not null auto_increment primary key, a int);
 
463
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
 
464
insert into t2(a) select a from t2;
 
465
insert into t2(a) select a from t2;
 
466
insert into t2(a) select a from t2;
 
467
update t2 set a=id;
 
468
insert into t1 select * from t2;
 
469
select count(*) from t1 join t2 on (t1.a=t2.a);
 
470
count(*)
 
471
64
 
472
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
473
affected rows: 0
 
474
info: Rows matched: 64  Changed: 0  Warnings: 0
 
475
insert into t2(a) select a from t2;
 
476
update t2 set a=id;
 
477
truncate t1;
 
478
insert into t1 select * from t2;
 
479
select count(*) from t1 join t2 on (t1.a=t2.a);
 
480
count(*)
 
481
128
 
482
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
483
affected rows: 0
 
484
info: Rows matched: 128  Changed: 0  Warnings: 0
 
485
update t1 set a=1;
 
486
update t2 set a=1;
 
487
select count(*) from t1 join t2 on (t1.a=t2.a);
 
488
count(*)
 
489
16384
 
490
update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
 
491
affected rows: 127
 
492
info: Rows matched: 128  Changed: 127  Warnings: 0
 
493
drop table t1,t2;
 
494
DROP TABLE IF EXISTS t1;
 
495
DROP FUNCTION IF EXISTS f1;
 
496
CREATE FUNCTION f1() RETURNS INT RETURN f1();
 
497
CREATE TABLE t1 (i INT);
 
498
INSERT INTO t1 VALUES (1);
 
499
UPDATE t1 SET i = 3 WHERE f1();
 
500
ERROR HY000: Recursive stored functions and triggers are not allowed.
 
501
UPDATE t1 SET i = f1();
 
502
ERROR HY000: Recursive stored functions and triggers are not allowed.
 
503
DROP TABLE t1;
 
504
DROP FUNCTION f1;
 
505
End of 5.0 tests
 
506
#
 
507
# Bug #47919 assert in open_table during ALTER temporary table
 
508
#
 
509
CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT, PRIMARY KEY (f1));
 
510
CREATE TEMPORARY TABLE t2 LIKE t1;
 
511
INSERT INTO t1 VALUES (1);
 
512
INSERT INTO t2 VALUES (1);
 
513
ALTER TABLE t2 COMMENT = 'ABC';
 
514
UPDATE t2, t1 SET t2.f1 = 2, t1.f1 = 9;
 
515
ALTER TABLE t2 COMMENT = 'DEF';
 
516
DROP TABLE t1, t2;