~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
personal employee company
22
22
drop table t1;
23
23
CREATE TABLE t1 (
24
 
price int DEFAULT '0' NOT NULL,
25
 
area varchar(160) DEFAULT '' NOT NULL,
26
 
type varchar(160) DEFAULT '' NOT NULL,
 
24
price int(5) DEFAULT '0' NOT NULL,
 
25
area varchar(40) DEFAULT '' NOT NULL,
 
26
type varchar(40) DEFAULT '' NOT NULL,
27
27
transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
28
28
shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
29
29
schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
32
32
);
33
33
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
34
34
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
35
 
INSERT INTO t1 (price, area, type) VALUES (900,'Vancouver','Shared/Roomate');
 
35
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
 
36
Warnings:
 
37
Warning 1265    Data truncated for column 'transityes' at row 1
 
38
Warning 1265    Data truncated for column 'shopsyes' at row 1
 
39
Warning 1265    Data truncated for column 'schoolsyes' at row 1
 
40
Warning 1265    Data truncated for column 'petsyes' at row 1
36
41
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
37
42
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
38
43
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
41
46
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
47
price   area    type    transityes      shopsyes        schoolsyes      petsyes
43
48
drop table t1;
44
 
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  PRIMARY KEY (program));
 
49
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  sites set('mt'),  PRIMARY KEY (program));
45
50
ALTER TABLE t1 modify program enum('signup','unique','sliding');
46
51
drop table t1;
47
52
CREATE TABLE t1 (
95
100
create table t2
96
101
(
97
102
name_id int not null auto_increment,
98
 
name char(255),
 
103
name char(255) binary,
99
104
INDEX name_idx (name(5)),
100
105
primary key (name_id)
101
106
);
124
129
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
125
130
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY'
126
131
drop table t1;
127
 
CREATE TEMPORARY TABLE t1 (
 
132
CREATE TABLE t1 (
128
133
a tinytext NOT NULL,
129
 
b int NOT NULL default '0',
 
134
b tinyint(3) unsigned NOT NULL default '0',
130
135
PRIMARY KEY (a(32),b)
131
136
) ENGINE=MyISAM;
132
137
INSERT INTO t1 VALUES ('a',1),('a',2);
147
152
t1      0       PRIMARY 1       d       A       0       NULL    NULL            BTREE           
148
153
t1      0       a       1       a       A       0       NULL    NULL            BTREE           
149
154
t1      0       e       1       e       A       0       NULL    NULL            BTREE           
150
 
t1      0       b       1       b       A       0       NULL    NULL    YES     BTREE           
151
 
t1      1       c       1       c       A       0       NULL    NULL    YES     BTREE           
 
155
t1      0       b       1       b       A       NULL    NULL    NULL    YES     BTREE           
 
156
t1      1       c       1       c       A       NULL    NULL    NULL    YES     BTREE           
152
157
drop table t1;
153
 
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
 
158
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
 
159
UNIQUE (c,i));
154
160
INSERT INTO t1 (c) VALUES (NULL),(NULL);
155
 
ERROR 23000: Column 'c' cannot be null
 
161
Warnings:
 
162
Warning 1048    Column 'c' cannot be null
 
163
Warning 1048    Column 'c' cannot be null
156
164
SELECT * FROM t1;
157
165
c       i
 
166
        1
 
167
        2
158
168
INSERT INTO t1 (c) VALUES ('a'),('a');
159
169
SELECT * FROM t1;
160
170
c       i
 
171
        1
 
172
        2
161
173
a       1
162
174
a       2
163
175
DROP TABLE IF EXISTS t1;
164
 
CREATE TABLE t1 (c CHAR(10) NULL, i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
 
176
CREATE TABLE t1 (c CHAR(10) NULL, i INT NOT NULL AUTO_INCREMENT,
 
177
UNIQUE (c,i));
165
178
INSERT INTO t1 (c) VALUES (NULL),(NULL);
166
179
SELECT * FROM t1;
167
180
c       i
172
185
c       i
173
186
NULL    1
174
187
NULL    2
175
 
a       3
176
 
a       4
177
 
drop table t1;
178
 
CREATE TEMPORARY TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
 
188
a       1
 
189
a       2
 
190
drop table t1;
 
191
create table t1 (i int, a char(200), b text, unique (a), unique (b(300))) charset utf8;
 
192
insert t1 values (1, repeat('a',210), repeat('b', 310));
 
193
Warnings:
 
194
Warning 1265    Data truncated for column 'a' at row 1
 
195
insert t1 values (2, repeat(0xD0B1,215), repeat(0xD0B1, 310));
 
196
Warnings:
 
197
Warning 1265    Data truncated for column 'a' at row 1
 
198
select i, length(a), length(b), char_length(a), char_length(b) from t1;
 
199
i       length(a)       length(b)       char_length(a)  char_length(b)
 
200
1       200     310     200     310
 
201
2       400     620     200     310
 
202
select i from t1 where a=repeat(_utf8 'a',200);
 
203
i
 
204
1
 
205
select i from t1 where a=repeat(_utf8 0xD0B1,200);
 
206
i
 
207
2
 
208
select i from t1 where b=repeat(_utf8 'b',310);
 
209
i
 
210
1
 
211
drop table t1;
 
212
CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam;
179
213
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
180
214
explain select 1 from t1 where id =2;
181
215
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
191
225
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
192
226
1       SIMPLE  t1      ref     id      id      4       const   1       Using index
193
227
drop table t1;
194
 
CREATE TABLE t1 (numeropost int NOT NULL default '0', numreponse int NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
 
228
CREATE TABLE t1 (numeropost mediumint(8) unsigned NOT NULL default '0', numreponse int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
195
229
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
196
230
SELECT numeropost FROM t1 WHERE numreponse='1';
197
231
numeropost
204
238
numeropost
205
239
1
206
240
drop table t1;
207
 
create temporary table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
 
241
create table t1 (c varchar(30) character set utf8, t text character set utf8, unique (c(2)), unique (t(3))) engine=myisam;
208
242
show create table t1;
209
243
Table   Create Table
210
 
t1      CREATE TEMPORARY TABLE `t1` (
211
 
  `c` varchar(30) DEFAULT NULL,
212
 
  `t` text,
 
244
t1      CREATE TABLE `t1` (
 
245
  `c` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
 
246
  `t` text CHARACTER SET utf8,
213
247
  UNIQUE KEY `c` (`c`(2)),
214
248
  UNIQUE KEY `t` (`t`(3))
215
 
) ENGINE=MyISAM
 
249
) ENGINE=MyISAM DEFAULT CHARSET=latin1
216
250
insert t1 values ('cccc', 'tttt'),
217
251
(0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
218
252
(0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1);
232
266
tttt
233
267
select c from t1 where c=0xD0B1212223D0B1D0B1D0B1D0B1D0B1;
234
268
c
235
 
б!"#ббббб
 
269
?!"#?????
236
270
select t from t1 where t=0xD0B1D0B1212223D0B1D0B1D0B1D0B1;
237
271
t
238
 
бб!"#бббб
 
272
??!"#????
239
273
drop table t1;
240
274
DROP TABLE IF EXISTS t1;
241
275
Warnings:
242
276
Note    1051    Unknown table 't1'
243
 
CREATE TEMPORARY TABLE t1 (
 
277
CREATE TABLE t1 (
244
278
c1 int,
245
279
c2 varbinary(240),
246
280
UNIQUE KEY (c1),
302
336
UNIQUE i2idx (i2));
303
337
desc t1;
304
338
Field   Type    Null    Key     Default Extra
305
 
i1      int     NO      PRI     NULL    
306
 
i2      int     NO      UNI     NULL    
 
339
i1      int(11) NO      PRI     NULL    
 
340
i2      int(11) NO      UNI     NULL    
307
341
show create table t1;
308
342
Table   Create Table
309
343
t1      CREATE TABLE `t1` (
310
 
  `i1` int NOT NULL,
311
 
  `i2` int NOT NULL,
 
344
  `i1` int(11) NOT NULL,
 
345
  `i2` int(11) NOT NULL,
312
346
  UNIQUE KEY `i1idx` (`i1`),
313
347
  UNIQUE KEY `i2idx` (`i2`)
314
 
) ENGINE=InnoDB
 
348
) ENGINE=MyISAM DEFAULT CHARSET=latin1
315
349
drop table t1;
316
 
create temporary table t1 (
 
350
create table t1 (
317
351
c1 int,
318
352
c2 varchar(20) not null,
319
353
primary key (c1),
337
371
  `a` varchar(10) DEFAULT NULL,
338
372
  `b` varchar(10) DEFAULT NULL,
339
373
  KEY `a` (`a`,`b`)
340
 
) ENGINE=InnoDB
 
374
) ENGINE=MyISAM DEFAULT CHARSET=latin1
341
375
alter table t1 modify b varchar(20);
342
376
show create table t1;
343
377
Table   Create Table
345
379
  `a` varchar(10) DEFAULT NULL,
346
380
  `b` varchar(20) DEFAULT NULL,
347
381
  KEY `a` (`a`,`b`)
348
 
) ENGINE=InnoDB
 
382
) ENGINE=MyISAM DEFAULT CHARSET=latin1
349
383
alter table t1 modify a varchar(20);
350
384
show create table t1;
351
385
Table   Create Table
353
387
  `a` varchar(20) DEFAULT NULL,
354
388
  `b` varchar(20) DEFAULT NULL,
355
389
  KEY `a` (`a`,`b`)
356
 
) ENGINE=InnoDB
 
390
) ENGINE=MyISAM DEFAULT CHARSET=latin1
357
391
drop table t1;
358
392
create table t1 (a int not null primary key, b varchar(20) not null unique);
359
393
desc t1;
360
394
Field   Type    Null    Key     Default Extra
361
 
a       int     NO      PRI     NULL    
 
395
a       int(11) NO      PRI     NULL    
362
396
b       varchar(20)     NO      UNI     NULL    
363
397
drop table t1;
364
398
create table t1 (a int not null primary key, b int not null unique);
365
399
desc t1;
366
400
Field   Type    Null    Key     Default Extra
367
 
a       int     NO      PRI     NULL    
368
 
b       int     NO      UNI     NULL    
 
401
a       int(11) NO      PRI     NULL    
 
402
b       int(11) NO      UNI     NULL    
369
403
drop table t1;
370
404
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
371
405
desc t1;
372
406
Field   Type    Null    Key     Default Extra
373
 
a       int     NO      PRI     NULL    
 
407
a       int(11) NO      PRI     NULL    
374
408
b       varchar(20)     NO      UNI     NULL    
375
409
drop table t1;
376
410
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
411
desc t1;
378
412
Field   Type    Null    Key     Default Extra
379
 
a       int     NO      PRI     NULL    
 
413
a       int(11) NO      PRI     NULL    
380
414
b       varchar(20)     NO      MUL     NULL    
381
415
c       varchar(20)     NO              NULL    
382
416
drop table t1;
396
430
show create table t1;
397
431
Table   Create Table
398
432
t1      CREATE TABLE `t1` (
399
 
  `c1` int DEFAULT NULL,
400
 
  `c2` varchar(12) NOT NULL,
401
 
  `c3` varchar(123) NOT NULL,
402
 
  `c4` timestamp NULL DEFAULT NULL,
 
433
  `c1` int(11) DEFAULT NULL,
 
434
  `c2` char(12) NOT NULL DEFAULT '',
 
435
  `c3` varchar(123) NOT NULL DEFAULT '',
 
436
  `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
403
437
  PRIMARY KEY (`c2`,`c3`),
404
438
  UNIQUE KEY `i4` (`c4`),
405
439
  KEY `c1` (`c1`),
408
442
  KEY `i3` (`c3`),
409
443
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
410
444
  KEY `c2` (`c2`,`c4`)
411
 
) ENGINE=InnoDB
 
445
) ENGINE=MyISAM DEFAULT CHARSET=latin1
412
446
alter table t1 drop index c1;
413
447
alter table t1 add index (c1);
414
448
alter table t1 add index (c1);
429
463
show create table t1;
430
464
Table   Create Table
431
465
t1      CREATE TABLE `t1` (
432
 
  `c1` int NOT NULL,
433
 
  `c2` varchar(12) NOT NULL,
434
 
  `c3` varchar(123) NOT NULL,
435
 
  `c4` timestamp NULL DEFAULT NULL,
 
466
  `c1` int(11) NOT NULL DEFAULT '0',
 
467
  `c2` char(12) NOT NULL DEFAULT '',
 
468
  `c3` varchar(123) NOT NULL DEFAULT '',
 
469
  `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
436
470
  KEY `i1` (`c1`),
437
471
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
438
472
  KEY `c1` (`c1`),
441
475
  KEY `i2` (`c2`),
442
476
  KEY `i4` (`c4`),
443
477
  KEY `c2` (`c2`(4),`c3`(7))
444
 
) ENGINE=InnoDB
 
478
) ENGINE=MyISAM DEFAULT CHARSET=latin1
445
479
insert into t1 values(1, 'a', 'a', NULL);
446
480
insert into t1 values(1, 'b', 'b', NULL);
447
481
alter table t1 drop index i3, drop index i2, drop index i1;
448
482
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
449
483
ERROR 23000: Duplicate entry '1' for key 'i1'
450
484
drop table t1;
451
 
CREATE TEMPORARY TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
 
485
CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM;
452
486
INSERT INTO t1 VALUES( 1 );
453
487
ALTER TABLE t1 DISABLE KEYS;
454
488
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
464
498
CREATE TABLE t2 (
465
499
a INTEGER auto_increment PRIMARY KEY,
466
500
b INTEGER NOT NULL,
467
 
c int NOT NULL,
 
501
c SMALLINT NOT NULL,
468
502
d DATETIME NOT NULL,
469
 
e int NOT NULL,
 
503
e SMALLINT NOT NULL,
470
504
f INTEGER NOT NULL,
471
505
g INTEGER NOT NULL,  
472
 
h int NOT NULL,
 
506
h SMALLINT NOT NULL,
473
507
i INTEGER NOT NULL,
474
508
j INTEGER NOT NULL,
475
509
UNIQUE INDEX (b),
494
528
c char(4) not null, unique key cc(c));
495
529
desc t1;
496
530
Field   Type    Null    Key     Default Extra
497
 
a       int     NO      MUL     NULL    
498
 
b       varchar(10)     NO      UNI     NULL    
499
 
c       varchar(4)      NO      PRI     NULL    
 
531
a       int(11) NO      MUL     NULL    
 
532
b       char(10)        NO      UNI     NULL    
 
533
c       char(4) NO      PRI     NULL    
500
534
show create table t1;
501
535
Table   Create Table
502
536
t1      CREATE TABLE `t1` (
503
 
  `a` int NOT NULL,
504
 
  `b` varchar(10) NOT NULL,
505
 
  `c` varchar(4) NOT NULL,
 
537
  `a` int(11) NOT NULL,
 
538
  `b` char(10) NOT NULL,
 
539
  `c` char(4) NOT NULL,
506
540
  UNIQUE KEY `cc` (`c`),
507
541
  UNIQUE KEY `bb` (`b`(1)),
508
542
  KEY `aa` (`a`)
509
 
) ENGINE=InnoDB
 
543
) ENGINE=MyISAM DEFAULT CHARSET=latin1
510
544
drop table t1;
511
545
create table t1(a int not null, key aa(a), 
512
546
b char(10) not null, unique key bb(b(1)),
513
547
c char(4) not null);
514
548
desc t1;
515
549
Field   Type    Null    Key     Default Extra
516
 
a       int     NO      MUL     NULL    
517
 
b       varchar(10)     NO      UNI     NULL    
518
 
c       varchar(4)      NO              NULL    
 
550
a       int(11) NO      MUL     NULL    
 
551
b       char(10)        NO      UNI     NULL    
 
552
c       char(4) NO              NULL    
519
553
alter table t1 add unique key cc(c);
520
554
desc t1;
521
555
Field   Type    Null    Key     Default Extra
522
 
a       int     NO      MUL     NULL    
523
 
b       varchar(10)     NO      UNI     NULL    
524
 
c       varchar(4)      NO      PRI     NULL    
 
556
a       int(11) NO      MUL     NULL    
 
557
b       char(10)        NO      UNI     NULL    
 
558
c       char(4) NO      PRI     NULL    
525
559
show create table t1;
526
560
Table   Create Table
527
561
t1      CREATE TABLE `t1` (
528
 
  `a` int NOT NULL,
529
 
  `b` varchar(10) NOT NULL,
530
 
  `c` varchar(4) NOT NULL,
 
562
  `a` int(11) NOT NULL,
 
563
  `b` char(10) NOT NULL,
 
564
  `c` char(4) NOT NULL,
531
565
  UNIQUE KEY `cc` (`c`),
532
566
  UNIQUE KEY `bb` (`b`(1)),
533
567
  KEY `aa` (`a`)
534
 
) ENGINE=InnoDB
 
568
) ENGINE=MyISAM DEFAULT CHARSET=latin1
535
569
drop table t1;
536
570
End of 5.0 tests
537
571
DROP TABLE IF EXISTS t1;
558
592
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
559
593
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
560
594
1       PRIMARY NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE
561
 
2       SUBQUERY        t1      range   NULL    a       5       NULL    3       Using index for group-by
 
595
2       SUBQUERY        t1      range   NULL    a       5       NULL    8       Using index for group-by
562
596
SELECT 1 as RES FROM t1 AS t1_outer WHERE 
563
597
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
564
598
RES