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
18
18
insert into t1 values (""),(null);
22
create temporary table t1 (a int not null auto_increment,primary key (a)) engine=MEMORY;
22
create temporary table t1 (a int not null auto_increment,primary key (a)) engine=heap;
26
26
# Test of some CREATE TABLE'S that should fail
29
--error ER_TABLE_UNKNOWN
30
create temporary table t2 engine=MEMORY select * from t1;
31
--error ER_TABLE_UNKNOWN
30
create temporary table t2 engine=heap select * from t1;
32
32
create table t2 select auto+1 from t1;
33
33
drop table if exists t1,t2;
34
--error ER_WRONG_KEY_COLUMN
35
35
create table t1 (b char(0) not null, index(b));
36
--error ER_TABLE_CANT_HANDLE_BLOB
37
create temporary table t1 (a int not null,b text) engine=MEMORY;
37
create temporary table t1 (a int not null,b text) engine=heap;
38
38
drop table if exists t1;
40
--error ER_WRONG_AUTO_KEY
41
create temporary table t1 (ordid int not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=MEMORY;
41
create temporary table t1 (ordid int not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap;
43
44
create table not_existing_database.test (a int);
44
45
create table `a/a` (a int);
45
46
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
46
47
show create table `a/a`;
47
48
create table t1 like `a/a`;
48
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
50
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
51
show create table `t1`;
54
--error ER_WRONG_TABLE_NAME
55
52
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
56
--error ER_TOO_LONG_IDENT
57
54
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
60
57
# Some wrong defaults, so these creates should fail too (Bug #5902)
62
--error ER_INVALID_DEFAULT
63
60
create table t1 (a datetime default now());
64
--error ER_INVALID_ON_UPDATE
65
62
create table t1 (a datetime on update now());
66
--error ER_INVALID_DEFAULT
67
64
create table t1 (a int default 100 auto_increment);
68
65
# TODO: Should this really fail? What's wrong with default 1000 ???
69
#--error ER_INVALID_DEFAULT
70
67
#create table t1 (a int default 1000);
71
--error ER_INVALID_DEFAULT
72
69
create table t1 (a varchar(5) default 'abcdef');
74
71
create table t1 (a varchar(5) default 'abcde');
75
72
insert into t1 values();
77
--error ER_INVALID_DEFAULT
78
75
alter table t1 alter column a set default 'abcdef';
99
95
drop table mysqltest.test2$;
100
96
drop database mysqltest;
102
--error ER_WRONG_TABLE_NAME
103
99
create table `` (a int);
104
--error ER_WRONG_TABLE_NAME
105
101
drop table if exists ``;
106
--error ER_WRONG_COLUMN_NAME
107
103
create table t1 (`` int);
108
--error ER_WRONG_NAME_FOR_INDEX
109
105
create table t1 (i int, index `` (i));
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
207
203
insert into t1 values ("c", NULL);
208
--error ER_BAD_NULL_ERROR
209
205
insert into t1 values (NULL, 3);
210
--error ER_BAD_NULL_ERROR
211
207
insert into t1 values (NULL, NULL);
225
221
create table t1 select 1,2,3;
226
--error ER_NO_DEFAULT_FOR_FIELD
227
223
create table if not exists t1 select 1,2;
228
--error ER_WRONG_VALUE_COUNT_ON_ROW
229
225
create table if not exists t1 select 1,2,3,4;
230
--error ER_NO_DEFAULT_FOR_FIELD
231
227
create table if not exists t1 select 1;
232
228
select * from t1;
314
309
create database mysqltest;
315
310
create table mysqltest.t3 like t1;
316
311
create temporary table t3 like mysqltest.t3;
318
312
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
319
313
show create table t3;
321
314
create table t2 like t3;
323
315
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
324
316
show create table t2;
325
317
select * from t2;
327
--error ER_TABLE_EXISTS_ERROR
328
318
create table t3 like t1;
330
--error ER_TABLE_EXISTS_ERROR
331
320
create table t3 like mysqltest.t3;
333
--error ER_BAD_DB_ERROR
334
322
create table non_existing_database.t1 like t1;
336
--error ER_TABLE_UNKNOWN
337
create table t4 like non_existing_table;
339
--error ER_TABLE_EXISTS_ERROR
323
--error ER_NO_SUCH_TABLE
324
create table t3 like non_existing_table;
340
326
create temporary table t3 like t1;
341
327
drop table t1, t2, t3;
342
329
drop database mysqltest;
345
332
# Test default table type
347
SET SESSION storage_engine="MEMORY";
334
SET SESSION storage_engine="heap";
348
335
SELECT @@storage_engine;
349
336
CREATE TEMPORARY TABLE t1 (a int not null);
350
337
show create table t1;
352
--error ER_UNKNOWN_STORAGE_ENGINE
353
340
SET SESSION storage_engine="gemini";
354
341
SELECT @@storage_engine;
355
342
CREATE TEMPORARY TABLE t1 (a int not null);
390
377
drop table t1, t2;
392
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));
393
SHOW CREATE TABLE t1;
394
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;
395
381
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
396
382
show create table t2;
423
409
create table t1(cenum enum('a'));
424
--error ER_DUPLICATED_VALUE_IN_TYPE
425
411
create table t2(cenum enum('a','a'));
426
--error ER_DUPLICATED_VALUE_IN_TYPE
427
413
create table t3(cenum enum('a','A','a','c','c'));
445
431
## TODO: Is this really a bug? It works in Drizzle. Should it?
446
#--error ER_WRONG_NAME_FOR_INDEX
447
433
#create table t1 (a int, index `primary` (a));
448
#--error ER_WRONG_NAME_FOR_INDEX
449
435
#create table t1 (a int, index `PRIMARY` (a));
451
437
#create table t1 (`primary` int, index(`primary`));
506
492
# Bug#10413: Invalid column name is not rejected
508
--error ER_WRONG_TABLE_NAME
509
495
create table t1(column.name int);
510
--error ER_WRONG_TABLE_NAME
511
497
create table t1(test.column.name int);
512
--error ER_WRONG_DB_NAME
513
499
create table t1(xyz.t1.name int);
514
500
create table t1(t1.name int);
515
501
create table t2(test.t2.name int);
1036
1022
# to be rewritten to hit the limit
1038
1024
# Ensure limit is really 64 keys
1039
--error ER_TOO_MANY_KEYS
1040
1026
alter table t1 add key
1041
1027
a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
1042
1028
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1050
1036
c16 int, c17 int);
1052
1038
# Get error for max key parts
1053
--error ER_TOO_MANY_KEY_PARTS
1054
1040
alter table t1 add key i1 (
1055
1041
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
1057
1043
# Get error for max key-name length
1058
--error ER_TOO_LONG_IDENT
1059
1045
alter table t1 add key
1060
1046
a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
1160
1146
# Test incorrect database names
1163
--error ER_WRONG_DB_NAME
1164
1150
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1165
--error ER_WRONG_DB_NAME
1166
1152
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1168
1154
# TODO: enable these tests when RENAME DATABASE is implemented.
1169
# --error ER_BAD_DB_ERROR
1170
1156
# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a;
1171
# --error ER_WRONG_DB_NAME
1172
1158
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1173
1159
# create database mysqltest;
1174
# --error ER_WRONG_DB_NAME
1175
1161
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1176
1162
# drop database mysqltest;
1178
--error ER_WRONG_DB_NAME
1179
1165
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1180
#--error ER_WRONG_DB_NAME
1181
1167
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1184
## Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1170
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1187
1173
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1188
1174
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1189
1175
select database();
1192
select SCHEMA_NAME from data_dictionary.schemas
1178
select SCHEMA_NAME from information_schema.schemata
1193
1179
where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45';
1195
1181
drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1203
1189
# database, table, field, key
1204
1190
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1206
select TABLE_NAME from data_dictionary.tables where
1207
table_schema='test';
1209
select COLUMN_NAME from data_dictionary.columns where
1210
table_schema='test';
1212
select INDEX_NAME from data_dictionary.indexes where
1192
select TABLE_NAME from information_schema.tables where
1193
table_schema='test';
1195
select COLUMN_NAME from information_schema.columns where
1196
table_schema='test';
1198
select INDEX_NAME from information_schema.statistics where
1213
1199
table_schema='test';
1215
1201
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1218
1204
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1222
1208
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
1224
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1225
create table t1 like data_dictionary.processlist;
1226
create table t1 like data_dictionary.processlist engine=innodb;
1210
create table t1 like information_schema.processlist;
1227
1211
show create table t1;
1229
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1230
create temporary table t1 like data_dictionary.processlist;
1231
create temporary table t1 like data_dictionary.processlist engine=myisam;
1213
create temporary table t1 like information_schema.processlist;
1232
1214
show create table t1;