~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/create.result

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
Warnings:
13
13
Note    1050    Table 't1' already exists
14
14
insert into t1 values (""),(null);
15
 
Warnings:
16
 
Warning 1048    Column 'b' cannot be null
 
15
ERROR 23000: Column 'b' cannot be null
17
16
select * from t1;
18
17
b
19
 
 
20
 
 
21
 
drop table t1;
22
 
create table t1 (a int not null auto_increment,primary key (a)) engine=heap;
23
 
drop table t1;
24
 
create table t2 engine=heap select * from t1;
 
18
drop table t1;
 
19
create temporary table t1 (a int not null auto_increment,primary key (a)) engine=heap;
 
20
drop table t1;
 
21
create temporary table t2 engine=heap select * from t1;
25
22
ERROR 42S02: Table 'test.t1' doesn't exist
26
23
create table t2 select auto+1 from t1;
27
24
ERROR 42S02: Table 'test.t1' doesn't exist
31
28
Note    1051    Unknown table 't2'
32
29
create table t1 (b char(0) not null, index(b));
33
30
ERROR 42000: The used storage engine can't index column 'b'
34
 
create table t1 (a int not null,b text) engine=heap;
 
31
create temporary table t1 (a int not null,b text) engine=heap;
35
32
ERROR 42000: The used table type doesn't support BLOB/TEXT columns
36
33
drop table if exists t1;
37
34
Warnings:
38
35
Note    1051    Unknown table 't1'
39
 
create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=heap;
 
36
create temporary table t1 (ordid int not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=heap;
40
37
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
41
38
create table not_existing_database.test (a int);
42
39
ERROR 42000: Unknown database 'not_existing_database'
44
41
show create table `a/a`;
45
42
Table   Create Table
46
43
a/a     CREATE TABLE `a/a` (
47
 
  `a` int(11) DEFAULT NULL
48
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
44
  `a` int DEFAULT NULL
 
45
) ENGINE=DEFAULT
49
46
create table t1 like `a/a`;
50
47
drop table `a/a`;
51
48
drop table `t1`;
59
56
ERROR HY000: Invalid ON UPDATE clause for 'a' column
60
57
create table t1 (a int default 100 auto_increment);
61
58
ERROR 42000: Invalid default value for 'a'
62
 
create table t1 (a tinyint default 1000);
63
 
ERROR 42000: Invalid default value for 'a'
64
59
create table t1 (a varchar(5) default 'abcdef');
65
60
ERROR 42000: Invalid default value for 'a'
66
61
create table t1 (a varchar(5) default 'abcde');
104
99
create table t2 (key (b)) select * from t1;
105
100
explain select * from t2 where b="world";
106
101
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
107
 
1       SIMPLE  t2      ref     B       B       21      const   1       Using index condition
 
102
1       SIMPLE  t2      ref     B       B       83      const   1       Using where
108
103
select * from t2 where b="world";
109
104
a       B
110
105
3       world
118
113
Field   Type    Null    Key     Default Extra
119
114
x       varchar(50)     YES             NULL    
120
115
drop table t2;
121
 
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;
 
116
create table t2 select now() as a , curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
122
117
describe t2;
123
118
Field   Type    Null    Key     Default Extra
124
 
a       datetime        NO              0000-00-00 00:00:00     
125
 
b       time    NO              00:00:00        
126
 
c       date    NO              0000-00-00      
127
 
d       int(3)  NO              0       
128
 
e       decimal(3,1)    NO              0.0     
129
 
f       bigint(19)      NO              0       
 
119
a       datetime        YES             NULL    
 
120
c       date    NO              NULL    
 
121
d       int     NO              NULL    
 
122
e       decimal(3,1)    NO              NULL    
 
123
f       bigint  NO              NULL    
130
124
drop table t2;
131
 
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;
 
125
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("2001-12-29  20:45:11" AS DATETIME) as dt;
132
126
describe t2;
133
127
Field   Type    Null    Key     Default Extra
134
128
d       date    YES             NULL    
135
 
t       time    YES             NULL    
136
129
dt      datetime        YES             NULL    
137
130
drop table t1,t2;
138
 
create table t1 (a tinyint);
 
131
create table t1 (a int);
139
132
create table t2 (a int) select * from t1;
140
133
describe t1;
141
134
Field   Type    Null    Key     Default Extra
142
 
a       tinyint(4)      YES             NULL    
 
135
a       int     YES             NULL    
143
136
describe t2;
144
137
Field   Type    Null    Key     Default Extra
145
 
a       int(11) YES             NULL    
 
138
a       int     YES             NULL    
146
139
drop table if exists t2;
147
140
create table t2 (a int, a float) select * from t1;
148
141
ERROR 42S21: Duplicate column name 'a'
173
166
show create table t1;
174
167
Table   Create Table
175
168
t1      CREATE TABLE `t1` (
176
 
  `a` int(11) NOT NULL,
177
 
  `b` int(11) DEFAULT NULL,
 
169
  `a` int NOT NULL,
 
170
  `b` int DEFAULT NULL,
178
171
  PRIMARY KEY (`a`),
179
172
  KEY `b` (`b`),
180
173
  KEY `b_2` (`b`),
207
200
  KEY `b_29` (`b`),
208
201
  KEY `b_30` (`b`),
209
202
  KEY `b_31` (`b`)
210
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
203
) ENGINE=DEFAULT
211
204
drop table t1;
212
205
create table t1 select if(1,'1','0'), month("2002-08-02");
213
206
drop table t1;
220
213
SELECT @@storage_engine;
221
214
@@storage_engine
222
215
MEMORY
223
 
CREATE TABLE t1 (a int not null);
 
216
CREATE TEMPORARY TABLE t1 (a int not null);
224
217
show create table t1;
225
218
Table   Create Table
226
 
t1      CREATE TABLE `t1` (
227
 
  `a` int(11) NOT NULL
228
 
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
219
t1      CREATE TEMPORARY TABLE `t1` (
 
220
  `a` int NOT NULL
 
221
) ENGINE=MEMORY
229
222
drop table t1;
230
223
SET SESSION storage_engine="gemini";
231
224
ERROR 42000: Unknown table engine 'gemini'
232
225
SELECT @@storage_engine;
233
226
@@storage_engine
234
227
MEMORY
235
 
CREATE TABLE t1 (a int not null);
 
228
CREATE TEMPORARY TABLE t1 (a int not null);
236
229
show create table t1;
237
230
Table   Create Table
238
 
t1      CREATE TABLE `t1` (
239
 
  `a` int(11) NOT NULL
240
 
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
231
t1      CREATE TEMPORARY TABLE `t1` (
 
232
  `a` int NOT NULL
 
233
) ENGINE=MEMORY
241
234
SET SESSION storage_engine=default;
242
235
drop table t1;
243
236
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
253
246
drop table t1;
254
247
create table t1 select 1,2,3;
255
248
create table if not exists t1 select 1,2;
256
 
Warnings:
257
 
Note    1050    Table 't1' already exists
 
249
ERROR HY000: Field '1' doesn't have a default value
258
250
create table if not exists t1 select 1,2,3,4;
259
251
ERROR 21S01: Column count doesn't match value count at row 1
260
252
create table if not exists t1 select 1;
261
 
Warnings:
262
 
Note    1050    Table 't1' already exists
 
253
ERROR HY000: Field '1' doesn't have a default value
263
254
select * from t1;
264
255
1       2       3
265
256
1       2       3
266
 
0       1       2
267
 
0       0       1
268
257
drop table t1;
269
258
flush status;
270
259
create table t1 (a int not null, b int, primary key (a));
271
260
insert into t1 values (1,1);
272
 
create table if not exists t1 select 2;
273
 
Warnings:
274
 
Note    1050    Table 't1' already exists
275
 
Warning 1364    Field 'a' doesn't have a default value
276
261
select * from t1;
277
262
a       b
278
263
1       1
279
 
0       2
280
264
create table if not exists t1 select 3 as 'a',4 as 'b';
281
265
Warnings:
282
266
Note    1050    Table 't1' already exists
292
276
select * from t1;
293
277
a       b
294
278
1       1
295
 
0       2
296
279
3       4
297
280
drop table t1;
298
281
create table `t1 `(a int);
302
285
create table t1(`a ` int);
303
286
ERROR 42000: Incorrect column name 'a '
304
287
create table t1 (a int,);
305
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
 
288
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near ')' at line 1
306
289
create table t1 (a int,,b int);
307
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b int)' at line 1
 
290
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'b int)' at line 1
308
291
create table t1 (,b int);
309
 
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'b int)' at line 1
 
292
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'b int)' at line 1
310
293
create table t1 (a int, key(a));
311
294
create table t2 (b int, foreign key(b) references t1(a), key(b));
312
295
drop table if exists t1,t2;
 
296
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
 
297
drop table if exists t2,t1;
 
298
Warnings:
 
299
Note    1051    Unknown table 't2'
313
300
create table t1(id int not null, name char(20));
314
301
insert into t1 values(10,'mysql'),(20,'monty- the creator');
315
302
create table t2(id int not null);
318
305
show create table t3;
319
306
Table   Create Table
320
307
t3      CREATE TABLE `t3` (
321
 
  `id` int(11) NOT NULL,
322
 
  `name` char(20) DEFAULT NULL
323
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
308
  `id` int NOT NULL,
 
309
  `name` varchar(20) DEFAULT NULL
 
310
) ENGINE=DEFAULT
324
311
select * from t3;
325
312
id      name
326
313
create table if not exists t3 like t1;
333
320
show create table t3;
334
321
Table   Create Table
335
322
t3      CREATE TEMPORARY TABLE `t3` (
336
 
  `id` int(11) NOT NULL
337
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
323
  `id` int NOT NULL
 
324
) ENGINE=DEFAULT
338
325
select * from t3;
339
326
id
340
327
drop table t3;
341
328
show create table t3;
342
329
Table   Create Table
343
330
t3      CREATE TABLE `t3` (
344
 
  `id` int(11) NOT NULL,
345
 
  `name` char(20) DEFAULT NULL
346
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
331
  `id` int NOT NULL,
 
332
  `name` varchar(20) DEFAULT NULL
 
333
) ENGINE=DEFAULT
347
334
select * from t3;
348
335
id      name
349
336
drop table t2, t3;
353
340
show create table t3;
354
341
Table   Create Table
355
342
t3      CREATE TEMPORARY TABLE `t3` (
356
 
  `id` int(11) NOT NULL,
357
 
  `name` char(20) DEFAULT NULL
358
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
343
  `id` int NOT NULL,
 
344
  `name` varchar(20) DEFAULT NULL
 
345
) ENGINE=DEFAULT
359
346
create table t2 like t3;
360
347
show create table t2;
361
348
Table   Create Table
362
349
t2      CREATE TABLE `t2` (
363
 
  `id` int(11) NOT NULL,
364
 
  `name` char(20) DEFAULT NULL
365
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
350
  `id` int NOT NULL,
 
351
  `name` varchar(20) DEFAULT NULL
 
352
) ENGINE=DEFAULT
366
353
select * from t2;
367
354
id      name
368
355
create table t3 like t1;
381
368
SELECT @@storage_engine;
382
369
@@storage_engine
383
370
MEMORY
384
 
CREATE TABLE t1 (a int not null);
 
371
CREATE TEMPORARY TABLE t1 (a int not null);
385
372
show create table t1;
386
373
Table   Create Table
387
 
t1      CREATE TABLE `t1` (
388
 
  `a` int(11) NOT NULL
389
 
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
374
t1      CREATE TEMPORARY TABLE `t1` (
 
375
  `a` int NOT NULL
 
376
) ENGINE=MEMORY
390
377
drop table t1;
391
378
SET SESSION storage_engine="gemini";
392
379
ERROR 42000: Unknown table engine 'gemini'
393
380
SELECT @@storage_engine;
394
381
@@storage_engine
395
382
MEMORY
396
 
CREATE TABLE t1 (a int not null);
 
383
CREATE TEMPORARY TABLE t1 (a int not null);
397
384
show create table t1;
398
385
Table   Create Table
399
 
t1      CREATE TABLE `t1` (
400
 
  `a` int(11) NOT NULL
401
 
) ENGINE=MEMORY DEFAULT CHARSET=latin1
 
386
t1      CREATE TEMPORARY TABLE `t1` (
 
387
  `a` int NOT NULL
 
388
) ENGINE=MEMORY
402
389
SET SESSION storage_engine=default;
403
390
drop table t1;
404
 
create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
 
391
create table t1(a int,b int,c int,d date,e char,f datetime,h blob);
405
392
insert into t1(a)values(1);
406
 
insert into t1(a,b,c,d,e,f,g,h)
407
 
values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
 
393
insert into t1(a,b,c,d,e,f,h)
 
394
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','binary data');
408
395
select * from t1;
409
 
a       b       c       d       e       f       g       h
410
 
1       NULL    NULL    NULL    NULL    NULL    NULL    NULL
411
 
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     04:03:02        binary data
 
396
a       b       c       d       e       f       h
 
397
1       NULL    NULL    NULL    NULL    NULL    NULL
 
398
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     binary data
412
399
select a, 
413
 
ifnull(b,cast(-7 as signed)) as b, 
414
 
ifnull(c,cast(7 as unsigned)) as c, 
 
400
ifnull(b,-7) as b, 
 
401
ifnull(c,7) as c, 
415
402
ifnull(d,cast('2000-01-01' as date)) as d, 
416
403
ifnull(e,cast('b' as char)) as e,
417
404
ifnull(f,cast('2000-01-01' as datetime)) as f, 
418
 
ifnull(g,cast('5:4:3' as time)) as g,
419
 
ifnull(h,cast('yet another binary data' as binary)) as h,
420
 
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd 
 
405
ifnull(h,cast('yet another binary data' as binary)) as h
421
406
from t1;
422
 
a       b       c       d       e       f       g       h       dd
423
 
1       -7      7       2000-01-01      b       2000-01-01 00:00:00     05:04:03        yet another binary data 02:00:00
424
 
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     04:03:02        binary data     02:00:00
 
407
a       b       c       d       e       f       h
 
408
1       -7      7       2000-01-01      b       2000-01-01 00:00:00     yet another binary data
 
409
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     binary data
425
410
create table t2
426
411
select
427
412
a, 
428
 
ifnull(b,cast(-7                        as signed))   as b,
429
 
ifnull(c,cast(7                         as unsigned)) as c,
 
413
ifnull(b,-7)                            as b,
 
414
ifnull(c,7)                             as c,
430
415
ifnull(d,cast('2000-01-01'              as date))     as d,
431
416
ifnull(e,cast('b'                       as char))     as e,
432
417
ifnull(f,cast('2000-01-01'              as datetime)) as f,
433
 
ifnull(g,cast('5:4:3'                   as time))     as g,
434
 
ifnull(h,cast('yet another binary data' as binary))   as h,
435
 
addtime(cast('1:0:0' as time),cast('1:0:0' as time))  as dd
 
418
ifnull(h,cast('yet another binary data' as binary))   as h
436
419
from t1;
437
420
explain t2;
438
421
Field   Type    Null    Key     Default Extra
439
 
a       int(11) YES             NULL    
440
 
b       bigint(11)      NO              0       
441
 
c       bigint(11) unsigned     NO              0       
 
422
a       int     YES             NULL    
 
423
b       bigint  NO              NULL    
 
424
c       bigint  NO              NULL    
442
425
d       date    YES             NULL    
443
 
e       varchar(1)      NO                      
 
426
e       varchar(1)      YES             NULL    
444
427
f       datetime        YES             NULL    
445
 
g       time    YES             NULL    
446
 
h       longblob        NO              NULL    
447
 
dd      time    YES             NULL    
 
428
h       blob    YES             NULL    
448
429
select * from t2;
449
 
a       b       c       d       e       f       g       h       dd
450
 
1       -7      7       2000-01-01      b       2000-01-01 00:00:00     05:04:03        yet another binary data 02:00:00
451
 
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     04:03:02        binary data     02:00:00
 
430
a       b       c       d       e       f       h
 
431
1       -7      7       2000-01-01      b       2000-01-01 00:00:00     yet another binary data
 
432
2       -2      2       1825-12-14      a       2003-01-01 03:02:01     binary data
452
433
drop table t1, t2;
453
 
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));
454
 
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;
 
434
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));
 
435
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;
455
436
show create table t2;
456
437
Table   Create Table
457
438
t2      CREATE TABLE `t2` (
458
 
  `ifnull(a,a)` tinyint(4) DEFAULT NULL,
459
 
  `ifnull(b,b)` smallint(6) DEFAULT NULL,
460
 
  `ifnull(c,c)` mediumint(8) DEFAULT NULL,
461
 
  `ifnull(d,d)` int(11) DEFAULT NULL,
462
 
  `ifnull(e,e)` bigint(20) DEFAULT NULL,
463
 
  `ifnull(f,f)` float(3,2) DEFAULT NULL,
 
439
  `ifnull(a,a)` int DEFAULT NULL,
 
440
  `ifnull(b,b)` int DEFAULT NULL,
 
441
  `ifnull(d,d)` int DEFAULT NULL,
 
442
  `ifnull(e,e)` bigint DEFAULT NULL,
 
443
  `ifnull(f,f)` double(3,2) DEFAULT NULL,
464
444
  `ifnull(g,g)` double(4,3) DEFAULT NULL,
465
445
  `ifnull(h,h)` decimal(5,4) DEFAULT NULL,
466
 
  `ifnull(i,i)` year(4) DEFAULT NULL,
467
446
  `ifnull(j,j)` date DEFAULT NULL,
468
 
  `ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 
447
  `ifnull(k,k)` timestamp NULL DEFAULT NULL,
469
448
  `ifnull(l,l)` datetime DEFAULT NULL,
470
449
  `ifnull(m,m)` varchar(1) DEFAULT NULL,
471
 
  `ifnull(n,n)` varchar(3) DEFAULT NULL,
472
450
  `ifnull(o,o)` varchar(10) DEFAULT NULL
473
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
451
) ENGINE=DEFAULT
474
452
drop table t1,t2;
475
453
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
476
454
insert into t1 values ('','',0,0.0);
478
456
Field   Type    Null    Key     Default Extra
479
457
str     varchar(10)     YES             def     
480
458
strnull varchar(10)     YES             NULL    
481
 
intg    int(11) YES             10      
 
459
intg    int     YES             10      
482
460
rel     double  YES             3.14    
483
461
create table t2 select default(str) as str, default(strnull) as strnull, default(intg) as intg, default(rel) as rel from t1;
484
462
describe t2;
485
463
Field   Type    Null    Key     Default Extra
486
464
str     varchar(10)     YES             NULL    
487
465
strnull varchar(10)     YES             NULL    
488
 
intg    int(11) YES             NULL    
 
466
intg    int     YES             NULL    
489
467
rel     double  YES             NULL    
490
468
drop table t1, t2;
491
 
create table t1(name varchar(10), age smallint default -1);
 
469
create table t1(name varchar(10), age int default -1);
492
470
describe t1;
493
471
Field   Type    Null    Key     Default Extra
494
472
name    varchar(10)     YES             NULL    
495
 
age     smallint(6)     YES             -1      
496
 
create table t2(name varchar(10), age smallint default - 1);
 
473
age     int     YES             -1      
 
474
create table t2(name varchar(10), age int default - 1);
497
475
describe t2;
498
476
Field   Type    Null    Key     Default Extra
499
477
name    varchar(10)     YES             NULL    
500
 
age     smallint(6)     YES             -1      
 
478
age     int     YES             -1      
501
479
drop table t1, t2;
502
 
create table t1(cenum enum('a'), cset set('b'));
503
 
create table t2(cenum enum('a','a'), cset set('b','b'));
504
 
Warnings:
505
 
Note    1291    Column 'cenum' has duplicated value 'a' in ENUM
506
 
Note    1291    Column 'cset' has duplicated value 'b' in SET
507
 
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
508
 
Warnings:
509
 
Note    1291    Column 'cenum' has duplicated value 'a' in ENUM
510
 
Note    1291    Column 'cenum' has duplicated value 'A' in ENUM
511
 
Note    1291    Column 'cenum' has duplicated value 'c' in ENUM
512
 
Note    1291    Column 'cset' has duplicated value 'b' in SET
513
 
Note    1291    Column 'cset' has duplicated value 'B' in SET
514
 
Note    1291    Column 'cset' has duplicated value 'd' in SET
515
 
drop table t1, t2, t3;
 
480
create table t1(cenum enum('a'));
 
481
create table t2(cenum enum('a','a'));
 
482
ERROR HY000: Column 'cenum' has duplicated value 'a' in ENUM
 
483
create table t3(cenum enum('a','A','a','c','c'));
 
484
ERROR HY000: Column 'cenum' has duplicated value 'a' in ENUM
 
485
drop table t1;
516
486
create database mysqltest;
517
487
use mysqltest;
518
488
select database();
522
492
select database();
523
493
database()
524
494
NULL
525
 
create user mysqltest_1;
526
 
select database(), user();
527
 
database()      user()
528
 
NULL    mysqltest_1@localhost
529
 
drop user mysqltest_1;
530
495
use test;
531
 
create table t1 (a int, index `primary` (a));
532
 
ERROR 42000: Incorrect index name 'primary'
533
 
create table t1 (a int, index `PRIMARY` (a));
534
 
ERROR 42000: Incorrect index name 'PRIMARY'
535
 
create table t1 (`primary` int, index(`primary`));
536
 
show create table t1;
537
 
Table   Create Table
538
 
t1      CREATE TABLE `t1` (
539
 
  `primary` int(11) DEFAULT NULL,
540
 
  KEY `primary_2` (`primary`)
541
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
542
 
create table t2 (`PRIMARY` int, index(`PRIMARY`));
543
 
show create table t2;
544
 
Table   Create Table
545
 
t2      CREATE TABLE `t2` (
546
 
  `PRIMARY` int(11) DEFAULT NULL,
547
 
  KEY `PRIMARY_2` (`PRIMARY`)
548
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
549
 
create table t3 (a int);
550
 
alter table t3 add index `primary` (a);
551
 
ERROR 42000: Incorrect index name 'primary'
552
 
alter table t3 add index `PRIMARY` (a);
553
 
ERROR 42000: Incorrect index name 'PRIMARY'
554
 
create table t4 (`primary` int);
555
 
alter table t4 add index(`primary`);
556
 
show create table t4;
557
 
Table   Create Table
558
 
t4      CREATE TABLE `t4` (
559
 
  `primary` int(11) DEFAULT NULL,
560
 
  KEY `primary_2` (`primary`)
561
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
562
 
create table t5 (`PRIMARY` int);
563
 
alter table t5 add index(`PRIMARY`);
564
 
show create table t5;
565
 
Table   Create Table
566
 
t5      CREATE TABLE `t5` (
567
 
  `PRIMARY` int(11) DEFAULT NULL,
568
 
  KEY `PRIMARY_2` (`PRIMARY`)
569
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
570
 
drop table t1, t2, t3, t4, t5;
571
496
CREATE TABLE t1(id varchar(10) NOT NULL PRIMARY KEY, dsc longtext);
572
497
INSERT INTO t1 VALUES ('5000000001', NULL),('5000000003', 'Test'),('5000000004', NULL);
573
498
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));
579
504
Test    0
580
505
NULL    1
581
506
drop table t1, t2, t3;
582
 
create table t1 (b bool not null default false);
583
 
create table t2 (b bool not null default true);
584
 
insert into t1 values ();
585
 
insert into t2 values ();
586
 
select * from t1;
587
 
b
588
 
0
589
 
select * from t2;
590
 
b
591
 
1
592
 
drop table t1,t2;
593
507
create table t1 (a int);
594
508
create table t1 select * from t1;
595
509
ERROR HY000: You can't specify target table 't1' for update in FROM clause
596
 
create table t2 union = (t1) select * from t1;
597
 
ERROR HY000: 'test.t2' is not BASE TABLE
598
510
flush tables with read lock;
599
511
unlock tables;
600
512
drop table t1;
607
519
create table t1(t1.name int);
608
520
create table t2(test.t2.name int);
609
521
drop table t1,t2;
610
 
CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
 
522
CREATE TABLE t1 (f1 VARCHAR(255));
611
523
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
612
524
DESC t2;
613
525
Field   Type    Null    Key     Default Extra
625
537
ERROR 3D000: No database selected
626
538
drop table if exists test.t1;
627
539
create database mysqltest;
628
 
use mysqltest;
629
 
create view v1 as select 'foo' from dual;
630
 
create table t1 like v1;
631
 
ERROR HY000: 'mysqltest.v1' is not BASE TABLE
632
 
drop view v1;
633
 
drop database mysqltest;
634
 
create database mysqltest;
635
 
create database if not exists mysqltest character set latin2;
 
540
create database if not exists mysqltest;
636
541
Warnings:
637
542
Note    1007    Can't create database 'mysqltest'; database exists
638
543
show create database mysqltest;
639
544
Database        Create Database
640
 
mysqltest       CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
 
545
mysqltest       CREATE DATABASE `mysqltest`
641
546
drop database mysqltest;
642
547
use test;
643
548
create table t1 (a int);
646
551
Note    1050    Table 't1' already exists
647
552
drop table t1;
648
553
create table t1 (
649
 
a varchar(112) charset utf8 collate utf8_bin not null,
 
554
a varchar(112) collate utf8_bin not null,
650
555
primary key (a)
651
556
) select 'test' as a ;
652
557
show create table t1;
654
559
t1      CREATE TABLE `t1` (
655
560
  `a` varchar(112) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
656
561
  PRIMARY KEY (`a`)
657
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
562
) ENGINE=DEFAULT
658
563
drop table t1;
659
564
CREATE TABLE t2 (
660
 
a int(11) default NULL
 
565
a int default NULL
661
566
);
662
567
insert into t2 values(111);
663
568
create table t1 ( 
664
 
a varchar(12) charset utf8 collate utf8_bin not null, 
 
569
a varchar(12) collate utf8_bin not null, 
665
570
b int not null, primary key (a)
666
571
) select a, 1 as b from t2 ;
667
572
show create table t1;
668
573
Table   Create Table
669
574
t1      CREATE TABLE `t1` (
670
575
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
671
 
  `b` int(11) NOT NULL,
 
576
  `b` int NOT NULL,
672
577
  PRIMARY KEY (`a`)
673
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
578
) ENGINE=DEFAULT
674
579
drop table t1;
675
580
create table t1 ( 
676
 
a varchar(12) charset utf8 collate utf8_bin not null, 
 
581
a varchar(12) collate utf8_bin not null, 
677
582
b int not null, primary key (a)
678
583
) select a, 1 as c from t2 ;
679
 
Warnings:
680
 
Warning 1364    Field 'b' doesn't have a default value
681
 
show create table t1;
682
 
Table   Create Table
683
 
t1      CREATE TABLE `t1` (
684
 
  `b` int(11) NOT NULL,
685
 
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
686
 
  `c` int(1) NOT NULL DEFAULT '0',
687
 
  PRIMARY KEY (`a`)
688
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
689
 
drop table t1;
 
584
ERROR HY000: Field 'b' doesn't have a default value
690
585
create table t1 ( 
691
 
a varchar(12) charset utf8 collate utf8_bin not null, 
 
586
a varchar(12) collate utf8_bin not null, 
692
587
b int null, primary key (a)
693
588
) select a, 1 as c from t2 ;
694
589
show create table t1;
695
590
Table   Create Table
696
591
t1      CREATE TABLE `t1` (
697
 
  `b` int(11) DEFAULT NULL,
698
 
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
699
 
  `c` int(1) NOT NULL DEFAULT '0',
700
 
  PRIMARY KEY (`a`)
701
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
702
 
drop table t1;
703
 
create table t1 ( 
704
 
a varchar(12) charset utf8 collate utf8_bin not null,
705
 
b int not null, primary key (a)
706
 
) select 'a' as a , 1 as b from t2 ;
707
 
show create table t1;
708
 
Table   Create Table
709
 
t1      CREATE TABLE `t1` (
710
 
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
711
 
  `b` int(11) NOT NULL,
712
 
  PRIMARY KEY (`a`)
713
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
714
 
drop table t1;
715
 
create table t1 ( 
716
 
a varchar(12) charset utf8 collate utf8_bin,
717
 
b int not null, primary key (a)
718
 
) select 'a' as a , 1 as b from t2 ;
719
 
show create table t1;
720
 
Table   Create Table
721
 
t1      CREATE TABLE `t1` (
722
 
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
723
 
  `b` int(11) NOT NULL,
724
 
  PRIMARY KEY (`a`)
725
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
592
  `b` int DEFAULT NULL,
 
593
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
 
594
  `c` int NOT NULL,
 
595
  PRIMARY KEY (`a`)
 
596
) ENGINE=DEFAULT
 
597
drop table t1;
 
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
show create table t1;
 
603
Table   Create Table
 
604
t1      CREATE TABLE `t1` (
 
605
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
 
606
  `b` int NOT NULL,
 
607
  PRIMARY KEY (`a`)
 
608
) ENGINE=DEFAULT
 
609
drop table t1;
 
610
create table t1 ( 
 
611
a varchar(12) collate utf8_bin,
 
612
b int not null, primary key (a)
 
613
) select 'a' as a , 1 as b from t2 ;
 
614
show create table t1;
 
615
Table   Create Table
 
616
t1      CREATE TABLE `t1` (
 
617
  `a` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
 
618
  `b` int NOT NULL,
 
619
  PRIMARY KEY (`a`)
 
620
) ENGINE=DEFAULT
726
621
drop table t1, t2;
727
622
create table t1 ( 
728
623
a1 int not null,
730
625
);
731
626
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
732
627
create table t2 ( 
733
 
a1 varchar(12) charset utf8 collate utf8_bin not null,
 
628
a1 varchar(12) collate utf8_bin not null,
734
629
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
735
630
primary key (a1)
736
631
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
737
632
drop table t2;
738
633
create table t2 ( 
739
 
a1 varchar(12) charset utf8 collate utf8_bin,
 
634
a1 varchar(12) collate utf8_bin,
740
635
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
741
636
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
742
637
drop table t1, t2;
745
640
);
746
641
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
747
642
create table t2 ( 
748
 
a1 varchar(12) charset utf8 collate utf8_bin not null,
 
643
a1 varchar(12) collate utf8_bin not null,
749
644
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
750
645
primary key (a1)
751
646
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
755
650
show create table t2;
756
651
Table   Create Table
757
652
t2      CREATE TABLE `t2` (
758
 
  `a` int(11) DEFAULT '3',
759
 
  `b` int(11) DEFAULT '3',
760
 
  `a1` int(11) DEFAULT NULL,
761
 
  `a2` int(11) DEFAULT NULL
762
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
653
  `a` int DEFAULT '3',
 
654
  `b` int DEFAULT '3',
 
655
  `a1` int DEFAULT NULL,
 
656
  `a2` int DEFAULT NULL
 
657
) ENGINE=DEFAULT
763
658
drop table t1, t2;
764
 
create table t1(a set("a,b","c,d") not null);
765
 
ERROR 22007: Illegal set 'a,b' value found during parsing
766
 
create table t1 (i int) engine=myisam max_rows=100000000000;
767
 
show create table t1;
768
 
Table   Create Table
769
 
t1      CREATE TABLE `t1` (
770
 
  `i` int(11) DEFAULT NULL
771
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
772
 
alter table t1 max_rows=100;
773
 
show create table t1;
774
 
Table   Create Table
775
 
t1      CREATE TABLE `t1` (
776
 
  `i` int(11) DEFAULT NULL
777
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=100
778
 
alter table t1 max_rows=100000000000;
779
 
show create table t1;
780
 
Table   Create Table
781
 
t1      CREATE TABLE `t1` (
782
 
  `i` int(11) DEFAULT NULL
783
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 MAX_ROWS=4294967295
784
 
drop table t1;
785
659
create table t1 select * from t2;
786
660
ERROR 42S02: Table 'test.t2' doesn't exist
787
661
create table t1 select * from t1;
788
662
ERROR HY000: You can't specify target table 't1' for update in FROM clause
789
 
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
790
 
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
 
663
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
 
664
ERROR HY000: Illegal mix of collations (utf8_swedish_ci,EXPLICIT) and (utf8_bin,EXPLICIT) for operation 'coalesce'
791
665
create table t1 (primary key(a)) select "b" as b;
792
666
ERROR 42000: Key column 'a' doesn't exist in table
793
 
create table t1 (a int);
794
 
create table if not exists t1 select 1 as a, 2 as b;
795
 
ERROR 21S01: Column count doesn't match value count at row 1
796
 
drop table t1;
797
667
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
798
668
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
799
669
create table t1 (i int);
800
 
create table t1 select 1 as i;
801
 
ERROR 42S01: Table 't1' already exists
802
670
create table if not exists t1 select 1 as i;
803
671
Warnings:
804
672
Note    1050    Table 't1' already exists
805
673
select * from t1;
806
674
i
807
675
1
808
 
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
809
 
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
810
 
select * from t1;
811
 
i
812
 
1
813
 
alter table t1 add primary key (i);
814
 
create table if not exists t1 (select 2 as i) union all (select 2 as i);
815
 
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
816
 
select * from t1;
817
 
i
818
 
1
819
 
2
820
676
drop table t1;
 
677
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
 
678
ERROR HY000: Illegal mix of collations (utf8_swedish_ci,EXPLICIT) and (utf8_bin,EXPLICIT) for operation 'coalesce'
821
679
create temporary table t1 (j int);
822
680
create table if not exists t1 select 1;
823
681
Warnings:
830
688
ERROR 42S02: Table 'test.t1' doesn't exist
831
689
drop table t1;
832
690
ERROR 42S02: Unknown table 't1'
833
 
create table t1 (i int);
834
 
insert into t1 values (1), (2);
835
 
lock tables t1 read;
836
 
create table t2 select * from t1;
837
 
ERROR HY000: Table 't2' was not locked with LOCK TABLES
838
 
create table if not exists t2 select * from t1;
839
 
ERROR HY000: Table 't2' was not locked with LOCK TABLES
840
 
unlock tables;
841
 
create table t2 (j int);
842
 
lock tables t1 read;
843
 
create table t2 select * from t1;
844
 
ERROR HY000: Table 't2' was not locked with LOCK TABLES
845
 
create table if not exists t2 select * from t1;
846
 
ERROR HY000: Table 't2' was not locked with LOCK TABLES
847
 
unlock tables;
848
 
lock table t1 read, t2 read;
849
 
create table t2 select * from t1;
850
 
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
851
 
create table if not exists t2 select * from t1;
852
 
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
853
 
unlock tables;
854
 
lock table t1 read, t2 write;
855
 
create table t2 select * from t1;
856
 
ERROR 42S01: Table 't2' already exists
857
 
create table if not exists t2 select * from t1;
858
 
Warnings:
859
 
Note    1050    Table 't2' already exists
860
 
select * from t1;
861
 
i
862
 
1
863
 
2
864
 
unlock tables;
865
 
drop table t2;
866
 
lock tables t1 read;
867
 
create temporary table t2 select * from t1;
868
 
create temporary table if not exists t2 select * from t1;
869
 
Warnings:
870
 
Note    1050    Table 't2' already exists
871
 
select * from t2;
872
 
i
873
 
1
874
 
2
875
 
1
876
 
2
877
 
unlock tables;
878
 
drop table t1, t2;
879
691
create table t1 (upgrade int);
880
692
drop table t1;
881
693
create table t1 (
1013
825
show create table t1;
1014
826
Table   Create Table
1015
827
t1      CREATE TABLE `t1` (
1016
 
  `c1` int(11) DEFAULT NULL,
1017
 
  `c2` int(11) DEFAULT NULL,
1018
 
  `c3` int(11) DEFAULT NULL,
1019
 
  `c4` int(11) DEFAULT NULL,
1020
 
  `c5` int(11) DEFAULT NULL,
1021
 
  `c6` int(11) DEFAULT NULL,
1022
 
  `c7` int(11) DEFAULT NULL,
1023
 
  `c8` int(11) DEFAULT NULL,
1024
 
  `c9` int(11) DEFAULT NULL,
1025
 
  `c10` int(11) DEFAULT NULL,
1026
 
  `c11` int(11) DEFAULT NULL,
1027
 
  `c12` int(11) DEFAULT NULL,
1028
 
  `c13` int(11) DEFAULT NULL,
1029
 
  `c14` int(11) DEFAULT NULL,
1030
 
  `c15` int(11) DEFAULT NULL,
1031
 
  `c16` int(11) DEFAULT NULL,
 
828
  `c1` int DEFAULT NULL,
 
829
  `c2` int DEFAULT NULL,
 
830
  `c3` int DEFAULT NULL,
 
831
  `c4` int DEFAULT NULL,
 
832
  `c5` int DEFAULT NULL,
 
833
  `c6` int DEFAULT NULL,
 
834
  `c7` int DEFAULT NULL,
 
835
  `c8` int DEFAULT NULL,
 
836
  `c9` int DEFAULT NULL,
 
837
  `c10` int DEFAULT NULL,
 
838
  `c11` int DEFAULT NULL,
 
839
  `c12` int DEFAULT NULL,
 
840
  `c13` int DEFAULT NULL,
 
841
  `c14` int DEFAULT NULL,
 
842
  `c15` int DEFAULT NULL,
 
843
  `c16` int DEFAULT NULL,
1032
844
  KEY `a001_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1033
845
  KEY `a002_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1034
846
  KEY `a003_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1093
905
  KEY `a062_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1094
906
  KEY `a063_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1095
907
  KEY `a064_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
1096
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
908
) ENGINE=DEFAULT
1097
909
flush tables;
1098
910
show create table t1;
1099
911
Table   Create Table
1100
912
t1      CREATE TABLE `t1` (
1101
 
  `c1` int(11) DEFAULT NULL,
1102
 
  `c2` int(11) DEFAULT NULL,
1103
 
  `c3` int(11) DEFAULT NULL,
1104
 
  `c4` int(11) DEFAULT NULL,
1105
 
  `c5` int(11) DEFAULT NULL,
1106
 
  `c6` int(11) DEFAULT NULL,
1107
 
  `c7` int(11) DEFAULT NULL,
1108
 
  `c8` int(11) DEFAULT NULL,
1109
 
  `c9` int(11) DEFAULT NULL,
1110
 
  `c10` int(11) DEFAULT NULL,
1111
 
  `c11` int(11) DEFAULT NULL,
1112
 
  `c12` int(11) DEFAULT NULL,
1113
 
  `c13` int(11) DEFAULT NULL,
1114
 
  `c14` int(11) DEFAULT NULL,
1115
 
  `c15` int(11) DEFAULT NULL,
1116
 
  `c16` int(11) DEFAULT NULL,
 
913
  `c1` int DEFAULT NULL,
 
914
  `c2` int DEFAULT NULL,
 
915
  `c3` int DEFAULT NULL,
 
916
  `c4` int DEFAULT NULL,
 
917
  `c5` int DEFAULT NULL,
 
918
  `c6` int DEFAULT NULL,
 
919
  `c7` int DEFAULT NULL,
 
920
  `c8` int DEFAULT NULL,
 
921
  `c9` int DEFAULT NULL,
 
922
  `c10` int DEFAULT NULL,
 
923
  `c11` int DEFAULT NULL,
 
924
  `c12` int DEFAULT NULL,
 
925
  `c13` int DEFAULT NULL,
 
926
  `c14` int DEFAULT NULL,
 
927
  `c15` int DEFAULT NULL,
 
928
  `c16` int DEFAULT NULL,
1117
929
  KEY `a001_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1118
930
  KEY `a002_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1119
931
  KEY `a003_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1178
990
  KEY `a062_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1179
991
  KEY `a063_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1180
992
  KEY `a064_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
1181
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
993
) ENGINE=DEFAULT
1182
994
drop table t1;
1183
995
create table t1 (c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, 
1184
996
c8 int, c9 int, c10 int, c11 int, c12 int, c13 int, c14 int, c15 int, c16 int);
1314
1126
show create table t1;
1315
1127
Table   Create Table
1316
1128
t1      CREATE TABLE `t1` (
1317
 
  `c1` int(11) DEFAULT NULL,
1318
 
  `c2` int(11) DEFAULT NULL,
1319
 
  `c3` int(11) DEFAULT NULL,
1320
 
  `c4` int(11) DEFAULT NULL,
1321
 
  `c5` int(11) DEFAULT NULL,
1322
 
  `c6` int(11) DEFAULT NULL,
1323
 
  `c7` int(11) DEFAULT NULL,
1324
 
  `c8` int(11) DEFAULT NULL,
1325
 
  `c9` int(11) DEFAULT NULL,
1326
 
  `c10` int(11) DEFAULT NULL,
1327
 
  `c11` int(11) DEFAULT NULL,
1328
 
  `c12` int(11) DEFAULT NULL,
1329
 
  `c13` int(11) DEFAULT NULL,
1330
 
  `c14` int(11) DEFAULT NULL,
1331
 
  `c15` int(11) DEFAULT NULL,
1332
 
  `c16` int(11) DEFAULT NULL,
 
1129
  `c1` int DEFAULT NULL,
 
1130
  `c2` int DEFAULT NULL,
 
1131
  `c3` int DEFAULT NULL,
 
1132
  `c4` int DEFAULT NULL,
 
1133
  `c5` int DEFAULT NULL,
 
1134
  `c6` int DEFAULT NULL,
 
1135
  `c7` int DEFAULT NULL,
 
1136
  `c8` int DEFAULT NULL,
 
1137
  `c9` int DEFAULT NULL,
 
1138
  `c10` int DEFAULT NULL,
 
1139
  `c11` int DEFAULT NULL,
 
1140
  `c12` int DEFAULT NULL,
 
1141
  `c13` int DEFAULT NULL,
 
1142
  `c14` int DEFAULT NULL,
 
1143
  `c15` int DEFAULT NULL,
 
1144
  `c16` int DEFAULT NULL,
1333
1145
  KEY `a001_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1334
1146
  KEY `a002_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1335
1147
  KEY `a003_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1394
1206
  KEY `a062_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1395
1207
  KEY `a063_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1396
1208
  KEY `a064_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
1397
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1209
) ENGINE=DEFAULT
1398
1210
flush tables;
1399
1211
show create table t1;
1400
1212
Table   Create Table
1401
1213
t1      CREATE TABLE `t1` (
1402
 
  `c1` int(11) DEFAULT NULL,
1403
 
  `c2` int(11) DEFAULT NULL,
1404
 
  `c3` int(11) DEFAULT NULL,
1405
 
  `c4` int(11) DEFAULT NULL,
1406
 
  `c5` int(11) DEFAULT NULL,
1407
 
  `c6` int(11) DEFAULT NULL,
1408
 
  `c7` int(11) DEFAULT NULL,
1409
 
  `c8` int(11) DEFAULT NULL,
1410
 
  `c9` int(11) DEFAULT NULL,
1411
 
  `c10` int(11) DEFAULT NULL,
1412
 
  `c11` int(11) DEFAULT NULL,
1413
 
  `c12` int(11) DEFAULT NULL,
1414
 
  `c13` int(11) DEFAULT NULL,
1415
 
  `c14` int(11) DEFAULT NULL,
1416
 
  `c15` int(11) DEFAULT NULL,
1417
 
  `c16` int(11) DEFAULT NULL,
 
1214
  `c1` int DEFAULT NULL,
 
1215
  `c2` int DEFAULT NULL,
 
1216
  `c3` int DEFAULT NULL,
 
1217
  `c4` int DEFAULT NULL,
 
1218
  `c5` int DEFAULT NULL,
 
1219
  `c6` int DEFAULT NULL,
 
1220
  `c7` int DEFAULT NULL,
 
1221
  `c8` int DEFAULT NULL,
 
1222
  `c9` int DEFAULT NULL,
 
1223
  `c10` int DEFAULT NULL,
 
1224
  `c11` int DEFAULT NULL,
 
1225
  `c12` int DEFAULT NULL,
 
1226
  `c13` int DEFAULT NULL,
 
1227
  `c14` int DEFAULT NULL,
 
1228
  `c15` int DEFAULT NULL,
 
1229
  `c16` int DEFAULT NULL,
1418
1230
  KEY `a001_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1419
1231
  KEY `a002_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1420
1232
  KEY `a003_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1479
1291
  KEY `a062_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1480
1292
  KEY `a063_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`),
1481
1293
  KEY `a064_long_123456789_123456789_123456789_123456789_123456789_1234` (`c1`,`c2`,`c3`,`c4`,`c5`,`c6`,`c7`,`c8`,`c9`,`c10`,`c11`,`c12`,`c13`,`c14`,`c15`,`c16`)
1482
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1294
) ENGINE=DEFAULT
1483
1295
alter table t1 add key 
1484
1296
a065_long_123456789_123456789_123456789_123456789_123456789_1234 (
1485
1297
c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16);
1497
1309
show create table t1;
1498
1310
Table   Create Table
1499
1311
t1      CREATE TABLE `t1` (
1500
 
  `c1` int(11) DEFAULT NULL,
1501
 
  `c2` int(11) DEFAULT NULL,
1502
 
  `c3` int(11) DEFAULT NULL,
1503
 
  `c4` int(11) DEFAULT NULL,
1504
 
  `c5` int(11) DEFAULT NULL,
1505
 
  `c6` int(11) DEFAULT NULL,
1506
 
  `c7` int(11) DEFAULT NULL,
1507
 
  `c8` int(11) DEFAULT NULL,
1508
 
  `c9` int(11) DEFAULT NULL,
1509
 
  `c10` int(11) DEFAULT NULL,
1510
 
  `c11` int(11) DEFAULT NULL,
1511
 
  `c12` int(11) DEFAULT NULL,
1512
 
  `c13` int(11) DEFAULT NULL,
1513
 
  `c14` int(11) DEFAULT NULL,
1514
 
  `c15` int(11) DEFAULT NULL,
1515
 
  `c16` int(11) DEFAULT NULL,
1516
 
  `c17` int(11) DEFAULT NULL
1517
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1312
  `c1` int DEFAULT NULL,
 
1313
  `c2` int DEFAULT NULL,
 
1314
  `c3` int DEFAULT NULL,
 
1315
  `c4` int DEFAULT NULL,
 
1316
  `c5` int DEFAULT NULL,
 
1317
  `c6` int DEFAULT NULL,
 
1318
  `c7` int DEFAULT NULL,
 
1319
  `c8` int DEFAULT NULL,
 
1320
  `c9` int DEFAULT NULL,
 
1321
  `c10` int DEFAULT NULL,
 
1322
  `c11` int DEFAULT NULL,
 
1323
  `c12` int DEFAULT NULL,
 
1324
  `c13` int DEFAULT NULL,
 
1325
  `c14` int DEFAULT NULL,
 
1326
  `c15` int DEFAULT NULL,
 
1327
  `c16` int DEFAULT NULL,
 
1328
  `c17` int DEFAULT NULL
 
1329
) ENGINE=DEFAULT
1518
1330
drop table t1;
1519
1331
 
1520
1332
Bug #26104 Bug on foreign key class constructor
1538
1350
create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
1539
1351
show status like 'handler_read%';
1540
1352
Variable_name   Value
1541
 
Handler_read_first      0
1542
 
Handler_read_key        0
 
1353
Handler_read_first      1
 
1354
Handler_read_key        3
1543
1355
Handler_read_next       0
1544
1356
Handler_read_prev       0
1545
1357
Handler_read_rnd        0
1549
1361
DROP TABLE t1;
1550
1362
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
1551
1363
DROP TABLE t1;
1552
 
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
 
1364
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
1553
1365
SHOW INDEX FROM t1;
1554
1366
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
1555
1367
t1      1       c1      1       c1      NULL    0       NULL    NULL    YES     HASH            
1556
1368
DROP TABLE t1;
1557
 
CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
 
1369
CREATE TEMPORARY TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
1558
1370
SHOW INDEX FROM t1;
1559
1371
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
1560
1372
t1      1       c1      1       c1      A       NULL    NULL    NULL    YES     BTREE           
1572
1384
drop table if exists t2;
1573
1385
Warnings:
1574
1386
Note    1051    Unknown table 't2'
1575
 
CREATE TABLE t2 (a int, b int, primary key (a));
1576
 
CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1577
 
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1578
 
SELECT * from t2;
1579
 
a       b
1580
 
1       1
1581
 
TRUNCATE table t2;
1582
 
INSERT INTO t2 select * from t1;
1583
 
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1584
 
SELECT * from t2;
1585
 
a       b
1586
 
1       1
1587
 
drop table t2;
1588
1387
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
1589
1388
CREATE TEMPORARY TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
1590
1389
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1591
1390
SELECT * from t2;
1592
1391
a       b
1593
 
1       1
1594
1392
TRUNCATE table t2;
1595
1393
INSERT INTO t2 select * from t1;
1596
1394
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
1597
1395
SELECT * from t2;
1598
1396
a       b
1599
 
1       1
1600
1397
drop table t1,t2;
1601
1398
CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1602
1399
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
1606
1403
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
1607
1404
SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
1608
1405
ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
1609
 
set names utf8;
1610
1406
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1611
1407
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1612
1408
select database();
1623
1419
имя_поля_в_кодировке_утф8_длиной_больше_чем_45 int,
1624
1420
index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45)
1625
1421
);
1626
 
create view имя_вью_кодировке_утф8_длиной_больше_чем_42 as
1627
 
select имя_поля_в_кодировке_утф8_длиной_больше_чем_45
1628
 
from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1629
1422
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1630
1423
имя_поля_в_кодировке_утф8_длиной_больше_чем_45
1631
1424
select TABLE_NAME from information_schema.tables where
1632
1425
table_schema='test';
1633
1426
TABLE_NAME
1634
 
имя_вью_кодировке_утф8_длиной_больше_чем_42
1635
1427
имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48
1636
1428
select COLUMN_NAME from information_schema.columns where
1637
1429
table_schema='test';
1638
1430
COLUMN_NAME
1639
1431
имя_поля_в_кодировке_утф8_длиной_больше_чем_45
1640
 
имя_поля_в_кодировке_утф8_длиной_больше_чем_45
1641
1432
select INDEX_NAME from information_schema.statistics where
1642
1433
table_schema='test';
1643
1434
INDEX_NAME
1644
1435
имя_индекса_в_кодировке_утф8_длиной_больше_чем_48
1645
 
select TABLE_NAME from information_schema.views where
1646
 
table_schema='test';
1647
 
TABLE_NAME
1648
 
имя_вью_кодировке_утф8_длиной_больше_чем_42
1649
1436
show create table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1650
1437
Table   Create Table
1651
1438
имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48       CREATE TABLE `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48` (
1652
 
  `имя_поля_в_кодировке_утф8_длиной_больше_чем_45` int(11) DEFAULT NULL,
 
1439
  `имя_поля_в_кодировке_утф8_длиной_больше_чем_45` int DEFAULT NULL,
1653
1440
  KEY `имя_индекса_в_кодировке_утф8_длиной_больше_чем_48` (`имя_поля_в_кодировке_утф8_длиной_больше_чем_45`)
1654
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1655
 
show create view имя_вью_кодировке_утф8_длиной_больше_чем_42;
1656
 
View    Create View     character_set_client    collation_connection
1657
 
имя_вью_кодировке_утф8_длиной_больше_чем_42     CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `имя_вью_кодировке_утф8_длиной_больше_чем_42` AS select `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48`.`имя_поля_в_кодировке_утф8_длиной_больше_чем_45` AS `имя_поля_в_кодировке_утф8_длиной_больше_чем_45` from `имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48`       utf8    utf8_general_ci
1658
 
create trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49
1659
 
before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1;
1660
 
select TRIGGER_NAME from information_schema.triggers where
1661
 
trigger_schema='test';
1662
 
TRIGGER_NAME
1663
 
имя_триггера_в_кодировке_утф8_длиной_больше_чем_49
1664
 
drop trigger имя_триггера_в_кодировке_утф8_длиной_больше_чем_49;
1665
 
create trigger
1666
 
очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66
1667
 
before insert on имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48 for each row set @a:=1;
1668
 
ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long
1669
 
drop trigger очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66;
1670
 
ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long
1671
 
create procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50()
1672
 
begin
1673
 
end;
1674
 
select ROUTINE_NAME from information_schema.routines where
1675
 
routine_schema='test';
1676
 
ROUTINE_NAME
1677
 
имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50
1678
 
drop procedure имя_процедуры_в_кодировке_утф8_длиной_больше_чем_50;
1679
 
create procedure очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66()
1680
 
begin
1681
 
end;
1682
 
ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long
1683
 
create function имя_функции_в_кодировке_утф8_длиной_больше_чем_49()
1684
 
returns int
1685
 
return 0;
1686
 
select ROUTINE_NAME from information_schema.routines where
1687
 
routine_schema='test';
1688
 
ROUTINE_NAME
1689
 
имя_функции_в_кодировке_утф8_длиной_больше_чем_49
1690
 
drop function имя_функции_в_кодировке_утф8_длиной_больше_чем_49;
1691
 
create function очень_очень_очень_очень_очень_очень_очень_очень_длинная_строка_66()
1692
 
returns int
1693
 
return 0;
1694
 
ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long
1695
 
drop view имя_вью_кодировке_утф8_длиной_больше_чем_42;
 
1441
) ENGINE=DEFAULT
1696
1442
drop table имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1697
 
set names default;
1698
 
drop table if exists t1,t2,t3;
1699
 
drop function if exists f1;
1700
 
create function f1() returns int
1701
 
begin
1702
 
declare res int;
1703
 
create temporary table t3 select 1 i;
1704
 
set res:= (select count(*) from t1);
1705
 
drop temporary table t3;
1706
 
return res;
1707
 
end|
1708
 
create table t1 as select 1;
1709
 
create table t2 as select f1() from t1;
1710
 
drop table t1,t2;
1711
 
drop function f1;
1712
1443
create table t1 like information_schema.processlist;
1713
1444
show create table t1;
1714
1445
Table   Create Table
1715
1446
t1      CREATE TABLE `t1` (
1716
 
  `ID` bigint(4) NOT NULL DEFAULT '0',
 
1447
  `ID` bigint NOT NULL DEFAULT '0',
1717
1448
  `USER` varchar(16) NOT NULL DEFAULT '',
1718
1449
  `HOST` varchar(64) NOT NULL DEFAULT '',
1719
1450
  `DB` varchar(64) DEFAULT NULL,
1720
1451
  `COMMAND` varchar(16) NOT NULL DEFAULT '',
1721
 
  `TIME` bigint(7) NOT NULL DEFAULT '0',
 
1452
  `TIME` bigint NOT NULL DEFAULT '0',
1722
1453
  `STATE` varchar(64) DEFAULT NULL,
1723
 
  `INFO` longtext
1724
 
) ENGINE=MyISAM DEFAULT CHARSET=utf8
 
1454
  `INFO` text
 
1455
) ENGINE=MyISAM
1725
1456
drop table t1;
1726
1457
create temporary table t1 like information_schema.processlist;
1727
1458
show create table t1;
1728
1459
Table   Create Table
1729
1460
t1      CREATE TEMPORARY TABLE `t1` (
1730
 
  `ID` bigint(4) NOT NULL DEFAULT '0',
 
1461
  `ID` bigint NOT NULL DEFAULT '0',
1731
1462
  `USER` varchar(16) NOT NULL DEFAULT '',
1732
1463
  `HOST` varchar(64) NOT NULL DEFAULT '',
1733
1464
  `DB` varchar(64) DEFAULT NULL,
1734
1465
  `COMMAND` varchar(16) NOT NULL DEFAULT '',
1735
 
  `TIME` bigint(7) NOT NULL DEFAULT '0',
 
1466
  `TIME` bigint NOT NULL DEFAULT '0',
1736
1467
  `STATE` varchar(64) DEFAULT NULL,
1737
 
  `INFO` longtext
1738
 
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1739
 
drop table t1;
1740
 
create table t1 like information_schema.character_sets;
1741
 
show create table t1;
1742
 
Table   Create Table
1743
 
t1      CREATE TABLE `t1` (
1744
 
  `CHARACTER_SET_NAME` varchar(64) NOT NULL DEFAULT '',
1745
 
  `DEFAULT_COLLATE_NAME` varchar(64) NOT NULL DEFAULT '',
1746
 
  `DESCRIPTION` varchar(60) NOT NULL DEFAULT '',
1747
 
  `MAXLEN` bigint(3) NOT NULL DEFAULT '0'
1748
 
) ENGINE=MEMORY DEFAULT CHARSET=utf8
 
1468
  `INFO` text
 
1469
) ENGINE=MyISAM
1749
1470
drop table t1;
1750
1471
 
1751
1472
# --
1760
1481
c1 INT DEFAULT 12 COMMENT 'column1',
1761
1482
c2 INT NULL COMMENT 'column2',
1762
1483
c3 INT NOT NULL COMMENT 'column3',
1763
 
c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a',
 
1484
c4 VARCHAR(255) NOT NULL DEFAULT 'a',
1764
1485
c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
1765
1486
c6 VARCHAR(255))
1766
 
COLLATE latin1_bin;
 
1487
COLLATE utf8_bin;
1767
1488
 
1768
1489
SHOW CREATE TABLE t1;
1769
1490
Table   Create Table
1770
1491
t1      CREATE TABLE `t1` (
1771
 
  `c1` int(11) DEFAULT '12' COMMENT 'column1',
1772
 
  `c2` int(11) DEFAULT NULL COMMENT 'column2',
1773
 
  `c3` int(11) NOT NULL COMMENT 'column3',
1774
 
  `c4` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a',
 
1492
  `c1` int DEFAULT '12' COMMENT 'column1',
 
1493
  `c2` int DEFAULT NULL COMMENT 'column2',
 
1494
  `c3` int NOT NULL COMMENT 'column3',
 
1495
  `c4` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT 'a',
1775
1496
  `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b',
1776
 
  `c6` varchar(255) COLLATE latin1_bin DEFAULT NULL
1777
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin
 
1497
  `c6` varchar(255) COLLATE utf8_bin DEFAULT NULL
 
1498
) ENGINE=DEFAULT
1778
1499
 
1779
1500
CREATE TABLE t2 AS SELECT * FROM t1;
1780
1501
 
1781
1502
SHOW CREATE TABLE t2;
1782
1503
Table   Create Table
1783
1504
t2      CREATE TABLE `t2` (
1784
 
  `c1` int(11) DEFAULT '12' COMMENT 'column1',
1785
 
  `c2` int(11) DEFAULT NULL COMMENT 'column2',
1786
 
  `c3` int(11) NOT NULL COMMENT 'column3',
1787
 
  `c4` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a',
 
1505
  `c1` int DEFAULT '12' COMMENT 'column1',
 
1506
  `c2` int DEFAULT NULL COMMENT 'column2',
 
1507
  `c3` int NOT NULL COMMENT 'column3',
 
1508
  `c4` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT 'a',
1788
1509
  `c5` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'b',
1789
 
  `c6` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL
1790
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
1510
  `c6` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
 
1511
) ENGINE=DEFAULT
1791
1512
 
1792
1513
DROP TABLE t2;
1793
1514
 
1803
1524
 
1804
1525
CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
1805
1526
 
1806
 
SET sql_mode = NO_ZERO_DATE;
1807
1527
 
1808
 
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
1809
 
ERROR 42000: Invalid default value for 'c2'
 
1528
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP NULL);
 
1529
drop table t2;
 
1530
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT '1982-01-29');
 
1531
drop table t2;
1810
1532
 
1811
1533
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
1812
 
ERROR 42000: Invalid default value for 'c2'
 
1534
drop table t2;
1813
1535
 
1814
1536
# -- Check that NULL column still can be created.
1815
1537
CREATE TABLE t2(c1 TIMESTAMP NULL);
1816
1538
 
1817
1539
# -- Check ALTER TABLE.
1818
1540
ALTER TABLE t1 ADD INDEX(c1);
1819
 
ERROR 42000: Invalid default value for 'c2'
1820
1541
 
1821
1542
# -- Check DATETIME.
1822
 
SET sql_mode = '';
1823
1543
 
1824
1544
CREATE TABLE t3(c1 DATETIME NOT NULL);
1825
1545
INSERT INTO t3 VALUES (0);
1826
 
 
1827
 
SET sql_mode = TRADITIONAL;
 
1546
ERROR HY000: Received an invalid datetime value '0'.
1828
1547
 
1829
1548
ALTER TABLE t3 ADD INDEX(c1);
1830
 
ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'c1' at row 1
1831
1549
 
1832
1550
# -- Cleanup.
1833
 
SET sql_mode = '';
1834
1551
DROP TABLE t1;
1835
1552
DROP TABLE t2;
1836
1553
DROP TABLE t3;
1837
1554
 
1838
1555
# -- End of Bug#18834.
1839
 
 
1840
 
# --
1841
 
# -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
1842
 
# --
1843
 
 
1844
 
DROP TABLE IF EXISTS t1;
1845
 
 
1846
 
CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
1847
 
 
1848
 
SHOW CREATE TABLE t1;
1849
 
Table   Create Table
1850
 
t1      CREATE TABLE `t1` (
1851
 
  `c1` year(4) DEFAULT '2008',
1852
 
  `c2` year(4) DEFAULT '0000'
1853
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1854
 
 
1855
 
INSERT INTO t1 VALUES();
1856
 
 
1857
 
SELECT * FROM t1;
1858
 
c1      c2
1859
 
2008    0000
1860
 
 
1861
 
ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
1862
 
 
1863
 
SHOW CREATE TABLE t1;
1864
 
Table   Create Table
1865
 
t1      CREATE TABLE `t1` (
1866
 
  `c1` year(4) DEFAULT '0000',
1867
 
  `c2` year(4) DEFAULT '0000'
1868
 
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1869
 
 
1870
 
INSERT INTO t1 VALUES();
1871
 
 
1872
 
SELECT * FROM t1;
1873
 
c1      c2
1874
 
2008    0000
1875
 
0000    0000
1876
 
 
1877
 
DROP TABLE t1;
1878
 
 
1879
 
# -- End of Bug#34274
1880
 
 
1881
 
End of 5.1 tests