~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/key.test

  • Committer: Lee
  • Date: 2008-10-03 23:31:06 UTC
  • mfrom: (413.2.3 drizzle)
  • mto: This revision was merged to the branch mainline in revision 459.
  • Revision ID: lbieber@lbieber-desktop-20081003233106-tgvzu0fh25gb3xeg
breaking out enum field classes

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;
161
161
 
162
162
CREATE TABLE t1 (
163
163
  a tinytext NOT NULL,
164
 
  b int NOT NULL default '0',
 
164
  b int(3) 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
 
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) NOT NULL default '0', numreponse int(10) 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),