~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/innodb_mysql.result

Merged in changes. 
Edited a the comment test case so deal with our version bump.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
set session innodb_support_xa=default;
3
3
SET SESSION STORAGE_ENGINE = InnoDB;
4
4
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
 
5
drop procedure if exists p1;
5
6
create table t1 (
6
 
c_id int not null default '0',
7
 
org_id int default null,
 
7
c_id int(11) not null default '0',
 
8
org_id int(11) default null,
8
9
unique key contacts$c_id (c_id),
9
10
key contacts$org_id (org_id)
10
11
);
13
14
(151,2),(234,2),(236,2),(243,2),(255,2),(259,2),(232,3),(235,3),(238,3),
14
15
(246,3),(253,3),(269,3),(285,3),(291,3),(293,3),(131,4),(230,4),(231,4);
15
16
create table t2 (
16
 
slai_id int not null default '0',
17
 
owner_tbl int default null,
18
 
owner_id int default null,
19
 
sla_id int default null,
20
 
inc_web int default null,
21
 
inc_email int default null,
22
 
inc_chat int default null,
23
 
inc_csr int default null,
24
 
inc_total int default null,
25
 
time_billed int default null,
 
17
slai_id int(11) not null default '0',
 
18
owner_tbl int(11) default null,
 
19
owner_id int(11) default null,
 
20
sla_id int(11) default null,
 
21
inc_web int(11) default null,
 
22
inc_email int(11) default null,
 
23
inc_chat int(11) default null,
 
24
inc_csr int(11) default null,
 
25
inc_total int(11) default null,
 
26
time_billed int(11) default null,
26
27
activedate timestamp null default null,
27
28
expiredate timestamp null default null,
28
 
state int default null,
29
 
sla_set int default null,
 
29
state int(11) default null,
 
30
sla_set int(11) default null,
30
31
unique key t2$slai_id (slai_id),
31
32
key t2$owner_id (owner_id),
32
33
key t2$sla_id (sla_id)
70
71
INSERT INTO t3 VALUES (1,1,1),(2,1,2);
71
72
INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
72
73
INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
73
 
SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE
 
74
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
74
75
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
75
76
ORDER BY t1.b LIMIT 2;
76
77
b       a
77
78
1       1
78
79
2       2
79
 
SELECT STRAIGHT_JOIN t1.b, t1.a FROM t1, t3, t2 WHERE
 
80
SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
80
81
t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
81
82
ORDER BY t1.b LIMIT 5;
82
83
b       a
107
108
id1
108
109
2
109
110
DROP TABLE t1, t2;
 
111
create table t1 (c1 int) engine=innodb;
 
112
handler t1 open;
 
113
handler t1 read first;
 
114
c1
 
115
Before and after comparison
 
116
0
 
117
drop table t1;
110
118
CREATE TABLE t1(c1 TEXT, UNIQUE (c1(1)), cnt INT DEFAULT 1)
111
 
ENGINE=INNODB;
 
119
ENGINE=INNODB CHARACTER SET UTF8;
112
120
INSERT INTO t1 (c1) VALUES ('1a');
113
121
SELECT * FROM t1;
114
122
c1      cnt
119
127
1a      2
120
128
DROP TABLE t1;
121
129
CREATE TABLE t1(c1 VARCHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
122
 
ENGINE=INNODB;
 
130
ENGINE=INNODB CHARACTER SET UTF8;
123
131
INSERT INTO t1 (c1) VALUES ('1a');
124
132
SELECT * FROM t1;
125
133
c1      cnt
130
138
1a      2
131
139
DROP TABLE t1;
132
140
CREATE TABLE t1(c1 CHAR(2), UNIQUE (c1(1)), cnt INT DEFAULT 1)
133
 
ENGINE=INNODB;
 
141
ENGINE=INNODB CHARACTER SET UTF8;
134
142
INSERT INTO t1 (c1) VALUES ('1a');
135
143
SELECT * FROM t1;
136
144
c1      cnt
143
151
CREATE TABLE t1 (
144
152
a1 decimal(10,0) DEFAULT NULL,
145
153
a2 blob,
 
154
a3 time DEFAULT NULL,
146
155
a4 blob,
147
156
a5 char(175) DEFAULT NULL,
148
 
a6 timestamp NOT NULL DEFAULT NOW(),
149
 
a7 blob,
 
157
a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 
158
a7 tinyblob,
150
159
INDEX idx (a6,a7(239),a5)
151
160
) ENGINE=InnoDB;
152
161
EXPLAIN SELECT a4 FROM t1 WHERE
160
169
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
161
170
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
162
171
DROP TABLE t1;
163
 
create temporary table t1m (a int) engine = MEMORY;
 
172
create table t1m (a int) engine = MEMORY;
164
173
create table t1i (a int);
165
 
create temporary table t2m (a int) engine = MEMORY;
 
174
create table t2m (a int) engine = MEMORY;
166
175
create table t2i (a int);
167
176
insert into t2m values (5);
168
177
insert into t2i values (5);
 
178
select min(a) from t1i;
 
179
min(a)
 
180
NULL
 
181
select min(7) from t1i;
 
182
min(7)
 
183
NULL
 
184
select min(7) from DUAL;
 
185
min(7)
 
186
7
 
187
explain select min(7) from t2i join t1i;
 
188
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
189
1       SIMPLE  t2i     ALL     NULL    NULL    NULL    NULL    1       
 
190
1       SIMPLE  t1i     ALL     NULL    NULL    NULL    NULL    1       Using join buffer
 
191
select min(7) from t2i join t1i;
 
192
min(7)
 
193
NULL
 
194
select max(a) from t1i;
 
195
max(a)
 
196
NULL
 
197
select max(7) from t1i;
 
198
max(7)
 
199
NULL
 
200
select max(7) from DUAL;
 
201
max(7)
 
202
7
 
203
explain select max(7) from t2i join t1i;
 
204
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
205
1       SIMPLE  t2i     ALL     NULL    NULL    NULL    NULL    1       
 
206
1       SIMPLE  t1i     ALL     NULL    NULL    NULL    NULL    1       Using join buffer
 
207
select max(7) from t2i join t1i;
 
208
max(7)
 
209
NULL
169
210
select 1, min(a) from t1i where a=99;
170
211
1       min(a)
171
212
1       NULL
212
253
count(*)        min(7)  max(7)
213
254
0       NULL    NULL
214
255
drop table t1m, t1i, t2m, t2i;
215
 
create TEMPORARY table t1 (
 
256
create table t1 (
216
257
a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' '
217
258
) ENGINE = MEMORY;
218
259
insert into t1 (a1, a2, b, c, d) values
299
340
alter table t1 drop primary key, add primary key (f2, f1);
300
341
explain select distinct f1 a, f1 b from t1;
301
342
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
302
 
1       SIMPLE  t1      index   NULL    PRIMARY 10      NULL    4       Using index; Using temporary
 
343
1       SIMPLE  t1      index   NULL    PRIMARY 5       NULL    4       Using index; Using temporary
303
344
explain select distinct f1, f2 from t1;
304
345
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
305
 
1       SIMPLE  t1      range   NULL    PRIMARY 10      NULL    3       Using index for group-by; Using temporary
 
346
1       SIMPLE  t1      range   NULL    PRIMARY 5       NULL    3       Using index for group-by; Using temporary
306
347
drop table t1;
307
 
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, name varchar(20),
 
348
CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
308
349
INDEX (name));
309
 
CREATE TABLE t2 (id int NOT NULL PRIMARY KEY, fkey int);
 
350
CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11));
310
351
ALTER TABLE t2 ADD FOREIGN KEY (fkey) REFERENCES t2(id);
311
352
INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
312
353
INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
327
368
id int NOT NULL,
328
369
name varchar(20) NOT NULL,
329
370
dept varchar(20) NOT NULL,
330
 
age int NOT NULL,
 
371
age tinyint(3) unsigned NOT NULL,
331
372
PRIMARY KEY (id),
332
373
INDEX (name,dept)
333
374
) ENGINE=InnoDB;
338
379
(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6');
339
380
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
340
381
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
341
 
1       SIMPLE  t1      range   name    name    164     NULL    2       Using where; Using index for group-by
 
382
1       SIMPLE  t1      range   name    name    44      NULL    2       Using where; Using index for group-by
342
383
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
343
384
name    dept
344
385
rs5     cs10
346
387
DELETE FROM t1;
347
388
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
348
389
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
349
 
1       SIMPLE  t1      range   name    name    164     NULL    2       Using where; Using index for group-by
 
390
1       SIMPLE  t1      range   name    name    44      NULL    2       Using where; Using index for group-by
350
391
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
351
392
name    dept
352
393
DROP TABLE t1;
354
395
show variables like 'innodb_rollback_on_timeout';
355
396
Variable_name   Value
356
397
innodb_rollback_on_timeout      OFF
357
 
create table t1 (a int not null primary key) engine = innodb;
 
398
create table t1 (a int unsigned not null primary key) engine = innodb;
358
399
insert into t1 values (1);
359
400
commit;
360
401
begin work;
387
428
2
388
429
5
389
430
drop table t1;
 
431
set @save_qcache_size=@@global.query_cache_size;
 
432
set @save_qcache_type=@@global.query_cache_type;
 
433
set global query_cache_size=10*1024*1024;
 
434
set global query_cache_type=1;
390
435
drop table if exists `test`;
391
436
Warnings:
392
437
Note    1051    Unknown table 'test'
393
438
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
394
439
`test2` varchar(4) NOT NULL,PRIMARY KEY  (`test1`))
395
 
ENGINE=InnoDB;
 
440
ENGINE=InnoDB DEFAULT CHARSET=latin1;
396
441
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
397
442
select * from test;
398
443
test1   test2
407
452
test1   test2
408
453
tes     1234
409
454
drop table test;
 
455
set global query_cache_type=@save_qcache_type;
 
456
set global query_cache_size=@save_qcache_size;
410
457
drop table if exists t1;
411
458
show variables like 'innodb_rollback_on_timeout';
412
459
Variable_name   Value
413
460
innodb_rollback_on_timeout      OFF
414
 
create table t1 (a int not null primary key) engine = innodb;
 
461
create table t1 (a int unsigned not null primary key) engine = innodb;
415
462
insert into t1 values (1);
416
463
commit;
417
464
begin work;
483
530
3       b       2
484
531
4       a       2
485
532
drop table t1;
 
533
CREATE TABLE t1(
 
534
id int AUTO_INCREMENT PRIMARY KEY,
 
535
stat_id int NOT NULL,
 
536
acct_id int DEFAULT NULL,
 
537
INDEX idx1 (stat_id, acct_id),
 
538
INDEX idx2 (acct_id)
 
539
) ENGINE=MyISAM;
 
540
CREATE TABLE t2(
 
541
id int AUTO_INCREMENT PRIMARY KEY,
 
542
stat_id int NOT NULL,
 
543
acct_id int DEFAULT NULL,
 
544
INDEX idx1 (stat_id, acct_id),
 
545
INDEX idx2 (acct_id)
 
546
) ENGINE=InnoDB;
 
547
INSERT INTO t1(stat_id,acct_id) VALUES
 
548
(1,759), (2,831), (3,785), (4,854), (1,921),
 
549
(1,553), (2,589), (3,743), (2,827), (2,545),
 
550
(4,779), (4,783), (1,597), (1,785), (4,832),
 
551
(1,741), (1,833), (3,788), (2,973), (1,907);
 
552
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
553
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
554
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
555
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
556
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
557
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
558
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
559
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
560
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
561
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
562
INSERT INTO t1(stat_id,acct_id) SELECT stat_id, mod(id+100000, acct_id) FROM t1;
 
563
UPDATE t1 SET acct_id=785 
 
564
WHERE MOD(stat_id,2)=0 AND MOD(id,stat_id)=MOD(acct_id,stat_id);
 
565
OPTIMIZE TABLE t1;
 
566
Table   Op      Msg_type        Msg_text
 
567
test.t1 optimize        status  OK
 
568
SELECT COUNT(*) FROM t1;
 
569
COUNT(*)
 
570
40960
 
571
SELECT COUNT(*) FROM t1 WHERE acct_id=785;
 
572
COUNT(*)
 
573
8702
 
574
EXPLAIN SELECT COUNT(*) FROM t1 WHERE stat_id IN (1,3) AND acct_id=785;
 
575
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
576
1       SIMPLE  t1      range   idx1,idx2       idx1    9       NULL    2       Using where; Using index
 
577
INSERT INTO t2 SELECT * FROM t1;
 
578
OPTIMIZE TABLE t2;
 
579
Table   Op      Msg_type        Msg_text
 
580
test.t2 optimize        status  OK
 
581
EXPLAIN SELECT COUNT(*) FROM t2 WHERE stat_id IN (1,3) AND acct_id=785;
 
582
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
583
1       SIMPLE  t2      range   idx1,idx2       idx1    9       NULL    2       Using where; Using index
 
584
DROP TABLE t1,t2;
486
585
create table t1(a int) engine=innodb;
487
586
alter table t1 comment '123';
488
587
show create table t1;
489
588
Table   Create Table
490
589
t1      CREATE TABLE `t1` (
491
 
  `a` int DEFAULT NULL
492
 
) ENGINE=InnoDB COMMENT='123'
 
590
  `a` int(11) DEFAULT NULL
 
591
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='123'
493
592
drop table t1;
494
 
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
 
593
CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
495
594
INSERT INTO t1 VALUES ('uk'),('bg');
496
595
SELECT * FROM t1 WHERE a = 'uk';
497
596
a
514
613
UPDATE t2 SET a = 'us' WHERE a = 'uk';
515
614
SELECT * FROM t2 WHERE a = 'uk';
516
615
a
517
 
CREATE TEMPORARY TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
 
616
CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
518
617
INSERT INTO t3 VALUES ('uk'),('bg');
519
618
SELECT * FROM t3 WHERE a = 'uk';
520
619
a
527
626
SELECT * FROM t3 WHERE a = 'uk';
528
627
a
529
628
DROP TABLE t1,t2,t3;
 
629
create table t1 (a int) engine=innodb;
 
630
select * from bug29807;
 
631
ERROR 42S02: Table 'test.bug29807' doesn't exist
 
632
drop table t1;
 
633
drop table bug29807;
 
634
ERROR 42S02: Unknown table 'bug29807'
 
635
create table bug29807 (a int);
 
636
drop table bug29807;
 
637
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
 
638
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
 
639
switch to connection c1
 
640
SET AUTOCOMMIT=0;
 
641
INSERT INTO t2 VALUES (1);
 
642
switch to connection c2
 
643
SET AUTOCOMMIT=0;
 
644
LOCK TABLES t1 READ, t2 READ;
 
645
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 
646
switch to connection c1
 
647
COMMIT;
 
648
INSERT INTO t1 VALUES (1);
 
649
switch to connection default
 
650
SET AUTOCOMMIT=default;
 
651
DROP TABLE t1,t2;
530
652
CREATE TABLE t1 (
531
653
id int NOT NULL auto_increment PRIMARY KEY,
532
654
b int NOT NULL,
537
659
CREATE TABLE t2 (
538
660
b int NOT NULL auto_increment PRIMARY KEY,
539
661
c datetime NOT NULL
540
 
) ENGINE= InnoDB;
 
662
) ENGINE= MyISAM;
541
663
INSERT INTO t2(c) VALUES ('2007-01-01');
542
664
INSERT INTO t2(c) SELECT c FROM t2;
543
665
INSERT INTO t2(c) SELECT c FROM t2;
556
678
INSERT INTO t1(b,c) SELECT b,c FROM t2;
557
679
set @@sort_buffer_size=8192;
558
680
Warnings:
559
 
Error   1292    Truncated incorrect sort_buffer_size value: '8192'
 
681
Warning 1292    Truncated incorrect sort_buffer_size value: '8192'
560
682
SELECT COUNT(*) FROM t1;
561
683
COUNT(*)
562
684
3072
637
759
SELECT * from t2;
638
760
a       b
639
761
drop table t1,t2;
640
 
create table t1(f1 varchar(800) not null, key(f1));
 
762
create table t1(f1 varchar(800) binary not null, key(f1))
 
763
character set utf8 collate utf8_general_ci;
641
764
Warnings:
642
765
Warning 1071    Specified key was too long; max key length is 767 bytes
643
766
insert into t1 values('aaa');
662
785
show variables like 'innodb_rollback_on_timeout';
663
786
Variable_name   Value
664
787
innodb_rollback_on_timeout      OFF
665
 
create table t1 (a int not null primary key) engine = innodb;
 
788
create table t1 (a int unsigned not null primary key) engine = innodb;
666
789
insert into t1 values (1);
667
790
commit;
668
791
begin work;
695
818
2
696
819
5
697
820
drop table t1;
 
821
drop table if exists t1;
 
822
create table t1 (a int) engine=innodb;
 
823
alter table t1 alter a set default 1;
 
824
drop table t1;
 
825
 
 
826
Bug#24918 drop table and lock / inconsistent between 
 
827
perm and temp tables
 
828
 
 
829
Check transactional tables under LOCK TABLES
 
830
 
 
831
drop table if exists t24918, t24918_tmp, t24918_trans, t24918_trans_tmp, 
 
832
t24918_access;
 
833
create table t24918_access (id int);
 
834
create table t24918 (id int) engine=myisam;
 
835
create temporary table t24918_tmp (id int) engine=myisam;
 
836
create table t24918_trans (id int) engine=innodb;
 
837
create temporary table t24918_trans_tmp (id int) engine=innodb;
 
838
lock table t24918 write, t24918_tmp write, t24918_trans write, t24918_trans_tmp write;
 
839
drop table t24918;
 
840
select * from t24918_access;
 
841
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
 
842
drop table t24918_trans;
 
843
select * from t24918_access;
 
844
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
 
845
drop table t24918_trans_tmp;
 
846
select * from t24918_access;
 
847
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
 
848
drop table t24918_tmp;
 
849
select * from t24918_access;
 
850
ERROR HY000: Table 't24918_access' was not locked with LOCK TABLES
 
851
unlock tables;
 
852
drop table t24918_access;
698
853
CREATE TABLE t1 (a int, b int, PRIMARY KEY (a), KEY bkey (b)) ENGINE=InnoDB;
699
854
INSERT INTO t1 VALUES (1,2),(3,2),(2,2),(4,2),(5,2),(6,2),(7,2),(8,2);
700
855
INSERT INTO t1 SELECT a + 8, 2 FROM t1;
940
1095
15      1       1
941
1096
16      1       1
942
1097
DROP TABLE t1,t2;
943
 
create table t1(a text) engine=innodb;
 
1098
CREATE TABLE t1 (a INT, PRIMARY KEY (a)) ENGINE=InnoDB;
 
1099
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8);
 
1100
INSERT INTO t1 SELECT a + 8  FROM t1;
 
1101
INSERT INTO t1 SELECT a + 16 FROM t1;
 
1102
CREATE PROCEDURE p1 ()
 
1103
BEGIN
 
1104
DECLARE i INT DEFAULT 50;
 
1105
DECLARE cnt INT;
 
1106
START TRANSACTION;
 
1107
ALTER TABLE t1 ENGINE=InnoDB;
 
1108
COMMIT;
 
1109
START TRANSACTION;
 
1110
WHILE (i > 0) DO
 
1111
SET i = i - 1;
 
1112
SELECT COUNT(*) INTO cnt FROM t1 LOCK IN SHARE MODE;
 
1113
END WHILE;
 
1114
COMMIT;
 
1115
END;|
 
1116
CALL p1();
 
1117
CALL p1();
 
1118
CALL p1();
 
1119
DROP PROCEDURE p1;
 
1120
DROP TABLE t1;
 
1121
create table t1(a text) engine=innodb default charset=utf8;
944
1122
insert into t1 values('aaa');
945
1123
alter table t1 add index(a(1024));
946
1124
Warnings:
947
1125
Warning 1071    Specified key was too long; max key length is 767 bytes
 
1126
Warning 1071    Specified key was too long; max key length is 767 bytes
 
1127
Warning 1071    Specified key was too long; max key length is 767 bytes
948
1128
show create table t1;
949
1129
Table   Create Table
950
1130
t1      CREATE TABLE `t1` (
951
1131
  `a` text,
952
1132
  KEY `a` (`a`(191))
953
 
) ENGINE=InnoDB
 
1133
) ENGINE=InnoDB DEFAULT CHARSET=utf8
954
1134
drop table t1;
955
1135
CREATE TABLE t1 (
956
1136
a INT,
1154
1334
b char(4) not null, unique key bb(b(4))) engine=innodb;
1155
1335
desc t1;
1156
1336
Field   Type    Null    Key     Default Extra
1157
 
a       varchar(10)     NO      UNI     NULL    
1158
 
b       varchar(4)      NO      PRI     NULL    
 
1337
a       char(10)        NO      UNI     NULL    
 
1338
b       char(4) NO      PRI     NULL    
1159
1339
show create table t1;
1160
1340
Table   Create Table
1161
1341
t1      CREATE TABLE `t1` (
1162
 
  `a` varchar(10) NOT NULL,
1163
 
  `b` varchar(4) NOT NULL,
 
1342
  `a` char(10) NOT NULL,
 
1343
  `b` char(4) NOT NULL,
1164
1344
  UNIQUE KEY `bb` (`b`),
1165
1345
  UNIQUE KEY `aa` (`a`(1))
1166
 
) ENGINE=InnoDB
 
1346
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1167
1347
drop table t1;
1168
1348
CREATE TABLE t1 (id int, type char(6), d int, INDEX idx(id,d)) ENGINE=InnoDB;
1169
1349
INSERT INTO t1 VALUES 
1185
1365
set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
1186
1366
End of 5.0 tests
1187
1367
CREATE TABLE `t2` (
1188
 
`k` int NOT NULL auto_increment,
1189
 
`a` int default NULL,
1190
 
`c` int default NULL,
 
1368
`k` int(11) NOT NULL auto_increment,
 
1369
`a` int(11) default NULL,
 
1370
`c` int(11) default NULL,
1191
1371
PRIMARY KEY  (`k`),
1192
1372
UNIQUE KEY `idx_1` (`a`)
1193
1373
);
1252
1432
11      15      1
1253
1433
12      20      1
1254
1434
drop table t2;
 
1435
drop table if exists t1, t2;
 
1436
create table t1 (i int);
 
1437
alter table t1 modify i int default 1;
 
1438
alter table t1 modify i int default 2, rename t2;
 
1439
lock table t2 write;
 
1440
alter table t2 modify i int default 3;
 
1441
unlock tables;
 
1442
lock table t2 write;
 
1443
alter table t2 modify i int default 4, rename t1;
 
1444
unlock tables;
 
1445
drop table t1;
 
1446
drop table if exists t1;
 
1447
create table t1 (i int);
 
1448
insert into t1 values ();
 
1449
lock table t1 write;
 
1450
alter table t1 modify i int default 1;
 
1451
insert into t1 values ();
 
1452
select * from t1;
 
1453
i
 
1454
NULL
 
1455
1
 
1456
alter table t1 change i c char(10) default "Two";
 
1457
insert into t1 values ();
 
1458
select * from t1;
 
1459
c
 
1460
NULL
 
1461
1
 
1462
Two
 
1463
unlock tables;
 
1464
select * from t1;
 
1465
c
 
1466
NULL
 
1467
1
 
1468
Two
 
1469
drop tables t1;
1255
1470
create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
1256
1471
CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
1257
1472
insert into t1(f1) values(1);
1258
1473
select @a:=f2 from t1;
1259
 
@a:=f2 
 
1474
@a:=f2
1260
1475
#
1261
1476
update t1 set f1=1;
1262
1477
select @b:=f2 from t1;
1263
 
@b:=f2 
 
1478
@b:=f2
1264
1479
#
1265
1480
select if(@a=@b,"ok","wrong");
1266
1481
if(@a=@b,"ok","wrong")
1267
1482
ok
1268
1483
insert into t1(f1) values (1) on duplicate key update f1="1";
1269
1484
select @b:=f2 from t1;
1270
 
@b:=f2 
 
1485
@b:=f2
1271
1486
#
1272
1487
select if(@a=@b,"ok","wrong");
1273
1488
if(@a=@b,"ok","wrong")
1274
1489
ok
1275
1490
insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
1276
1491
select @b:=f2 from t1;
1277
 
@b:=f2 
 
1492
@b:=f2
1278
1493
#
1279
1494
select if(@a=@b,"ok","wrong");
1280
1495
if(@a=@b,"ok","wrong")
1281
1496
ok
1282
1497
drop table t1;
 
1498
SET SESSION AUTOCOMMIT = 0;
 
1499
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
 
1500
# Switch to connection con1
 
1501
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256))
 
1502
ENGINE = InnoDB;
 
1503
INSERT INTO t1 VALUES (1,2);
 
1504
# 1. test for locking:
 
1505
BEGIN;
 
1506
UPDATE t1 SET b = 12 WHERE a = 1;
 
1507
affected rows: 1
 
1508
info: Rows matched: 1  Changed: 1  Warnings: 0
 
1509
SELECT * FROM t1;
 
1510
a       b
 
1511
1       12
 
1512
# Switch to connection con2
 
1513
UPDATE t1 SET b = 21 WHERE a = 1;
 
1514
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
 
1515
# Switch to connection con1
 
1516
SELECT * FROM t1;
 
1517
a       b
 
1518
1       12
 
1519
ROLLBACK;
 
1520
# 2. test for serialized update:
 
1521
CREATE TABLE t2 (a INT);
 
1522
TRUNCATE t1;
 
1523
INSERT INTO t1 VALUES (1,'init');
 
1524
CREATE PROCEDURE p1()
 
1525
BEGIN
 
1526
UPDATE t1 SET b = CONCAT(b, '+con2')  WHERE a = 1;
 
1527
INSERT INTO t2 VALUES ();
 
1528
END|
 
1529
BEGIN;
 
1530
UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1;
 
1531
affected rows: 1
 
1532
info: Rows matched: 1  Changed: 1  Warnings: 0
 
1533
SELECT * FROM t1;
 
1534
a       b
 
1535
1       init+con1
 
1536
# Switch to connection con2
 
1537
CALL p1;;
 
1538
# Switch to connection con1
 
1539
SELECT * FROM t1;
 
1540
a       b
 
1541
1       init+con1
 
1542
COMMIT;
 
1543
SELECT * FROM t1;
 
1544
a       b
 
1545
1       init+con1
 
1546
# Switch to connection con2
 
1547
SELECT * FROM t1;
 
1548
a       b
 
1549
1       init+con1+con2
 
1550
# Switch to connection con1
 
1551
# 3. test for updated key column:
 
1552
TRUNCATE t1;
 
1553
TRUNCATE t2;
 
1554
INSERT INTO t1 VALUES (1,'init');
 
1555
BEGIN;
 
1556
UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1;
 
1557
affected rows: 1
 
1558
info: Rows matched: 1  Changed: 1  Warnings: 0
 
1559
SELECT * FROM t1;
 
1560
a       b
 
1561
2       init+con1
 
1562
# Switch to connection con2
 
1563
CALL p1;;
 
1564
# Switch to connection con1
 
1565
SELECT * FROM t1;
 
1566
a       b
 
1567
2       init+con1
 
1568
COMMIT;
 
1569
SELECT * FROM t1;
 
1570
a       b
 
1571
2       init+con1
 
1572
# Switch to connection con2
 
1573
SELECT * FROM t1;
 
1574
a       b
 
1575
2       init+con1
 
1576
DROP PROCEDURE p1;
 
1577
DROP TABLE t1, t2;
1283
1578
CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb;
1284
1579
CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d),
1285
1580
CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb;
1306
1601
SHOW CREATE TABLE t2;
1307
1602
Table   Create Table
1308
1603
t2      CREATE TABLE `t2` (
1309
 
  `c` int NOT NULL,
1310
 
  `d` int NOT NULL,
 
1604
  `c` int(11) NOT NULL,
 
1605
  `d` int(11) NOT NULL,
1311
1606
  PRIMARY KEY (`c`,`d`),
1312
1607
  CONSTRAINT `c1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON DELETE NO ACTION,
1313
1608
  CONSTRAINT `c2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION,
1314
1609
  CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION,
1315
1610
  CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t1` (`a`) ON UPDATE NO ACTION
1316
 
) ENGINE=InnoDB
 
1611
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1317
1612
DROP TABLE t2;
1318
1613
DROP TABLE t1;
1319
1614
create table t1 (a int auto_increment primary key) engine=innodb;
1320
1615
alter table t1 order by a;
1321
 
ERROR HY000: order_st BY ignored because there is a user-defined clustered index in the table 't1'
 
1616
Warnings:
 
1617
Warning 1105    ORDER BY ignored as there is a user-defined clustered index in the table 't1'
1322
1618
drop table t1;
1323
1619
CREATE TABLE t1
1324
1620
(vid integer NOT NULL,