~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
(
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
54
place_id int NOT NULL,
55
shows int DEFAULT '0' NOT NULL,
56
ishows int DEFAULT '0' NOT NULL,
57
ushows int DEFAULT '0' NOT NULL,
58
clicks int DEFAULT '0' NOT NULL,
59
iclicks int DEFAULT '0' NOT NULL,
60
uclicks int DEFAULT '0' NOT NULL,
1 by brian
clean slate
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;
1063.9.45 by Stewart Smith
update.test for MyISAM as temp only.
71
CREATE TEMPORARY TABLE t1 (
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
72
lfdnr int NOT NULL default '0',
73
ticket int NOT NULL default '0',
1 by brian
clean slate
74
client varchar(255) NOT NULL default '',
75
replyto varchar(255) NOT NULL default '',
76
subject varchar(100) NOT NULL default '',
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
77
timestamp int NOT NULL default '0',
1 by brian
clean slate
78
tstamp timestamp NOT NULL,
223 by Brian Aker
Cleanup int() work.
79
status int NOT NULL default '0',
1 by brian
clean slate
80
type varchar(15) NOT NULL default '',
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
81
assignment int NOT NULL default '0',
82
fupcount int NOT NULL default '0',
83
parent int NOT NULL default '0',
84
activity int NOT NULL default '0',
85
priority int NOT NULL default '1',
1 by brian
clean slate
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,'','','','','');
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
99
alter table t1 change lfdnr lfdnr int not null auto_increment;
1 by brian
clean slate
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;
1063.9.45 by Stewart Smith
update.test for MyISAM as temp only.
144
CREATE TEMPORARY TABLE t1 (
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
145
`id_param` int NOT NULL default '0',
1 by brian
clean slate
146
`nom_option` char(40) NOT NULL default '',
396 by Brian Aker
Cleanup tiny and small int.
147
`valid` int NOT NULL default '0',
1 by brian
clean slate
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 (id int not null auto_increment primary key, id_str varchar(32));
157
insert into t1 (id_str) values ("test");
158
update t1 set id_str = concat(id_str, id) where id = last_insert_id();
159
select * from t1;
160
id	id_str
161
1	test1
162
drop table t1;
163
create table t1 (a int, b char(255), key(a, b(20)));
164
insert into t1 values (0, '1');
165
update t1 set b = b + 1 where a = 0;
166
select * from t1;
167
a	b
168
0	2
169
drop table t1;
170
create table t1(f1 int, f2 int);
171
create table t2(f3 int, f4 int);
172
create index idx on t2(f3);
173
insert into t1 values(1,0),(2,0);
174
insert into t2 values(1,1),(2,2);
175
UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
176
select * from t1;
177
f1	f2
178
1	1
179
2	2
180
drop table t1,t2;
181
create table t1(f1 int);
182
select DATABASE();
183
DATABASE()
184
test
185
update t1 set f1=1 where count(*)=1;
186
ERROR HY000: Invalid use of group function
187
select DATABASE();
188
DATABASE()
189
test
190
delete from t1 where count(*)=1;
191
ERROR HY000: Invalid use of group function
192
drop table t1;
193
create table t1 ( a int, b int default 0, index (a) );
194
insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0);
195
flush status;
196
select a from t1 order by a limit 1;
197
a
198
0
199
show status like 'handler_read%';
200
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
201
Handler_read_first	#
202
Handler_read_key	#
203
Handler_read_next	#
204
Handler_read_prev	#
205
Handler_read_rnd	#
206
Handler_read_rnd_next	#
1 by brian
clean slate
207
flush status;
208
update t1 set a=9999 order by a limit 1;
209
update t1 set b=9999 order by a limit 1;
210
show status like 'handler_read%';
211
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
212
Handler_read_first	#
213
Handler_read_key	#
214
Handler_read_next	#
215
Handler_read_prev	#
216
Handler_read_rnd	#
217
Handler_read_rnd_next	#
1 by brian
clean slate
218
flush status;
219
delete from t1 order by a limit 1;
220
show status like 'handler_read%';
221
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
222
Handler_read_first	#
223
Handler_read_key	#
224
Handler_read_next	#
225
Handler_read_prev	#
226
Handler_read_rnd	#
227
Handler_read_rnd_next	#
1 by brian
clean slate
228
flush status;
229
delete from t1 order by a desc limit 1;
230
show status like 'handler_read%';
231
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
232
Handler_read_first	#
233
Handler_read_key	#
234
Handler_read_next	#
235
Handler_read_prev	#
236
Handler_read_rnd	#
237
Handler_read_rnd_next	#
1 by brian
clean slate
238
alter table t1 disable keys;
201 by Brian Aker
Convert default engine to Innodb
239
Warnings:
240
Note	1031	Table storage engine for 't1' doesn't have this option
1 by brian
clean slate
241
flush status;
242
delete from t1 order by a limit 1;
243
show status like 'handler_read%';
244
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
245
Handler_read_first	#
246
Handler_read_key	#
247
Handler_read_next	#
248
Handler_read_prev	#
249
Handler_read_rnd	#
250
Handler_read_rnd_next	#
1 by brian
clean slate
251
select * from t1;
252
a	b
253
0	0
254
0	0
255
0	0
256
0	0
257
0	0
258
update t1 set a=a+10,b=1 order by a limit 3;
259
update t1 set a=a+11,b=2 order by a limit 3;
260
update t1 set a=a+12,b=3 order by a limit 3;
261
select * from t1 order by a;
262
a	b
263
11	2
264
21	2
265
22	3
266
22	3
267
23	3
268
drop table t1;
873.1.1 by Jay Pipes
Fixes the Field_date class to not allow any invalid input at
269
create table t1 (f1 date NULL);
270
insert into t1 values('2000-01-01'),(NULL);
1 by brian
clean slate
271
update t1 set f1='2002-02-02' where f1 is null;
272
select * from t1;
273
f1
274
2000-01-01
275
2002-02-02
276
drop table t1;
277
create table t1 (a int);
278
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
279
create table t2 (a int, filler1 char(200), filler2 char(200), key(a));
280
insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B;
281
flush status;
282
update t2 set a=3 where a=2;
283
show status like 'handler_read%';
284
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
285
Handler_read_first	#
286
Handler_read_key	#
287
Handler_read_next	#
288
Handler_read_prev	#
289
Handler_read_rnd	#
290
Handler_read_rnd_next	#
1 by brian
clean slate
291
drop table t1, t2;
292
create table t1(f1 int, `*f2` int);
293
insert into t1 values (1,1);
294
update t1 set `*f2`=1;
295
drop table t1;
296
create table t1(f1 int);
297
update t1 set f2=1 order by f2;
298
ERROR 42S22: Unknown column 'f2' in 'order clause'
299
drop table t1;
300
CREATE TABLE t1 (
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
301
request_id int NOT NULL auto_increment,
1 by brian
clean slate
302
user_id varchar(12) default NULL,
873.1.2 by Jay Pipes
Fixed Field_datetime to never accept any bad datetimes as a string. This broke
303
time_stamp datetime,
1 by brian
clean slate
304
ip_address varchar(15) default NULL,
305
PRIMARY KEY (request_id),
306
KEY user_id_2 (user_id,time_stamp)
307
);
308
INSERT INTO t1 (user_id) VALUES ('user1');
309
INSERT INTO t1(user_id) SELECT user_id FROM t1;
310
INSERT INTO t1(user_id) SELECT user_id FROM t1;
311
INSERT INTO t1(user_id) SELECT user_id FROM t1;
312
INSERT INTO t1(user_id) SELECT user_id FROM t1;
313
INSERT INTO t1(user_id) SELECT user_id FROM t1;
314
INSERT INTO t1(user_id) SELECT user_id FROM t1;
315
INSERT INTO t1(user_id) SELECT user_id FROM t1;
316
INSERT INTO t1(user_id) SELECT user_id FROM t1;
317
flush status;
318
SELECT user_id FROM t1 WHERE request_id=9999999999999;
319
user_id
320
show status like '%Handler_read%';
321
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
322
Handler_read_first	#
323
Handler_read_key	#
324
Handler_read_next	#
325
Handler_read_prev	#
326
Handler_read_rnd	#
327
Handler_read_rnd_next	#
1 by brian
clean slate
328
SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999;
329
user_id
330
show status like '%Handler_read%';
331
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
332
Handler_read_first	#
333
Handler_read_key	#
334
Handler_read_next	#
335
Handler_read_prev	#
336
Handler_read_rnd	#
337
Handler_read_rnd_next	#
1 by brian
clean slate
338
UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
339
show status like '%Handler_read%';
340
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
341
Handler_read_first	#
342
Handler_read_key	#
343
Handler_read_next	#
344
Handler_read_prev	#
345
Handler_read_rnd	#
346
Handler_read_rnd_next	#
1 by brian
clean slate
347
UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
348
show status like '%Handler_read%';
349
Variable_name	Value
1273.16.1 by Brian Aker
More removal of show code.
350
Handler_read_first	#
351
Handler_read_key	#
352
Handler_read_next	#
353
Handler_read_prev	#
354
Handler_read_rnd	#
355
Handler_read_rnd_next	#
1 by brian
clean slate
356
DROP TABLE t1;
357
CREATE TABLE t1 (
223 by Brian Aker
Cleanup int() work.
358
a int,
1 by brian
clean slate
359
quux decimal( 31, 30 ),
360
UNIQUE KEY bar (a),
361
KEY quux (quux)
362
);
363
INSERT INTO
364
t1 ( a, quux )
365
VALUES
366
( 1,    1 ),
367
( 2,  0.1 );
368
INSERT INTO t1( a )
369
SELECT @newA := 1 + a FROM t1 WHERE quux <= 0.1;
370
SELECT * FROM t1;
371
a	quux
372
1	1.000000000000000000000000000000
373
2	0.100000000000000000000000000000
374
3	NULL
375
DROP TABLE t1;
376
set tmp_table_size=1024;
377
create table t1 (id int, a int, key idx(a));
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
378
create table t2 (id int not null auto_increment primary key, a int);
1 by brian
clean slate
379
insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
380
insert into t2(a) select a from t2;
381
insert into t2(a) select a from t2;
382
insert into t2(a) select a from t2;
383
update t2 set a=id;
384
insert into t1 select * from t2;
385
select count(*) from t1 join t2 on (t1.a=t2.a);
386
count(*)
387
64
388
insert into t2(a) select a from t2;
389
update t2 set a=id;
390
truncate t1;
391
insert into t1 select * from t2;
392
select count(*) from t1 join t2 on (t1.a=t2.a);
393
count(*)
394
128
395
update t1 set a=1;
396
update t2 set a=1;
397
select count(*) from t1 join t2 on (t1.a=t2.a);
398
count(*)
399
16384
400
drop table t1,t2;
1124.2.14 by Diego Medina
* On certain UPDATE and DELETE statements, drizzled failed an assert() in
401
CREATE TABLE t1(col1 enum('a','b') NOT NULL, col2 enum('a','b') DEFAULT NULL, KEY col2 (col2));
402
UPDATE t1 SET col1 = "crash" WHERE col2 = now() ;
1 by brian
clean slate
403
End of 5.0 tests