~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/create.test

  • Committer: Mark Atwood
  • Date: 2008-10-03 01:39:40 UTC
  • mto: This revision was merged to the branch mainline in revision 437.
  • Revision ID: mark@fallenpegasus.com-20081003013940-mvefjo725dltz41h
rename logging_noop to logging_query

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_TABLE_UNKNOWN
30
 
create temporary table t2 engine=MEMORY select * from t1;
31
 
--error ER_TABLE_UNKNOWN
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_TABLE_UNKNOWN
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 AND TABLE_SCHEMA = SCHEMA() > 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
 
 
317
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
318
 
show create table t3;
319
 
 
320
 
create table t2 like t3;
321
 
 
322
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
323
 
show create table t2;
324
 
select * from t2;
325
 
 
326
 
--error ER_TABLE_EXISTS_ERROR
327
 
create table t3 like t1;
328
 
 
329
 
--error ER_TABLE_EXISTS_ERROR
330
 
create table t3 like mysqltest.t3;
331
 
 
332
 
--error ER_BAD_DB_ERROR
333
 
create table non_existing_database.t1 like t1;
334
 
 
335
 
--error ER_TABLE_UNKNOWN
336
 
create table t4 like non_existing_table;
337
 
 
338
 
--error ER_TABLE_EXISTS_ERROR
339
 
create temporary table t3 like t1;
340
 
drop table t1, t2, t3;
341
 
drop database mysqltest;
342
 
 
343
 
#
344
 
# Test default table type
345
 
#
346
 
SET SESSION storage_engine="MEMORY";
347
 
SELECT @@storage_engine;
348
 
CREATE TEMPORARY TABLE t1 (a int not null);
349
 
show create table t1;
350
 
drop table t1;
351
 
--error ER_UNKNOWN_STORAGE_ENGINE
352
 
SET SESSION storage_engine="gemini";
353
 
SELECT @@storage_engine;
354
 
CREATE TEMPORARY TABLE t1 (a int not null);
355
 
show create table t1;
356
 
SET SESSION storage_engine=default;
357
 
drop table t1;
358
 
 
359
 
#
360
 
# Test types of data for create select with functions
361
 
#
362
 
 
363
 
create table t1(a int,b int,c int,d date,e char,f datetime,h blob);
364
 
insert into t1(a)values(1);
365
 
insert into t1(a,b,c,d,e,f,h)
366
 
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','binary data');
367
 
select * from t1;
368
 
select a, 
369
 
    ifnull(b,-7) as b, 
370
 
    ifnull(c,7) as c, 
371
 
    ifnull(d,cast('2000-01-01' as date)) as d, 
372
 
    ifnull(e,cast('b' as char)) as e,
373
 
    ifnull(f,cast('2000-01-01' as datetime)) as f, 
374
 
    ifnull(h,cast('yet another binary data' as binary)) as h
375
 
from t1;
376
 
 
377
 
create table t2
378
 
select
379
 
    a, 
380
 
    ifnull(b,-7)                            as b,
381
 
    ifnull(c,7)                             as c,
382
 
    ifnull(d,cast('2000-01-01'              as date))     as d,
383
 
    ifnull(e,cast('b'                       as char))     as e,
384
 
    ifnull(f,cast('2000-01-01'              as datetime)) as f,
385
 
    ifnull(h,cast('yet another binary data' as binary))   as h
386
 
from t1;
387
 
explain t2;
388
 
select * from t2;
389
 
drop table t1, t2;
390
 
 
391
 
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));
392
 
SHOW CREATE TABLE t1;
393
 
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;
394
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
395
 
show create table t2;
396
 
drop table t1,t2;
397
 
 
398
 
#
399
 
# Test of default()
400
 
#
401
 
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
402
 
insert into t1 values ('','',0,0.0);
403
 
describe t1;
404
 
create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1;
405
 
describe t2;
406
 
drop table t1, t2;
407
 
 
408
 
#
409
 
# Bug #2075
410
 
#
411
 
 
412
 
create table t1(name varchar(10), age int default -1);
413
 
describe t1;
414
 
create table t2(name varchar(10), age int default - 1);
415
 
describe t2;
416
 
drop table t1, t2;
417
 
 
418
 
#
419
 
# test for bug #1427 "enum allows duplicate values in the list"
420
 
#
421
 
 
422
 
create table t1(cenum enum('a'));
423
 
--error ER_DUPLICATED_VALUE_IN_TYPE
424
 
create table t2(cenum enum('a','a'));
425
 
--error ER_DUPLICATED_VALUE_IN_TYPE
426
 
create table t3(cenum enum('a','A','a','c','c'));
427
 
drop table t1;
428
 
 
429
 
#
430
 
# Bug #1209
431
 
#
432
 
 
433
 
create database mysqltest;
434
 
use mysqltest;
435
 
select database();
436
 
drop database mysqltest;
437
 
select database();
438
 
use test;
439
 
 
440
 
#
441
 
# Test for Bug 856 'Naming a key "Primary" causes trouble'
442
 
#
443
 
 
444
 
## TODO: Is this really a bug? It works in Drizzle. Should it?
445
 
#--error ER_WRONG_NAME_FOR_INDEX
446
 
#create table t1 (a int, index `primary` (a));
447
 
#--error ER_WRONG_NAME_FOR_INDEX
448
 
#create table t1 (a int, index `PRIMARY` (a));
449
 
#
450
 
#create table t1 (`primary` int, index(`primary`));
451
 
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
452
 
#show create table t1;
453
 
#create table t2 (`PRIMARY` int, index(`PRIMARY`));
454
 
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
455
 
#show create table t2;
456
 
#
457
 
#create table t3 (a int);
458
 
#--error ER_WRONG_NAME_FOR_INDEX
459
 
#alter table t3 add index `primary` (a);
460
 
#--error ER_WRONG_NAME_FOR_INDEX
461
 
#alter table t3 add index `PRIMARY` (a);
462
 
#
463
 
#create table t4 (`primary` int);
464
 
#alter table t4 add index(`primary`);
465
 
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
466
 
#show create table t4;
467
 
#create table t5 (`PRIMARY` int);
468
 
#alter table t5 add index(`PRIMARY`);
469
 
#--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
470
 
#show create table t5;
471
 
#
472
 
#drop table t1, t2, t3, t4, t5;
473
 
 
474
 
#
475
 
# bug #3266 TEXT in CREATE TABLE SELECT
476
 
#
477
 
 
478
 
CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
479
 
INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
480
 
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));
481
 
 
482
 
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');
483
 
 
484
 
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;
485
 
SELECT * FROM t3;
486
 
drop table t1, t2, t3;
487
 
 
488
 
 
489
 
#
490
 
# Bug#10224 - ANALYZE TABLE crashing with simultaneous
491
 
# CREATE ... SELECT statement.
492
 
# This tests two additional possible errors and a hang if 
493
 
# an improper fix is present.
494
 
#
495
 
create table t1 (a int);
496
 
--error ER_UPDATE_TABLE_USED
497
 
create table t1 select * from t1;
498
 
## TODO: Huh? --error ER_WRONG_OBJECT
499
 
#create table t2 union = (t1) select * from t1;
500
 
flush tables with read lock;
501
 
unlock tables;
502
 
drop table t1;
503
 
 
504
 
#
505
 
# Bug#10413: Invalid column name is not rejected
506
 
#
507
 
--error ER_WRONG_TABLE_NAME
508
 
create table t1(column.name int);
509
 
--error ER_WRONG_TABLE_NAME
510
 
create table t1(test.column.name int);
511
 
--error ER_WRONG_DB_NAME
512
 
create table t1(xyz.t1.name int);
513
 
create table t1(t1.name int);
514
 
create table t2(test.t2.name int);
515
 
drop table t1,t2;
516
 
 
517
 
#
518
 
# Bug #12537: UNION produces longtext instead of varchar
519
 
#
520
 
CREATE TABLE t1 (f1 VARCHAR(255));
521
 
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
522
 
DESC t2;
523
 
DROP TABLE t1,t2;
524
 
 
525
 
#
526
 
# Bug#12913 Simple SQL can crash server or connection
527
 
#
528
 
CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1;
529
 
SELECT * FROM t12913;
530
 
DROP TABLE t12913;
531
 
 
532
 
#
533
 
# Bug#11028: Crash on create table like
534
 
#
535
 
create database mysqltest;
536
 
use mysqltest;
537
 
drop database mysqltest;
538
 
--error ER_NO_DB_ERROR 
539
 
create table test.t1 like x;
540
 
--disable_warnings
541
 
drop table if exists test.t1;
542
 
--enable_warnings
543
 
 
544
 
# Bug #6008 MySQL does not create warnings when
545
 
# creating database and using IF NOT EXISTS
546
 
#
547
 
create database mysqltest;
548
 
create database if not exists mysqltest;
549
 
show create database mysqltest;
550
 
drop database mysqltest;
551
 
use test;
552
 
create table t1 (a int);
553
 
create table if not exists t1 (a int);
554
 
drop table t1;
555
 
 
556
 
# BUG#14139
557
 
create table t1 (
558
 
  a varchar(112) collate utf8_bin not null,
559
 
  primary key (a)
560
 
) select 'test' as a ;
561
 
#--warning 1364
562
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
563
 
show create table t1;
564
 
drop table t1;
565
 
 
566
 
#
567
 
# BUG#14480: assert failure in CREATE ... SELECT because of wrong
568
 
#            calculation of number of NULLs.
569
 
#
570
 
CREATE TABLE t2 (
571
 
  a int default NULL
572
 
);
573
 
insert into t2 values(111);
574
 
 
575
 
#--warning 1364
576
 
create table t1 ( 
577
 
  a varchar(12) collate utf8_bin not null, 
578
 
  b int not null, primary key (a)
579
 
) select a, 1 as b from t2 ;
580
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
581
 
show create table t1;
582
 
drop table t1;
583
 
 
584
 
--error ER_NO_DEFAULT_FOR_FIELD
585
 
create table t1 ( 
586
 
  a varchar(12) collate utf8_bin not null, 
587
 
  b int not null, primary key (a)
588
 
) select a, 1 as c from t2 ;
589
 
 
590
 
create table t1 ( 
591
 
  a varchar(12) collate utf8_bin not null, 
592
 
  b int null, primary key (a)
593
 
) select a, 1 as c 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 not null,
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;
605
 
 
606
 
create table t1 ( 
607
 
  a varchar(12) collate utf8_bin,
608
 
  b int not null, primary key (a)
609
 
) select 'a' as a , 1 as b from t2 ;
610
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
611
 
show create table t1;
612
 
drop table t1, t2;
613
 
 
614
 
create table t1 ( 
615
 
  a1 int not null,
616
 
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
617
 
);
618
 
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
619
 
 
620
 
#--warning 1364
621
 
create table t2 ( 
622
 
  a1 varchar(12) collate utf8_bin not null,
623
 
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
624
 
  primary key (a1)
625
 
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
626
 
drop table t2;
627
 
 
628
 
#--warning 1364
629
 
create table t2 ( 
630
 
  a1 varchar(12) collate utf8_bin,
631
 
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
632
 
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
633
 
 
634
 
drop table t1, t2;
635
 
#--warning 1364
636
 
create table t1 ( 
637
 
  a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
638
 
);
639
 
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
640
 
 
641
 
#--warning 1364
642
 
create table t2 ( 
643
 
  a1 varchar(12) collate utf8_bin not null,
644
 
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
645
 
  primary key (a1)
646
 
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
647
 
 
648
 
# Test the default value
649
 
drop table t2;
650
 
 
651
 
create table t2 ( a int default 3, b int default 3)
652
 
  select a1,a2 from t1;
653
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
654
 
show create table t2;
655
 
 
656
 
drop table t1, t2;
657
 
 
658
 
 
659
 
#
660
 
# Tests for errors happening at various stages of CREATE TABLES ... SELECT
661
 
#
662
 
# (Also checks that it behaves atomically in the sense that in case
663
 
#  of error it is automatically dropped if it has not existed before.)
664
 
#
665
 
# Error during open_and_lock_tables() of tables
666
 
--error ER_TABLE_UNKNOWN
667
 
create table t1 select * from t2;
668
 
# Rather special error which also caught during open tables pahse
669
 
--error ER_UPDATE_TABLE_USED
670
 
create table t1 select * from t1;
671
 
# Error which happens before select_create::prepare()
672
 
--error ER_CANT_AGGREGATE_2COLLATIONS
673
 
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
674
 
# Error during table creation
675
 
--error ER_KEY_COLUMN_DOES_NOT_EXITS
676
 
create table t1 (primary key(a)) select "b" as b;
677
 
# Error in select_create::prepare() which is not related to table creation
678
 
# TODO: This really should be failing...
679
 
# create table t1 (a int);
680
 
# --error ER_WRONG_VALUE_COUNT_ON_ROW
681
 
# create table if not exists t1 select 1 as a, 2 as b;
682
 
# drop table t1;
683
 
# Finally error which happens during insert
684
 
--error ER_DUP_ENTRY
685
 
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
686
 
# What happens if table already exists ?
687
 
create table t1 (i int);
688
 
# TODO: BUG lp:311045
689
 
#--error ER_TABLE_EXISTS_ERROR
690
 
#create table t1 select 1 as i;
691
 
create table if not exists t1 select 1 as i;
692
 
select * from t1;
693
 
drop table t1;
694
 
# Error before select_create::prepare()
695
 
--error ER_CANT_AGGREGATE_2COLLATIONS
696
 
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
697
 
# Error which happens during insertion of rows
698
 
# TODO: Bug lp:311072
699
 
# create table t1 (i int);
700
 
# alter table t1 add primary key (i);
701
 
# --error ER_DUP_ENTRY
702
 
# create table if not exists t1 (select 2 as i) union all (select 2 as i);
703
 
# select * from t1;
704
 
# drop table t1;
705
 
 
706
 
 
707
 
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
708
 
# results of CREATE TABLE ... SELECT when temporary table exists").
709
 
# In this situation we either have to create non-temporary table and
710
 
# insert data in it or insert data in temporary table without creation
711
 
# of permanent table. Since currently temporary tables always shadow
712
 
# permanent tables we adopt second approach.
713
 
create temporary table t1 (j int);
714
 
create table if not exists t1 select 1;
715
 
select * from t1;
716
 
drop temporary table t1;
717
 
--error ER_TABLE_UNKNOWN
718
 
select * from t1;
719
 
--error ER_BAD_TABLE_ERROR
720
 
drop table t1;
721
 
 
722
 
 
723
 
#
724
 
# Bug#21772: can not name a column 'upgrade' when create a table
725
 
#
726
 
create table t1 (upgrade int);
727
 
drop table t1;
728
 
 
729
 
 
730
 
#
731
 
# Bug #26642: create index corrupts table definition in .frm
732
 
#
733
 
# Problem with creating keys with maximum key-parts and maximum name length
734
 
# This test is made for a mysql server supporting names up to 64 bytes
735
 
# and a maximum of 16 key segements per Key
736
 
#
737
 
 
738
 
create table t1 (
739
 
  c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int,
740
 
  c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int,
741
 
 
742
 
 key a001_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 a002_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 a003_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 a004_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 a005_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 a006_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 a007_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 a008_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 a009_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
 
 
761
 
 key a010_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 a011_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 a012_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 a013_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 a014_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 a015_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 a016_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 a017_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 a018_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 a019_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
 
 
782
 
 key a020_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 a021_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 a022_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 a023_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 a024_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 a025_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 a026_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 a027_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 a028_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 a029_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
 
 
803
 
 key a030_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 a031_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 a032_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 a033_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 a034_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 a035_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 a036_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 a037_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 a038_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 a039_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
 
 
824
 
 key a040_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 a041_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 a042_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 a043_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 a044_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 a045_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 a046_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 a047_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 a048_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 a049_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
 
 
845
 
 key a050_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 a051_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 a052_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 a053_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 a054_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 a055_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 a056_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 a057_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 a058_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
 
 key a059_long_123456789_123456789_123456789_123456789_123456789_1234 (
864
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
865
 
 
866
 
 key a060_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
 
 key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
869
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
870
 
 key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
871
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
872
 
 key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
873
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
874
 
 key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
875
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16)
876
 
);
877
 
 
878
 
# Check that the table is not corrupted
879
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
880
 
show create table t1;
881
 
flush tables;
882
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
883
 
show create table t1;
884
 
 
885
 
# Repeat test using ALTER to add indexes
886
 
 
887
 
drop table t1;
888
 
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
889
 
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int);
890
 
 
891
 
alter table t1
892
 
 
893
 
 add key a001_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 a002_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 a003_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 a004_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 a005_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 a006_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 a007_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 a008_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 a009_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
 
 
912
 
 add key a010_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 a011_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 a012_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 a013_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 a014_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 a015_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 a016_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 a017_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 a018_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 a019_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
 
 
933
 
 add key a020_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 a021_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 a022_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 a023_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 a024_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 a025_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 a026_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 a027_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 a028_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 a029_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
 
 
954
 
 add key a030_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 a031_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 a032_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 a033_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 a034_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 a035_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 a036_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 a037_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 a038_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 a039_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
 
 
975
 
 add key a040_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 a041_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 a042_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 a043_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 a044_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 a045_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 a046_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 a047_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 a048_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 a049_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
 
 
996
 
 add key a050_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 a051_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 a052_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 a053_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 a054_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 a055_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 a056_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 a057_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 a058_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
 
 add key a059_long_123456789_123456789_123456789_123456789_123456789_1234 (
1015
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1016
 
 
1017
 
 add key a060_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
 
 add key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
1020
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1021
 
 add key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
1022
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1023
 
 add key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
1024
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
1025
 
 add key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
1026
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1027
 
 
1028
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1029
 
show create table t1;
1030
 
flush tables;
1031
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1032
 
show create table t1;
1033
 
 
1034
 
# Test the server limits; if any of these pass, all above tests need
1035
 
# to be rewritten to hit the limit
1036
 
#
1037
 
# Ensure limit is really 64 keys
1038
 
--error ER_TOO_MANY_KEYS
1039
 
alter table t1 add key 
1040
 
 a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
1041
 
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1042
 
 
1043
 
drop table t1;
1044
 
 
1045
 
# Ensure limit is really 16 key parts per key
1046
 
 
1047
 
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
1048
 
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, 
1049
 
c16 int, c17 int);
1050
 
 
1051
 
# Get error for max key parts
1052
 
--error ER_TOO_MANY_KEY_PARTS
1053
 
alter table t1 add key i1 (
1054
 
 c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
1055
 
 
1056
 
# Get error for max key-name length
1057
 
--error ER_TOO_LONG_IDENT
1058
 
alter table t1 add key 
1059
 
 a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
1060
 
 
1061
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1062
 
show create table t1;
1063
 
 
1064
 
drop table t1;
1065
 
 
1066
 
--echo
1067
 
--echo Bug #26104 Bug on foreign key class constructor
1068
 
--echo
1069
 
--echo Check that ref_columns is initalized correctly in the constructor
1070
 
--echo and semantic checks in mysql_prepare_table work.
1071
 
--echo
1072
 
--echo We do not need a storage engine that supports foreign keys
1073
 
--echo for this test, as the checks are purely syntax-based, and the
1074
 
--echo syntax is supported for all engines.
1075
 
--echo
1076
 
--disable_warnings
1077
 
drop table if exists t1,t2;
1078
 
--enable_warnings
1079
 
 
1080
 
create table t1(a int not null, b int not null, primary key (a, b));
1081
 
--error ER_WRONG_FK_DEF
1082
 
create table t2(a int not null, b int not null, c int not null, primary key (a),
1083
 
foreign key fk_bug26104 (b,c) references t1(a));
1084
 
drop table t1;
1085
 
 
1086
 
#
1087
 
# Bug#15130:CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
1088
 
#
1089
 
create table t1(f1 int,f2 int);
1090
 
insert into t1 value(1,1),(1,2),(1,3),(2,1),(2,2),(2,3);
1091
 
flush status;
1092
 
create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
1093
 
show status like 'handler_read%';
1094
 
drop table t1,t2;
1095
 
 
1096
 
#
1097
 
# Bug #25162: Backing up DB from 5.1 adds 'USING BTREE' to KEYs on table creates
1098
 
#
1099
 
 
1100
 
# Show that the old syntax for index type is supported
1101
 
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
1102
 
DROP TABLE t1;
1103
 
 
1104
 
# Show that the new syntax for index type is supported
1105
 
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
1106
 
DROP TABLE t1;
1107
 
 
1108
 
# Show that in case of multiple index type definitions, the last one takes 
1109
 
# precedence
1110
 
 
1111
 
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
1112
 
#SHOW INDEX FROM t1;
1113
 
DROP TABLE t1;
1114
 
 
1115
 
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
1116
 
#SHOW INDEX FROM t1;
1117
 
DROP TABLE t1;
1118
 
 
1119
 
 
1120
 
--echo End of 5.0 tests
1121
 
 
1122
 
#
1123
 
# Test of behaviour with CREATE ... SELECT
1124
 
#
1125
 
 
1126
 
CREATE TABLE t1 (a int, b int);
1127
 
insert into t1 values (1,1),(1,2);
1128
 
--error ER_DUP_ENTRY
1129
 
CREATE TABLE t2 (primary key (a)) select * from t1;
1130
 
# This should give warning
1131
 
drop table if exists t2;
1132
 
--error ER_DUP_ENTRY
1133
 
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
1134
 
# This should give warning
1135
 
drop table if exists t2;
1136
 
# TODO: Bug lp:311072
1137
 
#CREATE TABLE t2 (a int, b int, primary key (a));
1138
 
#--error ER_DUP_ENTRY
1139
 
#CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1140
 
#SELECT * from t2;
1141
 
#TRUNCATE table t2;
1142
 
#--error ER_DUP_ENTRY
1143
 
#INSERT INTO t2 select * from t1;
1144
 
#SELECT * from t2;
1145
 
#drop table t2;
1146
 
 
1147
 
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
1148
 
--error ER_DUP_ENTRY
1149
 
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1150
 
SELECT * from t2;
1151
 
TRUNCATE table t2;
1152
 
--error ER_DUP_ENTRY
1153
 
INSERT INTO t2 select * from t1;
1154
 
SELECT * from t2;
1155
 
drop table t1,t2;
1156
 
 
1157
 
 
1158
 
#
1159
 
# Test incorrect database names
1160
 
#
1161
 
 
1162
 
--error ER_WRONG_DB_NAME
1163
 
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1164
 
--error ER_WRONG_DB_NAME
1165
 
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1166
 
 
1167
 
# TODO: enable these tests when RENAME DATABASE is implemented.
1168
 
# --error ER_BAD_DB_ERROR
1169
 
# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a;
1170
 
# --error ER_WRONG_DB_NAME
1171
 
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1172
 
# create database mysqltest;
1173
 
# --error ER_WRONG_DB_NAME
1174
 
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1175
 
# drop database mysqltest;
1176
 
 
1177
 
--error ER_WRONG_DB_NAME
1178
 
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1179
 
#--error ER_WRONG_DB_NAME
1180
 
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1181
 
 
1182
 
##
1183
 
## Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1184
 
##
1185
 
 
1186
 
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1187
 
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1188
 
select database();
1189
 
use test;
1190
 
 
1191
 
select SCHEMA_NAME from data_dictionary.schemas
1192
 
where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45';
1193
 
 
1194
 
drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1195
 
create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48
1196
 
(
1197
 
  имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int,
1198
 
  index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45)
1199
 
);
1200
 
 
1201
 
 
1202
 
# database, table, field, key
1203
 
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1204
 
 
1205
 
select TABLE_NAME from data_dictionary.tables where
1206
 
table_schema='test';
1207
 
 
1208
 
select COLUMN_NAME from data_dictionary.columns where
1209
 
table_schema='test';
1210
 
 
1211
 
select INDEX_NAME from data_dictionary.indexes where
1212
 
table_schema='test';
1213
 
 
1214
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1215
 
show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1216
 
 
1217
 
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1218
 
 
1219
 
#
1220
 
#
1221
 
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
1222
 
#
1223
 
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1224
 
create table t1 like data_dictionary.processlist;
1225
 
create table t1 like data_dictionary.processlist engine=innodb;
1226
 
show create table t1;
1227
 
drop table t1;
1228
 
--error ER_CANT_CREATE_TABLE,ER_TABLE_PERMISSION_DENIED
1229
 
create temporary table t1 like data_dictionary.processlist;
1230
 
create temporary table t1 like data_dictionary.processlist engine=myisam;
1231
 
show create table t1;
1232
 
drop table t1;
1233
 
 
1234
 
###########################################################################
1235
 
 
1236
 
--echo
1237
 
--echo # --
1238
 
--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE
1239
 
--echo # -- TABLE/SELECT to the new table.
1240
 
--echo # --
1241
 
--echo
1242
 
 
1243
 
 
1244
 
--disable_warnings
1245
 
DROP TABLE IF EXISTS t1;
1246
 
DROP TABLE IF EXISTS t2;
1247
 
--enable_warnings
1248
 
 
1249
 
--echo
1250
 
 
1251
 
CREATE TABLE t1(
1252
 
  c1 INT DEFAULT 12 COMMENT 'column1',
1253
 
  c2 INT NULL COMMENT 'column2',
1254
 
  c3 INT NOT NULL COMMENT 'column3',
1255
 
  c4 VARCHAR(255) NOT NULL DEFAULT 'a',
1256
 
  c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
1257
 
  c6 VARCHAR(255))
1258
 
  COLLATE=utf8_bin;
1259
 
 
1260
 
--echo
1261
 
 
1262
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1263
 
SHOW CREATE TABLE t1;
1264
 
 
1265
 
--echo
1266
 
 
1267
 
CREATE TABLE t2 AS SELECT * FROM t1;
1268
 
 
1269
 
--echo
1270
 
 
1271
 
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
1272
 
SHOW CREATE TABLE t2;
1273
 
 
1274
 
--echo
1275
 
 
1276
 
DROP TABLE t2;
1277
 
 
1278
 
--echo
1279
 
--echo # -- End of test case for Bug#21380.
1280
 
 
1281
 
###########################################################################
1282
 
 
1283
 
--echo
1284
 
--echo # --
1285
 
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
1286
 
--echo # --
1287
 
--echo
1288
 
 
1289
 
--disable_warnings
1290
 
DROP TABLE IF EXISTS t1;
1291
 
DROP TABLE IF EXISTS t2;
1292
 
DROP TABLE IF EXISTS t3;
1293
 
--enable_warnings
1294
 
 
1295
 
--echo
1296
 
 
1297
 
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
1298
 
 
1299
 
--echo
1300
 
 
1301
 
--echo
1302
 
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP NULL);
1303
 
drop table t2;
1304
 
 
1305
 
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT '1982-01-29');
1306
 
drop table t2;
1307
 
 
1308
 
--echo
1309
 
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
1310
 
drop table t2;
1311
 
 
1312
 
--echo
1313
 
--echo # -- Check that NULL column still can be created.
1314
 
CREATE TABLE t2(c1 TIMESTAMP NULL);
1315
 
 
1316
 
--echo
1317
 
--echo # -- Check ALTER TABLE.
1318
 
ALTER TABLE t1 ADD INDEX(c1);
1319
 
 
1320
 
--echo
1321
 
--echo # -- Check DATETIME.
1322
 
--echo
1323
 
 
1324
 
CREATE TABLE t3(c1 DATETIME NOT NULL);
1325
 
--error ER_INVALID_DATETIME_VALUE # Bad datetime
1326
 
INSERT INTO t3 VALUES (0);
1327
 
 
1328
 
--echo
1329
 
ALTER TABLE t3 ADD INDEX(c1);
1330
 
 
1331
 
--echo
1332
 
--echo # -- Cleanup.
1333
 
 
1334
 
DROP TABLE t1;
1335
 
DROP TABLE t2;
1336
 
DROP TABLE t3;
1337
 
 
1338
 
--echo
1339
 
--echo # -- End of Bug#18834.
1340