~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/create.test

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

Show diffs side-by-side

added added

removed removed

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