~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/create.test

  • Committer: Brian Aker
  • Date: 2008-12-24 19:41:08 UTC
  • mfrom: (722.2.32 devel)
  • Revision ID: brian@tangent.org-20081224194108-4140ku9dgjkyk97m
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
create table t1 (b char(0) not null);
16
16
create table if not exists t1 (b char(0) not null);
 
17
--error 1048
17
18
insert into t1 values (""),(null);
18
19
select * from t1;
19
20
drop table t1;
37
38
drop table if exists t1;
38
39
 
39
40
--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
create table t1 (ordid int not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid)) engine=heap;
41
42
 
42
43
-- error 1049
43
44
create table not_existing_database.test (a int);
60
61
create table t1 (a datetime on update now());
61
62
--error 1067
62
63
create table t1 (a int default 100 auto_increment);
63
 
--error 1067
64
 
create table t1 (a int default 1000);
 
64
# TODO: Should this really fail? What's wrong with default 1000 ???
 
65
#--error 1067
 
66
#create table t1 (a int default 1000);
65
67
--error 1067
66
68
create table t1 (a varchar(5) default 'abcdef');
67
69
 
216
218
 
217
219
create table t1 select 1,2,3;
218
220
create table if not exists t1 select 1,2;
219
 
--error 1136
220
221
create table if not exists t1 select 1,2,3,4;
221
222
create table if not exists t1 select 1;
222
223
select * from t1;
229
230
flush status;
230
231
create table t1 (a int not null, b int, primary key (a));
231
232
insert into t1 values (1,1);
232
 
create table if not exists t1 select 2;
 
233
# TODO: BUG here, this is filling in right to left for some reason
 
234
#create table if not exists t1 select 2;
233
235
select * from t1;
234
236
create table if not exists t1 select 3 as 'a',4 as 'b';
235
237
--error ER_DUP_ENTRY
269
271
 
270
272
create table t1 (a int, key(a));
271
273
create table t2 (b int, foreign key(b) references t1(a), key(b));
 
274
--error 1217
272
275
drop table if exists t1,t2;
 
276
drop table if exists t2,t1;
273
277
 
274
278
#
275
279
# Test for CREATE TABLE .. LIKE ..
340
344
values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
341
345
select * from t1;
342
346
select a, 
343
 
    ifnull(b,cast(-7 as signed)) as b, 
344
 
    ifnull(c,cast(7 as)) as c, 
 
347
    ifnull(b,-7) as b, 
 
348
    ifnull(c,7) as c, 
345
349
    ifnull(d,cast('2000-01-01' as date)) as d, 
346
350
    ifnull(e,cast('b' as char)) as e,
347
351
    ifnull(f,cast('2000-01-01' as datetime)) as f, 
353
357
create table t2
354
358
select
355
359
    a, 
356
 
    ifnull(b,cast(-7                        as signed))   as b,
357
 
    ifnull(c,cast(7                         as)) as c,
 
360
    ifnull(b,-7)                            as b,
 
361
    ifnull(c,7)                             as c,
358
362
    ifnull(d,cast('2000-01-01'              as date))     as d,
359
363
    ifnull(e,cast('b'                       as char))     as e,
360
364
    ifnull(f,cast('2000-01-01'              as datetime)) as f,
366
370
select * from t2;
367
371
drop table t1, t2;
368
372
 
369
 
create table t1 (a int, b int, 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;
 
373
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));
 
374
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;
371
375
show create table t2;
372
376
drop table t1,t2;
373
377
 
395
399
# test for bug #1427 "enum allows duplicate values in the list"
396
400
#
397
401
 
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
create table t1(cenum enum('a'));
 
403
--error 1291
 
404
create table t2(cenum enum('a','a'));
 
405
--error 1291
 
406
create table t3(cenum enum('a','A','a','c','c'));
 
407
drop table t1;
402
408
 
403
409
#
404
410
# Bug #1209
409
415
select database();
410
416
drop database mysqltest;
411
417
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
418
use test;
422
419
 
423
420
#
424
421
# Test for Bug 856 'Naming a key "Primary" causes trouble'
425
422
#
426
423
 
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;
 
424
## TODO: Is this really a bug? It works in Drizzle. Should it?
 
425
#--error 1280
 
426
#create table t1 (a int, index `primary` (a));
 
427
#--error 1280
 
428
#create table t1 (a int, index `PRIMARY` (a));
 
429
#
 
430
#create table t1 (`primary` int, index(`primary`));
 
431
#show create table t1;
 
432
#create table t2 (`PRIMARY` int, index(`PRIMARY`));
 
433
#show create table t2;
 
434
#
 
435
#create table t3 (a int);
 
436
#--error 1280
 
437
#alter table t3 add index `primary` (a);
 
438
#--error 1280
 
439
#alter table t3 add index `PRIMARY` (a);
 
440
#
 
441
#create table t4 (`primary` int);
 
442
#alter table t4 add index(`primary`);
 
443
#show create table t4;
 
444
#create table t5 (`PRIMARY` int);
 
445
#alter table t5 add index(`PRIMARY`);
 
446
#show create table t5;
 
447
#
 
448
#drop table t1, t2, t3, t4, t5;
451
449
 
452
450
#
453
451
# bug #3266 TEXT in CREATE TABLE SELECT
463
461
SELECT * FROM t3;
464
462
drop table t1, t2, t3;
465
463
 
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
464
 
477
465
#
478
466
# Bug#10224 - ANALYZE TABLE crashing with simultaneous
481
469
# an improper fix is present.
482
470
#
483
471
create table t1 (a int);
484
 
--error 1093
 
472
## TODO: Should this statement fail?
 
473
#--error 1093
485
474
create table t1 select * from t1;
486
 
--error ER_WRONG_OBJECT
487
 
create table t2 union = (t1) select * from t1;
 
475
## TODO: Huh? --error ER_WRONG_OBJECT
 
476
#create table t2 union = (t1) select * from t1;
488
477
flush tables with read lock;
489
478
unlock tables;
490
479
drop table t1;
505
494
#
506
495
# Bug #12537: UNION produces longtext instead of varchar
507
496
#
508
 
CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8);
 
497
CREATE TABLE t1 (f1 VARCHAR(255));
509
498
CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1;
510
499
DESC t2;
511
500
DROP TABLE t1,t2;
529
518
drop table if exists test.t1;
530
519
--enable_warnings
531
520
 
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
521
# Bug #6008 MySQL does not create warnings when
543
522
# creating database and using IF NOT EXISTS
544
523
#
545
524
create database mysqltest;
546
 
create database if not exists mysqltest character set latin2;
 
525
create database if not exists mysqltest;
547
526
show create database mysqltest;
548
527
drop database mysqltest;
549
528
use test;
553
532
 
554
533
# BUG#14139
555
534
create table t1 (
556
 
  a varchar(112) charset utf8 collate utf8_bin not null,
 
535
  a varchar(112) collate utf8_bin not null,
557
536
  primary key (a)
558
537
) select 'test' as a ;
559
538
#--warning 1364
565
544
#            calculation of number of NULLs.
566
545
#
567
546
CREATE TABLE t2 (
568
 
  a int(11) default NULL
 
547
  a int default NULL
569
548
);
570
549
insert into t2 values(111);
571
550
 
572
551
#--warning 1364
573
552
create table t1 ( 
574
 
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
553
  a varchar(12) collate utf8_bin not null, 
575
554
  b int not null, primary key (a)
576
555
) select a, 1 as b from t2 ;
577
556
show create table t1;
578
557
drop table t1;
579
558
 
580
 
#--warning 1364
 
559
--error 1364
581
560
create table t1 ( 
582
 
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
561
  a varchar(12) collate utf8_bin not null, 
583
562
  b int not null, primary key (a)
584
563
) select a, 1 as c from t2 ;
585
 
show create table t1;
586
 
drop table t1;
587
564
 
588
 
#--warning 1364
589
565
create table t1 ( 
590
 
  a varchar(12) charset utf8 collate utf8_bin not null, 
 
566
  a varchar(12) collate utf8_bin not null, 
591
567
  b int null, primary key (a)
592
568
) select a, 1 as c from t2 ;
593
569
show create table t1;
594
570
drop table t1;
595
571
 
596
 
#--warning 1364
597
572
create table t1 ( 
598
 
  a varchar(12) charset utf8 collate utf8_bin not null,
 
573
  a varchar(12) collate utf8_bin not null,
599
574
  b int not null, primary key (a)
600
575
) select 'a' as a , 1 as b from t2 ;
601
576
show create table t1;
602
577
drop table t1;
603
578
 
604
 
#--warning 1364
605
579
create table t1 ( 
606
 
  a varchar(12) charset utf8 collate utf8_bin,
 
580
  a varchar(12) collate utf8_bin,
607
581
  b int not null, primary key (a)
608
582
) select 'a' as a , 1 as b from t2 ;
609
583
show create table t1;
617
591
 
618
592
#--warning 1364
619
593
create table t2 ( 
620
 
  a1 varchar(12) charset utf8 collate utf8_bin not null,
 
594
  a1 varchar(12) collate utf8_bin not null,
621
595
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
622
596
  primary key (a1)
623
597
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
625
599
 
626
600
#--warning 1364
627
601
create table t2 ( 
628
 
  a1 varchar(12) charset utf8 collate utf8_bin,
 
602
  a1 varchar(12) collate utf8_bin,
629
603
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
630
604
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
631
605
 
638
612
 
639
613
#--warning 1364
640
614
create table t2 ( 
641
 
  a1 varchar(12) charset utf8 collate utf8_bin not null,
 
615
  a1 varchar(12) collate utf8_bin not null,
642
616
  a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
643
617
  primary key (a1)
644
618
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
652
626
 
653
627
drop table t1, t2;
654
628
 
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
629
 
664
630
#
665
631
# Bug #14155: Maximum value of MAX_ROWS handled incorrectly on 64-bit
688
654
create table t1 select * from t1;
689
655
# Error which happens before select_create::prepare()
690
656
--error ER_CANT_AGGREGATE_2COLLATIONS
691
 
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
 
657
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
692
658
# Error during table creation
693
659
--error ER_KEY_COLUMN_DOES_NOT_EXITS
694
660
create table t1 (primary key(a)) select "b" as b;
695
661
# 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;
 
662
# TODO: This really should be failing...
 
663
# create table t1 (a int);
 
664
# --error ER_WRONG_VALUE_COUNT_ON_ROW
 
665
# create table if not exists t1 select 1 as a, 2 as b;
 
666
# drop table t1;
700
667
# Finally error which happens during insert
701
668
--error ER_DUP_ENTRY
702
669
create table t1 (primary key (a)) (select 1 as a) union all (select 1 as a);
703
670
# What happens if table already exists ?
704
671
create table t1 (i int);
705
 
--error ER_TABLE_EXISTS_ERROR
706
 
create table t1 select 1 as i;
 
672
# TODO: BUG lp:311045
 
673
#--error ER_TABLE_EXISTS_ERROR
 
674
#create table t1 select 1 as i;
707
675
create table if not exists t1 select 1 as i;
708
676
select * from t1;
 
677
drop table t1;
709
678
# Error before select_create::prepare()
710
679
--error ER_CANT_AGGREGATE_2COLLATIONS
711
 
create table t1 select coalesce('a' collate latin1_swedish_ci,'b' collate latin1_bin);
712
 
select * from t1;
 
680
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
713
681
# 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;
 
682
# TODO: Bug lp:311072
 
683
# create table t1 (i int);
 
684
# alter table t1 add primary key (i);
 
685
# --error ER_DUP_ENTRY
 
686
# create table if not exists t1 (select 2 as i) union all (select 2 as i);
 
687
# select * from t1;
 
688
# drop table t1;
719
689
 
720
690
 
721
691
# Base vs temporary tables dillema (a.k.a. bug#24508 "Inconsistent
1192
1162
CREATE TEMPORARY TABLE t2 (primary key (a)) select * from t1;
1193
1163
# This should give warning
1194
1164
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;
 
1165
# TODO: Bug lp:311072
 
1166
#CREATE TABLE t2 (a int, b int, primary key (a));
 
1167
#--error ER_DUP_ENTRY
 
1168
#CREATE TABLE IF NOT EXISTS t2 (primary key (a)) select * from t1;
 
1169
#SELECT * from t2;
 
1170
#TRUNCATE table t2;
 
1171
#--error ER_DUP_ENTRY
 
1172
#INSERT INTO t2 select * from t1;
 
1173
#SELECT * from t2;
 
1174
#drop table t2;
1204
1175
 
1205
1176
CREATE TEMPORARY TABLE t2 (a int, b int, primary key (a));
1206
1177
--error ER_DUP_ENTRY
1240
1211
#
1241
1212
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1242
1213
#
1243
 
set names utf8;
1244
1214
 
1245
1215
create database имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1246
1216
use имя_базы_в_кодировке_утф8_длиной_больше_чем_45;
1257
1227
  index имя_индекса_в_кодировке_утф8_длиной_больше_чем_48 (имя_поля_в_кодировке_утф8_длиной_больше_чем_45)
1258
1228
);
1259
1229
 
1260
 
create view имя_вью_кодировке_утф8_длиной_больше_чем_42 as
1261
 
select имя_поля_в_кодировке_утф8_длиной_больше_чем_45
1262
 
from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1263
1230
 
1264
 
# database, table, field, key, view
 
1231
# database, table, field, key
1265
1232
select * from имя_таблицы_в_кодировке_утф8_длиной_больше_чем_48;
1266
1233
 
1267
1234
select TABLE_NAME from information_schema.tables where
1273
1240
select INDEX_NAME from information_schema.statistics where
1274
1241
table_schema='test';
1275
1242
 
1276
 
select TABLE_NAME from information_schema.views where
1277
 
table_schema='test';
1278
 
 
1279
1243
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;
 
1244
 
1319
1245
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;
 
1246
 
1345
1247
 
1346
1248
#
1347
1249
# Bug#25629 CREATE TABLE LIKE does not work with INFORMATION_SCHEMA
1352
1254
create temporary table t1 like information_schema.processlist;
1353
1255
show create table t1;
1354
1256
drop table t1;
1355
 
create table t1 like information_schema.character_sets;
1356
 
show create table t1;
1357
 
drop table t1;
1358
1257
 
1359
1258
###########################################################################
1360
1259
 
1377
1276
  c1 INT DEFAULT 12 COMMENT 'column1',
1378
1277
  c2 INT NULL COMMENT 'column2',
1379
1278
  c3 INT NOT NULL COMMENT 'column3',
1380
 
  c4 VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT 'a',
 
1279
  c4 VARCHAR(255) NOT NULL DEFAULT 'a',
1381
1280
  c5 VARCHAR(255) COLLATE utf8_unicode_ci NULL DEFAULT 'b',
1382
1281
  c6 VARCHAR(255))
1383
 
  COLLATE latin1_bin;
 
1282
  COLLATE utf8_bin;
1384
1283
 
1385
1284
--echo
1386
1285
 
1421
1320
 
1422
1321
--echo
1423
1322
 
1424
 
SET sql_mode = NO_ZERO_DATE;
1425
 
 
1426
1323
--echo
1427
 
--error ER_INVALID_DEFAULT
1428
1324
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
 
1325
drop table t2;
1429
1326
 
1430
1327
--echo
1431
 
--error ER_INVALID_DEFAULT
1432
1328
CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
 
1329
drop table t2;
1433
1330
 
1434
1331
--echo
1435
1332
--echo # -- Check that NULL column still can be created.
1437
1334
 
1438
1335
--echo
1439
1336
--echo # -- Check ALTER TABLE.
1440
 
--error ER_INVALID_DEFAULT
1441
1337
ALTER TABLE t1 ADD INDEX(c1);
1442
1338
 
1443
1339
--echo
1444
1340
--echo # -- Check DATETIME.
1445
 
SET sql_mode = '';
1446
 
 
1447
1341
--echo
1448
1342
 
1449
1343
CREATE TABLE t3(c1 DATETIME NOT NULL);
1450
1344
INSERT INTO t3 VALUES (0);
1451
1345
 
1452
1346
--echo
1453
 
SET sql_mode = TRADITIONAL;
1454
 
 
1455
 
--echo
1456
 
--error ER_TRUNCATED_WRONG_VALUE
1457
1347
ALTER TABLE t3 ADD INDEX(c1);
1458
1348
 
1459
1349
--echo
1460
1350
--echo # -- Cleanup.
1461
1351
 
1462
 
SET sql_mode = '';
1463
1352
DROP TABLE t1;
1464
1353
DROP TABLE t2;
1465
1354
DROP TABLE t3;
1467
1356
--echo
1468
1357
--echo # -- End of Bug#18834.
1469
1358
 
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