~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/key.test

  • Committer: Brian Aker
  • Date: 2010-02-07 01:33:54 UTC
  • Revision ID: brian@gaz-20100207013354-d2pg1n68u5c09pgo
Remove giant include header to its own file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#
35
35
 
36
36
CREATE TABLE t1 (
37
 
  price int(5) DEFAULT '0' NOT NULL,
38
 
  area varchar(40) DEFAULT '' NOT NULL,
39
 
  type varchar(40) DEFAULT '' NOT NULL,
 
37
  price int DEFAULT '0' NOT NULL,
 
38
  area varchar(160) DEFAULT '' NOT NULL,
 
39
  type varchar(160) 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 VALUES (900,'Vancouver','Shared/Roomate','','','','');
 
49
INSERT INTO t1 (price, area, type) 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'),  sites set('mt'),  PRIMARY KEY (program));
 
64
CREATE TABLE t1 (program enum('signup','unique','sliding') not null,  type enum('basic','sliding','signup'),  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;
122
122
create table t2
123
123
(
124
124
  name_id int not null auto_increment,
125
 
  name char(255) binary,
 
125
  name char(255),
126
126
  INDEX name_idx (name(5)),
127
127
  primary key (name_id)
128
128
);
155
155
drop table t1;
156
156
 
157
157
#
158
 
# Test with blob + tinyint key
 
158
# Test with blob + int key
159
159
# (Failed for Greg Valure)
160
160
#
161
161
 
162
 
CREATE TABLE t1 (
 
162
CREATE TEMPORARY TABLE t1 (
163
163
  a tinytext NOT NULL,
164
 
  b tinyint(3) unsigned NOT NULL default '0',
 
164
  b int 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 CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
186
 
UNIQUE (c,i));
 
185
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
 
186
--error 1048
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 NOT NULL AUTO_INCREMENT,
193
 
UNIQUE (c,i));
 
192
CREATE TABLE t1 (c CHAR(10) NULL, i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
194
193
INSERT INTO t1 (c) VALUES (NULL),(NULL);
195
194
SELECT * FROM t1;
196
195
INSERT INTO t1 (c) VALUES ('a'),('a');
198
197
drop table t1;
199
198
 
200
199
#
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
 
#
213
200
# Test of key read with primary key (Bug #3497)
214
201
#
215
202
 
216
 
CREATE TABLE t1 (id int unsigned auto_increment, name char(50), primary key (id)) engine=myisam;
 
203
CREATE TEMPORARY TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
217
204
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
218
205
explain select 1 from t1 where id =2;
219
206
explain select 1 from t1 where id =2 or id=3;
226
213
# Test of problem with key read (Bug #3666)
227
214
#
228
215
 
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));
 
216
CREATE TABLE t1 (numeropost int NOT NULL default '0', numreponse int NOT NULL auto_increment, PRIMARY KEY (numeropost,numreponse), UNIQUE KEY numreponse (numreponse));
230
217
INSERT INTO t1 (numeropost,numreponse) VALUES ('1','1'),('1','2'),('2','3'),('2','4');
231
218
SELECT numeropost FROM t1 WHERE numreponse='1';
232
219
EXPLAIN SELECT numeropost FROM t1 WHERE numreponse='1';
238
225
# UNIQUE prefix keys and multi-byte charsets
239
226
#
240
227
 
241
 
create table t1 (c varchar(30) character set utf8, t text character set utf8, unique (c(2)), unique (t(3))) engine=myisam;
 
228
create temporary table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
242
229
show create table t1;
243
230
insert t1 values ('cccc', 'tttt'),
244
231
  (0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
261
248
# BUG#6151 - myisam index corruption
262
249
#
263
250
DROP TABLE IF EXISTS t1;
264
 
CREATE TABLE t1 (
 
251
CREATE TEMPORARY TABLE t1 (
265
252
  c1 int,
266
253
  c2 varbinary(240),
267
254
  UNIQUE KEY (c1),
341
328
# Bug#12565 - ERROR 1034 when running simple UPDATE or DELETE 
342
329
#             on large MyISAM table
343
330
#
344
 
create table t1 (
 
331
create temporary table t1 (
345
332
  c1 int,
346
333
  c2 varchar(20) not null,
347
334
  primary key (c1),
447
434
# Bug #20604: Test for disabled keys with aggregate functions and FORCE INDEX.
448
435
#
449
436
 
450
 
CREATE TABLE t1( a TINYINT, KEY(a) ) ENGINE=MyISAM;
 
437
CREATE TEMPORARY TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
451
438
INSERT INTO t1 VALUES( 1 );
452
439
ALTER TABLE t1 DISABLE KEYS;
453
440
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
467
454
CREATE TABLE t2 (
468
455
  a INTEGER auto_increment PRIMARY KEY,
469
456
  b INTEGER NOT NULL,
470
 
  c SMALLINT NOT NULL,
 
457
  c int NOT NULL,
471
458
  d DATETIME NOT NULL,
472
 
  e SMALLINT NOT NULL,
 
459
  e int NOT NULL,
473
460
  f INTEGER NOT NULL,
474
461
  g INTEGER NOT NULL,  
475
 
  h SMALLINT NOT NULL,
 
462
  h int NOT NULL,
476
463
  i INTEGER NOT NULL,
477
464
  j INTEGER NOT NULL,
478
465
  UNIQUE INDEX (b),