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