~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Check some special create statements.
3
#
4
5
--disable_warnings
6
drop table if exists t1,t2,t3,t4,t5;
7
drop database if exists mysqltest;
8
--enable_warnings
9
10
create table t1 (b char(0));
11
insert into t1 values (""),(null);
12
select * from t1;
13
drop table if exists t1;
14
15
create table t1 (b char(0) not null);
16
create table if not exists t1 (b char(0) not null);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
17
--error ER_BAD_NULL_ERROR
1 by brian
clean slate
18
insert into t1 values (""),(null);
19
select * from t1;
20
drop table t1;
21
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
22
create temporary table t1 (a int not null auto_increment,primary key (a)) engine=MEMORY;
1 by brian
clean slate
23
drop table t1;
24
25
#
26
# Test of some CREATE TABLE'S that should fail
27
#
28
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
29
--error ER_TABLE_UNKNOWN
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
30
create temporary table t2 engine=MEMORY select * from t1;
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
31
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
32
create table t2 select auto+1 from t1;
33
drop table if exists t1,t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
34
--error ER_WRONG_KEY_COLUMN
1 by brian
clean slate
35
create table t1 (b char(0) not null, index(b));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
36
--error ER_TABLE_CANT_HANDLE_BLOB
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
37
create temporary table t1 (a int not null,b text) engine=MEMORY;
1 by brian
clean slate
38
drop table if exists t1;
39
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
40
--error ER_WRONG_AUTO_KEY
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
41
create temporary table t1 (ordid int not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=MEMORY;
1 by brian
clean slate
42
2114.2.1 by Brian Aker
Next pass through of tests (remove number, use label for error).
43
-- error ER_BAD_DB_ERROR
1 by brian
clean slate
44
create table not_existing_database.test (a int);
45
create table `a/a` (a int);
942.3.1 by Vladimir Kolesnikov
test generalizations
46
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
47
show create table `a/a`;
48
create table t1 like `a/a`;
1547 by Brian Aker
This fixes a bug where we did a full open for a temporary table for CREATE
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`;
1 by brian
clean slate
53
drop table `a/a`;
54
drop table `t1`;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
55
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
56
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
57
--error ER_TOO_LONG_IDENT
1 by brian
clean slate
58
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
59
60
#
61
# Some wrong defaults, so these creates should fail too (Bug #5902)
62
#
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
63
--error ER_INVALID_DEFAULT
1 by brian
clean slate
64
create table t1 (a datetime default now());
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
65
--error ER_INVALID_ON_UPDATE
1 by brian
clean slate
66
create table t1 (a datetime on update now());
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
67
--error ER_INVALID_DEFAULT
1 by brian
clean slate
68
create table t1 (a int default 100 auto_increment);
722.2.15 by Monty Taylor
Fixed create.test.
69
# TODO: Should this really fail? What's wrong with default 1000 ???
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
70
#--error ER_INVALID_DEFAULT
722.2.15 by Monty Taylor
Fixed create.test.
71
#create table t1 (a int default 1000);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
72
--error ER_INVALID_DEFAULT
1 by brian
clean slate
73
create table t1 (a varchar(5) default 'abcdef');
74
75
create table t1 (a varchar(5) default 'abcde');
76
insert into t1 values();
77
select * from t1;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
78
--error ER_INVALID_DEFAULT
1 by brian
clean slate
79
alter table t1 alter column a set default 'abcdef';
80
drop table t1;
81
82
#
83
# test of dummy table names
84
#
85
86
create table 1ea10 (1a20 int,1e int);
87
insert into 1ea10 values(1,1);
88
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
89
drop table 1ea10;
90
create table t1 (t1.index int);
91
drop table t1;
92
# Test that we get warning for this
93
drop database if exists mysqltest;
94
create database mysqltest;
95
create table mysqltest.$test1 (a$1 int, $b int, c$ int);
96
insert into mysqltest.$test1 values (1,2,3);
97
select a$1, $b, c$ from mysqltest.$test1;
98
create table mysqltest.test2$ (a int);
99
drop table mysqltest.test2$;
100
drop database mysqltest;
101
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
102
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
103
create table `` (a int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
104
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
105
drop table if exists ``;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
106
--error ER_WRONG_COLUMN_NAME
1 by brian
clean slate
107
create table t1 (`` int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
108
--error ER_WRONG_NAME_FOR_INDEX
1 by brian
clean slate
109
create table t1 (i int, index `` (i)); 
110
111
#
112
# Test of CREATE ... SELECT with indexes
113
#
114
115
create table t1 (a int auto_increment not null primary key, B CHAR(20));
116
insert into t1 (b) values ("hello"),("my"),("world");
117
create table t2 (key (b)) select * from t1;
118
explain select * from t2 where b="world";
119
select * from t2 where b="world";
120
drop table t1,t2;
121
122
#
123
# Test types after CREATE ... SELECT
124
#
125
126
create table t1(x varchar(50) );
127
create table t2 select x from t1 where 1=2;
128
describe t1;
129
describe t2;
130
drop table t2;
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
131
create table t2 select now() as a , curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
1 by brian
clean slate
132
describe t2;
133
drop table t2;
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
134
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("2001-12-29  20:45:11" AS DATETIME) as dt;
1 by brian
clean slate
135
describe t2;
136
drop table t1,t2;
137
138
#
139
# Test of CREATE ... SELECT with duplicate fields
140
#
141
396 by Brian Aker
Cleanup tiny and small int.
142
create table t1 (a int);
1 by brian
clean slate
143
create table t2 (a int) select * from t1;                        
144
describe t1;
145
describe t2;
146
drop table if exists t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
147
--error ER_DUP_FIELDNAME
1 by brian
clean slate
148
create table t2 (a int, a float) select * from t1;               
149
drop table if exists t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
150
--error ER_DUP_FIELDNAME
1 by brian
clean slate
151
create table t2 (a int) select a as b, a+1 as b from t1;         
152
drop table if exists t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
153
--error ER_DUP_FIELDNAME
1 by brian
clean slate
154
create table t2 (b int) select a as b, a+1 as b from t1;         
155
drop table if exists t1,t2;
156
157
#
158
# Test CREATE ... SELECT when insert fails
159
#
160
161
CREATE TABLE t1 (a int not null);
162
INSERT INTO t1 values (1),(2),(1);
163
--error ER_DUP_ENTRY
164
CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
165
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
166
SELECT * from t2;
167
DROP TABLE t1;
168
DROP TABLE IF EXISTS t2;
169
170
#
171
# Test of primary key with 32 index
172
#
173
174
create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b));
942.3.1 by Vladimir Kolesnikov
test generalizations
175
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
176
show create table t1;
177
drop table t1;
178
create table t1 select if(1,'1','0'), month("2002-08-02");
179
drop table t1;
180
create table t1 select if('2002'='2002','Y','N');
181
select * from t1;
182
drop table if exists t1;
183
184
#
185
# Test default table type
186
#
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
187
SET SESSION storage_engine="MEMORY";
1 by brian
clean slate
188
SELECT @@storage_engine;
1106.3.1 by Brian Aker
Heap is now tmp only table
189
CREATE TEMPORARY TABLE t1 (a int not null);
1 by brian
clean slate
190
show create table t1;
191
drop table t1;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
192
--error ER_UNKNOWN_STORAGE_ENGINE
1 by brian
clean slate
193
SET SESSION storage_engine="gemini";
194
SELECT @@storage_engine;
1106.3.1 by Brian Aker
Heap is now tmp only table
195
CREATE TEMPORARY TABLE t1 (a int not null);
1 by brian
clean slate
196
show create table t1;
197
SET SESSION storage_engine=default;
198
drop table t1;
199
200
201
#
202
# ISO requires that primary keys are implicitly NOT NULL
203
#
204
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
205
insert into t1 values ("a", 1), ("b", 2);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
206
--error ER_BAD_NULL_ERROR
1 by brian
clean slate
207
insert into t1 values ("c", NULL);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
208
--error ER_BAD_NULL_ERROR
1 by brian
clean slate
209
insert into t1 values (NULL, 3);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
210
--error ER_BAD_NULL_ERROR
1 by brian
clean slate
211
insert into t1 values (NULL, NULL);
212
drop table t1;
213
214
#
215
# Bug # 801
216
#
217
218
create table t1 select x'4132';
219
drop table t1;
220
221
#
222
# bug #1434
223
#
224
225
create table t1 select 1,2,3;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
226
--error ER_NO_DEFAULT_FOR_FIELD
1 by brian
clean slate
227
create table if not exists t1 select 1,2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
228
--error ER_WRONG_VALUE_COUNT_ON_ROW
1 by brian
clean slate
229
create table if not exists t1 select 1,2,3,4;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
230
--error ER_NO_DEFAULT_FOR_FIELD
1 by brian
clean slate
231
create table if not exists t1 select 1;
232
select * from t1;
233
drop table t1;
234
235
#
236
# Test create table if not exists with duplicate key error
237
#
238
239
flush status;
240
create table t1 (a int not null, b int, primary key (a));
241
insert into t1 values (1,1);
722.2.15 by Monty Taylor
Fixed create.test.
242
# TODO: BUG here, this is filling in right to left for some reason
243
#create table if not exists t1 select 2;
1 by brian
clean slate
244
select * from t1;
245
create table if not exists t1 select 3 as 'a',4 as 'b';
246
--error ER_DUP_ENTRY
247
create table if not exists t1 select 3 as 'a',3 as 'b';
248
show warnings;
1345 by Brian Aker
Corrections.
249
--replace_column 3 # 4 # 5 #
2024.1.2 by Brian Aker
Update to tests, we just want to look at our own tables, not global.
250
select * from DATA_DICTIONARY.TABLE_DEFINITION_CACHE WHERE TABLE_COUNT AND TABLE_SCHEMA = SCHEMA() > 1 ORDER BY TABLE_SCHEMA, TABLE_NAME;
1 by brian
clean slate
251
select * from t1;
252
drop table t1;
253
254
#
255
# Test for Bug #2985 
256
#   "Table truncated when creating another table name with Spaces"
257
#
258
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
259
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
260
create table `t1 `(a int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
261
--error ER_WRONG_DB_NAME
1 by brian
clean slate
262
create database `db1 `;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
263
--error ER_WRONG_COLUMN_NAME
1 by brian
clean slate
264
create table t1(`a ` int);
265
266
#
267
# Test for Bug #3481 
268
#   "Parser permits multiple commas without syntax error"
269
#
270
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
271
--error ER_PARSE_ERROR
1 by brian
clean slate
272
create table t1 (a int,);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
273
--error ER_PARSE_ERROR
1 by brian
clean slate
274
create table t1 (a int,,b int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
275
--error ER_PARSE_ERROR
1 by brian
clean slate
276
create table t1 (,b int);
277
278
#
279
# Test create with foreign keys
280
#
281
282
create table t1 (a int, key(a));
283
create table t2 (b int, foreign key(b) references t1(a), key(b));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
284
--error ER_ROW_IS_REFERENCED
1 by brian
clean slate
285
drop table if exists t1,t2;
722.2.15 by Monty Taylor
Fixed create.test.
286
drop table if exists t2,t1;
1 by brian
clean slate
287
288
#
289
# Test for CREATE TABLE .. LIKE ..
290
#
291
292
create table t1(id int not null, name char(20));
293
insert into t1 values(10,'mysql'),(20,'monty- the creator');
294
create table t2(id int not null);
295
insert into t2 values(10),(20);
296
create table t3 like t1;
942.3.1 by Vladimir Kolesnikov
test generalizations
297
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
298
show create table t3;
299
select * from t3;
300
# Disable PS becasue of @@warning_count
301
create table if not exists t3 like t1;
302
--disable_ps_protocol
303
select @@warning_count;
304
--enable_ps_protocol
305
create temporary table t3 like t2;
942.3.1 by Vladimir Kolesnikov
test generalizations
306
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
307
show create table t3;
308
select * from t3;
309
drop table t3;
942.3.1 by Vladimir Kolesnikov
test generalizations
310
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
311
show create table t3;
312
select * from t3;
313
drop table t2, t3;
314
create database mysqltest;
315
create table mysqltest.t3 like t1;
316
create temporary table t3 like mysqltest.t3;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
317
942.3.1 by Vladimir Kolesnikov
test generalizations
318
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
319
show create table t3;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
320
1 by brian
clean slate
321
create table t2 like t3;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
322
942.3.1 by Vladimir Kolesnikov
test generalizations
323
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
324
show create table t2;
325
select * from t2;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
326
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
327
--error ER_TABLE_EXISTS_ERROR
1 by brian
clean slate
328
create table t3 like t1;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
329
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
330
--error ER_TABLE_EXISTS_ERROR
1 by brian
clean slate
331
create table t3 like mysqltest.t3;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
332
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
333
--error ER_BAD_DB_ERROR
1 by brian
clean slate
334
create table non_existing_database.t1 like t1;
2079.3.1 by Brian Aker
Rework the CREATE TABLE LIKE call.
335
336
--error ER_TABLE_UNKNOWN
337
create table t4 like non_existing_table;
338
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
339
--error ER_TABLE_EXISTS_ERROR
1 by brian
clean slate
340
create temporary table t3 like t1;
341
drop table t1, t2, t3;
342
drop database mysqltest;
343
344
#
345
# Test default table type
346
#
1233.2.1 by Monty Taylor
Renamed instances of HEAP engine to MEMORY. Removed the alias.
347
SET SESSION storage_engine="MEMORY";
1 by brian
clean slate
348
SELECT @@storage_engine;
1106.3.1 by Brian Aker
Heap is now tmp only table
349
CREATE TEMPORARY TABLE t1 (a int not null);
1 by brian
clean slate
350
show create table t1;
351
drop table t1;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
352
--error ER_UNKNOWN_STORAGE_ENGINE
1 by brian
clean slate
353
SET SESSION storage_engine="gemini";
354
SELECT @@storage_engine;
1106.3.1 by Brian Aker
Heap is now tmp only table
355
CREATE TEMPORARY TABLE t1 (a int not null);
1 by brian
clean slate
356
show create table t1;
357
SET SESSION storage_engine=default;
358
drop table t1;
359
360
#
361
# Test types of data for create select with functions
362
#
363
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
364
create table t1(a int,b int,c int,d date,e char,f datetime,h blob);
1 by brian
clean slate
365
insert into t1(a)values(1);
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
366
insert into t1(a,b,c,d,e,f,h)
367
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','binary data');
1 by brian
clean slate
368
select * from t1;
369
select a, 
722.2.15 by Monty Taylor
Fixed create.test.
370
    ifnull(b,-7) as b, 
371
    ifnull(c,7) as c, 
1 by brian
clean slate
372
    ifnull(d,cast('2000-01-01' as date)) as d, 
373
    ifnull(e,cast('b' as char)) as e,
374
    ifnull(f,cast('2000-01-01' as datetime)) as f, 
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
375
    ifnull(h,cast('yet another binary data' as binary)) as h
1 by brian
clean slate
376
from t1;
377
378
create table t2
379
select
380
    a, 
722.2.15 by Monty Taylor
Fixed create.test.
381
    ifnull(b,-7)                            as b,
382
    ifnull(c,7)                             as c,
1 by brian
clean slate
383
    ifnull(d,cast('2000-01-01'              as date))     as d,
384
    ifnull(e,cast('b'                       as char))     as e,
385
    ifnull(f,cast('2000-01-01'              as datetime)) as f,
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
386
    ifnull(h,cast('yet another binary data' as binary))   as h
1 by brian
clean slate
387
from t1;
388
explain t2;
389
select * from t2;
390
drop table t1, t2;
391
722.2.15 by Monty Taylor
Fixed create.test.
392
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));
1996.2.1 by Brian Aker
uuid type code.
393
SHOW CREATE TABLE t1;
722.2.15 by Monty Taylor
Fixed create.test.
394
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;
942.3.1 by Vladimir Kolesnikov
test generalizations
395
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
396
show create table t2;
397
drop table t1,t2;
398
399
#
400
# Test of default()
401
#
402
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
403
insert into t1 values ('','',0,0.0);
404
describe t1;
405
create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1;
406
describe t2;
407
drop table t1, t2;
408
409
#
410
# Bug #2075
411
#
412
396 by Brian Aker
Cleanup tiny and small int.
413
create table t1(name varchar(10), age int default -1);
1 by brian
clean slate
414
describe t1;
396 by Brian Aker
Cleanup tiny and small int.
415
create table t2(name varchar(10), age int default - 1);
1 by brian
clean slate
416
describe t2;
417
drop table t1, t2;
418
419
#
420
# test for bug #1427 "enum allows duplicate values in the list"
421
#
422
722.2.15 by Monty Taylor
Fixed create.test.
423
create table t1(cenum enum('a'));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
424
--error ER_DUPLICATED_VALUE_IN_TYPE
722.2.15 by Monty Taylor
Fixed create.test.
425
create table t2(cenum enum('a','a'));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
426
--error ER_DUPLICATED_VALUE_IN_TYPE
722.2.15 by Monty Taylor
Fixed create.test.
427
create table t3(cenum enum('a','A','a','c','c'));
428
drop table t1;
1 by brian
clean slate
429
430
#
431
# Bug #1209
432
#
433
434
create database mysqltest;
435
use mysqltest;
436
select database();
437
drop database mysqltest;
438
select database();
439
use test;
440
441
#
442
# Test for Bug 856 'Naming a key "Primary" causes trouble'
443
#
444
722.2.15 by Monty Taylor
Fixed create.test.
445
## TODO: Is this really a bug? It works in Drizzle. Should it?
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
446
#--error ER_WRONG_NAME_FOR_INDEX
722.2.15 by Monty Taylor
Fixed create.test.
447
#create table t1 (a int, index `primary` (a));
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
448
#--error ER_WRONG_NAME_FOR_INDEX
722.2.15 by Monty Taylor
Fixed create.test.
449
#create table t1 (a int, index `PRIMARY` (a));
450
#
451
#create table t1 (`primary` int, index(`primary`));
942.3.1 by Vladimir Kolesnikov
test generalizations
452
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
722.2.15 by Monty Taylor
Fixed create.test.
453
#show create table t1;
454
#create table t2 (`PRIMARY` int, index(`PRIMARY`));
942.3.1 by Vladimir Kolesnikov
test generalizations
455
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
722.2.15 by Monty Taylor
Fixed create.test.
456
#show create table t2;
457
#
458
#create table t3 (a int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
459
#--error ER_WRONG_NAME_FOR_INDEX
722.2.15 by Monty Taylor
Fixed create.test.
460
#alter table t3 add index `primary` (a);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
461
#--error ER_WRONG_NAME_FOR_INDEX
722.2.15 by Monty Taylor
Fixed create.test.
462
#alter table t3 add index `PRIMARY` (a);
463
#
464
#create table t4 (`primary` int);
465
#alter table t4 add index(`primary`);
942.3.1 by Vladimir Kolesnikov
test generalizations
466
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
722.2.15 by Monty Taylor
Fixed create.test.
467
#show create table t4;
468
#create table t5 (`PRIMARY` int);
469
#alter table t5 add index(`PRIMARY`);
942.3.1 by Vladimir Kolesnikov
test generalizations
470
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
722.2.15 by Monty Taylor
Fixed create.test.
471
#show create table t5;
472
#
473
#drop table t1, t2, t3, t4, t5;
1 by brian
clean slate
474
475
#
476
# bug #3266 TEXT in CREATE TABLE SELECT
477
#
478
479
CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
480
INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
481
CREATE TABLE t2(id varchar(15) NOT NULL, proc varchar(100) NOT NULL, runID varchar(16) NOT NULL, start datetime NOT NULL, PRIMARY KEY  (id,proc,runID,start));
482
483
INSERT INTO t2 VALUES ('5000000001', 'proc01', '20031029090650', '2003-10-29 13:38:40'),('5000000001', 'proc02', '20031029090650', '2003-10-29 13:38:51'),('5000000001', 'proc03', '20031029090650', '2003-10-29 13:38:11'),('5000000002', 'proc09', '20031024013310', '2003-10-24 01:33:11'),('5000000002', 'proc09', '20031024153537', '2003-10-24 15:36:04'),('5000000004', 'proc01', '20031024013641', '2003-10-24 01:37:29'),('5000000004', 'proc02', '20031024013641', '2003-10-24 01:37:39');
484
485
CREATE TABLE t3  SELECT t1.dsc,COUNT(DISTINCT t2.id) AS countOfRuns  FROM t1 LEFT JOIN t2 ON (t1.id=t2.id) GROUP BY t1.id;
486
SELECT * FROM t3;
487
drop table t1, t2, t3;
488
489
490
#
491
# Bug#10224 - ANALYZE TABLE crashing with simultaneous
492
# CREATE ... SELECT statement.
493
# This tests two additional possible errors and a hang if 
494
# an improper fix is present.
495
#
496
create table t1 (a int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
497
--error ER_UPDATE_TABLE_USED
1 by brian
clean slate
498
create table t1 select * from t1;
722.2.15 by Monty Taylor
Fixed create.test.
499
## TODO: Huh? --error ER_WRONG_OBJECT
500
#create table t2 union = (t1) select * from t1;
1 by brian
clean slate
501
flush tables with read lock;
502
unlock tables;
503
drop table t1;
504
505
#
506
# Bug#10413: Invalid column name is not rejected
507
#
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
508
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
509
create table t1(column.name int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
510
--error ER_WRONG_TABLE_NAME
1 by brian
clean slate
511
create table t1(test.column.name int);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
512
--error ER_WRONG_DB_NAME
1 by brian
clean slate
513
create table t1(xyz.t1.name int);
514
create table t1(t1.name int);
515
create table t2(test.t2.name int);
516
drop table t1,t2;
517
518
#
519
# Bug #12537: UNION produces longtext instead of varchar
520
#
722.2.15 by Monty Taylor
Fixed create.test.
521
CREATE TABLE t1 (f1 VARCHAR(255));
1 by brian
clean slate
522
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
523
DESC t2;
524
DROP TABLE t1,t2;
525
526
#
527
# Bug#12913 Simple SQL can crash server or connection
528
#
529
CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1;
530
SELECT * FROM t12913;
531
DROP TABLE t12913;
532
533
#
534
# Bug#11028: Crash on create table like
535
#
536
create database mysqltest;
537
use mysqltest;
538
drop database mysqltest;
539
--error ER_NO_DB_ERROR 
540
create table test.t1 like x;
541
--disable_warnings
542
drop table if exists test.t1;
543
--enable_warnings
544
545
# Bug #6008 MySQL does not create warnings when
546
# creating database and using IF NOT EXISTS
547
#
548
create database mysqltest;
722.2.15 by Monty Taylor
Fixed create.test.
549
create database if not exists mysqltest;
1 by brian
clean slate
550
show create database mysqltest;
551
drop database mysqltest;
552
use test;
553
create table t1 (a int);
554
create table if not exists t1 (a int);
555
drop table t1;
556
557
# BUG#14139
558
create table t1 (
722.2.15 by Monty Taylor
Fixed create.test.
559
  a varchar(112) collate utf8_bin not null,
1 by brian
clean slate
560
  primary key (a)
561
) select 'test' as a ;
562
#--warning 1364
942.3.1 by Vladimir Kolesnikov
test generalizations
563
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
564
show create table t1;
565
drop table t1;
566
567
#
568
# BUG#14480: assert failure in CREATE ... SELECT because of wrong
569
#            calculation of number of NULLs.
570
#
571
CREATE TABLE t2 (
722.2.15 by Monty Taylor
Fixed create.test.
572
  a int default NULL
1 by brian
clean slate
573
);
574
insert into t2 values(111);
575
576
#--warning 1364
577
create table t1 ( 
722.2.15 by Monty Taylor
Fixed create.test.
578
  a varchar(12) collate utf8_bin not null, 
1 by brian
clean slate
579
  b int not null, primary key (a)
580
) select a, 1 as b from t2 ;
942.3.1 by Vladimir Kolesnikov
test generalizations
581
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
582
show create table t1;
583
drop table t1;
584
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
585
--error ER_NO_DEFAULT_FOR_FIELD
1 by brian
clean slate
586
create table t1 ( 
722.2.15 by Monty Taylor
Fixed create.test.
587
  a varchar(12) collate utf8_bin not null, 
1 by brian
clean slate
588
  b int not null, primary key (a)
589
) select a, 1 as c from t2 ;
590
591
create table t1 ( 
722.2.15 by Monty Taylor
Fixed create.test.
592
  a varchar(12) collate utf8_bin not null, 
1 by brian
clean slate
593
  b int null, primary key (a)
594
) select a, 1 as c from t2 ;
942.3.1 by Vladimir Kolesnikov
test generalizations
595
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
596
show create table t1;
597
drop table t1;
598
599
create table t1 ( 
722.2.15 by Monty Taylor
Fixed create.test.
600
  a varchar(12) collate utf8_bin not null,
1 by brian
clean slate
601
  b int not null, primary key (a)
602
) select 'a' as a , 1 as b from t2 ;
942.3.1 by Vladimir Kolesnikov
test generalizations
603
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
604
show create table t1;
605
drop table t1;
606
607
create table t1 ( 
722.2.15 by Monty Taylor
Fixed create.test.
608
  a varchar(12) collate utf8_bin,
1 by brian
clean slate
609
  b int not null, primary key (a)
610
) select 'a' as a , 1 as b from t2 ;
942.3.1 by Vladimir Kolesnikov
test generalizations
611
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
612
show create table t1;
613
drop table t1, t2;
614
615
create table t1 ( 
616
  a1 int not null,
617
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
618
);
619
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
620
621
#--warning 1364
622
create table t2 ( 
722.2.15 by Monty Taylor
Fixed create.test.
623
  a1 varchar(12) collate utf8_bin not null,
1 by brian
clean slate
624
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
625
  primary key (a1)
626
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
627
drop table t2;
628
629
#--warning 1364
630
create table t2 ( 
722.2.15 by Monty Taylor
Fixed create.test.
631
  a1 varchar(12) collate utf8_bin,
1 by brian
clean slate
632
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
633
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
634
635
drop table t1, t2;
636
#--warning 1364
637
create table t1 ( 
638
  a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
639
);
640
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
641
642
#--warning 1364
643
create table t2 ( 
722.2.15 by Monty Taylor
Fixed create.test.
644
  a1 varchar(12) collate utf8_bin not null,
1 by brian
clean slate
645
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
646
  primary key (a1)
647
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
648
649
# Test the default value
650
drop table t2;
651
652
create table t2 ( a int default 3, b int default 3)
653
  select a1,a2 from t1;
942.3.1 by Vladimir Kolesnikov
test generalizations
654
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
655
show create table t2;
656
657
drop table t1, t2;
658
659
660
#
661
# Tests for errors happening at various stages of CREATE TABLES ... SELECT
662
#
663
# (Also checks that it behaves atomically in the sense that in case
664
#  of error it is automatically dropped if it has not existed before.)
665
#
666
# Error during open_and_lock_tables() of tables
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
667
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
668
create table t1 select * from t2;
669
# Rather special error which also caught during open tables pahse
670
--error ER_UPDATE_TABLE_USED
671
create table t1 select * from t1;
672
# Error which happens before select_create::prepare()
673
--error ER_CANT_AGGREGATE_2COLLATIONS
722.2.15 by Monty Taylor
Fixed create.test.
674
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
1 by brian
clean slate
675
# Error during table creation
676
--error ER_KEY_COLUMN_DOES_NOT_EXITS
677
create table t1 (primary key(a)) select "b" as b;
678
# Error in select_create::prepare() which is not related to table creation
722.2.15 by Monty Taylor
Fixed create.test.
679
# TODO: This really should be failing...
680
# create table t1 (a int);
681
# --error ER_WRONG_VALUE_COUNT_ON_ROW
682
# create table if not exists t1 select 1 as a, 2 as b;
683
# drop table t1;
1 by brian
clean slate
684
# Finally error which happens during insert
685
--error ER_DUP_ENTRY
686
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
687
# What happens if table already exists ?
688
create table t1 (i int);
722.2.15 by Monty Taylor
Fixed create.test.
689
# TODO: BUG lp:311045
690
#--error ER_TABLE_EXISTS_ERROR
691
#create table t1 select 1 as i;
1 by brian
clean slate
692
create table if not exists t1 select 1 as i;
693
select * from t1;
722.2.15 by Monty Taylor
Fixed create.test.
694
drop table t1;
1 by brian
clean slate
695
# Error before select_create::prepare()
696
--error ER_CANT_AGGREGATE_2COLLATIONS
722.2.15 by Monty Taylor
Fixed create.test.
697
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
1 by brian
clean slate
698
# Error which happens during insertion of rows
722.2.15 by Monty Taylor
Fixed create.test.
699
# TODO: Bug lp:311072
700
# create table t1 (i int);
701
# alter table t1 add primary key (i);
702
# --error ER_DUP_ENTRY
703
# create table if not exists t1 (select 2 as i) union all (select 2 as i);
704
# select * from t1;
705
# drop table t1;
1 by brian
clean slate
706
707
708
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
709
# results of CREATE TABLE ... SELECT when temporary table exists").
710
# In this situation we either have to create non-temporary table and
711
# insert data in it or insert data in temporary table without creation
712
# of permanent table. Since currently temporary tables always shadow
713
# permanent tables we adopt second approach.
714
create temporary table t1 (j int);
715
create table if not exists t1 select 1;
716
select * from t1;
717
drop temporary table t1;
2140.1.2 by Brian Aker
Merge in decomplication of our error system when reading through the table
718
--error ER_TABLE_UNKNOWN
1 by brian
clean slate
719
select * from t1;
720
--error ER_BAD_TABLE_ERROR
721
drop table t1;
722
723
724
#
725
# Bug#21772: can not name a column 'upgrade' when create a table
726
#
727
create table t1 (upgrade int);
728
drop table t1;
729
730
731
#
732
# Bug #26642: create index corrupts table definition in .frm
733
#
734
# Problem with creating keys with maximum key-parts and maximum name length
735
# This test is made for a mysql server supporting names up to 64 bytes
736
# and a maximum of 16 key segements per Key
737
#
738
739
create table t1 (
740
  c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int,
741
  c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int,
742
743
 key a001_long_123456789_123456789_123456789_123456789_123456789_1234 (
744
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
745
 key a002_long_123456789_123456789_123456789_123456789_123456789_1234 (
746
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
747
 key a003_long_123456789_123456789_123456789_123456789_123456789_1234 (
748
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
749
 key a004_long_123456789_123456789_123456789_123456789_123456789_1234 (
750
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
751
 key a005_long_123456789_123456789_123456789_123456789_123456789_1234 (
752
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
753
 key a006_long_123456789_123456789_123456789_123456789_123456789_1234 (
754
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
755
 key a007_long_123456789_123456789_123456789_123456789_123456789_1234 (
756
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
757
 key a008_long_123456789_123456789_123456789_123456789_123456789_1234 (
758
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
759
 key a009_long_123456789_123456789_123456789_123456789_123456789_1234 (
760
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
761
762
 key a010_long_123456789_123456789_123456789_123456789_123456789_1234 (
763
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
764
 key a011_long_123456789_123456789_123456789_123456789_123456789_1234 (
765
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
766
 key a012_long_123456789_123456789_123456789_123456789_123456789_1234 (
767
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
768
 key a013_long_123456789_123456789_123456789_123456789_123456789_1234 (
769
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
770
 key a014_long_123456789_123456789_123456789_123456789_123456789_1234 (
771
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
772
 key a015_long_123456789_123456789_123456789_123456789_123456789_1234 (
773
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
774
 key a016_long_123456789_123456789_123456789_123456789_123456789_1234 (
775
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
776
 key a017_long_123456789_123456789_123456789_123456789_123456789_1234 (
777
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
778
 key a018_long_123456789_123456789_123456789_123456789_123456789_1234 (
779
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
780
 key a019_long_123456789_123456789_123456789_123456789_123456789_1234 (
781
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
782
783
 key a020_long_123456789_123456789_123456789_123456789_123456789_1234 (
784
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
785
 key a021_long_123456789_123456789_123456789_123456789_123456789_1234 (
786
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
787
 key a022_long_123456789_123456789_123456789_123456789_123456789_1234 (
788
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
789
 key a023_long_123456789_123456789_123456789_123456789_123456789_1234 (
790
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
791
 key a024_long_123456789_123456789_123456789_123456789_123456789_1234 (
792
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
793
 key a025_long_123456789_123456789_123456789_123456789_123456789_1234 (
794
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
795
 key a026_long_123456789_123456789_123456789_123456789_123456789_1234 (
796
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
797
 key a027_long_123456789_123456789_123456789_123456789_123456789_1234 (
798
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
799
 key a028_long_123456789_123456789_123456789_123456789_123456789_1234 (
800
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
801
 key a029_long_123456789_123456789_123456789_123456789_123456789_1234 (
802
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
803
804
 key a030_long_123456789_123456789_123456789_123456789_123456789_1234 (
805
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
806
 key a031_long_123456789_123456789_123456789_123456789_123456789_1234 (
807
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
808
 key a032_long_123456789_123456789_123456789_123456789_123456789_1234 (
809
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
810
 key a033_long_123456789_123456789_123456789_123456789_123456789_1234 (
811
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
812
 key a034_long_123456789_123456789_123456789_123456789_123456789_1234 (
813
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
814
 key a035_long_123456789_123456789_123456789_123456789_123456789_1234 (
815
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
816
 key a036_long_123456789_123456789_123456789_123456789_123456789_1234 (
817
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
818
 key a037_long_123456789_123456789_123456789_123456789_123456789_1234 (
819
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
820
 key a038_long_123456789_123456789_123456789_123456789_123456789_1234 (
821
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
822
 key a039_long_123456789_123456789_123456789_123456789_123456789_1234 (
823
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
824
825
 key a040_long_123456789_123456789_123456789_123456789_123456789_1234 (
826
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
827
 key a041_long_123456789_123456789_123456789_123456789_123456789_1234 (
828
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
829
 key a042_long_123456789_123456789_123456789_123456789_123456789_1234 (
830
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
831
 key a043_long_123456789_123456789_123456789_123456789_123456789_1234 (
832
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
833
 key a044_long_123456789_123456789_123456789_123456789_123456789_1234 (
834
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
835
 key a045_long_123456789_123456789_123456789_123456789_123456789_1234 (
836
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
837
 key a046_long_123456789_123456789_123456789_123456789_123456789_1234 (
838
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
839
 key a047_long_123456789_123456789_123456789_123456789_123456789_1234 (
840
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
841
 key a048_long_123456789_123456789_123456789_123456789_123456789_1234 (
842
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
843
 key a049_long_123456789_123456789_123456789_123456789_123456789_1234 (
844
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
845
846
 key a050_long_123456789_123456789_123456789_123456789_123456789_1234 (
847
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
848
 key a051_long_123456789_123456789_123456789_123456789_123456789_1234 (
849
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
850
 key a052_long_123456789_123456789_123456789_123456789_123456789_1234 (
851
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
852
 key a053_long_123456789_123456789_123456789_123456789_123456789_1234 (
853
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
854
 key a054_long_123456789_123456789_123456789_123456789_123456789_1234 (
855
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
856
 key a055_long_123456789_123456789_123456789_123456789_123456789_1234 (
857
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
858
 key a056_long_123456789_123456789_123456789_123456789_123456789_1234 (
859
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
860
 key a057_long_123456789_123456789_123456789_123456789_123456789_1234 (
861
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
862
 key a058_long_123456789_123456789_123456789_123456789_123456789_1234 (
863
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
864
 key a059_long_123456789_123456789_123456789_123456789_123456789_1234 (
865
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
866
867
 key a060_long_123456789_123456789_123456789_123456789_123456789_1234 (
868
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
869
 key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
870
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
871
 key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
872
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
873
 key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
874
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
875
 key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
876
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16)
877
);
878
879
# Check that the table is not corrupted
942.3.1 by Vladimir Kolesnikov
test generalizations
880
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
881
show create table t1;
882
flush tables;
942.3.1 by Vladimir Kolesnikov
test generalizations
883
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
884
show create table t1;
885
886
# Repeat test using ALTER to add indexes
887
888
drop table t1;
889
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
890
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int);
891
892
alter table t1
893
894
 add key a001_long_123456789_123456789_123456789_123456789_123456789_1234 (
895
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
896
 add key a002_long_123456789_123456789_123456789_123456789_123456789_1234 (
897
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
898
 add key a003_long_123456789_123456789_123456789_123456789_123456789_1234 (
899
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
900
 add key a004_long_123456789_123456789_123456789_123456789_123456789_1234 (
901
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
902
 add key a005_long_123456789_123456789_123456789_123456789_123456789_1234 (
903
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
904
 add key a006_long_123456789_123456789_123456789_123456789_123456789_1234 (
905
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
906
 add key a007_long_123456789_123456789_123456789_123456789_123456789_1234 (
907
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
908
 add key a008_long_123456789_123456789_123456789_123456789_123456789_1234 (
909
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
910
 add key a009_long_123456789_123456789_123456789_123456789_123456789_1234 (
911
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
912
913
 add key a010_long_123456789_123456789_123456789_123456789_123456789_1234 (
914
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
915
 add key a011_long_123456789_123456789_123456789_123456789_123456789_1234 (
916
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
917
 add key a012_long_123456789_123456789_123456789_123456789_123456789_1234 (
918
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
919
 add key a013_long_123456789_123456789_123456789_123456789_123456789_1234 (
920
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
921
 add key a014_long_123456789_123456789_123456789_123456789_123456789_1234 (
922
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
923
 add key a015_long_123456789_123456789_123456789_123456789_123456789_1234 (
924
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
925
 add key a016_long_123456789_123456789_123456789_123456789_123456789_1234 (
926
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
927
 add key a017_long_123456789_123456789_123456789_123456789_123456789_1234 (
928
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
929
 add key a018_long_123456789_123456789_123456789_123456789_123456789_1234 (
930
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
931
 add key a019_long_123456789_123456789_123456789_123456789_123456789_1234 (
932
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
933
934
 add key a020_long_123456789_123456789_123456789_123456789_123456789_1234 (
935
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
936
 add key a021_long_123456789_123456789_123456789_123456789_123456789_1234 (
937
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
938
 add key a022_long_123456789_123456789_123456789_123456789_123456789_1234 (
939
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
940
 add key a023_long_123456789_123456789_123456789_123456789_123456789_1234 (
941
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
942
 add key a024_long_123456789_123456789_123456789_123456789_123456789_1234 (
943
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
944
 add key a025_long_123456789_123456789_123456789_123456789_123456789_1234 (
945
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
946
 add key a026_long_123456789_123456789_123456789_123456789_123456789_1234 (
947
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
948
 add key a027_long_123456789_123456789_123456789_123456789_123456789_1234 (
949
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
950
 add key a028_long_123456789_123456789_123456789_123456789_123456789_1234 (
951
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
952
 add key a029_long_123456789_123456789_123456789_123456789_123456789_1234 (
953
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
954
955
 add key a030_long_123456789_123456789_123456789_123456789_123456789_1234 (
956
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
957
 add key a031_long_123456789_123456789_123456789_123456789_123456789_1234 (
958
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
959
 add key a032_long_123456789_123456789_123456789_123456789_123456789_1234 (
960
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
961
 add key a033_long_123456789_123456789_123456789_123456789_123456789_1234 (
962
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
963
 add key a034_long_123456789_123456789_123456789_123456789_123456789_1234 (
964
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
965
 add key a035_long_123456789_123456789_123456789_123456789_123456789_1234 (
966
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
967
 add key a036_long_123456789_123456789_123456789_123456789_123456789_1234 (
968
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
969
 add key a037_long_123456789_123456789_123456789_123456789_123456789_1234 (
970
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
971
 add key a038_long_123456789_123456789_123456789_123456789_123456789_1234 (
972
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
973
 add key a039_long_123456789_123456789_123456789_123456789_123456789_1234 (
974
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
975
976
 add key a040_long_123456789_123456789_123456789_123456789_123456789_1234 (
977
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
978
 add key a041_long_123456789_123456789_123456789_123456789_123456789_1234 (
979
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
980
 add key a042_long_123456789_123456789_123456789_123456789_123456789_1234 (
981
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
982
 add key a043_long_123456789_123456789_123456789_123456789_123456789_1234 (
983
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
984
 add key a044_long_123456789_123456789_123456789_123456789_123456789_1234 (
985
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
986
 add key a045_long_123456789_123456789_123456789_123456789_123456789_1234 (
987
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
988
 add key a046_long_123456789_123456789_123456789_123456789_123456789_1234 (
989
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
990
 add key a047_long_123456789_123456789_123456789_123456789_123456789_1234 (
991
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
992
 add key a048_long_123456789_123456789_123456789_123456789_123456789_1234 (
993
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
994
 add key a049_long_123456789_123456789_123456789_123456789_123456789_1234 (
995
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
996
997
 add key a050_long_123456789_123456789_123456789_123456789_123456789_1234 (
998
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
999
 add key a051_long_123456789_123456789_123456789_123456789_123456789_1234 (
1000
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1001
 add key a052_long_123456789_123456789_123456789_123456789_123456789_1234 (
1002
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1003
 add key a053_long_123456789_123456789_123456789_123456789_123456789_1234 (
1004
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1005
 add key a054_long_123456789_123456789_123456789_123456789_123456789_1234 (
1006
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1007
 add key a055_long_123456789_123456789_123456789_123456789_123456789_1234 (
1008
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1009
 add key a056_long_123456789_123456789_123456789_123456789_123456789_1234 (
1010
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1011
 add key a057_long_123456789_123456789_123456789_123456789_123456789_1234 (
1012
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1013
 add key a058_long_123456789_123456789_123456789_123456789_123456789_1234 (
1014
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1015
 add key a059_long_123456789_123456789_123456789_123456789_123456789_1234 (
1016
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1017
1018
 add key a060_long_123456789_123456789_123456789_123456789_123456789_1234 (
1019
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1020
 add key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
1021
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1022
 add key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
1023
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1024
 add key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
1025
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1026
 add key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
1027
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1028
942.3.1 by Vladimir Kolesnikov
test generalizations
1029
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
1030
show create table t1;
1031
flush tables;
942.3.1 by Vladimir Kolesnikov
test generalizations
1032
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
1033
show create table t1;
1034
1035
# Test the server limits; if any of these pass, all above tests need
1036
# to be rewritten to hit the limit
1037
#
1038
# Ensure limit is really 64 keys
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1039
--error ER_TOO_MANY_KEYS
1 by brian
clean slate
1040
alter table t1 add key 
1041
 a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
1042
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1043
1044
drop table t1;
1045
1046
# Ensure limit is really 16 key parts per key
1047
1048
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
1049
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, 
1050
c16 int, c17 int);
1051
1052
# Get error for max key parts
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1053
--error ER_TOO_MANY_KEY_PARTS
1 by brian
clean slate
1054
alter table t1 add key i1 (
1055
 c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
1056
1057
# Get error for max key-name length
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1058
--error ER_TOO_LONG_IDENT
1 by brian
clean slate
1059
alter table t1 add key 
1060
 a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
1061
942.3.1 by Vladimir Kolesnikov
test generalizations
1062
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
1063
show create table t1;
1064
1065
drop table t1;
1066
1067
--echo
1068
--echo Bug #26104 Bug on foreign key class constructor
1069
--echo
1070
--echo Check that ref_columns is initalized correctly in the constructor
1071
--echo and semantic checks in mysql_prepare_table work.
1072
--echo
1073
--echo We do not need a storage engine that supports foreign keys
1074
--echo for this test, as the checks are purely syntax-based, and the
1075
--echo syntax is supported for all engines.
1076
--echo
1077
--disable_warnings
1078
drop table if exists t1,t2;
1079
--enable_warnings
1080
1081
create table t1(a int not null, b int not null, primary key (a, b));
1082
--error ER_WRONG_FK_DEF
1083
create table t2(a int not null, b int not null, c int not null, primary key (a),
1084
foreign key fk_bug26104 (b,c) references t1(a));
1085
drop table t1;
1086
1087
#
1088
# Bug#15130:CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
1089
#
1090
create table t1(f1 int,f2 int);
1091
insert into t1 value(1,1),(1,2),(1,3),(2,1),(2,2),(2,3);
1092
flush status;
1093
create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
1094
show status like 'handler_read%';
1095
drop table t1,t2;
1096
1097
#
1098
# Bug #25162: Backing up DB from 5.1 adds 'USING BTREE' to KEYs on table creates
1099
#
1100
1101
# Show that the old syntax for index type is supported
1102
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
1103
DROP TABLE t1;
1104
1105
# Show that the new syntax for index type is supported
1106
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
1107
DROP TABLE t1;
1108
1109
# Show that in case of multiple index type definitions, the last one takes 
1110
# precedence
1111
1106.3.1 by Brian Aker
Heap is now tmp only table
1112
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
1273.19.2 by Brian Aker
First pass through show indexs.
1113
#SHOW INDEX FROM t1;
1 by brian
clean slate
1114
DROP TABLE t1;
1115
1106.3.1 by Brian Aker
Heap is now tmp only table
1116
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
1273.19.2 by Brian Aker
First pass through show indexs.
1117
#SHOW INDEX FROM t1;
1 by brian
clean slate
1118
DROP TABLE t1;
1119
1120
1121
--echo End of 5.0 tests
1122
1123
#
1124
# Test of behaviour with CREATE ... SELECT
1125
#
1126
1127
CREATE TABLE t1 (a int, b int);
1128
insert into t1 values (1,1),(1,2);
1129
--error ER_DUP_ENTRY
1130
CREATE TABLE t2 (primary key (a)) select * from t1;
1131
# This should give warning
1132
drop table if exists t2;
1133
--error ER_DUP_ENTRY
1134
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
1135
# This should give warning
1136
drop table if exists t2;
722.2.15 by Monty Taylor
Fixed create.test.
1137
# TODO: Bug lp:311072
1138
#CREATE TABLE t2 (a int, b int, primary key (a));
1139
#--error ER_DUP_ENTRY
1140
#CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1141
#SELECT * from t2;
1142
#TRUNCATE table t2;
1143
#--error ER_DUP_ENTRY
1144
#INSERT INTO t2 select * from t1;
1145
#SELECT * from t2;
1146
#drop table t2;
1 by brian
clean slate
1147
1148
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
1149
--error ER_DUP_ENTRY
1150
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1151
SELECT * from t2;
1152
TRUNCATE table t2;
1153
--error ER_DUP_ENTRY
1154
INSERT INTO t2 select * from t1;
1155
SELECT * from t2;
1156
drop table t1,t2;
1157
1158
1159
#
1160
# Test incorrect database names
1161
#
1162
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1163
--error ER_WRONG_DB_NAME
1 by brian
clean slate
1164
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1165
--error ER_WRONG_DB_NAME
1 by brian
clean slate
1166
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1167
1168
# TODO: enable these tests when RENAME DATABASE is implemented.
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1169
# --error ER_BAD_DB_ERROR
1 by brian
clean slate
1170
# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1171
# --error ER_WRONG_DB_NAME
1 by brian
clean slate
1172
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1173
# create database mysqltest;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1174
# --error ER_WRONG_DB_NAME
1 by brian
clean slate
1175
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1176
# drop database mysqltest;
1177
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1178
--error ER_WRONG_DB_NAME
1 by brian
clean slate
1179
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1812.5.9 by Brian Aker
First pass on moving show create schema out.
1180
#--error ER_WRONG_DB_NAME
1 by brian
clean slate
1181
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1182
1273.13.99 by Brian Aker
Bug on OSX.
1183
##
1184
## Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1185
##
1309.1.4 by Brian Aker
Re-enabling test for OSX.
1186
1187
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1188
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1189
select database();
1190
use test;
1191
1192
select SCHEMA_NAME from data_dictionary.schemas
1193
where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45';
1194
1195
drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1196
create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48
1197
(
1198
  имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int,
1199
  index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45)
1200
);
1201
1202
1203
# database, table, field, key
1204
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1205
1206
select TABLE_NAME from data_dictionary.tables where
1207
table_schema='test';
1208
1209
select COLUMN_NAME from data_dictionary.columns where
1210
table_schema='test';
1211
1212
select INDEX_NAME from data_dictionary.indexes where
1213
table_schema='test';
1214
1215
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1216
show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1217
1218
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1219
1273.13.99 by Brian Aker
Bug on OSX.
1220
#
1 by brian
clean slate
1221
#
1222
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
1223
#
2068.7.1 by Brian Aker
First pass through error correction in SE interface for drop table.
1224
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1273.13.35 by Brian Aker
Remove processlist from old I_S.
1225
create table t1 like data_dictionary.processlist;
1226
create table t1 like data_dictionary.processlist engine=innodb;
1 by brian
clean slate
1227
show create table t1;
1228
drop table t1;
2068.7.1 by Brian Aker
First pass through error correction in SE interface for drop table.
1229
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1273.13.35 by Brian Aker
Remove processlist from old I_S.
1230
create temporary table t1 like data_dictionary.processlist;
1231
create temporary table t1 like data_dictionary.processlist engine=myisam;
1 by brian
clean slate
1232
show create table t1;
1233
drop table t1;
1234
1235
###########################################################################
1236
1237
--echo
1238
--echo # --
1239
--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE
1240
--echo # -- TABLE/SELECT to the new table.
1241
--echo # --
1242
--echo
1243
1244
1245
--disable_warnings
1246
DROP TABLE IF EXISTS t1;
1247
DROP TABLE IF EXISTS t2;
1248
--enable_warnings
1249
1250
--echo
1251
1252
CREATE TABLE t1(
1253
  c1 INT DEFAULT 12 COMMENT 'column1',
1254
  c2 INT NULL COMMENT 'column2',
1255
  c3 INT NOT NULL COMMENT 'column3',
722.2.15 by Monty Taylor
Fixed create.test.
1256
  c4 VARCHAR(255) NOT NULL DEFAULT 'a',
1 by brian
clean slate
1257
  c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
1258
  c6 VARCHAR(255))
1245.3.4 by Stewart Smith
make the equals of KEY=VALUE required for CREATE TABLE options
1259
  COLLATE=utf8_bin;
1 by brian
clean slate
1260
1261
--echo
1262
942.3.1 by Vladimir Kolesnikov
test generalizations
1263
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
1264
SHOW CREATE TABLE t1;
1265
1266
--echo
1267
1268
CREATE TABLE t2 AS SELECT * FROM t1;
1269
1270
--echo
1271
942.3.1 by Vladimir Kolesnikov
test generalizations
1272
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1 by brian
clean slate
1273
SHOW CREATE TABLE t2;
1274
1275
--echo
1276
1277
DROP TABLE t2;
1278
1279
--echo
1280
--echo # -- End of test case for Bug#21380.
1281
1282
###########################################################################
1283
1284
--echo
1285
--echo # --
1286
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
1287
--echo # --
1288
--echo
1289
1290
--disable_warnings
1291
DROP TABLE IF EXISTS t1;
1292
DROP TABLE IF EXISTS t2;
1293
DROP TABLE IF EXISTS t3;
1294
--enable_warnings
1295
1296
--echo
1297
1298
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
1299
1300
--echo
1301
1302
--echo
907.1.7 by Jay Pipes
Merged in remove-timezone work
1303
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP NULL);
722.2.15 by Monty Taylor
Fixed create.test.
1304
drop table t2;
1 by brian
clean slate
1305
896.4.9 by Stewart Smith
No longer write the FRM. just use proto.
1306
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT '1982-01-29');
722.2.15 by Monty Taylor
Fixed create.test.
1307
drop table t2;
1 by brian
clean slate
1308
1309
--echo
1310
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
722.2.15 by Monty Taylor
Fixed create.test.
1311
drop table t2;
1 by brian
clean slate
1312
1313
--echo
1314
--echo # -- Check that NULL column still can be created.
1315
CREATE TABLE t2(c1 TIMESTAMP NULL);
1316
1317
--echo
1318
--echo # -- Check ALTER TABLE.
1319
ALTER TABLE t1 ADD INDEX(c1);
1320
1321
--echo
1322
--echo # -- Check DATETIME.
1323
--echo
1324
1325
CREATE TABLE t3(c1 DATETIME NOT NULL);
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
1326
--error ER_INVALID_DATETIME_VALUE # Bad datetime
1 by brian
clean slate
1327
INSERT INTO t3 VALUES (0);
1328
1329
--echo
873.1.7 by Jay Pipes
Fixes Field_datetime::store(NUMBER) to throw an error when invalid
1330
ALTER TABLE t3 ADD INDEX(c1);
1 by brian
clean slate
1331
1332
--echo
1333
--echo # -- Cleanup.
1334
1335
DROP TABLE t1;
1336
DROP TABLE t2;
1337
DROP TABLE t3;
1338
1339
--echo
1340
--echo # -- End of Bug#18834.
1341