~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/create.test

  • Committer: Joe Daly
  • Date: 2010-01-06 02:20:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1267.
  • Revision ID: skinny.moey@gmail.com-20100106022042-8ov23wc4aq8f9k7d
rename hash_algorithm to algorithm

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
create table t1 (b char(0) not null);
16
16
create table if not exists t1 (b char(0) not null);
17
 
--error ER_BAD_NULL_ERROR
 
17
--error 1048
18
18
insert into t1 values (""),(null);
19
19
select * from t1;
20
20
drop table t1;
26
26
# Test of some CREATE TABLE'S that should fail
27
27
#
28
28
 
29
 
--error ER_NO_SUCH_TABLE
 
29
--error 1146
30
30
create temporary table t2 engine=MEMORY select * from t1;
31
 
--error ER_NO_SUCH_TABLE
 
31
--error 1146
32
32
create table t2 select auto+1 from t1;
33
33
drop table if exists t1,t2;
34
 
--error ER_WRONG_KEY_COLUMN
 
34
--error 1167
35
35
create table t1 (b char(0) not null, index(b));
36
 
--error ER_TABLE_CANT_HANDLE_BLOB
 
36
--error 1163
37
37
create temporary table t1 (a int not null,b text) engine=MEMORY;
38
38
drop table if exists t1;
39
39
 
40
 
--error ER_WRONG_AUTO_KEY
 
40
--error 1075
41
41
create temporary table t1 (ordid int not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=MEMORY;
42
42
 
43
43
-- error 1049
46
46
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
47
47
show create table `a/a`;
48
48
create table t1 like `a/a`;
49
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
50
 
show create table t1;
51
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
52
 
show create table `t1`;
53
49
drop table `a/a`;
54
50
drop table `t1`;
55
 
--error ER_WRONG_TABLE_NAME
 
51
--error 1103
56
52
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
57
 
--error ER_TOO_LONG_IDENT
 
53
--error 1059
58
54
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
59
55
 
60
56
#
61
57
# Some wrong defaults, so these creates should fail too (Bug #5902)
62
58
#
63
 
--error ER_INVALID_DEFAULT
 
59
--error 1067
64
60
create table t1 (a datetime default now());
65
 
--error ER_INVALID_ON_UPDATE
 
61
--error 1294
66
62
create table t1 (a datetime on update now());
67
 
--error ER_INVALID_DEFAULT
 
63
--error 1067
68
64
create table t1 (a int default 100 auto_increment);
69
65
# TODO: Should this really fail? What's wrong with default 1000 ???
70
 
#--error ER_INVALID_DEFAULT
 
66
#--error 1067
71
67
#create table t1 (a int default 1000);
72
 
--error ER_INVALID_DEFAULT
 
68
--error 1067
73
69
create table t1 (a varchar(5) default 'abcdef');
74
70
 
75
71
create table t1 (a varchar(5) default 'abcde');
76
72
insert into t1 values();
77
73
select * from t1;
78
 
--error ER_INVALID_DEFAULT
 
74
--error 1067
79
75
alter table t1 alter column a set default 'abcdef';
80
76
drop table t1;
81
77
 
99
95
drop table mysqltest.test2$;
100
96
drop database mysqltest;
101
97
 
102
 
--error ER_WRONG_TABLE_NAME
 
98
--error 1103
103
99
create table `` (a int);
104
 
--error ER_WRONG_TABLE_NAME
 
100
--error 1103
105
101
drop table if exists ``;
106
 
--error ER_WRONG_COLUMN_NAME
 
102
--error 1166
107
103
create table t1 (`` int);
108
 
--error ER_WRONG_NAME_FOR_INDEX
 
104
--error 1280
109
105
create table t1 (i int, index `` (i)); 
110
106
 
111
107
#
144
140
describe t1;
145
141
describe t2;
146
142
drop table if exists t2;
147
 
--error ER_DUP_FIELDNAME
 
143
--error 1060
148
144
create table t2 (a int, a float) select * from t1;               
149
145
drop table if exists t2;
150
 
--error ER_DUP_FIELDNAME
 
146
--error 1060
151
147
create table t2 (a int) select a as b, a+1 as b from t1;         
152
148
drop table if exists t2;
153
 
--error ER_DUP_FIELDNAME
 
149
--error 1060
154
150
create table t2 (b int) select a as b, a+1 as b from t1;         
155
151
drop table if exists t1,t2;
156
152
 
162
158
INSERT INTO t1 values (1),(2),(1);
163
159
--error ER_DUP_ENTRY
164
160
CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
165
 
--error ER_NO_SUCH_TABLE
 
161
--error 1146
166
162
SELECT * from t2;
167
163
DROP TABLE t1;
168
164
DROP TABLE IF EXISTS t2;
189
185
CREATE TEMPORARY TABLE t1 (a int not null);
190
186
show create table t1;
191
187
drop table t1;
192
 
--error ER_UNKNOWN_STORAGE_ENGINE
 
188
--error 1286
193
189
SET SESSION storage_engine="gemini";
194
190
SELECT @@storage_engine;
195
191
CREATE TEMPORARY TABLE t1 (a int not null);
203
199
#
204
200
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
205
201
insert into t1 values ("a", 1), ("b", 2);
206
 
--error ER_BAD_NULL_ERROR
 
202
--error 1048
207
203
insert into t1 values ("c", NULL);
208
 
--error ER_BAD_NULL_ERROR
 
204
--error 1048
209
205
insert into t1 values (NULL, 3);
210
 
--error ER_BAD_NULL_ERROR
 
206
--error 1048
211
207
insert into t1 values (NULL, NULL);
212
208
drop table t1;
213
209
 
223
219
#
224
220
 
225
221
create table t1 select 1,2,3;
226
 
--error ER_NO_DEFAULT_FOR_FIELD
 
222
--error 1364
227
223
create table if not exists t1 select 1,2;
228
 
--error ER_WRONG_VALUE_COUNT_ON_ROW
 
224
--error 1136
229
225
create table if not exists t1 select 1,2,3,4;
230
 
--error ER_NO_DEFAULT_FOR_FIELD
 
226
--error 1364
231
227
create table if not exists t1 select 1;
232
228
select * from t1;
233
229
drop table t1;
246
242
--error ER_DUP_ENTRY
247
243
create table if not exists t1 select 3 as 'a',3 as 'b';
248
244
show warnings;
249
 
--replace_column 3 # 4 # 5 #
250
 
select * from DATA_DICTIONARY.TABLE_DEFINITION_CACHE WHERE TABLE_COUNT > 1 ORDER BY TABLE_SCHEMA, TABLE_NAME;
 
245
show status like "Opened_tables";
251
246
select * from t1;
252
247
drop table t1;
253
248
 
256
251
#   "Table truncated when creating another table name with Spaces"
257
252
#
258
253
 
259
 
--error ER_WRONG_TABLE_NAME
 
254
--error 1103
260
255
create table `t1 `(a int);
261
 
--error ER_WRONG_DB_NAME
 
256
--error 1102
262
257
create database `db1 `;
263
 
--error ER_WRONG_COLUMN_NAME
 
258
--error 1166
264
259
create table t1(`a ` int);
265
260
 
266
261
#
268
263
#   "Parser permits multiple commas without syntax error"
269
264
#
270
265
 
271
 
--error ER_PARSE_ERROR
 
266
--error 1064
272
267
create table t1 (a int,);
273
 
--error ER_PARSE_ERROR
 
268
--error 1064
274
269
create table t1 (a int,,b int);
275
 
--error ER_PARSE_ERROR
 
270
--error 1064
276
271
create table t1 (,b int);
277
272
 
278
273
#
281
276
 
282
277
create table t1 (a int, key(a));
283
278
create table t2 (b int, foreign key(b) references t1(a), key(b));
284
 
--error ER_ROW_IS_REFERENCED
 
279
--error 1217
285
280
drop table if exists t1,t2;
286
281
drop table if exists t2,t1;
287
282
 
320
315
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
321
316
show create table t2;
322
317
select * from t2;
323
 
--error ER_TABLE_EXISTS_ERROR
324
318
create table t3 like t1;
325
 
--error ER_TABLE_EXISTS_ERROR
 
319
--error 1050
326
320
create table t3 like mysqltest.t3;
327
 
--error ER_BAD_DB_ERROR
 
321
--error 1049
328
322
create table non_existing_database.t1 like t1;
329
323
--error ER_NO_SUCH_TABLE
330
324
create table t3 like non_existing_table;
331
 
--error ER_TABLE_EXISTS_ERROR
 
325
--error 1050
332
326
create temporary table t3 like t1;
333
327
drop table t1, t2, t3;
 
328
drop table t3;
334
329
drop database mysqltest;
335
330
 
336
331
#
341
336
CREATE TEMPORARY TABLE t1 (a int not null);
342
337
show create table t1;
343
338
drop table t1;
344
 
--error ER_UNKNOWN_STORAGE_ENGINE
 
339
--error 1286
345
340
SET SESSION storage_engine="gemini";
346
341
SELECT @@storage_engine;
347
342
CREATE TEMPORARY TABLE t1 (a int not null);
382
377
drop table t1, t2;
383
378
 
384
379
create table t1 (a int, b int, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), j date, k timestamp, l datetime, m enum('a','b'), o char(10));
385
 
SHOW CREATE TABLE t1;
386
380
create table t2 select ifnull(a,a), ifnull(b,b), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(o,o) from t1;
387
381
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
388
382
show create table t2;
413
407
#
414
408
 
415
409
create table t1(cenum enum('a'));
416
 
--error ER_DUPLICATED_VALUE_IN_TYPE
 
410
--error 1291
417
411
create table t2(cenum enum('a','a'));
418
 
--error ER_DUPLICATED_VALUE_IN_TYPE
 
412
--error 1291
419
413
create table t3(cenum enum('a','A','a','c','c'));
420
414
drop table t1;
421
415
 
435
429
#
436
430
 
437
431
## TODO: Is this really a bug? It works in Drizzle. Should it?
438
 
#--error ER_WRONG_NAME_FOR_INDEX
 
432
#--error 1280
439
433
#create table t1 (a int, index `primary` (a));
440
 
#--error ER_WRONG_NAME_FOR_INDEX
 
434
#--error 1280
441
435
#create table t1 (a int, index `PRIMARY` (a));
442
436
#
443
437
#create table t1 (`primary` int, index(`primary`));
448
442
#show create table t2;
449
443
#
450
444
#create table t3 (a int);
451
 
#--error ER_WRONG_NAME_FOR_INDEX
 
445
#--error 1280
452
446
#alter table t3 add index `primary` (a);
453
 
#--error ER_WRONG_NAME_FOR_INDEX
 
447
#--error 1280
454
448
#alter table t3 add index `PRIMARY` (a);
455
449
#
456
450
#create table t4 (`primary` int);
486
480
# an improper fix is present.
487
481
#
488
482
create table t1 (a int);
489
 
--error ER_UPDATE_TABLE_USED
 
483
--error 1093
490
484
create table t1 select * from t1;
491
485
## TODO: Huh? --error ER_WRONG_OBJECT
492
486
#create table t2 union = (t1) select * from t1;
497
491
#
498
492
# Bug#10413: Invalid column name is not rejected
499
493
#
500
 
--error ER_WRONG_TABLE_NAME
 
494
--error 1103
501
495
create table t1(column.name int);
502
 
--error ER_WRONG_TABLE_NAME
 
496
--error 1103
503
497
create table t1(test.column.name int);
504
 
--error ER_WRONG_DB_NAME
 
498
--error 1102
505
499
create table t1(xyz.t1.name int);
506
500
create table t1(t1.name int);
507
501
create table t2(test.t2.name int);
574
568
show create table t1;
575
569
drop table t1;
576
570
 
577
 
--error ER_NO_DEFAULT_FOR_FIELD
 
571
--error 1364
578
572
create table t1 ( 
579
573
  a varchar(12) collate utf8_bin not null, 
580
574
  b int not null, primary key (a)
1028
1022
# to be rewritten to hit the limit
1029
1023
#
1030
1024
# Ensure limit is really 64 keys
1031
 
--error ER_TOO_MANY_KEYS
 
1025
--error 1069
1032
1026
alter table t1 add key 
1033
1027
 a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
1034
1028
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1042
1036
c16 int, c17 int);
1043
1037
 
1044
1038
# Get error for max key parts
1045
 
--error ER_TOO_MANY_KEY_PARTS
 
1039
--error 1070
1046
1040
alter table t1 add key i1 (
1047
1041
 c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
1048
1042
 
1049
1043
# Get error for max key-name length
1050
 
--error ER_TOO_LONG_IDENT
 
1044
--error 1059
1051
1045
alter table t1 add key 
1052
1046
 a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
1053
1047
 
1102
1096
# precedence
1103
1097
 
1104
1098
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
1105
 
#SHOW INDEX FROM t1;
 
1099
SHOW INDEX FROM t1;
1106
1100
DROP TABLE t1;
1107
1101
 
1108
1102
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
1109
 
#SHOW INDEX FROM t1;
 
1103
SHOW INDEX FROM t1;
1110
1104
DROP TABLE t1;
1111
1105
 
1112
1106
 
1152
1146
# Test incorrect database names
1153
1147
#
1154
1148
 
1155
 
--error ER_WRONG_DB_NAME
 
1149
--error 1102
1156
1150
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1157
 
--error ER_WRONG_DB_NAME
 
1151
--error 1102
1158
1152
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1159
1153
 
1160
1154
# TODO: enable these tests when RENAME DATABASE is implemented.
1161
 
# --error ER_BAD_DB_ERROR
 
1155
# --error 1049
1162
1156
# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a;
1163
 
# --error ER_WRONG_DB_NAME
 
1157
# --error 1102
1164
1158
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1165
1159
# create database mysqltest;
1166
 
# --error ER_WRONG_DB_NAME
 
1160
# --error 1102
1167
1161
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1168
1162
# drop database mysqltest;
1169
1163
 
1170
 
--error ER_WRONG_DB_NAME
 
1164
--error 1102
1171
1165
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1172
 
#--error ER_WRONG_DB_NAME
 
1166
--error 1102
1173
1167
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1174
1168
 
1175
 
##
1176
 
## Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1177
 
##
 
1169
#
 
1170
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
 
1171
#
1178
1172
 
1179
1173
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1180
1174
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1181
1175
select database();
1182
1176
use test;
1183
1177
 
1184
 
select SCHEMA_NAME from data_dictionary.schemas
 
1178
select SCHEMA_NAME from information_schema.schemata
1185
1179
where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45';
1186
1180
 
1187
1181
drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1195
1189
# database, table, field, key
1196
1190
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1197
1191
 
1198
 
select TABLE_NAME from data_dictionary.tables where
1199
 
table_schema='test';
1200
 
 
1201
 
select COLUMN_NAME from data_dictionary.columns where
1202
 
table_schema='test';
1203
 
 
1204
 
select INDEX_NAME from data_dictionary.indexes where
 
1192
select TABLE_NAME from information_schema.tables where
 
1193
table_schema='test';
 
1194
 
 
1195
select COLUMN_NAME from information_schema.columns where
 
1196
table_schema='test';
 
1197
 
 
1198
select INDEX_NAME from information_schema.statistics where
1205
1199
table_schema='test';
1206
1200
 
1207
1201
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1209
1203
 
1210
1204
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1211
1205
 
1212
 
#
 
1206
 
1213
1207
#
1214
1208
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
1215
1209
#
1216
 
--error ER_CANT_CREATE_TABLE
1217
 
create table t1 like data_dictionary.processlist;
1218
 
create table t1 like data_dictionary.processlist engine=innodb;
 
1210
--error 1478
 
1211
create table t1 like information_schema.processlist;
 
1212
create table t1 like information_schema.processlist engine=innodb;
1219
1213
show create table t1;
1220
1214
drop table t1;
1221
 
--error ER_CANT_CREATE_TABLE
1222
 
create temporary table t1 like data_dictionary.processlist;
1223
 
create temporary table t1 like data_dictionary.processlist engine=myisam;
 
1215
--error 1478
 
1216
create temporary table t1 like information_schema.processlist;
 
1217
create temporary table t1 like information_schema.processlist engine=myisam;
1224
1218
show create table t1;
1225
1219
drop table t1;
1226
1220
 
1248
1242
  c4 VARCHAR(255) NOT NULL DEFAULT 'a',
1249
1243
  c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
1250
1244
  c6 VARCHAR(255))
1251
 
  COLLATE=utf8_bin;
 
1245
  COLLATE utf8_bin;
1252
1246
 
1253
1247
--echo
1254
1248
 
1315
1309
--echo
1316
1310
 
1317
1311
CREATE TABLE t3(c1 DATETIME NOT NULL);
1318
 
--error ER_INVALID_DATETIME_VALUE # Bad datetime
 
1312
--error 1686 # Bad datetime
1319
1313
INSERT INTO t3 VALUES (0);
1320
1314
 
1321
1315
--echo