~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/innodb.test

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#                                                                     #
12
12
#######################################################################
13
13
 
14
 
SET @orig_lock_wait_timeout= @@innodb_lock_wait_timeout; 
15
 
SET GLOBAL innodb_lock_wait_timeout=2;
16
 
 
 
14
-- source include/have_innodb.inc
17
15
 
18
16
#
19
17
# Small basic test with ignore
69
67
explain select level,id,parent_id from t1 where level=1;
70
68
select level,id from t1 where level=1;
71
69
select level,id,parent_id from t1 where level=1;
72
 
alter table t1 ENGINE=innodb;
 
70
optimize table t1;
73
71
--replace_column 7 #
74
72
show keys from t1;
75
73
drop table t1;
96
94
 
97
95
create table t1 (a int) engine=innodb;
98
96
insert into t1 values (1), (2);
99
 
alter table t1 engine=innodb;
 
97
optimize table t1;
100
98
delete from t1 where a = 1;
101
99
select * from t1;
102
100
check table t1;
156
154
select n from t1;
157
155
savepoint savept3;
158
156
rollback to savepoint savept2;
159
 
--error ER_SP_DOES_NOT_EXIST
 
157
--error 1305
160
158
rollback to savepoint savept3;
161
159
rollback to savepoint savept2;
162
160
release savepoint `my_savepoint`;
163
161
select n from t1;
164
 
--error 1305
 
162
-- error 1305
165
163
rollback to savepoint `my_savepoint`;
 
164
--error 1305
166
165
rollback to savepoint savept2;
167
166
insert into t1 values (8);
168
167
savepoint sv;
183
182
flush tables with read lock;
184
183
#
185
184
# Current code can't handle a read lock in middle of transaction
186
 
#--error ER_CANT_UPDATE_WITH_READLOCK
 
185
#--error 1223;
187
186
commit;
188
187
unlock tables;
189
188
commit;
304
303
select * from t1;
305
304
update t1 set col2='7' where col1='4';
306
305
select * from t1;
307
 
ALTER TABLE t1 ADD co3 INT DEFAULT 42 NOT NULL;
 
306
alter table t1 add co3 int not null;
308
307
select * from t1;
309
308
update t1 set col2='9' where col1='2';
310
309
select * from t1;
315
314
#
316
315
 
317
316
create table t1 (a int not null , b int, primary key (a)) engine = innodb;
318
 
create TEMPORARY table t2 (a int not null , b int, primary key (a)) engine = myisam;
 
317
create table t2 (a int not null , b int, primary key (a)) engine = myisam;
319
318
insert into t1 VALUES (1,3) , (2,3), (3,3);
320
319
select * from t1;
321
320
insert into t2 select * from t1;
431
430
create table t1 (a varchar(100) not null, primary key(a), b int not null) engine=innodb;
432
431
insert into t1 values("hello",1),("world",2);
433
432
select * from t1 order by b desc;
434
 
alter table t1 engine=innodb;
 
433
optimize table t1;
435
434
--replace_column 7 #
436
435
show keys from t1;
437
436
drop table t1;
483
482
drop table t1;
484
483
 
485
484
#
 
485
# Test lock tables
 
486
#
 
487
 
 
488
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
 
489
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 
490
LOCK TABLES t1 WRITE;
 
491
--error ER_DUP_ENTRY
 
492
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 
493
select id from t1;
 
494
select id from t1;
 
495
UNLOCK TABLES;
 
496
DROP TABLE t1;
 
497
 
 
498
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) engine=innodb;
 
499
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
 
500
LOCK TABLES t1 WRITE;
 
501
begin;
 
502
--error ER_DUP_ENTRY
 
503
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
 
504
select id from t1;
 
505
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
 
506
commit;
 
507
select id,id3 from t1;
 
508
UNLOCK TABLES;
 
509
DROP TABLE t1;
 
510
 
 
511
#
486
512
# Test prefix key
487
513
#
488
514
create table t1 (a char(20), unique (a(5))) engine=innodb;
532
558
create database mysqltest;
533
559
create table mysqltest.t1 (a int not null) engine= innodb;
534
560
insert into mysqltest.t1 values(1);
535
 
create TEMPORARY table mysqltest.t2 (a int not null) engine= myisam;
 
561
create table mysqltest.t2 (a int not null) engine= myisam;
536
562
insert into mysqltest.t2 values(1);
537
 
create temporary table mysqltest.t3 (a int not null) engine= MEMORY;
 
563
create table mysqltest.t3 (a int not null) engine= heap;
538
564
insert into mysqltest.t3 values(1);
539
565
commit;
540
566
drop database mysqltest;
541
567
# Don't check error message
542
 
--error ER_BAD_DB_ERROR
 
568
--error 1049
543
569
show tables from mysqltest;
544
570
 
545
571
#
605
631
drop table t1;
606
632
 
607
633
#
 
634
# Test of multi-table-delete
 
635
#
 
636
 
 
637
CREATE TABLE t1 (
 
638
  number bigint NOT NULL default '0',
 
639
  cname char(15) NOT NULL default '',
 
640
  carrier_id int NOT NULL default '0',
 
641
  privacy int NOT NULL default '0',
 
642
  last_mod_date timestamp NOT NULL,
 
643
  last_mod_id int NOT NULL default '0',
 
644
  last_app_date timestamp NULL,
 
645
  last_app_id int default '-1',
 
646
  version int NOT NULL default '0',
 
647
  assigned_scps int default '0',
 
648
  status int default '0'
 
649
) ENGINE=InnoDB;
 
650
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,NULL,-1,2,3,1);
 
651
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
 
652
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,NULL,-1,1,24,1);
 
653
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
 
654
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
 
655
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
 
656
CREATE TABLE t2 (
 
657
  number bigint NOT NULL default '0',
 
658
  cname char(15) NOT NULL default '',
 
659
  carrier_id int NOT NULL default '0',
 
660
  privacy int NOT NULL default '0',
 
661
  last_mod_date timestamp NOT NULL,
 
662
  last_mod_id int NOT NULL default '0',
 
663
  last_app_date timestamp NULL,
 
664
  last_app_id int default '-1',
 
665
  version int NOT NULL default '0',
 
666
  assigned_scps int default '0',
 
667
  status int default '0'
 
668
) ENGINE=InnoDB;
 
669
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,NULL,-1,2,3,1);
 
670
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
 
671
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,NULL,-1,1,24,1);
 
672
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
 
673
select * from t1;
 
674
select * from t2;
 
675
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
 
676
select * from t1;
 
677
select * from t2; 
 
678
select * from t2;
 
679
drop table t1,t2;
 
680
 
 
681
#
608
682
# A simple test with some isolation levels
609
683
# TODO: Make this into a test using replication to really test how
610
684
# this works.
633
707
DROP TABLE t1;
634
708
 
635
709
#
 
710
# Test of multi-table-update
 
711
#
 
712
create table t1 (n int, d int) engine=innodb;
 
713
create table t2 (n int, d int) engine=innodb;
 
714
insert into t1 values(1,1),(1,2);
 
715
insert into t2 values(1,10),(2,20);
 
716
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
 
717
select * from t1;
 
718
select * from t2;
 
719
drop table t1,t2;
 
720
 
 
721
#
636
722
# Testing of IFNULL
637
723
#
638
724
create table t1 (a int, b int) engine=innodb;
650
736
# Test of read_through not existing const_table
651
737
#
652
738
 
653
 
create TEMPORARY table t1 (a varchar(10) not null) engine=myisam;
 
739
create table t1 (a varchar(10) not null) engine=myisam;
654
740
create table t2 (b varchar(10) not null unique) engine=innodb;
655
741
select t1.a from t1,t2 where t1.a=t2.b;
656
742
drop table t1,t2;
658
744
create table t2 (a int not null, b int, primary key (a)) engine = innodb;
659
745
insert into t1 values (10, 20);
660
746
insert into t2 values (10, 20);
 
747
update t1, t2 set t1.b = 150, t2.b = t1.b where t2.a = t1.a and t1.a = 10;
661
748
drop table t1,t2;
662
749
 
663
750
#
 
751
# Test of multi-table-delete with foreign key constraints
 
752
#
 
753
 
 
754
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
 
755
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (t1_id) REFERENCES t1(id)  ON DELETE CASCADE ) ENGINE=INNODB;
 
756
insert into t1 set id=1;
 
757
insert into t2 set id=1, t1_id=1;
 
758
delete t1,t2 from t1,t2 where t1.id=t2.t1_id;
 
759
select * from t1;
 
760
select * from t2;
 
761
drop table t2,t1;
 
762
CREATE TABLE t1(id INT NOT NULL,  PRIMARY KEY (id)) ENGINE=INNODB;
 
763
CREATE TABLE t2(id  INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id)  ) ENGINE=INNODB;
 
764
INSERT INTO t1 VALUES(1);
 
765
INSERT INTO t2 VALUES(1, 1);
 
766
SELECT * from t1;
 
767
UPDATE t1,t2 SET t1.id=t1.id+1, t2.t1_id=t1.id+1;
 
768
SELECT * from t1;
 
769
UPDATE t1,t2 SET t1.id=t1.id+1 where t1.id!=t2.id;
 
770
SELECT * from t1;
 
771
DROP TABLE t1,t2;
 
772
 
 
773
#
664
774
# Test of range_optimizer
665
775
#
666
776
 
704
814
drop table t1;
705
815
 
706
816
#
 
817
# Test multi update with different join methods
 
818
#
 
819
 
 
820
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) engine=innodb;
 
821
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) engine=innodb;
 
822
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
 
823
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
 
824
 
 
825
# Full join, without key
 
826
update t1,t2 set t1.a=t1.a+100;
 
827
select * from t1;
 
828
 
 
829
# unique key
 
830
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
 
831
select * from t1;
 
832
 
 
833
# ref key
 
834
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
 
835
select * from t1;
 
836
 
 
837
# Range key (in t1)
 
838
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
 
839
select * from t1;
 
840
select * from t2;
 
841
 
 
842
drop table t1,t2;
 
843
CREATE TABLE t2 (   NEXT_T         BIGINT NOT NULL PRIMARY KEY) ENGINE=MyISAM;
 
844
CREATE TABLE t1 (  B_ID           INTEGER NOT NULL PRIMARY KEY) ENGINE=InnoDB;
 
845
SET AUTOCOMMIT=0;
 
846
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
 
847
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
 
848
ROLLBACK;
 
849
SELECT * FROM t1;
 
850
drop table  t1,t2;
 
851
create table t1  ( pk         int primary key,    parent     int not null,    child      int not null,       index (parent)  ) engine = innodb;
 
852
insert into t1 values   (1,0,4),  (2,1,3),  (3,2,1),  (4,1,2);
 
853
select distinct  parent,child   from t1   order by parent;
 
854
drop table t1;
 
855
 
 
856
#
707
857
# Test that MySQL priorities clustered indexes
708
858
#
709
859
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) engine=innodb;
749
899
drop table t1;
750
900
 
751
901
#
 
902
# Test of multi-table-updates (bug #1980).
 
903
#
 
904
 
 
905
create table t1 ( c char(8) not null ) engine=innodb;
 
906
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
 
907
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
 
908
 
 
909
alter table t1 add b char(8) not null;
 
910
alter table t1 add a char(8) not null;
 
911
alter table t1 add primary key (a,b,c);
 
912
update t1 set a=c, b=c;
 
913
 
 
914
create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) engine=innodb;
 
915
insert into t2 select * from t1;
 
916
 
 
917
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
 
918
drop table t1,t2;
 
919
 
 
920
#
752
921
# test autoincrement with TRUNCATE
753
922
#
754
923
 
770
939
drop table t2,t1;
771
940
 
772
941
#
 
942
# Test of multi updated and foreign keys
 
943
#
 
944
 
 
945
create table `t1` (`id` int not null  ,primary key ( `id` )) engine = innodb;
 
946
insert into `t1`values ( 1 ) ;
 
947
create table `t2` (`id` int not null default '0',unique key `id` ( `id` ) ,constraint `t1_id_fk` foreign key ( `id` ) references `t1` (`id` )) engine = innodb;
 
948
insert into `t2`values ( 1 ) ;
 
949
create table `t3` (`id` int not null default '0',key `id` ( `id` ) ,constraint `t2_id_fk` foreign key ( `id` ) references `t2` (`id` )) engine = innodb;
 
950
insert into `t3`values ( 1 ) ;
 
951
--error 1451
 
952
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
953
--error 1451
 
954
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
955
--error 1054
 
956
update t3 set  t3.id=7  where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
 
957
drop table t3,t2,t1;
 
958
 
 
959
#
773
960
# test for recursion depth limit
774
961
#
775
962
create table t1(
830
1017
ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
831
1018
drop table t1,t2;
832
1019
 
833
 
create TEMPORARY table t1 (a int, b varchar(200), c text not null)  engine=myisam;
834
 
create table t2 (a int, b varchar(200), c text not null) engine=innodb;
835
 
create table t3 (a int, b varchar(200), c text not null) engine=innodb;
 
1020
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=myisam;
 
1021
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=innodb;
 
1022
create table t3 (a int, b varchar(200), c text not null) checksum=1 engine=innodb;
836
1023
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
837
1024
insert t2 select * from t1;
838
1025
insert t3 select * from t1;
839
 
--replace_column 1 #  6 # 7 # 8 # 9 # 10 #
 
1026
checksum table t1, t2, t3, t4 quick;
 
1027
checksum table t1, t2, t3, t4;
 
1028
checksum table t1, t2, t3, t4 extended;
 
1029
#show table status;
840
1030
drop table t1,t2,t3;
841
1031
 
842
1032
#
868
1058
create index id2 on t2 (id);
869
1059
show create table t2;
870
1060
drop index id2 on t2;
871
 
--error ER_ERROR_ON_RENAME, ER_ERROR_ON_RENAME
 
1061
--error 1025,1025
872
1062
drop index id on t2;
873
1063
show create table t2;
874
1064
drop table t2;
905
1095
# Test error handling
906
1096
 
907
1097
# Embedded server doesn't chdir to data directory
908
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1098
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
909
1099
--error ER_WRONG_FK_DEF
910
1100
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
911
1101
 
922
1112
#
923
1113
# Bug #6126: Duplicate columns in keys gives misleading error message
924
1114
#
925
 
--error ER_DUP_FIELDNAME
 
1115
--error 1060
926
1116
create table t1 (c char(10), index (c,c)) engine=innodb;
927
 
--error ER_DUP_FIELDNAME
 
1117
--error 1060
928
1118
create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb;
929
 
--error ER_DUP_FIELDNAME
 
1119
--error 1060
930
1120
create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb;
931
 
--error ER_DUP_FIELDNAME
 
1121
--error 1060
932
1122
create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb;
933
1123
create table t1 (c1 char(10), c2 char(10)) engine=innodb;
934
 
--error ER_DUP_FIELDNAME
 
1124
--error 1060
935
1125
alter table t1 add key (c1,c1);
936
 
--error ER_DUP_FIELDNAME
 
1126
--error 1060
937
1127
alter table t1 add key (c2,c1,c1);
938
 
--error ER_DUP_FIELDNAME
 
1128
--error 1060
939
1129
alter table t1 add key (c1,c2,c1);
940
 
--error ER_DUP_FIELDNAME
 
1130
--error 1060
941
1131
alter table t1 add key (c1,c1,c2);
942
1132
drop table t1;
943
1133
 
1027
1217
## Not deterministic.
1028
1218
# Test for testable InnoDB status variables. This test
1029
1219
# uses previous ones(pages_created, rows_deleted, ...).
1030
 
--replace_column 2 #
1031
 
show status like "Innodb_buffer_pool_pages_total";
1032
 
--replace_column 2 #
1033
 
show status like "Innodb_page_size";
1034
 
--replace_column 2 #
1035
 
show status like "Innodb_rows_deleted";
1036
 
--replace_column 2 #
1037
 
show status like "Innodb_rows_inserted";
1038
 
--replace_column 2 #
1039
 
show status like "Innodb_rows_updated";
 
1220
#show status like "Innodb_buffer_pool_pages_total";
 
1221
#show status like "Innodb_page_size";
 
1222
#show status like "Innodb_rows_deleted";
 
1223
#show status like "Innodb_rows_inserted";
 
1224
#show status like "Innodb_rows_updated";
1040
1225
 
1041
1226
## Test for row locks InnoDB status variables.
1042
 
--replace_column 2 #
1043
 
show status like "Innodb_row_lock_waits";
1044
 
--replace_column 2 #
1045
 
show status like "Innodb_row_lock_current_waits";
1046
 
--replace_column 2 #
1047
 
show status like "Innodb_row_lock_time";
1048
 
--replace_column 2 #
1049
 
show status like "Innodb_row_lock_time_max";
1050
 
--replace_column 2 #
1051
 
show status like "Innodb_row_lock_time_avg";
 
1227
#show status like "Innodb_row_lock_waits";
 
1228
#show status like "Innodb_row_lock_current_waits";
 
1229
#show status like "Innodb_row_lock_time";
 
1230
#show status like "Innodb_row_lock_time_max";
 
1231
#show status like "Innodb_row_lock_time_avg";
1052
1232
 
1053
1233
# Test for innodb_sync_spin_loops variable
1054
1234
show variables like "innodb_sync_spin_loops";
1099
1279
#
1100
1280
 
1101
1281
# Embedded server doesn't chdir to data directory
1102
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1282
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1103
1283
create table t1 (v varchar(16383), key(v));
1104
1284
drop table t1;
1105
1285
create table t1 (v varchar(16383));
1151
1331
drop table t1;
1152
1332
 
1153
1333
#
 
1334
# Test that update does not change internal auto-increment value
 
1335
#
 
1336
 
 
1337
create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB;
 
1338
insert into t1 (val) values (1);
 
1339
update t1 set a=2 where a=1;
 
1340
# We should get the following error because InnoDB does not update the counter
 
1341
--error ER_DUP_ENTRY
 
1342
insert into t1 (val) values (1);
 
1343
select * from t1;
 
1344
drop table t1;
 
1345
#
1154
1346
# Bug #10465
1155
1347
#
1156
1348
 
1163
1355
DROP TABLE t1;
1164
1356
 
1165
1357
#
 
1358
# Bug #12340 multitable delete deletes only one record
 
1359
#
 
1360
create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb;
 
1361
create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb;
 
1362
insert into t2 values ('aa','cc');
 
1363
insert into t1 values ('aa','bb'),('aa','cc');
 
1364
delete t1 from t1,t2 where f1=f3 and f4='cc';
 
1365
select * from t1;
 
1366
drop table t1,t2;
 
1367
 
 
1368
#
1166
1369
# Test that the slow TRUNCATE implementation resets autoincrement columns
1167
1370
# (bug #11946)
1168
1371
#
1196
1399
 id INT PRIMARY KEY
1197
1400
) ENGINE=InnoDB;
1198
1401
 
1199
 
--error ER_CANT_CREATE_TABLE, ER_CANT_CREATE_TABLE
 
1402
--error 1005,1005
1200
1403
CREATE TEMPORARY TABLE t2
1201
1404
(
1202
1405
 id INT NOT NULL PRIMARY KEY,
1250
1453
drop table t1, t2, t3, t4;
1251
1454
 
1252
1455
# these should be refused
1253
 
--error ER_TOO_LONG_KEY
 
1456
--error 1071
1254
1457
create table t1 (col1 varchar(768) primary key)
1255
1458
 engine = innodb;
1256
 
--error ER_TOO_LONG_KEY
1257
 
create table t2 (col1 varbinary(1024) primary key)
 
1459
--error 1071
 
1460
create table t2 (col1 varbinary(768) primary key)
1258
1461
 engine = innodb;
1259
 
--error ER_TOO_LONG_KEY
 
1462
--error 1071
1260
1463
create table t3 (col1 text, primary key(col1(768)))
1261
1464
 engine = innodb;
1262
 
--error ER_TOO_LONG_KEY
1263
 
create table t4 (col1 blob, primary key(col1(1024)))
 
1465
--error 1071
 
1466
create table t4 (col1 blob, primary key(col1(768)))
1264
1467
 engine = innodb;
1265
1468
 
1266
1469
#
1278
1481
 CONSTRAINT c1 FOREIGN KEY (v) REFERENCES t1(id)
1279
1482
) ENGINE=InnoDB;
1280
1483
 
1281
 
--error ER_NO_REFERENCED_ROW_2
 
1484
--error 1452
1282
1485
INSERT INTO t2 VALUES(2);
1283
1486
 
1284
1487
INSERT INTO t1 VALUES(1);
1285
1488
INSERT INTO t2 VALUES(1);
1286
1489
 
1287
 
--error ER_ROW_IS_REFERENCED_2
 
1490
--error 1451
1288
1491
DELETE FROM t1 WHERE id = 1;
1289
1492
 
1290
 
--error ER_ROW_IS_REFERENCED
 
1493
--error 1217
1291
1494
DROP TABLE t1;
1292
1495
 
1293
1496
SET FOREIGN_KEY_CHECKS=0;
1294
1497
DROP TABLE t1;
1295
1498
SET FOREIGN_KEY_CHECKS=1;
1296
1499
 
1297
 
--error ER_NO_REFERENCED_ROW_2
 
1500
--error 1452
1298
1501
INSERT INTO t2 VALUES(3);
1299
1502
 
1300
1503
DROP TABLE t2;
 
1504
#
 
1505
# Test that checksum table uses a consistent read Bug #12669
 
1506
#
 
1507
connect (a,localhost,root,,);
 
1508
connect (b,localhost,root,,);
 
1509
connection a;
 
1510
create table t1(a int not null) engine=innodb;
 
1511
insert into t1 values (1),(2);
 
1512
set autocommit=0;
 
1513
checksum table t1;
 
1514
connection b;
 
1515
insert into t1 values(3);
 
1516
connection a;
 
1517
#
 
1518
# Here checksum should not see insert
 
1519
#
 
1520
checksum table t1;
 
1521
connection a;
 
1522
commit;
 
1523
checksum table t1;
 
1524
commit;
 
1525
drop table t1;
 
1526
#
 
1527
# autocommit = 1
 
1528
#
 
1529
connection a;
 
1530
create table t1(a int not null) engine=innodb;
 
1531
insert into t1 values (1),(2);
 
1532
set autocommit=1;
 
1533
checksum table t1;
 
1534
connection b;
 
1535
set autocommit=1;
 
1536
insert into t1 values(3);
 
1537
connection a;
 
1538
#
 
1539
# Here checksum sees insert
 
1540
#
 
1541
checksum table t1;
 
1542
drop table t1;
 
1543
 
 
1544
connection default;
 
1545
disconnect a;
 
1546
disconnect b;
1301
1547
 
1302
1548
# tests for bugs #9802 and #13778
1303
1549
 
1306
1552
set foreign_key_checks=0;
1307
1553
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
1308
1554
# Embedded server doesn't chdir to data directory
1309
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
 
1555
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
1310
1556
-- error 1005
1311
1557
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
1312
1558
set foreign_key_checks=1;
1364
1610
                 b varchar(255),
1365
1611
                 c varchar(255),
1366
1612
                 d varchar(255),
1367
 
                 key (a(200),b(200),c(200),d(200))) engine=innodb;
 
1613
                 key (a,b,c,d)) engine=innodb;
1368
1614
drop table t1;
1369
1615
--error ER_TOO_LONG_KEY
1370
1616
create table t1 (a varchar(255),
1378
1624
# test the padding of BINARY types and collations (Bug #14189)
1379
1625
 
1380
1626
create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
1381
 
create table t3 (s1 varchar(2) ,primary key (s1)) engine=innodb;
1382
 
create table t4 (s1 char(2) ,primary key (s1)) engine=innodb;
 
1627
create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
 
1628
create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
1383
1629
 
1384
1630
insert into t1 values (0x41),(0x4120),(0x4100);
1385
1631
-- error ER_DUP_ENTRY
1423
1669
 
1424
1670
drop table t2,t1;
1425
1671
 
1426
 
create table t1 (a int primary key,s1 varchar(2) not null unique) engine=innodb;
1427
 
create table t2 (s1 char(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
 
1672
create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
 
1673
create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
1428
1674
 
1429
1675
insert into t1 values(1,0x4100),(2,0x41);
1430
1676
insert into t2 values(0x41);
1526
1772
INSERT INTO t2 VALUES (1, 0, '');
1527
1773
INSERT INTO t2 VALUES (8, 1, '');
1528
1774
commit;
 
1775
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
 
1776
WHERE mm.id IS NULL;
1529
1777
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
1530
1778
where mm.id is null lock in share mode;
1531
1779
drop table t1,t2;
1579
1827
#
1580
1828
# S-lock to records (2,2),(4,2), and (6,2) should not be released in a update
1581
1829
#
1582
 
--error ER_LOCK_WAIT_TIMEOUT
 
1830
--error 1205
1583
1831
select * from t1 where a = 2 and b = 2 for update;
1584
1832
#
1585
1833
# X-lock to record (1,1),(3,1),(5,1) should not be released in a update
1586
1834
#
1587
 
--error ER_LOCK_WAIT_TIMEOUT
 
1835
--error 1205
1588
1836
connection a;
1589
1837
commit;
1590
1838
connection b;
1714
1962
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
1715
1963
 
1716
1964
connection b;
1717
 
--error ER_LOCK_WAIT_TIMEOUT
 
1965
--error 1205
1718
1966
reap;
1719
1967
 
1720
1968
connection c;
1721
 
--error ER_LOCK_WAIT_TIMEOUT
 
1969
--error 1205
1722
1970
reap;
1723
1971
 
1724
1972
connection d;
1725
 
--error ER_LOCK_WAIT_TIMEOUT
 
1973
--error 1205
1726
1974
reap;
1727
1975
 
1728
1976
connection e;
1729
 
--error ER_LOCK_WAIT_TIMEOUT
 
1977
--error 1205
1730
1978
reap;
1731
1979
 
1732
1980
connection f;
1733
 
--error ER_LOCK_WAIT_TIMEOUT
 
1981
--error 1205
1734
1982
reap;
1735
1983
 
1736
1984
connection g;
1737
 
--error ER_LOCK_WAIT_TIMEOUT
 
1985
--error 1205
1738
1986
reap;
1739
1987
 
1740
1988
connection h;
1741
 
--error ER_LOCK_WAIT_TIMEOUT
 
1989
--error 1205
1742
1990
reap;
1743
1991
 
1744
1992
connection i;
1745
 
--error ER_LOCK_WAIT_TIMEOUT
 
1993
--error 1205
1746
1994
reap;
1747
1995
 
1748
1996
connection j;
1749
 
--error ER_LOCK_WAIT_TIMEOUT
 
1997
--error 1205
1750
1998
reap;
1751
1999
 
1752
2000
connection a;
1766
2014
drop table t1, t2, t3, t5, t6, t8, t9;
1767
2015
 
1768
2016
# bug 18934, "InnoDB crashes when table uses column names like DB_ROW_ID"
1769
 
--error ER_CANT_CREATE_TABLE,1166
 
2017
--error 1005
1770
2018
CREATE TABLE t1 (DB_ROW_ID int) engine=innodb;
1771
2019
 
1772
2020
#
1810
2058
CREATE TABLE t1 ( a int ) ENGINE=innodb;
1811
2059
BEGIN;
1812
2060
INSERT INTO t1 VALUES (1);
1813
 
ALTER TABLE t1 ENGINE=innodb;
 
2061
OPTIMIZE TABLE t1;
1814
2062
DROP TABLE t1;
1815
2063
 
1816
2064
#
1842
2090
# mysqltest first does replace_regex, then replace_result
1843
2091
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
1844
2092
# Embedded server doesn't chdir to data directory
1845
 
--replace_result $DRIZZLETEST_VARDIR . master-data/ ''
1846
 
--error ER_ERROR_ON_RENAME
 
2093
--replace_result $MYSQLTEST_VARDIR . master-data/ ''
 
2094
--error 1025
1847
2095
ALTER TABLE t2 MODIFY a INT NOT NULL;
1848
2096
DELETE FROM t1;
1849
2097
DROP TABLE t2,t1;
1868
2116
CREATE TABLE t1 (id int PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB
1869
2117
AUTO_INCREMENT=42;
1870
2118
 
1871
 
INSERT INTO t1 VALUES (NULL),(347),(NULL);
 
2119
INSERT INTO t1 VALUES (0),(347),(0);
1872
2120
SELECT * FROM t1;
1873
2121
 
1874
2122
SHOW CREATE TABLE t1;
1899
2147
SELECT * FROM t1;
1900
2148
DROP TABLE t1;
1901
2149
 
1902
 
SET GLOBAL innodb_lock_wait_timeout=@orig_lock_wait_timeout ;
1903
 
 
1904
 
 
1905
2150
#######################################################################
1906
2151
#                                                                     #
1907
2152
# Please, DO NOT TOUCH this file as well as the innodb.result file.   #