~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/key.test

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:16:12 UTC
  • mfrom: (520.1.2 drizzle)
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016111612-5nei7m5subslx912
mergeĀ fromĀ head

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;
161
161
 
162
162
CREATE TABLE t1 (
163
163
  a tinytext NOT NULL,
164
 
  b int(3) 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
 
226
213
# Test of problem with key read (Bug #3666)
227
214
#
228
215
 
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));
 
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 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),