~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/key.test

  • 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:
34
34
#
35
35
 
36
36
CREATE TABLE t1 (
37
 
  price int DEFAULT '0' NOT NULL,
38
 
  area varchar(160) DEFAULT '' NOT NULL,
39
 
  type varchar(160) DEFAULT '' NOT NULL,
 
37
  price int(5) DEFAULT '0' NOT NULL,
 
38
  area varchar(40) DEFAULT '' NOT NULL,
 
39
  type varchar(40) DEFAULT '' NOT NULL,
40
40
  transityes enum('Y','N') DEFAULT 'Y' NOT NULL,
41
41
  shopsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
42
42
  schoolsyes enum('Y','N') DEFAULT 'Y' NOT NULL,
46
46
 
47
47
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
48
48
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
49
 
INSERT INTO t1 (price, area, type) VALUES (900,'Vancouver','Shared/Roomate');
 
49
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
50
50
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
51
51
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
52
52
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
61
61
# No longer a problem with primary key
62
62
#
63
63
 
64
 
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  PRIMARY KEY (program));
 
64
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  sites set('mt'),  PRIMARY KEY (program));
65
65
# This no longer give an error for wrong primary key
66
66
ALTER TABLE t1 modify program enum('signup','unique','sliding');
67
67
drop table t1;
155
155
drop table t1;
156
156
 
157
157
#
158
 
# Test with blob + int key
 
158
# Test with blob + tinyint key
159
159
# (Failed for Greg Valure)
160
160
#
161
161
 
162
162
CREATE TABLE t1 (
163
163
  a tinytext NOT NULL,
164
 
  b int NOT NULL default '0',
 
164
  b tinyint(3) unsigned NOT NULL default '0',
165
165
  PRIMARY KEY (a(32),b)
166
166
) ENGINE=MyISAM;
167
167
INSERT INTO t1 VALUES ('a',1),('a',2);
182
182
# Problem with UNIQUE() with NULL parts and auto increment
183
183
#
184
184
 
185
 
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
186
 
--error 1048
 
185
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
 
186
UNIQUE (c,i));
187
187
INSERT INTO t1 (c) VALUES (NULL),(NULL);
188
188
SELECT * FROM t1;
189
189
INSERT INTO t1 (c) VALUES ('a'),('a');
190
190
SELECT * FROM t1;
191
191
DROP TABLE IF EXISTS t1;
192
 
CREATE TABLE t1 (c CHAR(10) NULL, i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
 
192
CREATE TABLE t1 (c CHAR(10) NULL, i INT NOT NULL AUTO_INCREMENT,
 
193
UNIQUE (c,i));
193
194
INSERT INTO t1 (c) VALUES (NULL),(NULL);
194
195
SELECT * FROM t1;
195
196
INSERT INTO t1 (c) VALUES ('a'),('a');
197
198
drop table t1;
198
199
 
199
200
#
 
201
# longer keys
 
202
#
 
203
create table t1 (i int, a char(200), b text, unique (a), unique (b(300))) charset utf8;
 
204
insert t1 values (1, repeat('a',210), repeat('b', 310));
 
205
insert t1 values (2, repeat(0xD0B1,215), repeat(0xD0B1, 310));
 
206
select i, length(a), length(b), char_length(a), char_length(b) from t1;
 
207
select i from t1 where a=repeat(_utf8 'a',200);
 
208
select i from t1 where a=repeat(_utf8 0xD0B1,200);
 
209
select i from t1 where b=repeat(_utf8 'b',310);
 
210
drop table t1;
 
211
 
 
212
#
200
213
# Test of key read with primary key (Bug #3497)
201
214
#
202
215
 
203
 
CREATE TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
 
216
CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam;
204
217
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
205
218
explain select 1 from t1 where id =2;
206
219
explain select 1 from t1 where id =2 or id=3;
213
226
# Test of problem with key read (Bug #3666)
214
227
#
215
228
 
216
 
CREATE TABLE t1 (numeropost int NOT NULL default '0', numreponse int NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
 
229
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));
217
230
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
218
231
SELECT numeropost FROM t1 WHERE numreponse='1';
219
232
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
225
238
# UNIQUE prefix keys and multi-byte charsets
226
239
#
227
240
 
228
 
create 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;
229
242
show create table t1;
230
243
insert t1 values ('cccc', 'tttt'),
231
244
  (0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
434
447
# Bug #20604: Test for disabled keys with aggregate functions and FORCE INDEX.
435
448
#
436
449
 
437
 
CREATE TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
 
450
CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM;
438
451
INSERT INTO t1 VALUES( 1 );
439
452
ALTER TABLE t1 DISABLE KEYS;
440
453
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
454
467
CREATE TABLE t2 (
455
468
  a INTEGER auto_increment PRIMARY KEY,
456
469
  b INTEGER NOT NULL,
457
 
  c int NOT NULL,
 
470
  c SMALLINT NOT NULL,
458
471
  d DATETIME NOT NULL,
459
 
  e int NOT NULL,
 
472
  e SMALLINT NOT NULL,
460
473
  f INTEGER NOT NULL,
461
474
  g INTEGER NOT NULL,  
462
 
  h int NOT NULL,
 
475
  h SMALLINT NOT NULL,
463
476
  i INTEGER NOT NULL,
464
477
  j INTEGER NOT NULL,
465
478
  UNIQUE INDEX (b),