~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/key.result

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
create table t2
96
96
(
97
97
name_id int not null auto_increment,
98
 
name char(255),
 
98
name char(255) binary,
99
99
INDEX name_idx (name(5)),
100
100
primary key (name_id)
101
101
);
124
124
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
125
125
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY'
126
126
drop table t1;
127
 
CREATE TEMPORARY TABLE t1 (
 
127
CREATE TABLE t1 (
128
128
a tinytext NOT NULL,
129
129
b int NOT NULL default '0',
130
130
PRIMARY KEY (a(32),b)
143
143
drop table t1;
144
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
145
show keys from t1;
146
 
Table   Unique  Key_name        Seq_in_index    Column_name
147
 
t1      YES     PRIMARY 1       d
148
 
t1      YES     a       1       a
149
 
t1      YES     e       1       e
150
 
t1      YES     b       1       b
151
 
t1      NO      c       1       c
 
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           
 
150
t1      0       b       1       b       A       0       NULL    NULL    YES     BTREE           
 
151
t1      1       c       1       c       A       0       NULL    NULL    YES     BTREE           
152
152
drop table t1;
153
153
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
154
154
INSERT INTO t1 (c) VALUES (NULL),(NULL);
175
175
a       3
176
176
a       4
177
177
drop table t1;
178
 
CREATE TEMPORARY TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
 
178
CREATE TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
179
179
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
180
180
explain select 1 from t1 where id =2;
181
181
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
204
204
numeropost
205
205
1
206
206
drop table t1;
207
 
create temporary table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
 
207
create table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
208
208
show create table t1;
209
209
Table   Create Table
210
 
t1      CREATE TEMPORARY TABLE `t1` (
211
 
  `c` VARCHAR(30) COLLATE utf8_general_ci DEFAULT NULL,
212
 
  `t` TEXT COLLATE utf8_general_ci,
213
 
  UNIQUE KEY `c` (`c`(2)),
214
 
  UNIQUE KEY `t` (`t`(3))
215
 
) ENGINE=MyISAM COLLATE = utf8_general_ci
 
210
t1      CREATE TABLE `t1` (
 
211
  `c` varchar(30) DEFAULT NULL,
 
212
  `t` text,
 
213
  UNIQUE KEY `c` (`c`()),
 
214
  UNIQUE KEY `t` (`t`())
 
215
) ENGINE=MyISAM
216
216
insert t1 values ('cccc', 'tttt'),
217
217
(0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
218
218
(0xD0B1222123D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1222123D0B1D0B1D0B1D0B1);
240
240
DROP TABLE IF EXISTS t1;
241
241
Warnings:
242
242
Note    1051    Unknown table 't1'
243
 
CREATE TEMPORARY TABLE t1 (
 
243
CREATE TABLE t1 (
244
244
c1 int,
245
245
c2 varbinary(240),
246
246
UNIQUE KEY (c1),
301
301
UNIQUE i1idx (i1),
302
302
UNIQUE i2idx (i2));
303
303
desc t1;
304
 
Field   Type    Null    Default Default_is_NULL On_Update
305
 
i1      INTEGER NO              NO      
306
 
i2      INTEGER NO              NO      
 
304
Field   Type    Null    Key     Default Extra
 
305
i1      int     NO      PRI     NULL    
 
306
i2      int     NO      UNI     NULL    
307
307
show create table t1;
308
308
Table   Create Table
309
309
t1      CREATE TABLE `t1` (
310
 
  `i1` INT NOT NULL,
311
 
  `i2` INT NOT NULL,
 
310
  `i1` int NOT NULL,
 
311
  `i2` int NOT NULL,
312
312
  UNIQUE KEY `i1idx` (`i1`),
313
313
  UNIQUE KEY `i2idx` (`i2`)
314
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
314
) ENGINE=InnoDB
315
315
drop table t1;
316
 
create temporary table t1 (
 
316
create table t1 (
317
317
c1 int,
318
318
c2 varchar(20) not null,
319
319
primary key (c1),
334
334
show create table t1;
335
335
Table   Create Table
336
336
t1      CREATE TABLE `t1` (
337
 
  `a` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
338
 
  `b` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
 
337
  `a` varchar(10) DEFAULT NULL,
 
338
  `b` varchar(10) DEFAULT NULL,
339
339
  KEY `a` (`a`,`b`)
340
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
340
) ENGINE=InnoDB
341
341
alter table t1 modify b varchar(20);
342
342
show create table t1;
343
343
Table   Create Table
344
344
t1      CREATE TABLE `t1` (
345
 
  `a` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
346
 
  `b` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
 
345
  `a` varchar(10) DEFAULT NULL,
 
346
  `b` varchar(20) DEFAULT NULL,
347
347
  KEY `a` (`a`,`b`)
348
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
348
) ENGINE=InnoDB
349
349
alter table t1 modify a varchar(20);
350
350
show create table t1;
351
351
Table   Create Table
352
352
t1      CREATE TABLE `t1` (
353
 
  `a` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
354
 
  `b` VARCHAR(20) COLLATE utf8_general_ci DEFAULT NULL,
 
353
  `a` varchar(20) DEFAULT NULL,
 
354
  `b` varchar(20) DEFAULT NULL,
355
355
  KEY `a` (`a`,`b`)
356
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
356
) ENGINE=InnoDB
357
357
drop table t1;
358
358
create table t1 (a int not null primary key, b varchar(20) not null unique);
359
359
desc t1;
360
 
Field   Type    Null    Default Default_is_NULL On_Update
361
 
a       INTEGER NO              NO      
362
 
b       VARCHAR NO              NO      
 
360
Field   Type    Null    Key     Default Extra
 
361
a       int     NO      PRI     NULL    
 
362
b       varchar(20)     NO      UNI     NULL    
363
363
drop table t1;
364
364
create table t1 (a int not null primary key, b int not null unique);
365
365
desc t1;
366
 
Field   Type    Null    Default Default_is_NULL On_Update
367
 
a       INTEGER NO              NO      
368
 
b       INTEGER NO              NO      
 
366
Field   Type    Null    Key     Default Extra
 
367
a       int     NO      PRI     NULL    
 
368
b       int     NO      UNI     NULL    
369
369
drop table t1;
370
370
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
371
371
desc t1;
372
 
Field   Type    Null    Default Default_is_NULL On_Update
373
 
a       INTEGER NO              NO      
374
 
b       VARCHAR NO              NO      
 
372
Field   Type    Null    Key     Default Extra
 
373
a       int     NO      PRI     NULL    
 
374
b       varchar(20)     NO      UNI     NULL    
375
375
drop table t1;
376
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
377
desc t1;
378
 
Field   Type    Null    Default Default_is_NULL On_Update
379
 
a       INTEGER NO              NO      
380
 
b       VARCHAR NO              NO      
381
 
c       VARCHAR NO              NO      
 
378
Field   Type    Null    Key     Default Extra
 
379
a       int     NO      PRI     NULL    
 
380
b       varchar(20)     NO      MUL     NULL    
 
381
c       varchar(20)     NO              NULL    
382
382
drop table t1;
383
383
create table t1 (
384
384
c1 int,
396
396
show create table t1;
397
397
Table   Create Table
398
398
t1      CREATE TABLE `t1` (
399
 
  `c1` INT DEFAULT NULL,
400
 
  `c2` VARCHAR(12) COLLATE utf8_general_ci NOT NULL,
401
 
  `c3` VARCHAR(123) COLLATE utf8_general_ci NOT NULL,
402
 
  `c4` TIMESTAMP NULL DEFAULT NULL,
 
399
  `c1` int DEFAULT NULL,
 
400
  `c2` varchar(12) NOT NULL DEFAULT '',
 
401
  `c3` varchar(123) NOT NULL DEFAULT '',
 
402
  `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
403
403
  PRIMARY KEY (`c2`,`c3`),
404
404
  UNIQUE KEY `i4` (`c4`),
405
405
  KEY `c1` (`c1`),
408
408
  KEY `i3` (`c3`),
409
409
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
410
410
  KEY `c2` (`c2`,`c4`)
411
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
411
) ENGINE=InnoDB
412
412
alter table t1 drop index c1;
413
413
alter table t1 add index (c1);
414
414
alter table t1 add index (c1);
429
429
show create table t1;
430
430
Table   Create Table
431
431
t1      CREATE TABLE `t1` (
432
 
  `c1` INT NOT NULL,
433
 
  `c2` VARCHAR(12) COLLATE utf8_general_ci NOT NULL,
434
 
  `c3` VARCHAR(123) COLLATE utf8_general_ci NOT NULL,
435
 
  `c4` TIMESTAMP NULL DEFAULT NULL,
 
432
  `c1` int NOT NULL DEFAULT '0',
 
433
  `c2` varchar(12) NOT NULL DEFAULT '',
 
434
  `c3` varchar(123) NOT NULL DEFAULT '',
 
435
  `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
436
436
  KEY `i1` (`c1`),
437
437
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
438
438
  KEY `c1` (`c1`),
440
440
  KEY `i3` (`c3`),
441
441
  KEY `i2` (`c2`),
442
442
  KEY `i4` (`c4`),
443
 
  KEY `c2` (`c2`(4),`c3`(7))
444
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
443
  KEY `c2` (`c2`(),`c3`())
 
444
) ENGINE=InnoDB
445
445
insert into t1 values(1, 'a', 'a', NULL);
446
446
insert into t1 values(1, 'b', 'b', NULL);
447
447
alter table t1 drop index i3, drop index i2, drop index i1;
448
448
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
449
449
ERROR 23000: Duplicate entry '1' for key 'i1'
450
450
drop table t1;
451
 
CREATE TEMPORARY TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
 
451
CREATE TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
452
452
INSERT INTO t1 VALUES( 1 );
453
453
ALTER TABLE t1 DISABLE KEYS;
454
454
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
493
493
b char(10) not null, unique key bb(b(1)), 
494
494
c char(4) not null, unique key cc(c));
495
495
desc t1;
496
 
Field   Type    Null    Default Default_is_NULL On_Update
497
 
a       INTEGER NO              NO      
498
 
b       VARCHAR NO              NO      
499
 
c       VARCHAR NO              NO      
 
496
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    
500
500
show create table t1;
501
501
Table   Create Table
502
502
t1      CREATE TABLE `t1` (
503
 
  `a` INT NOT NULL,
504
 
  `b` VARCHAR(10) COLLATE utf8_general_ci NOT NULL,
505
 
  `c` VARCHAR(4) COLLATE utf8_general_ci NOT NULL,
 
503
  `a` int NOT NULL,
 
504
  `b` varchar(10) NOT NULL,
 
505
  `c` varchar(4) NOT NULL,
506
506
  UNIQUE KEY `cc` (`c`),
507
 
  UNIQUE KEY `bb` (`b`(1)),
 
507
  UNIQUE KEY `bb` (`b`()),
508
508
  KEY `aa` (`a`)
509
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
509
) ENGINE=InnoDB
510
510
drop table t1;
511
511
create table t1(a int not null, key aa(a), 
512
512
b char(10) not null, unique key bb(b(1)),
513
513
c char(4) not null);
514
514
desc t1;
515
 
Field   Type    Null    Default Default_is_NULL On_Update
516
 
a       INTEGER NO              NO      
517
 
b       VARCHAR NO              NO      
518
 
c       VARCHAR NO              NO      
 
515
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    
519
519
alter table t1 add unique key cc(c);
520
520
desc t1;
521
 
Field   Type    Null    Default Default_is_NULL On_Update
522
 
a       INTEGER NO              NO      
523
 
b       VARCHAR NO              NO      
524
 
c       VARCHAR NO              NO      
 
521
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    
525
525
show create table t1;
526
526
Table   Create Table
527
527
t1      CREATE TABLE `t1` (
528
 
  `a` INT NOT NULL,
529
 
  `b` VARCHAR(10) COLLATE utf8_general_ci NOT NULL,
530
 
  `c` VARCHAR(4) COLLATE utf8_general_ci NOT NULL,
 
528
  `a` int NOT NULL,
 
529
  `b` varchar(10) NOT NULL,
 
530
  `c` varchar(4) NOT NULL,
531
531
  UNIQUE KEY `cc` (`c`),
532
 
  UNIQUE KEY `bb` (`b`(1)),
 
532
  UNIQUE KEY `bb` (`b`()),
533
533
  KEY `aa` (`a`)
534
 
) ENGINE=InnoDB COLLATE = utf8_general_ci
 
534
) ENGINE=InnoDB
535
535
drop table t1;
536
536
End of 5.0 tests
537
537
DROP TABLE IF EXISTS t1;