~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2,t3;
2
SET SQL_WARNINGS=1;
3
CREATE TABLE t1 (
4
ID CHAR(32) NOT NULL,
5
name CHAR(32) NOT NULL,
6
value CHAR(255),
7
INDEX indexIDname (ID(8),name(8))
8
) ;
9
INSERT INTO t1 VALUES
10
('keyword','indexdir','/export/home/local/www/database/indexes/keyword');
11
INSERT INTO t1 VALUES ('keyword','urlprefix','text/ /text');
12
INSERT INTO t1 VALUES ('keyword','urlmap','/text/ /');
13
INSERT INTO t1 VALUES ('keyword','attr','personal employee company');
14
INSERT INTO t1 VALUES
15
('emailgids','indexdir','/export/home/local/www/database/indexes/emailgids');
16
INSERT INTO t1 VALUES ('emailgids','urlprefix','text/ /text');
17
INSERT INTO t1 VALUES ('emailgids','urlmap','/text/ /');
18
INSERT INTO t1 VALUES ('emailgids','attr','personal employee company');
19
SELECT value FROM t1 WHERE ID='emailgids' AND name='attr';
20
value
21
personal employee company
22
drop table t1;
23
CREATE TABLE t1 (
510 by Brian Aker
Test updates.
24
price int DEFAULT '0' NOT NULL,
25
area varchar(160) DEFAULT '' NOT NULL,
26
type varchar(160) DEFAULT '' NOT NULL,
1 by brian
clean slate
27
transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
28
shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
29
schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
30
petsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
31
KEY price (price,area,type,transityes,shopsyes,schoolsyes,petsyes)
32
);
33
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
34
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
510 by Brian Aker
Test updates.
35
INSERT INTO t1 (price, area, type) VALUES (900,'Vancouver','Shared/Roomate');
1 by brian
clean slate
36
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
37
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
38
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
39
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
40
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
41
SELECT * FROM t1 WHERE area='Vancouver' and transityes='y' and schoolsyes='y' and ( ((type='1 Bedroom' or type='Studio/Bach') and (price<=500)) or ((type='2 Bedroom') and (price<=550)) or ((type='Shared/Roomate') and (price<=300)) or ((type='Room and Board') and (price<=500)) ) and price <= 400;
42
price	area	type	transityes	shopsyes	schoolsyes	petsyes
43
drop table t1;
510 by Brian Aker
Test updates.
44
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  PRIMARY KEY (program));
1 by brian
clean slate
45
ALTER TABLE t1 modify program enum('signup','unique','sliding');
46
drop table t1;
47
CREATE TABLE t1 (
48
name varchar(50) DEFAULT '' NOT NULL,
49
author varchar(50) DEFAULT '' NOT NULL,
50
category decimal(10,0) DEFAULT '0' NOT NULL,
51
email varchar(50),
52
password varchar(50),
53
proxy varchar(50),
54
bitmap varchar(20),
55
msg varchar(255),
56
urlscol varchar(127),
57
urlhttp varchar(127),
58
timeout decimal(10,0),
59
nbcnx decimal(10,0),
60
creation decimal(10,0),
61
livinguntil decimal(10,0),
62
lang decimal(10,0),
63
type decimal(10,0),
64
subcat decimal(10,0),
65
subtype decimal(10,0),
66
reg char(1),
67
scs varchar(255),
68
capacity decimal(10,0),
69
userISP varchar(50),
70
CCident varchar(50) DEFAULT '' NOT NULL,
71
PRIMARY KEY (name,author,category)
72
);
73
INSERT INTO t1 VALUES
74
('patnom','patauteur',0,'p.favre@cryo-networks.fr',NULL,NULL,'#p2sndnq6ae5g1u6t','essai salut','scol://195.242.78.119:patauteur.patnom',NULL,NULL,NULL,950036174,-882087474,NULL,3,0,3,'1','Pub/patnom/futur_divers.scs',NULL,'pat','CC1');
75
INSERT INTO t1 VALUES
76
('LeNomDeMonSite','Marc',0,'m.barilley@cryo-networks.fr',NULL,NULL,NULL,NULL,'scol://195.242.78.119:Marc.LeNomDeMonSite',NULL,NULL,NULL,950560434,-881563214,NULL,3,0,3,'1','Pub/LeNomDeMonSite/domus_hibere.scs',NULL,'Marq','CC1');
77
select * from t1 where name='patnom' and author='patauteur' and category=0;
78
name	author	category	email	password	proxy	bitmap	msg	urlscol	urlhttp	timeout	nbcnx	creation	livinguntil	lang	type	subcat	subtype	reg	scs	capacity	userISP	CCident
79
patnom	patauteur	0	p.favre@cryo-networks.fr	NULL	NULL	#p2sndnq6ae5g1u6t	essai salut	scol://195.242.78.119:patauteur.patnom	NULL	NULL	NULL	950036174	-882087474	NULL	3	0	3	1	Pub/patnom/futur_divers.scs	NULL	pat	CC1
80
drop table t1;
81
create table t1
82
(
83
name_id int not null auto_increment,
84
name blob,
85
INDEX name_idx (name(5)),
86
primary key (name_id)
87
);
88
INSERT t1 VALUES(NULL,'/');
89
INSERT t1 VALUES(NULL,'[T,U]_axpby');
90
SELECT * FROM t1 WHERE name='[T,U]_axpy';
91
name_id	name
92
SELECT * FROM t1 WHERE name='[T,U]_axpby';
93
name_id	name
94
2	[T,U]_axpby
95
create table t2
96
(
97
name_id int not null auto_increment,
98
name char(255) binary,
99
INDEX name_idx (name(5)),
100
primary key (name_id)
101
);
102
INSERT t2 select * from t1;
103
SELECT * FROM t2 WHERE name='[T,U]_axpy';
104
name_id	name
105
SELECT * FROM t2 WHERE name='[T,U]_axpby';
106
name_id	name
107
2	[T,U]_axpby
108
CREATE TABLE t3 SELECT * FROM t2 WHERE name='[T,U]_axpby';
109
SELECT * FROM t2 WHERE name='[T,U]_axpby';
110
name_id	name
111
2	[T,U]_axpby
112
drop table t1,t2,t3;
113
create table t1
114
(
115
SEQNO                         numeric(12 ) not null,
116
MOTYPEID                 numeric(12 ) not null,
117
MOINSTANCEID     numeric(12 ) not null,
118
ATTRID                       numeric(12 ) not null,
119
VALUE                         varchar(120) not null,
120
primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
121
);
122
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
123
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
124
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
125
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY'
126
drop table t1;
127
CREATE TABLE t1 (
128
a tinytext NOT NULL,
510 by Brian Aker
Test updates.
129
b int NOT NULL default '0',
1 by brian
clean slate
130
PRIMARY KEY (a(32),b)
131
) ENGINE=MyISAM;
132
INSERT INTO t1 VALUES ('a',1),('a',2);
133
SELECT * FROM t1 WHERE a='a' AND b=2;
134
a	b
135
a	2
136
SELECT * FROM t1 WHERE a='a' AND b in (2);
137
a	b
138
a	2
139
SELECT * FROM t1 WHERE a='a' AND b in (1,2);
140
a	b
141
a	1
142
a	2
143
drop table t1;
144
create table t1 (a int not null unique, b int unique, c int, d int not null primary key, key(c), e int not null unique);
145
show keys from t1;
146
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_Comment
147
t1	0	PRIMARY	1	d	A	0	NULL	NULL		BTREE		
148
t1	0	a	1	a	A	0	NULL	NULL		BTREE		
149
t1	0	e	1	e	A	0	NULL	NULL		BTREE		
510 by Brian Aker
Test updates.
150
t1	0	b	1	b	A	0	NULL	NULL	YES	BTREE		
151
t1	1	c	1	c	A	0	NULL	NULL	YES	BTREE		
1 by brian
clean slate
152
drop table t1;
510 by Brian Aker
Test updates.
153
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
1 by brian
clean slate
154
INSERT INTO t1 (c) VALUES (NULL),(NULL);
510 by Brian Aker
Test updates.
155
ERROR 23000: Column 'c' cannot be null
1 by brian
clean slate
156
SELECT * FROM t1;
157
c	i
158
INSERT INTO t1 (c) VALUES ('a'),('a');
159
SELECT * FROM t1;
160
c	i
161
a	1
162
a	2
163
DROP TABLE IF EXISTS t1;
510 by Brian Aker
Test updates.
164
CREATE TABLE t1 (c CHAR(10) NULL, i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
1 by brian
clean slate
165
INSERT INTO t1 (c) VALUES (NULL),(NULL);
166
SELECT * FROM t1;
167
c	i
168
NULL	1
169
NULL	2
170
INSERT INTO t1 (c) VALUES ('a'),('a');
171
SELECT * FROM t1;
172
c	i
173
NULL	1
174
NULL	2
510 by Brian Aker
Test updates.
175
a	3
176
a	4
177
drop table t1;
178
CREATE TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
1 by brian
clean slate
179
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
180
explain select 1 from t1 where id =2;
181
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
182
1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	1	Using index
183
explain select 1 from t1 where id =2 or id=3;
184
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
185
1	SIMPLE	t1	index	PRIMARY	PRIMARY	4	NULL	7	Using where; Using index
186
explain select name from t1 where id =2;
187
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
188
1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	1	
189
ALTER TABLE t1 DROP PRIMARY KEY, ADD INDEX (id);
190
explain select 1 from t1 where id =2;
191
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
192
1	SIMPLE	t1	ref	id	id	4	const	1	Using index
193
drop table t1;
510 by Brian Aker
Test updates.
194
CREATE TABLE t1 (numeropost int NOT NULL default '0', numreponse int NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
1 by brian
clean slate
195
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
196
SELECT numeropost FROM t1 WHERE numreponse='1';
197
numeropost
198
1
199
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
200
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
201
1	SIMPLE	t1	const	numreponse	numreponse	4	const	1	Using index
202
FLUSH TABLES;
203
SELECT numeropost FROM t1 WHERE numreponse='1';
204
numeropost
205
1
206
drop table t1;
510 by Brian Aker
Test updates.
207
create table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
1 by brian
clean slate
208
show create table t1;
209
Table	Create Table
210
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
211
  `c` varchar(30) DEFAULT NULL,
510 by Brian Aker
Test updates.
212
  `t` text,
213
  UNIQUE KEY `c` (`c`()),
214
  UNIQUE KEY `t` (`t`())
215
) ENGINE=MyISAM
1 by brian
clean slate
216
insert t1 values ('cccc', 'tttt'),
217
(0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
218
(0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1);
219
insert t1 (c) values ('cc22');
220
ERROR 23000: Duplicate entry 'cc' for key 'c'
221
insert t1 (t) values ('ttt22');
222
ERROR 23000: Duplicate entry 'ttt' for key 't'
223
insert t1 (c) values (0xD0B1212322D0B1D0B1D0B1D0B1D0B1);
224
ERROR 23000: Duplicate entry 'б!' for key 'c'
225
insert t1 (t) values (0xD0B1D0B1212322D0B1D0B1D0B1D0B1);
226
ERROR 23000: Duplicate entry 'бб!' for key 't'
227
select c from t1 where c='cccc';
228
c
229
cccc
230
select t from t1 where t='tttt';
231
t
232
tttt
233
select c from t1 where c=0xD0B1212223D0B1D0B1D0B1D0B1D0B1;
234
c
510 by Brian Aker
Test updates.
235
б!"#ббббб
1 by brian
clean slate
236
select t from t1 where t=0xD0B1D0B1212223D0B1D0B1D0B1D0B1;
237
t
510 by Brian Aker
Test updates.
238
бб!"#бббб
1 by brian
clean slate
239
drop table t1;
240
DROP TABLE IF EXISTS t1;
241
Warnings:
242
Note	1051	Unknown table 't1'
243
CREATE TABLE t1 (
244
c1 int,
245
c2 varbinary(240),
246
UNIQUE KEY (c1),
247
KEY (c2)
248
) ENGINE=MyISAM;
249
INSERT INTO t1 VALUES (1,'\Z\Z\Z\Z');
250
INSERT INTO t1 VALUES (2,'\Z\Z\Z\Z\Z\Z');
251
INSERT INTO t1 VALUES (3,'\Z\Z\Z\Z');
252
select c1 from t1 where c2='\Z\Z\Z\Z';
253
c1
254
1
255
3
256
DELETE FROM t1 WHERE (c1 = 1);
257
check table t1;
258
Table	Op	Msg_type	Msg_text
259
test.t1	check	status	OK
260
select c1 from t1 where c2='\Z\Z\Z\Z';
261
c1
262
3
263
DELETE FROM t1 WHERE (c1 = 3);
264
check table t1;
265
Table	Op	Msg_type	Msg_text
266
test.t1	check	status	OK
267
select c1 from t1 where c2='\Z\Z\Z\Z';
268
c1
269
truncate table t1;
270
insert into t1 values(1,"aaaa"),(2,"aaab"),(3,"aaac"),(4,"aaccc");
271
delete from t1 where c1=3;
272
delete from t1 where c1=1;
273
delete from t1 where c1=4;
274
check table t1;
275
Table	Op	Msg_type	Msg_text
276
test.t1	check	status	OK
277
drop table t1;
278
create table t1 (c char(10), index (c(0)));
279
ERROR HY000: Key part 'c' length cannot be 0
280
create table t1 (c char(10), index (c,c));
281
ERROR 42S21: Duplicate column name 'c'
282
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1));
283
ERROR 42S21: Duplicate column name 'c1'
284
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2));
285
ERROR 42S21: Duplicate column name 'c1'
286
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1));
287
ERROR 42S21: Duplicate column name 'c1'
288
create table t1 (c1 char(10), c2 char(10));
289
alter table t1 add key (c1,c1);
290
ERROR 42S21: Duplicate column name 'c1'
291
alter table t1 add key (c2,c1,c1);
292
ERROR 42S21: Duplicate column name 'c1'
293
alter table t1 add key (c1,c2,c1);
294
ERROR 42S21: Duplicate column name 'c1'
295
alter table t1 add key (c1,c1,c2);
296
ERROR 42S21: Duplicate column name 'c1'
297
drop table t1;
298
create table t1 (
299
i1 INT NOT NULL,
300
i2 INT NOT NULL,
301
UNIQUE i1idx (i1),
302
UNIQUE i2idx (i2));
303
desc t1;
304
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
305
i1	int	NO	PRI	NULL	
306
i2	int	NO	UNI	NULL	
1 by brian
clean slate
307
show create table t1;
308
Table	Create Table
309
t1	CREATE TABLE `t1` (
510 by Brian Aker
Test updates.
310
  `i1` int NOT NULL,
311
  `i2` int NOT NULL,
1 by brian
clean slate
312
  UNIQUE KEY `i1idx` (`i1`),
313
  UNIQUE KEY `i2idx` (`i2`)
510 by Brian Aker
Test updates.
314
) ENGINE=InnoDB
1 by brian
clean slate
315
drop table t1;
316
create table t1 (
317
c1 int,
318
c2 varchar(20) not null,
319
primary key (c1),
320
key (c2(10))
321
) engine=myisam;
322
insert into t1 values (1,'');
323
insert into t1 values (2,' \t\tTest String');
324
insert into t1 values (3,' \n\tTest String');
325
update t1 set c2 = 'New Test String' where c1 = 1;
326
select * from t1;
327
c1	c2
328
1	New Test String
329
2	 		Test String
330
3	 
331
	Test String
332
drop table t1;
333
create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
334
show create table t1;
335
Table	Create Table
336
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
337
  `a` varchar(10) DEFAULT NULL,
338
  `b` varchar(10) DEFAULT NULL,
1 by brian
clean slate
339
  KEY `a` (`a`,`b`)
510 by Brian Aker
Test updates.
340
) ENGINE=InnoDB
1 by brian
clean slate
341
alter table t1 modify b varchar(20);
342
show create table t1;
343
Table	Create Table
344
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
345
  `a` varchar(10) DEFAULT NULL,
346
  `b` varchar(20) DEFAULT NULL,
1 by brian
clean slate
347
  KEY `a` (`a`,`b`)
510 by Brian Aker
Test updates.
348
) ENGINE=InnoDB
1 by brian
clean slate
349
alter table t1 modify a varchar(20);
350
show create table t1;
351
Table	Create Table
352
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
353
  `a` varchar(20) DEFAULT NULL,
354
  `b` varchar(20) DEFAULT NULL,
1 by brian
clean slate
355
  KEY `a` (`a`,`b`)
510 by Brian Aker
Test updates.
356
) ENGINE=InnoDB
1 by brian
clean slate
357
drop table t1;
358
create table t1 (a int not null primary key, b varchar(20) not null unique);
359
desc t1;
360
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
361
a	int	NO	PRI	NULL	
1 by brian
clean slate
362
b	varchar(20)	NO	UNI	NULL	
363
drop table t1;
364
create table t1 (a int not null primary key, b int not null unique);
365
desc t1;
366
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
367
a	int	NO	PRI	NULL	
368
b	int	NO	UNI	NULL	
1 by brian
clean slate
369
drop table t1;
370
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
371
desc t1;
372
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
373
a	int	NO	PRI	NULL	
1 by brian
clean slate
374
b	varchar(20)	NO	UNI	NULL	
375
drop table t1;
376
create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10)));
377
desc t1;
378
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
379
a	int	NO	PRI	NULL	
1 by brian
clean slate
380
b	varchar(20)	NO	MUL	NULL	
381
c	varchar(20)	NO		NULL	
382
drop table t1;
383
create table t1 (
384
c1 int,
385
c2 char(12),
386
c3 varchar(123),
387
c4 timestamp,
388
index (c1),
389
index i1 (c1),
390
index i2 (c2),
391
index i3 (c3),
392
unique i4 (c4),
393
index i5 (c1, c2, c3, c4),
394
primary key (c2, c3),
395
index (c2, c4));
396
show create table t1;
397
Table	Create Table
398
t1	CREATE TABLE `t1` (
873.2.35 by Monty Taylor
Update tests based on how Toru's latest patch changes create table statements.
399
  `c1` int DEFAULT NULL,
896.3.6 by Stewart Smith
Read Fields out of proto instead of FRM.
400
  `c2` varchar(12) NOT NULL,
401
  `c3` varchar(123) NOT NULL,
907.1.5 by Jay Pipes
Fixed remaining test cases. TIMESTAMP with no default is NULL, DEFAULT NULL, not auto-set
402
  `c4` timestamp NULL DEFAULT NULL,
1 by brian
clean slate
403
  PRIMARY KEY (`c2`,`c3`),
404
  UNIQUE KEY `i4` (`c4`),
405
  KEY `c1` (`c1`),
406
  KEY `i1` (`c1`),
407
  KEY `i2` (`c2`),
408
  KEY `i3` (`c3`),
409
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
410
  KEY `c2` (`c2`,`c4`)
510 by Brian Aker
Test updates.
411
) ENGINE=InnoDB
1 by brian
clean slate
412
alter table t1 drop index c1;
413
alter table t1 add index (c1);
414
alter table t1 add index (c1);
415
alter table t1 drop index i3;
416
alter table t1 add index i3 (c3);
417
alter table t1 drop index i2, drop index i4;
418
alter table t1 add index i2 (c2), add index i4 (c4);
419
alter table t1 drop index i2, drop index i4, add index i6 (c2, c4);
420
alter table t1 add index i2 (c2), add index i4 (c4), drop index i6;
421
alter table t1 drop index i2, drop index i4, add unique i4 (c4);
422
alter table t1 add index i2 (c2), drop index i4, add index i4 (c4);
423
alter table t1 drop index c2, add index (c2(4),c3(7));
424
alter table t1 drop index c2, add index (c2(4),c3(7));
425
alter table t1 add primary key (c1, c2), drop primary key;
426
alter table t1 drop primary key;
427
alter table t1 add primary key (c1, c2), drop primary key;
428
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
429
show create table t1;
430
Table	Create Table
431
t1	CREATE TABLE `t1` (
896.3.6 by Stewart Smith
Read Fields out of proto instead of FRM.
432
  `c1` int NOT NULL,
433
  `c2` varchar(12) NOT NULL,
434
  `c3` varchar(123) NOT NULL,
907.1.5 by Jay Pipes
Fixed remaining test cases. TIMESTAMP with no default is NULL, DEFAULT NULL, not auto-set
435
  `c4` timestamp NULL DEFAULT NULL,
1 by brian
clean slate
436
  KEY `i1` (`c1`),
437
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
438
  KEY `c1` (`c1`),
439
  KEY `c1_2` (`c1`),
440
  KEY `i3` (`c3`),
441
  KEY `i2` (`c2`),
442
  KEY `i4` (`c4`),
510 by Brian Aker
Test updates.
443
  KEY `c2` (`c2`(),`c3`())
444
) ENGINE=InnoDB
1 by brian
clean slate
445
insert into t1 values(1, 'a', 'a', NULL);
446
insert into t1 values(1, 'b', 'b', NULL);
447
alter table t1 drop index i3, drop index i2, drop index i1;
448
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
449
ERROR 23000: Duplicate entry '1' for key 'i1'
450
drop table t1;
510 by Brian Aker
Test updates.
451
CREATE TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
1 by brian
clean slate
452
INSERT INTO t1 VALUES( 1 );
453
ALTER TABLE t1 DISABLE KEYS;
454
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
455
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
456
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
457
drop table t1;
458
CREATE TABLE t1 (
459
a INTEGER auto_increment PRIMARY KEY,
460
b INTEGER NOT NULL,
461
c INTEGER NOT NULL,
462
d CHAR(64)
463
);
464
CREATE TABLE t2 (
465
a INTEGER auto_increment PRIMARY KEY,
466
b INTEGER NOT NULL,
510 by Brian Aker
Test updates.
467
c int NOT NULL,
1 by brian
clean slate
468
d DATETIME NOT NULL,
510 by Brian Aker
Test updates.
469
e int NOT NULL,
1 by brian
clean slate
470
f INTEGER NOT NULL,
471
g INTEGER NOT NULL,  
510 by Brian Aker
Test updates.
472
h int NOT NULL,
1 by brian
clean slate
473
i INTEGER NOT NULL,
474
j INTEGER NOT NULL,
475
UNIQUE INDEX (b),
476
INDEX (b, d, e, f, g, h, i, j, c),
477
INDEX (c)
478
);
479
INSERT INTO t2 VALUES 
480
(NULL, 1, 254, '1000-01-01 00:00:00', 257, 0, 0, 0, 0, 0),
481
(NULL, 2, 1, '2004-11-30 12:00:00', 1, 0, 0, 0, 0, 0),
482
(NULL, 3, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -21600, 0),
483
(NULL, 4, 1, '2004-11-30 12:00:00', 1, 0, 0, 2, -10800, 0),
484
(NULL, 5, 1, '2004-11-30 12:00:00', 1, 0, 0, 5, -10800, 0),
485
(NULL, 6, 1, '2004-11-30 12:00:00', 102, 0, 0, 0, 0, 0),
486
(NULL, 7, 1, '2004-11-30 12:00:00', 105, 2, 0, 0, 0, 0),
487
(NULL, 8, 1, '2004-11-30 12:00:00', 105, 10, 0, 0, 0, 0);
488
INSERT INTO t1 (b, c, d) VALUES
489
(3388000, -553000, NULL),
490
(3388000, -553000, NULL);
491
DROP TABLE t1, t2;
492
create table t1(a int not null, key aa(a), 
493
b char(10) not null, unique key bb(b(1)), 
494
c char(4) not null, unique key cc(c));
495
desc t1;
496
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
497
a	int	NO	MUL	NULL	
498
b	varchar(10)	NO	UNI	NULL	
499
c	varchar(4)	NO	PRI	NULL	
1 by brian
clean slate
500
show create table t1;
501
Table	Create Table
502
t1	CREATE TABLE `t1` (
510 by Brian Aker
Test updates.
503
  `a` int NOT NULL,
504
  `b` varchar(10) NOT NULL,
505
  `c` varchar(4) NOT NULL,
1 by brian
clean slate
506
  UNIQUE KEY `cc` (`c`),
510 by Brian Aker
Test updates.
507
  UNIQUE KEY `bb` (`b`()),
1 by brian
clean slate
508
  KEY `aa` (`a`)
510 by Brian Aker
Test updates.
509
) ENGINE=InnoDB
1 by brian
clean slate
510
drop table t1;
511
create table t1(a int not null, key aa(a), 
512
b char(10) not null, unique key bb(b(1)),
513
c char(4) not null);
514
desc t1;
515
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
516
a	int	NO	MUL	NULL	
517
b	varchar(10)	NO	UNI	NULL	
518
c	varchar(4)	NO		NULL	
1 by brian
clean slate
519
alter table t1 add unique key cc(c);
520
desc t1;
521
Field	Type	Null	Key	Default	Extra
510 by Brian Aker
Test updates.
522
a	int	NO	MUL	NULL	
523
b	varchar(10)	NO	UNI	NULL	
524
c	varchar(4)	NO	PRI	NULL	
1 by brian
clean slate
525
show create table t1;
526
Table	Create Table
527
t1	CREATE TABLE `t1` (
510 by Brian Aker
Test updates.
528
  `a` int NOT NULL,
529
  `b` varchar(10) NOT NULL,
530
  `c` varchar(4) NOT NULL,
1 by brian
clean slate
531
  UNIQUE KEY `cc` (`c`),
510 by Brian Aker
Test updates.
532
  UNIQUE KEY `bb` (`b`()),
1 by brian
clean slate
533
  KEY `aa` (`a`)
510 by Brian Aker
Test updates.
534
) ENGINE=InnoDB
1 by brian
clean slate
535
drop table t1;
536
End of 5.0 tests
537
DROP TABLE IF EXISTS t1;
538
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT);
539
INSERT INTO t1 VALUES (), (), ();
540
SELECT 1 AS c1
541
FROM t1
542
ORDER BY (
543
SELECT 1 AS c2
544
FROM t1
545
GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ASC
546
LIMIT 1);
547
c1
548
1
549
1
550
1
551
DROP TABLE t1;
552
CREATE TABLE t1 (a INT, b INT, INDEX (a,b));
553
INSERT INTO t1 (a, b)
554
VALUES
555
(1,1), (1,2), (1,3), (1,4), (1,5),
556
(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
557
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE 
558
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
559
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
560
1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE
510 by Brian Aker
Test updates.
561
2	SUBQUERY	t1	range	NULL	a	5	NULL	3	Using index for group-by
1 by brian
clean slate
562
SELECT 1 as RES FROM t1 AS t1_outer WHERE 
563
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
564
RES
565
DROP TABLE t1;