~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/t/create.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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
insert into t1 values (""),(null);
 
18
select * from t1;
 
19
drop table t1;
 
20
 
 
21
create table t1 (a int not null auto_increment,primary key (a)) engine=heap;
 
22
drop table t1;
 
23
 
 
24
#
 
25
# Test of some CREATE TABLE'S that should fail
 
26
#
 
27
 
 
28
--error 1146
 
29
create table t2 engine=heap select * from t1;
 
30
--error 1146
 
31
create table t2 select auto+1 from t1;
 
32
drop table if exists t1,t2;
 
33
--error 1167
 
34
create table t1 (b char(0) not null, index(b));
 
35
--error 1163
 
36
create table t1 (a int not null,b text) engine=heap;
 
37
drop table if exists t1;
 
38
 
 
39
--error 1075
 
40
create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=heap;
 
41
 
 
42
-- error 1049
 
43
create table not_existing_database.test (a int);
 
44
create table `a/a` (a int);
 
45
show create table `a/a`;
 
46
create table t1 like `a/a`;
 
47
drop table `a/a`;
 
48
drop table `t1`;
 
49
--error 1103
 
50
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
 
51
--error 1059
 
52
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
 
53
 
 
54
#
 
55
# Some wrong defaults, so these creates should fail too (Bug #5902)
 
56
#
 
57
--error 1067
 
58
create table t1 (a datetime default now());
 
59
--error 1294
 
60
create table t1 (a datetime on update now());
 
61
--error 1067
 
62
create table t1 (a int default 100 auto_increment);
 
63
--error 1067
 
64
create table t1 (a tinyint default 1000);
 
65
--error 1067
 
66
create table t1 (a varchar(5) default 'abcdef');
 
67
 
 
68
create table t1 (a varchar(5) default 'abcde');
 
69
insert into t1 values();
 
70
select * from t1;
 
71
--error 1067
 
72
alter table t1 alter column a set default 'abcdef';
 
73
drop table t1;
 
74
 
 
75
#
 
76
# test of dummy table names
 
77
#
 
78
 
 
79
create table 1ea10 (1a20 int,1e int);
 
80
insert into 1ea10 values(1,1);
 
81
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
 
82
drop table 1ea10;
 
83
create table t1 (t1.index int);
 
84
drop table t1;
 
85
# Test that we get warning for this
 
86
drop database if exists mysqltest;
 
87
create database mysqltest;
 
88
create table mysqltest.$test1 (a$1 int, $b int, c$ int);
 
89
insert into mysqltest.$test1 values (1,2,3);
 
90
select a$1, $b, c$ from mysqltest.$test1;
 
91
create table mysqltest.test2$ (a int);
 
92
drop table mysqltest.test2$;
 
93
drop database mysqltest;
 
94
 
 
95
--error 1103
 
96
create table `` (a int);
 
97
--error 1103
 
98
drop table if exists ``;
 
99
--error 1166
 
100
create table t1 (`` int);
 
101
--error 1280
 
102
create table t1 (i int, index `` (i)); 
 
103
 
 
104
#
 
105
# Test of CREATE ... SELECT with indexes
 
106
#
 
107
 
 
108
create table t1 (a int auto_increment not null primary key, B CHAR(20));
 
109
insert into t1 (b) values ("hello"),("my"),("world");
 
110
create table t2 (key (b)) select * from t1;
 
111
explain select * from t2 where b="world";
 
112
select * from t2 where b="world";
 
113
drop table t1,t2;
 
114
 
 
115
#
 
116
# Test types after CREATE ... SELECT
 
117
#
 
118
 
 
119
create table t1(x varchar(50) );
 
120
create table t2 select x from t1 where 1=2;
 
121
describe t1;
 
122
describe t2;
 
123
drop table t2;
 
124
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
 
125
describe t2;
 
126
drop table t2;
 
127
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29  20:45:11" AS DATETIME) as dt;
 
128
describe t2;
 
129
drop table t1,t2;
 
130
 
 
131
#
 
132
# Test of CREATE ... SELECT with duplicate fields
 
133
#
 
134
 
 
135
create table t1 (a tinyint);
 
136
create table t2 (a int) select * from t1;                        
 
137
describe t1;
 
138
describe t2;
 
139
drop table if exists t2;
 
140
--error 1060
 
141
create table t2 (a int, a float) select * from t1;               
 
142
drop table if exists t2;
 
143
--error 1060
 
144
create table t2 (a int) select a as b, a+1 as b from t1;         
 
145
drop table if exists t2;
 
146
--error 1060
 
147
create table t2 (b int) select a as b, a+1 as b from t1;         
 
148
drop table if exists t1,t2;
 
149
 
 
150
#
 
151
# Test CREATE ... SELECT when insert fails
 
152
#
 
153
 
 
154
CREATE TABLE t1 (a int not null);
 
155
INSERT INTO t1 values (1),(2),(1);
 
156
--error ER_DUP_ENTRY
 
157
CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
 
158
--error 1146
 
159
SELECT * from t2;
 
160
DROP TABLE t1;
 
161
DROP TABLE IF EXISTS t2;
 
162
 
 
163
#
 
164
# Test of primary key with 32 index
 
165
#
 
166
 
 
167
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));
 
168
show create table t1;
 
169
drop table t1;
 
170
create table t1 select if(1,'1','0'), month("2002-08-02");
 
171
drop table t1;
 
172
create table t1 select if('2002'='2002','Y','N');
 
173
select * from t1;
 
174
drop table if exists t1;
 
175
 
 
176
#
 
177
# Test default table type
 
178
#
 
179
SET SESSION storage_engine="heap";
 
180
SELECT @@storage_engine;
 
181
CREATE TABLE t1 (a int not null);
 
182
show create table t1;
 
183
drop table t1;
 
184
--error 1286
 
185
SET SESSION storage_engine="gemini";
 
186
SELECT @@storage_engine;
 
187
CREATE TABLE t1 (a int not null);
 
188
show create table t1;
 
189
SET SESSION storage_engine=default;
 
190
drop table t1;
 
191
 
 
192
 
 
193
#
 
194
# ISO requires that primary keys are implicitly NOT NULL
 
195
#
 
196
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
 
197
insert into t1 values ("a", 1), ("b", 2);
 
198
--error 1048
 
199
insert into t1 values ("c", NULL);
 
200
--error 1048
 
201
insert into t1 values (NULL, 3);
 
202
--error 1048
 
203
insert into t1 values (NULL, NULL);
 
204
drop table t1;
 
205
 
 
206
#
 
207
# Bug # 801
 
208
#
 
209
 
 
210
create table t1 select x'4132';
 
211
drop table t1;
 
212
 
 
213
#
 
214
# bug #1434
 
215
#
 
216
 
 
217
create table t1 select 1,2,3;
 
218
create table if not exists t1 select 1,2;
 
219
--error 1136
 
220
create table if not exists t1 select 1,2,3,4;
 
221
create table if not exists t1 select 1;
 
222
select * from t1;
 
223
drop table t1;
 
224
 
 
225
#
 
226
# Test create table if not exists with duplicate key error
 
227
#
 
228
 
 
229
flush status;
 
230
create table t1 (a int not null, b int, primary key (a));
 
231
insert into t1 values (1,1);
 
232
create table if not exists t1 select 2;
 
233
select * from t1;
 
234
create table if not exists t1 select 3 as 'a',4 as 'b';
 
235
--error ER_DUP_ENTRY
 
236
create table if not exists t1 select 3 as 'a',3 as 'b';
 
237
show warnings;
 
238
show status like "Opened_tables";
 
239
select * from t1;
 
240
drop table t1;
 
241
 
 
242
#
 
243
# Test for Bug #2985 
 
244
#   "Table truncated when creating another table name with Spaces"
 
245
#
 
246
 
 
247
--error 1103
 
248
create table `t1 `(a int);
 
249
--error 1102
 
250
create database `db1 `;
 
251
--error 1166
 
252
create table t1(`a ` int);
 
253
 
 
254
#
 
255
# Test for Bug #3481 
 
256
#   "Parser permits multiple commas without syntax error"
 
257
#
 
258
 
 
259
--error 1064
 
260
create table t1 (a int,);
 
261
--error 1064
 
262
create table t1 (a int,,b int);
 
263
--error 1064
 
264
create table t1 (,b int);
 
265
 
 
266
#
 
267
# Test create with foreign keys
 
268
#
 
269
 
 
270
create table t1 (a int, key(a));
 
271
create table t2 (b int, foreign key(b) references t1(a), key(b));
 
272
drop table if exists t1,t2;
 
273
 
 
274
#
 
275
# Test for CREATE TABLE .. LIKE ..
 
276
#
 
277
 
 
278
create table t1(id int not null, name char(20));
 
279
insert into t1 values(10,'mysql'),(20,'monty- the creator');
 
280
create table t2(id int not null);
 
281
insert into t2 values(10),(20);
 
282
create table t3 like t1;
 
283
show create table t3;
 
284
select * from t3;
 
285
# Disable PS becasue of @@warning_count
 
286
create table if not exists t3 like t1;
 
287
--disable_ps_protocol
 
288
select @@warning_count;
 
289
--enable_ps_protocol
 
290
create temporary table t3 like t2;
 
291
show create table t3;
 
292
select * from t3;
 
293
drop table t3;
 
294
show create table t3;
 
295
select * from t3;
 
296
drop table t2, t3;
 
297
create database mysqltest;
 
298
create table mysqltest.t3 like t1;
 
299
create temporary table t3 like mysqltest.t3;
 
300
show create table t3;
 
301
create table t2 like t3;
 
302
show create table t2;
 
303
select * from t2;
 
304
create table t3 like t1;
 
305
--error 1050
 
306
create table t3 like mysqltest.t3;
 
307
--error 1049
 
308
create table non_existing_database.t1 like t1;
 
309
--error ER_NO_SUCH_TABLE
 
310
create table t3 like non_existing_table;
 
311
--error 1050
 
312
create temporary table t3 like t1;
 
313
drop table t1, t2, t3;
 
314
drop table t3;
 
315
drop database mysqltest;
 
316
 
 
317
#
 
318
# Test default table type
 
319
#
 
320
SET SESSION storage_engine="heap";
 
321
SELECT @@storage_engine;
 
322
CREATE TABLE t1 (a int not null);
 
323
show create table t1;
 
324
drop table t1;
 
325
--error 1286
 
326
SET SESSION storage_engine="gemini";
 
327
SELECT @@storage_engine;
 
328
CREATE TABLE t1 (a int not null);
 
329
show create table t1;
 
330
SET SESSION storage_engine=default;
 
331
drop table t1;
 
332
 
 
333
#
 
334
# Test types of data for create select with functions
 
335
#
 
336
 
 
337
create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
 
338
insert into t1(a)values(1);
 
339
insert into t1(a,b,c,d,e,f,g,h)
 
340
values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
 
341
select * from t1;
 
342
select a, 
 
343
    ifnull(b,cast(-7 as signed)) as b, 
 
344
    ifnull(c,cast(7 as unsigned)) as c, 
 
345
    ifnull(d,cast('2000-01-01' as date)) as d, 
 
346
    ifnull(e,cast('b' as char)) as e,
 
347
    ifnull(f,cast('2000-01-01' as datetime)) as f, 
 
348
    ifnull(g,cast('5:4:3' as time)) as g,
 
349
    ifnull(h,cast('yet another binary data' as binary)) as h,
 
350
    addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd 
 
351
from t1;
 
352
 
 
353
create table t2
 
354
select
 
355
    a, 
 
356
    ifnull(b,cast(-7                        as signed))   as b,
 
357
    ifnull(c,cast(7                         as unsigned)) as c,
 
358
    ifnull(d,cast('2000-01-01'              as date))     as d,
 
359
    ifnull(e,cast('b'                       as char))     as e,
 
360
    ifnull(f,cast('2000-01-01'              as datetime)) as f,
 
361
    ifnull(g,cast('5:4:3'                   as time))     as g,
 
362
    ifnull(h,cast('yet another binary data' as binary))   as h,
 
363
    addtime(cast('1:0:0' as time),cast('1:0:0' as time))  as dd
 
364
from t1;
 
365
explain t2;
 
366
select * from t2;
 
367
drop table t1, t2;
 
368
 
 
369
create table t1 (a tinyint, b smallint, c mediumint, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), i year, j date, k timestamp, l datetime, m enum('a','b'), n set('a','b'), o char(10));
 
370
create table t2 select ifnull(a,a), ifnull(b,b), ifnull(c,c), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(i,i), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(n,n), ifnull(o,o) from t1;
 
371
show create table t2;
 
372
drop table t1,t2;
 
373
 
 
374
#
 
375
# Test of default()
 
376
#
 
377
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
 
378
insert into t1 values ('','',0,0.0);
 
379
describe t1;
 
380
create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1;
 
381
describe t2;
 
382
drop table t1, t2;
 
383
 
 
384
#
 
385
# Bug #2075
 
386
#
 
387
 
 
388
create table t1(name varchar(10), age smallint default -1);
 
389
describe t1;
 
390
create table t2(name varchar(10), age smallint default - 1);
 
391
describe t2;
 
392
drop table t1, t2;
 
393
 
 
394
#
 
395
# test for bug #1427 "enum allows duplicate values in the list"
 
396
#
 
397
 
 
398
create table t1(cenum enum('a'), cset set('b'));
 
399
create table t2(cenum enum('a','a'), cset set('b','b'));
 
400
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
 
401
drop table t1, t2, t3;
 
402
 
 
403
#
 
404
# Bug #1209
 
405
#
 
406
 
 
407
create database mysqltest;
 
408
use mysqltest;
 
409
select database();
 
410
drop database mysqltest;
 
411
select database();
 
412
 
 
413
# Connect without a database as user mysqltest_1
 
414
create user mysqltest_1;
 
415
connect (user1,localhost,mysqltest_1,,*NO-ONE*);
 
416
connection user1;
 
417
select database(), user();
 
418
connection default;
 
419
disconnect user1;
 
420
drop user mysqltest_1;
 
421
use test;
 
422
 
 
423
#
 
424
# Test for Bug 856 'Naming a key "Primary" causes trouble'
 
425
#
 
426
 
 
427
--error 1280
 
428
create table t1 (a int, index `primary` (a));
 
429
--error 1280
 
430
create table t1 (a int, index `PRIMARY` (a));
 
431
 
 
432
create table t1 (`primary` int, index(`primary`));
 
433
show create table t1;
 
434
create table t2 (`PRIMARY` int, index(`PRIMARY`));
 
435
show create table t2;
 
436
 
 
437
create table t3 (a int);
 
438
--error 1280
 
439
alter table t3 add index `primary` (a);
 
440
--error 1280
 
441
alter table t3 add index `PRIMARY` (a);
 
442
 
 
443
create table t4 (`primary` int);
 
444
alter table t4 add index(`primary`);
 
445
show create table t4;
 
446
create table t5 (`PRIMARY` int);
 
447
alter table t5 add index(`PRIMARY`);
 
448
show create table t5;
 
449
 
 
450
drop table t1, t2, t3, t4, t5;
 
451
 
 
452
#
 
453
# bug #3266 TEXT in CREATE TABLE SELECT
 
454
#
 
455
 
 
456
CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
 
457
INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
 
458
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));
 
459
 
 
460
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');
 
461
 
 
462
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;
 
463
SELECT * FROM t3;
 
464
drop table t1, t2, t3;
 
465
 
 
466
#
 
467
# Bug#9666: Can't use 'DEFAULT FALSE' for column of type bool
 
468
#
 
469
create table t1 (b bool not null default false);
 
470
create table t2 (b bool not null default true);
 
471
insert into t1 values ();
 
472
insert into t2 values ();
 
473
select * from t1;
 
474
select * from t2;
 
475
drop table t1,t2;
 
476
 
 
477
#
 
478
# Bug#10224 - ANALYZE TABLE crashing with simultaneous
 
479
# CREATE ... SELECT statement.
 
480
# This tests two additional possible errors and a hang if 
 
481
# an improper fix is present.
 
482
#
 
483
create table t1 (a int);
 
484
--error 1093
 
485
create table t1 select * from t1;
 
486
--error ER_WRONG_OBJECT
 
487
create table t2 union = (t1) select * from t1;
 
488
flush tables with read lock;
 
489
unlock tables;
 
490
drop table t1;
 
491
 
 
492
#
 
493
# Bug#10413: Invalid column name is not rejected
 
494
#
 
495
--error 1103
 
496
create table t1(column.name int);
 
497
--error 1103
 
498
create table t1(test.column.name int);
 
499
--error 1102
 
500
create table t1(xyz.t1.name int);
 
501
create table t1(t1.name int);
 
502
create table t2(test.t2.name int);
 
503
drop table t1,t2;
 
504
 
 
505
#
 
506
# Bug #12537: UNION produces longtext instead of varchar
 
507
#
 
508
CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
 
509
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
 
510
DESC t2;
 
511
DROP TABLE t1,t2;
 
512
 
 
513
#
 
514
# Bug#12913 Simple SQL can crash server or connection
 
515
#
 
516
CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1;
 
517
SELECT * FROM t12913;
 
518
DROP TABLE t12913;
 
519
 
 
520
#
 
521
# Bug#11028: Crash on create table like
 
522
#
 
523
create database mysqltest;
 
524
use mysqltest;
 
525
drop database mysqltest;
 
526
--error ER_NO_DB_ERROR 
 
527
create table test.t1 like x;
 
528
--disable_warnings
 
529
drop table if exists test.t1;
 
530
--enable_warnings
 
531
 
 
532
#
 
533
# Bug #6859: Bogus error message on attempt to CREATE TABLE t LIKE view
 
534
#
 
535
create database mysqltest;
 
536
use mysqltest;
 
537
create view v1 as select 'foo' from dual;
 
538
--error 1347
 
539
create table t1 like v1;
 
540
drop view v1;
 
541
drop database mysqltest;
 
542
# Bug #6008 MySQL does not create warnings when
 
543
# creating database and using IF NOT EXISTS
 
544
#
 
545
create database mysqltest;
 
546
create database if not exists mysqltest character set latin2;
 
547
show create database mysqltest;
 
548
drop database mysqltest;
 
549
use test;
 
550
create table t1 (a int);
 
551
create table if not exists t1 (a int);
 
552
drop table t1;
 
553
 
 
554
# BUG#14139
 
555
create table t1 (
 
556
  a varchar(112) charset utf8 collate utf8_bin not null,
 
557
  primary key (a)
 
558
) select 'test' as a ;
 
559
#--warning 1364
 
560
show create table t1;
 
561
drop table t1;
 
562
 
 
563
#
 
564
# BUG#14480: assert failure in CREATE ... SELECT because of wrong
 
565
#            calculation of number of NULLs.
 
566
#
 
567
CREATE TABLE t2 (
 
568
  a int(11) default NULL
 
569
);
 
570
insert into t2 values(111);
 
571
 
 
572
#--warning 1364
 
573
create table t1 ( 
 
574
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
575
  b int not null, primary key (a)
 
576
) select a, 1 as b from t2 ;
 
577
show create table t1;
 
578
drop table t1;
 
579
 
 
580
#--warning 1364
 
581
create table t1 ( 
 
582
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
583
  b int not null, primary key (a)
 
584
) select a, 1 as c from t2 ;
 
585
show create table t1;
 
586
drop table t1;
 
587
 
 
588
#--warning 1364
 
589
create table t1 ( 
 
590
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
591
  b int null, primary key (a)
 
592
) select a, 1 as c from t2 ;
 
593
show create table t1;
 
594
drop table t1;
 
595
 
 
596
#--warning 1364
 
597
create table t1 ( 
 
598
  a varchar(12) charset utf8 collate utf8_bin not null,
 
599
  b int not null, primary key (a)
 
600
) select 'a' as a , 1 as b from t2 ;
 
601
show create table t1;
 
602
drop table t1;
 
603
 
 
604
#--warning 1364
 
605
create table t1 ( 
 
606
  a varchar(12) charset utf8 collate utf8_bin,
 
607
  b int not null, primary key (a)
 
608
) select 'a' as a , 1 as b from t2 ;
 
609
show create table t1;
 
610
drop table t1, t2;
 
611
 
 
612
create table t1 ( 
 
613
  a1 int not null,
 
614
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
 
615
);
 
616
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
 
617
 
 
618
#--warning 1364
 
619
create table t2 ( 
 
620
  a1 varchar(12) charset utf8 collate utf8_bin not null,
 
621
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
 
622
  primary key (a1)
 
623
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
 
624
drop table t2;
 
625
 
 
626
#--warning 1364
 
627
create table t2 ( 
 
628
  a1 varchar(12) charset utf8 collate utf8_bin,
 
629
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
 
630
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
 
631
 
 
632
drop table t1, t2;
 
633
#--warning 1364
 
634
create table t1 ( 
 
635
  a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
 
636
);
 
637
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
 
638
 
 
639
#--warning 1364
 
640
create table t2 ( 
 
641
  a1 varchar(12) charset utf8 collate utf8_bin not null,
 
642
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
 
643
  primary key (a1)
 
644
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
 
645
 
 
646
# Test the default value
 
647
drop table t2;
 
648
 
 
649
create table t2 ( a int default 3, b int default 3)
 
650
  select a1,a2 from t1;
 
651
show create table t2;
 
652
 
 
653
drop table t1, t2;
 
654
 
 
655
#
 
656
# Bug #15316 SET value having comma not correctly handled
 
657
#
 
658
--error 1367
 
659
create table t1(a set("a,b","c,d") not null);
 
660
 
 
661
# End of 4.1 tests
 
662
 
 
663
 
 
664
#
 
665
# Bug #14155: Maximum value of MAX_ROWS handled incorrectly on 64-bit
 
666
# platforms
 
667
#
 
668
create table t1 (i int) engine=myisam max_rows=100000000000;
 
669
show create table t1;
 
670
alter table t1 max_rows=100;
 
671
show create table t1;
 
672
alter table t1 max_rows=100000000000;
 
673
show create table t1;
 
674
drop table t1;
 
675
 
 
676
 
 
677
#
 
678
# Tests for errors happening at various stages of CREATE TABLES ... SELECT
 
679
#
 
680
# (Also checks that it behaves atomically in the sense that in case
 
681
#  of error it is automatically dropped if it has not existed before.)
 
682
#
 
683
# Error during open_and_lock_tables() of tables
 
684
--error ER_NO_SUCH_TABLE
 
685
create table t1 select * from t2;
 
686
# Rather special error which also caught during open tables pahse
 
687
--error ER_UPDATE_TABLE_USED
 
688
create table t1 select * from t1;
 
689
# Error which happens before select_create::prepare()
 
690
--error ER_CANT_AGGREGATE_2COLLATIONS
 
691
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
 
692
# Error during table creation
 
693
--error ER_KEY_COLUMN_DOES_NOT_EXITS
 
694
create table t1 (primary key(a)) select "b" as b;
 
695
# Error in select_create::prepare() which is not related to table creation
 
696
create table t1 (a int);
 
697
--error ER_WRONG_VALUE_COUNT_ON_ROW
 
698
create table if not exists t1 select 1 as a, 2 as b;
 
699
drop table t1;
 
700
# Finally error which happens during insert
 
701
--error ER_DUP_ENTRY
 
702
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
 
703
# What happens if table already exists ?
 
704
create table t1 (i int);
 
705
--error ER_TABLE_EXISTS_ERROR
 
706
create table t1 select 1 as i;
 
707
create table if not exists t1 select 1 as i;
 
708
select * from t1;
 
709
# Error before select_create::prepare()
 
710
--error ER_CANT_AGGREGATE_2COLLATIONS
 
711
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
 
712
select * from t1;
 
713
# Error which happens during insertion of rows
 
714
alter table t1 add primary key (i);
 
715
--error ER_DUP_ENTRY
 
716
create table if not exists t1 (select 2 as i) union all (select 2 as i);
 
717
select * from t1;
 
718
drop table t1;
 
719
 
 
720
 
 
721
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
 
722
# results of CREATE TABLE ... SELECT when temporary table exists").
 
723
# In this situation we either have to create non-temporary table and
 
724
# insert data in it or insert data in temporary table without creation
 
725
# of permanent table. Since currently temporary tables always shadow
 
726
# permanent tables we adopt second approach.
 
727
create temporary table t1 (j int);
 
728
create table if not exists t1 select 1;
 
729
select * from t1;
 
730
drop temporary table t1;
 
731
--error ER_NO_SUCH_TABLE
 
732
select * from t1;
 
733
--error ER_BAD_TABLE_ERROR
 
734
drop table t1;
 
735
 
 
736
 
 
737
#
 
738
# CREATE TABLE ... SELECT and LOCK TABLES
 
739
#
 
740
# There is little sense in using CREATE TABLE ... SELECT under
 
741
# LOCK TABLES as it mostly does not work. At least we check that
 
742
# the server doesn't crash, hang and produces sensible errors.
 
743
# Includes test for bug #20662 "Infinite loop in CREATE TABLE
 
744
# IF NOT EXISTS ... SELECT with locked tables".
 
745
create table t1 (i int);
 
746
insert into t1 values (1), (2);
 
747
lock tables t1 read;
 
748
--error ER_TABLE_NOT_LOCKED
 
749
create table t2 select * from t1;
 
750
--error ER_TABLE_NOT_LOCKED
 
751
create table if not exists t2 select * from t1;
 
752
unlock tables;
 
753
create table t2 (j int);
 
754
lock tables t1 read;
 
755
--error ER_TABLE_NOT_LOCKED
 
756
create table t2 select * from t1;
 
757
# This should not be ever allowed as it will undermine
 
758
# lock-all-at-once approach
 
759
--error ER_TABLE_NOT_LOCKED
 
760
create table if not exists t2 select * from t1;
 
761
unlock tables;
 
762
lock table t1 read, t2 read;
 
763
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
 
764
create table t2 select * from t1;
 
765
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
 
766
create table if not exists t2 select * from t1;
 
767
unlock tables;
 
768
lock table t1 read, t2 write;
 
769
--error ER_TABLE_EXISTS_ERROR
 
770
create table t2 select * from t1;
 
771
# This is the only case which really works.
 
772
create table if not exists t2 select * from t1;
 
773
select * from t1;
 
774
unlock tables;
 
775
drop table t2;
 
776
 
 
777
# OTOH CREATE TEMPORARY TABLE ... SELECT should work
 
778
# well under LOCK TABLES.
 
779
lock tables t1 read;
 
780
create temporary table t2 select * from t1;
 
781
create temporary table if not exists t2 select * from t1;
 
782
select * from t2;
 
783
unlock tables;
 
784
drop table t1, t2;
 
785
 
 
786
 
 
787
#
 
788
# Bug#21772: can not name a column 'upgrade' when create a table
 
789
#
 
790
create table t1 (upgrade int);
 
791
drop table t1;
 
792
 
 
793
 
 
794
#
 
795
# Bug #26642: create index corrupts table definition in .frm
 
796
#
 
797
# Problem with creating keys with maximum key-parts and maximum name length
 
798
# This test is made for a mysql server supporting names up to 64 bytes
 
799
# and a maximum of 16 key segements per Key
 
800
#
 
801
 
 
802
create table t1 (
 
803
  c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, c8 int,
 
804
  c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int,
 
805
 
 
806
 key a001_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
807
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
808
 key a002_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
809
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
810
 key a003_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
811
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
812
 key a004_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
813
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
814
 key a005_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
815
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
816
 key a006_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 a007_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 a008_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 a009_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
823
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
824
 
 
825
 key a010_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
826
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
827
 key a011_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
828
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
829
 key a012_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
830
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
831
 key a013_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
832
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
833
 key a014_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
834
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
835
 key a015_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
836
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
837
 key a016_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 a017_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 a018_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 a019_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
844
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
845
 
 
846
 key a020_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
847
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
848
 key a021_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
849
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
850
 key a022_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
851
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
852
 key a023_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
853
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
854
 key a024_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
855
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
856
 key a025_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
857
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
858
 key a026_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 a027_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 a028_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 a029_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
865
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
866
 
 
867
 key a030_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
868
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
869
 key a031_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
870
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
871
 key a032_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
872
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
873
 key a033_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
874
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
875
 key a034_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
876
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
877
 key a035_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
878
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
879
 key a036_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
880
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
881
 key a037_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
882
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
883
 key a038_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
884
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
885
 key a039_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
 
 
888
 key a040_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
889
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
890
 key a041_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
891
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
892
 key a042_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
893
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
894
 key a043_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
895
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
896
 key a044_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
897
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
898
 key a045_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
899
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
900
 key a046_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
901
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
902
 key a047_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
903
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
904
 key a048_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
 key a049_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
 
 
909
 key a050_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
 key a051_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
912
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
913
 key a052_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
914
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
915
 key a053_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
916
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
917
 key a054_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
918
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
919
 key a055_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
920
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
921
 key a056_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
922
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
923
 key a057_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
924
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
925
 key a058_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
 key a059_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
 
 
930
 key a060_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
 key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
933
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
934
 key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
935
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
936
 key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
937
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
938
 key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
939
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16)
 
940
);
 
941
 
 
942
# Check that the table is not corrupted
 
943
show create table t1;
 
944
flush tables;
 
945
show create table t1;
 
946
 
 
947
# Repeat test using ALTER to add indexes
 
948
 
 
949
drop table t1;
 
950
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
 
951
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int);
 
952
 
 
953
alter table t1
 
954
 
 
955
 add key a001_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
956
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
957
 add key a002_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
958
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
959
 add key a003_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
960
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
961
 add key a004_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
962
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
963
 add key a005_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
964
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
965
 add key a006_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
966
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
967
 add key a007_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 a008_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 a009_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
 
 
974
 add key a010_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
975
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
976
 add key a011_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
977
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
978
 add key a012_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
979
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
980
 add key a013_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
981
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
982
 add key a014_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
983
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
984
 add key a015_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
985
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
986
 add key a016_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
987
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
988
 add key a017_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 a018_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 a019_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
 
 
995
 add key a020_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
996
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
997
 add key a021_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
998
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
999
 add key a022_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1000
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1001
 add key a023_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1002
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1003
 add key a024_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1004
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1005
 add key a025_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1006
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1007
 add key a026_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1008
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1009
 add key a027_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 a028_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 a029_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
 
 
1016
 add key a030_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1017
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1018
 add key a031_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1019
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1020
 add key a032_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1021
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1022
 add key a033_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1023
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1024
 add key a034_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1025
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1026
 add key a035_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1027
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1028
 add key a036_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1029
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1030
 add key a037_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1031
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1032
 add key a038_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
 add key a039_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1035
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1036
 
 
1037
 add key a040_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1038
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1039
 add key a041_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1040
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1041
 add key a042_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1042
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1043
 add key a043_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1044
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1045
 add key a044_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1046
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1047
 add key a045_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1048
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1049
 add key a046_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1050
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1051
 add key a047_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1052
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1053
 add key a048_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1054
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1055
 add key a049_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1056
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1057
 
 
1058
 add key a050_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1059
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1060
 add key a051_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1061
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1062
 add key a052_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1063
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1064
 add key a053_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1065
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1066
 add key a054_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1067
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1068
 add key a055_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1069
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1070
 add key a056_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1071
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1072
 add key a057_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1073
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1074
 add key a058_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1075
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1076
 add key a059_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1077
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1078
 
 
1079
 add key a060_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1080
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1081
 add key a061_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1082
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1083
 add key a062_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1084
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1085
 add key a063_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1086
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16),
 
1087
 add key a064_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1088
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
 
1089
 
 
1090
show create table t1;
 
1091
flush tables;
 
1092
show create table t1;
 
1093
 
 
1094
# Test the server limits; if any of these pass, all above tests need
 
1095
# to be rewritten to hit the limit
 
1096
#
 
1097
# Ensure limit is really 64 keys
 
1098
--error 1069
 
1099
alter table t1 add key 
 
1100
 a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
 
1101
  c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
 
1102
 
 
1103
drop table t1;
 
1104
 
 
1105
# Ensure limit is really 16 key parts per key
 
1106
 
 
1107
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
 
1108
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, 
 
1109
c16 int, c17 int);
 
1110
 
 
1111
# Get error for max key parts
 
1112
--error 1070
 
1113
alter table t1 add key i1 (
 
1114
 c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16, c17);
 
1115
 
 
1116
# Get error for max key-name length
 
1117
--error 1059
 
1118
alter table t1 add key 
 
1119
 a001_long_123456789_123456789_123456789_123456789_123456789_12345 (c1);
 
1120
 
 
1121
show create table t1;
 
1122
 
 
1123
drop table t1;
 
1124
 
 
1125
--echo
 
1126
--echo Bug #26104 Bug on foreign key class constructor
 
1127
--echo
 
1128
--echo Check that ref_columns is initalized correctly in the constructor
 
1129
--echo and semantic checks in mysql_prepare_table work.
 
1130
--echo
 
1131
--echo We do not need a storage engine that supports foreign keys
 
1132
--echo for this test, as the checks are purely syntax-based, and the
 
1133
--echo syntax is supported for all engines.
 
1134
--echo
 
1135
--disable_warnings
 
1136
drop table if exists t1,t2;
 
1137
--enable_warnings
 
1138
 
 
1139
create table t1(a int not null, b int not null, primary key (a, b));
 
1140
--error ER_WRONG_FK_DEF
 
1141
create table t2(a int not null, b int not null, c int not null, primary key (a),
 
1142
foreign key fk_bug26104 (b,c) references t1(a));
 
1143
drop table t1;
 
1144
 
 
1145
#
 
1146
# Bug#15130:CREATE .. SELECT was denied to use advantages of the SQL_BIG_RESULT.
 
1147
#
 
1148
create table t1(f1 int,f2 int);
 
1149
insert into t1 value(1,1),(1,2),(1,3),(2,1),(2,2),(2,3);
 
1150
flush status;
 
1151
create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
 
1152
show status like 'handler_read%';
 
1153
drop table t1,t2;
 
1154
 
 
1155
#
 
1156
# Bug #25162: Backing up DB from 5.1 adds 'USING BTREE' to KEYs on table creates
 
1157
#
 
1158
 
 
1159
# Show that the old syntax for index type is supported
 
1160
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
 
1161
DROP TABLE t1;
 
1162
 
 
1163
# Show that the new syntax for index type is supported
 
1164
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
 
1165
DROP TABLE t1;
 
1166
 
 
1167
# Show that in case of multiple index type definitions, the last one takes 
 
1168
# precedence
 
1169
 
 
1170
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
 
1171
SHOW INDEX FROM t1;
 
1172
DROP TABLE t1;
 
1173
 
 
1174
CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
 
1175
SHOW INDEX FROM t1;
 
1176
DROP TABLE t1;
 
1177
 
 
1178
 
 
1179
--echo End of 5.0 tests
 
1180
 
 
1181
#
 
1182
# Test of behaviour with CREATE ... SELECT
 
1183
#
 
1184
 
 
1185
CREATE TABLE t1 (a int, b int);
 
1186
insert into t1 values (1,1),(1,2);
 
1187
--error ER_DUP_ENTRY
 
1188
CREATE TABLE t2 (primary key (a)) select * from t1;
 
1189
# This should give warning
 
1190
drop table if exists t2;
 
1191
--error ER_DUP_ENTRY
 
1192
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
 
1193
# This should give warning
 
1194
drop table if exists t2;
 
1195
CREATE TABLE t2 (a int, b int, primary key (a));
 
1196
--error ER_DUP_ENTRY
 
1197
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
 
1198
SELECT * from t2;
 
1199
TRUNCATE table t2;
 
1200
--error ER_DUP_ENTRY
 
1201
INSERT INTO t2 select * from t1;
 
1202
SELECT * from t2;
 
1203
drop table t2;
 
1204
 
 
1205
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
 
1206
--error ER_DUP_ENTRY
 
1207
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
 
1208
SELECT * from t2;
 
1209
TRUNCATE table t2;
 
1210
--error ER_DUP_ENTRY
 
1211
INSERT INTO t2 select * from t1;
 
1212
SELECT * from t2;
 
1213
drop table t1,t2;
 
1214
 
 
1215
 
 
1216
#
 
1217
# Test incorrect database names
 
1218
#
 
1219
 
 
1220
--error 1102
 
1221
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1222
--error 1102
 
1223
DROP DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1224
 
 
1225
# TODO: enable these tests when RENAME DATABASE is implemented.
 
1226
# --error 1049
 
1227
# RENAME DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa TO a;
 
1228
# --error 1102
 
1229
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1230
# create database mysqltest;
 
1231
# --error 1102
 
1232
# RENAME DATABASE mysqltest TO aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1233
# drop database mysqltest;
 
1234
 
 
1235
--error 1102
 
1236
USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1237
--error 1102
 
1238
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
 
1239
 
 
1240
#
 
1241
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
 
1242
#
 
1243
set names utf8;
 
1244
 
 
1245
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
 
1246
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
 
1247
select database();
 
1248
use test;
 
1249
 
 
1250
select SCHEMA_NAME from information_schema.schemata
 
1251
where schema_name='имя_базы_в_кодировке_утф8_длиной_больше_чем_45';
 
1252
 
 
1253
drop database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
 
1254
create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48
 
1255
(
 
1256
  имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int,
 
1257
  index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45)
 
1258
);
 
1259
 
 
1260
create view имя_вью_кодировке_утф8_длиной_больше_чем_42 as
 
1261
select имя_поля_в_кодировке_утф8_длиной_больше_чем_45
 
1262
from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
 
1263
 
 
1264
# database, table, field, key, view
 
1265
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
 
1266
 
 
1267
select TABLE_NAME from information_schema.tables where
 
1268
table_schema='test';
 
1269
 
 
1270
select COLUMN_NAME from information_schema.columns where
 
1271
table_schema='test';
 
1272
 
 
1273
select INDEX_NAME from information_schema.statistics where
 
1274
table_schema='test';
 
1275
 
 
1276
select TABLE_NAME from information_schema.views where
 
1277
table_schema='test';
 
1278
 
 
1279
show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
 
1280
show create view имя_вью_кодировке_утф8_длиной_больше_чем_42;
 
1281
 
 
1282
# procedure, function, trigger
 
1283
 
 
1284
create trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49
 
1285
before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1;
 
1286
select TRIGGER_NAME from information_schema.triggers where
 
1287
trigger_schema='test';
 
1288
drop trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49;
 
1289
--error 1059
 
1290
create trigger
 
1291
очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66
 
1292
before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1;
 
1293
--error 1059
 
1294
drop trigger очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66;
 
1295
 
 
1296
create procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50()
 
1297
begin
 
1298
end;
 
1299
select ROUTINE_NAME from information_schema.routines where
 
1300
routine_schema='test';
 
1301
drop procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50;
 
1302
--error 1059
 
1303
create procedure очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66()
 
1304
begin
 
1305
end;
 
1306
 
 
1307
create function имя_функции_в_кодировке_утф8_длиной_больше_чем_49()
 
1308
   returns int
 
1309
return 0;
 
1310
select ROUTINE_NAME from information_schema.routines where
 
1311
routine_schema='test';
 
1312
drop function имя_функции_в_кодировке_утф8_длиной_больше_чем_49;
 
1313
--error 1059
 
1314
create function очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66()
 
1315
   returns int
 
1316
return 0;
 
1317
 
 
1318
drop view имя_вью_кодировке_утф8_длиной_больше_чем_42;
 
1319
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
 
1320
set names default;
 
1321
 
 
1322
#
 
1323
# Bug#21136 CREATE TABLE SELECT within CREATE TABLE SELECT causes server crash
 
1324
#
 
1325
 
 
1326
--disable_warnings
 
1327
drop table if exists t1,t2,t3;
 
1328
drop function if exists f1;
 
1329
--enable_warnings
 
1330
 
 
1331
--delimiter |
 
1332
create function f1() returns int
 
1333
begin
 
1334
  declare res int;
 
1335
  create temporary table t3 select 1 i;
 
1336
  set res:= (select count(*) from t1);
 
1337
  drop temporary table t3;
 
1338
  return res;
 
1339
end|
 
1340
--delimiter ;
 
1341
create table t1 as select 1;
 
1342
create table t2 as select f1() from t1;
 
1343
drop table t1,t2;
 
1344
drop function f1;
 
1345
 
 
1346
#
 
1347
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
 
1348
#
 
1349
create table t1 like information_schema.processlist;
 
1350
show create table t1;
 
1351
drop table t1;
 
1352
create temporary table t1 like information_schema.processlist;
 
1353
show create table t1;
 
1354
drop table t1;
 
1355
create table t1 like information_schema.character_sets;
 
1356
show create table t1;
 
1357
drop table t1;
 
1358
 
 
1359
###########################################################################
 
1360
 
 
1361
--echo
 
1362
--echo # --
 
1363
--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE
 
1364
--echo # -- TABLE/SELECT to the new table.
 
1365
--echo # --
 
1366
--echo
 
1367
 
 
1368
 
 
1369
--disable_warnings
 
1370
DROP TABLE IF EXISTS t1;
 
1371
DROP TABLE IF EXISTS t2;
 
1372
--enable_warnings
 
1373
 
 
1374
--echo
 
1375
 
 
1376
CREATE TABLE t1(
 
1377
  c1 INT DEFAULT 12 COMMENT 'column1',
 
1378
  c2 INT NULL COMMENT 'column2',
 
1379
  c3 INT NOT NULL COMMENT 'column3',
 
1380
  c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a',
 
1381
  c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
 
1382
  c6 VARCHAR(255))
 
1383
  COLLATE latin1_bin;
 
1384
 
 
1385
--echo
 
1386
 
 
1387
SHOW CREATE TABLE t1;
 
1388
 
 
1389
--echo
 
1390
 
 
1391
CREATE TABLE t2 AS SELECT * FROM t1;
 
1392
 
 
1393
--echo
 
1394
 
 
1395
SHOW CREATE TABLE t2;
 
1396
 
 
1397
--echo
 
1398
 
 
1399
DROP TABLE t2;
 
1400
 
 
1401
--echo
 
1402
--echo # -- End of test case for Bug#21380.
 
1403
 
 
1404
###########################################################################
 
1405
 
 
1406
--echo
 
1407
--echo # --
 
1408
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
 
1409
--echo # --
 
1410
--echo
 
1411
 
 
1412
--disable_warnings
 
1413
DROP TABLE IF EXISTS t1;
 
1414
DROP TABLE IF EXISTS t2;
 
1415
DROP TABLE IF EXISTS t3;
 
1416
--enable_warnings
 
1417
 
 
1418
--echo
 
1419
 
 
1420
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
 
1421
 
 
1422
--echo
 
1423
 
 
1424
SET sql_mode = NO_ZERO_DATE;
 
1425
 
 
1426
--echo
 
1427
--error ER_INVALID_DEFAULT
 
1428
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
 
1429
 
 
1430
--echo
 
1431
--error ER_INVALID_DEFAULT
 
1432
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
 
1433
 
 
1434
--echo
 
1435
--echo # -- Check that NULL column still can be created.
 
1436
CREATE TABLE t2(c1 TIMESTAMP NULL);
 
1437
 
 
1438
--echo
 
1439
--echo # -- Check ALTER TABLE.
 
1440
--error ER_INVALID_DEFAULT
 
1441
ALTER TABLE t1 ADD INDEX(c1);
 
1442
 
 
1443
--echo
 
1444
--echo # -- Check DATETIME.
 
1445
SET sql_mode = '';
 
1446
 
 
1447
--echo
 
1448
 
 
1449
CREATE TABLE t3(c1 DATETIME NOT NULL);
 
1450
INSERT INTO t3 VALUES (0);
 
1451
 
 
1452
--echo
 
1453
SET sql_mode = TRADITIONAL;
 
1454
 
 
1455
--echo
 
1456
--error ER_TRUNCATED_WRONG_VALUE
 
1457
ALTER TABLE t3 ADD INDEX(c1);
 
1458
 
 
1459
--echo
 
1460
--echo # -- Cleanup.
 
1461
 
 
1462
SET sql_mode = '';
 
1463
DROP TABLE t1;
 
1464
DROP TABLE t2;
 
1465
DROP TABLE t3;
 
1466
 
 
1467
--echo
 
1468
--echo # -- End of Bug#18834.
 
1469
 
 
1470
###########################################################################
 
1471
 
 
1472
--echo
 
1473
--echo # --
 
1474
--echo # -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
 
1475
--echo # --
 
1476
--echo
 
1477
 
 
1478
--disable_warnings
 
1479
DROP TABLE IF EXISTS t1;
 
1480
--enable_warnings
 
1481
 
 
1482
--echo
 
1483
CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
 
1484
 
 
1485
--echo
 
1486
SHOW CREATE TABLE t1;
 
1487
 
 
1488
--echo
 
1489
INSERT INTO t1 VALUES();
 
1490
 
 
1491
--echo
 
1492
SELECT * FROM t1;
 
1493
 
 
1494
--echo
 
1495
ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
 
1496
 
 
1497
--echo
 
1498
SHOW CREATE TABLE t1;
 
1499
 
 
1500
--echo
 
1501
INSERT INTO t1 VALUES();
 
1502
 
 
1503
--echo
 
1504
SELECT * FROM t1;
 
1505
 
 
1506
--echo
 
1507
DROP TABLE t1;
 
1508
 
 
1509
--echo
 
1510
--echo # -- End of Bug#34274
 
1511
 
 
1512
###########################################################################
 
1513
 
 
1514
--echo
 
1515
--echo End of 5.1 tests