"1. Test some basic dml action involving truncate of table."
use test;
set global innodb_file_per_table = 0;
create table t1
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create table t2
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) do
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t1_small()
begin
declare i int default 1;
while (i <= 20) do
insert into t1 values (i, 'c', 'd');
set i = i + 1;
end while;
end|
create procedure populate_t1_small2()
begin
declare i int default 30;
while (i <= 50) do
insert into t1 values (i, 'e', 'f');
set i = i + 1;
end while;
end|
begin;
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
select * from t1 limit 10;
keyc	c1	c2
1	a	b
2	a	b
3	a	b
4	a	b
5	a	b
6	a	b
7	a	b
8	a	b
9	a	b
10	a	b
rollback;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
select count(*) from t1;
count(*)
200
commit;
select count(*) from t1;
count(*)
200
truncate table t1;
select count(*) from t1;
count(*)
0
call populate_t1_small();
select count(*) from t1;
count(*)
20
rollback;
select count(*) from t1;
count(*)
20
truncate table t1;
call populate_t1();
select count(*) from t1;
count(*)
200
delete from t1 where keyc <= 60;
select count(*) from t1;
count(*)
140
call populate_t1_small();
select count(*) from t1;
count(*)
160
select * from t1 limit 10;
keyc	c1	c2
1	c	d
2	c	d
3	c	d
4	c	d
5	c	d
6	c	d
7	c	d
8	c	d
9	c	d
10	c	d
begin;
call populate_t1_small2();
select count(*) from t1;
count(*)
181
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
31	e	f
32	e	f
33	e	f
34	e	f
35	e	f
36	e	f
37	e	f
38	e	f
39	e	f
40	e	f
rollback;
select count(*) from t1;
count(*)
160
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
61	a	b
62	a	b
63	a	b
64	a	b
65	a	b
66	a	b
67	a	b
68	a	b
69	a	b
70	a	b
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
rollback;
begin;
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
4001	c	d
4002	c	d
4003	c	d
4004	c	d
4005	c	d
4006	c	d
4007	c	d
4008	c	d
4009	c	d
4010	c	d
rollback;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
commit;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
insert into t2 select * from t1 where keyc < 2101;
select count(*) from t2;
count(*)
60
drop procedure populate_t1;
drop procedure populate_t1_small;
drop procedure populate_t1_small2;
drop table t1;
drop table t2;
create temporary table t1
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create temporary table t2
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) do
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t1_small()
begin
declare i int default 1;
while (i <= 20) do
insert into t1 values (i, 'c', 'd');
set i = i + 1;
end while;
end|
create procedure populate_t1_small2()
begin
declare i int default 30;
while (i <= 50) do
insert into t1 values (i, 'e', 'f');
set i = i + 1;
end while;
end|
begin;
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
select * from t1 limit 10;
keyc	c1	c2
1	a	b
2	a	b
3	a	b
4	a	b
5	a	b
6	a	b
7	a	b
8	a	b
9	a	b
10	a	b
rollback;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
select count(*) from t1;
count(*)
200
commit;
select count(*) from t1;
count(*)
200
truncate table t1;
select count(*) from t1;
count(*)
0
call populate_t1_small();
select count(*) from t1;
count(*)
20
rollback;
select count(*) from t1;
count(*)
20
truncate table t1;
call populate_t1();
select count(*) from t1;
count(*)
200
delete from t1 where keyc <= 60;
select count(*) from t1;
count(*)
140
call populate_t1_small();
select count(*) from t1;
count(*)
160
select * from t1 limit 10;
keyc	c1	c2
1	c	d
2	c	d
3	c	d
4	c	d
5	c	d
6	c	d
7	c	d
8	c	d
9	c	d
10	c	d
begin;
call populate_t1_small2();
select count(*) from t1;
count(*)
181
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
31	e	f
32	e	f
33	e	f
34	e	f
35	e	f
36	e	f
37	e	f
38	e	f
39	e	f
40	e	f
rollback;
select count(*) from t1;
count(*)
160
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
61	a	b
62	a	b
63	a	b
64	a	b
65	a	b
66	a	b
67	a	b
68	a	b
69	a	b
70	a	b
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
rollback;
begin;
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
4001	c	d
4002	c	d
4003	c	d
4004	c	d
4005	c	d
4006	c	d
4007	c	d
4008	c	d
4009	c	d
4010	c	d
rollback;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
commit;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
insert into t2 select * from t1 where keyc < 2101;
select count(*) from t2;
count(*)
60
drop procedure populate_t1;
drop procedure populate_t1_small;
drop procedure populate_t1_small2;
drop table t1;
drop table t2;
set global innodb_file_per_table = 1;
create table t1
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create table t2
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) do
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t1_small()
begin
declare i int default 1;
while (i <= 20) do
insert into t1 values (i, 'c', 'd');
set i = i + 1;
end while;
end|
create procedure populate_t1_small2()
begin
declare i int default 30;
while (i <= 50) do
insert into t1 values (i, 'e', 'f');
set i = i + 1;
end while;
end|
begin;
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
select * from t1 limit 10;
keyc	c1	c2
1	a	b
2	a	b
3	a	b
4	a	b
5	a	b
6	a	b
7	a	b
8	a	b
9	a	b
10	a	b
rollback;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
select count(*) from t1;
count(*)
200
commit;
select count(*) from t1;
count(*)
200
truncate table t1;
select count(*) from t1;
count(*)
0
call populate_t1_small();
select count(*) from t1;
count(*)
20
rollback;
select count(*) from t1;
count(*)
20
truncate table t1;
call populate_t1();
select count(*) from t1;
count(*)
200
delete from t1 where keyc <= 60;
select count(*) from t1;
count(*)
140
call populate_t1_small();
select count(*) from t1;
count(*)
160
select * from t1 limit 10;
keyc	c1	c2
1	c	d
2	c	d
3	c	d
4	c	d
5	c	d
6	c	d
7	c	d
8	c	d
9	c	d
10	c	d
begin;
call populate_t1_small2();
select count(*) from t1;
count(*)
181
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
31	e	f
32	e	f
33	e	f
34	e	f
35	e	f
36	e	f
37	e	f
38	e	f
39	e	f
40	e	f
rollback;
select count(*) from t1;
count(*)
160
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
61	a	b
62	a	b
63	a	b
64	a	b
65	a	b
66	a	b
67	a	b
68	a	b
69	a	b
70	a	b
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
rollback;
begin;
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
4001	c	d
4002	c	d
4003	c	d
4004	c	d
4005	c	d
4006	c	d
4007	c	d
4008	c	d
4009	c	d
4010	c	d
rollback;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
commit;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
insert into t2 select * from t1 where keyc < 2101;
select count(*) from t2;
count(*)
60
drop procedure populate_t1;
drop procedure populate_t1_small;
drop procedure populate_t1_small2;
drop table t1;
drop table t2;
create temporary table t1
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create temporary table t2
(keyc int, c1 char(100), c2 char(100),
primary key(keyc), index sec_index(c1)
) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) do
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t1_small()
begin
declare i int default 1;
while (i <= 20) do
insert into t1 values (i, 'c', 'd');
set i = i + 1;
end while;
end|
create procedure populate_t1_small2()
begin
declare i int default 30;
while (i <= 50) do
insert into t1 values (i, 'e', 'f');
set i = i + 1;
end while;
end|
begin;
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
select * from t1 limit 10;
keyc	c1	c2
1	a	b
2	a	b
3	a	b
4	a	b
5	a	b
6	a	b
7	a	b
8	a	b
9	a	b
10	a	b
rollback;
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
select count(*) from t1;
count(*)
200
commit;
select count(*) from t1;
count(*)
200
truncate table t1;
select count(*) from t1;
count(*)
0
call populate_t1_small();
select count(*) from t1;
count(*)
20
rollback;
select count(*) from t1;
count(*)
20
truncate table t1;
call populate_t1();
select count(*) from t1;
count(*)
200
delete from t1 where keyc <= 60;
select count(*) from t1;
count(*)
140
call populate_t1_small();
select count(*) from t1;
count(*)
160
select * from t1 limit 10;
keyc	c1	c2
1	c	d
2	c	d
3	c	d
4	c	d
5	c	d
6	c	d
7	c	d
8	c	d
9	c	d
10	c	d
begin;
call populate_t1_small2();
select count(*) from t1;
count(*)
181
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
31	e	f
32	e	f
33	e	f
34	e	f
35	e	f
36	e	f
37	e	f
38	e	f
39	e	f
40	e	f
rollback;
select count(*) from t1;
count(*)
160
select * from t1 where keyc > 30 limit 10;
keyc	c1	c2
61	a	b
62	a	b
63	a	b
64	a	b
65	a	b
66	a	b
67	a	b
68	a	b
69	a	b
70	a	b
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
rollback;
begin;
update t1 set keyc = keyc + 2000;
select * from t1 limit 10;
keyc	c1	c2
4001	c	d
4002	c	d
4003	c	d
4004	c	d
4005	c	d
4006	c	d
4007	c	d
4008	c	d
4009	c	d
4010	c	d
rollback;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
commit;
select * from t1 limit 10;
keyc	c1	c2
2001	c	d
2002	c	d
2003	c	d
2004	c	d
2005	c	d
2006	c	d
2007	c	d
2008	c	d
2009	c	d
2010	c	d
insert into t2 select * from t1 where keyc < 2101;
select count(*) from t2;
count(*)
60
drop procedure populate_t1;
drop procedure populate_t1_small;
drop procedure populate_t1_small2;
drop table t1;
drop table t2;
"2. Test that truncating reference table is blocked."
use test;
create table master
(i int, f float, c char(100),
primary key pk(i), index fidx(f))
engine = innodb;
create table slave
(i int, j int,
primary key pk(i),
foreign key fk(j) references master(i))
engine = innodb;
insert into master values
(1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'),
(4, 4.4, 'd'), (5, 5.5, 'e');
insert into slave values
(101, 1), (202, 3), (303, 5);
select * from master;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
4	4.4	d
5	5.5	e
select * from slave;
i	j
101	1
202	3
303	5
truncate table master;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`slave`, CONSTRAINT `slave_ibfk_1` FOREIGN KEY (`j`) REFERENCES `test`.`master` (`i`))
drop table slave;
drop table master;
"3. Test truncate of loaded table that has blob + compression."
use test;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) DO
insert into t1 values (i, i, repeat(concat('tc3_', i), 1000),
repeat('a', 1000));
set i = i + 1;
end while;
end|
set global innodb_file_per_table = 0;
create table t1 (a int not null, d int not null, b blob not null, c text,
primary key (b(10), a, d),  index (d), index(a),  index (c(355),
b(255)), index (b(5), c(10), a)
) engine=InnoDB;
call populate_t1();
select count(*) from t1;
count(*)
200
set session debug = "+d,ib_trunc_crash_before_log_removal";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
drop table t1;
set innodb_strict_mode=off;
create table t1 (a int not null, d int not null, b blob not null, c text,
primary key (b(10), a, d),  index (d), index(a),  index (c(355),
b(255)), index (b(5), c(10), a)
) engine=InnoDB row_format=compressed key_block_size=8;
set innodb_strict_mode=default;
call populate_t1();
select count(*) from t1;
count(*)
200
set session debug = "+d,ib_trunc_crash_before_log_removal";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select count(*) from t1;
count(*)
0
call populate_t1();
select count(*) from t1;
count(*)
200
drop table t1;
drop procedure populate_t1;
use test;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 200) DO
insert into t1 values (i, i, repeat(concat('tc3_', i), 150),
repeat('a', 100));
set i = i + 1;
end while;
end|
set global innodb_file_per_table = 1;
create table t1 (a int not null, d int not null, b varchar(198) not null,
c char(185), unique key (b(10), a, d), index (d), index(a),
index (c(120), b(120)), index (b(5), c(10), a))
engine=InnoDB stats_persistent=0 row_format=compressed key_block_size=1;
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
200
SET sql_mode = default;
set session debug = "+d,ib_trunc_crash_before_log_removal";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
200
drop table t1;
set global innodb_file_per_table = 0;
set global innodb_file_format = 'Antelope';
Warnings:
Warning	131	Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
create table t1 (a int not null, d int not null, b varchar(198) not null,
c char(185), unique key (b(10), a, d), index (d), index(a),
index (c(120), b(120)), index (b(5), c(10), a))
engine=InnoDB stats_persistent=0;
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
200
set session debug = "+d,ib_trunc_crash_before_log_removal";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select count(*) from t1;
count(*)
0
begin;
call populate_t1();
commit;
select count(*) from t1;
count(*)
200
drop table t1;
drop procedure populate_t1;
"5 check truncate with lock/unlock"
use test;
set global innodb_file_per_table = 1;
create table master
(i int, f float, c char(100),
primary key pk(i), index fidx(f))
engine = innodb;
insert into master values
(1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'),
(4, 4.4, 'd'), (5, 5.5, 'e');
select * from master;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
4	4.4	d
5	5.5	e
"--In con1 connection--"
use test;
lock tables master write;
"--In default connection--"
use test;
truncate table master;;
"--In con1 connection--"
select * from master;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
4	4.4	d
5	5.5	e
unlock tables;
"--In default connection--"
select * from master;
i	f	c
drop table master;
use test;
set global innodb_file_per_table = 1;
create table t1
(i int, f float, c char(100),
primary key pk(i), index fidx(f))
engine = innodb;
insert into t1 values
(1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'),
(4, 4.4, 'd'), (5, 5.5, 'e');
select * from t1;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
4	4.4	d
5	5.5	e
set session debug = "+d,ib_trunc_crash_after_logging_complete";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
select * from t1;
i	f	c
insert into t1 values
(1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
select * from t1;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
drop table t1;
use test;
set global innodb_file_per_table = 1;
create table t1
(i int, f float, c char(100),
primary key pk(i), index fidx(f))
engine = innodb;
insert into t1 values
(1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'),
(4, 4.4, 'd'), (5, 5.5, 'e');
select * from t1;
i	f	c
1	1.1	a
2	2.2	b
3	3.3	c
4	4.4	d
5	5.5	e
set session debug = "+d,ib_trunc_crash_with_intermediate_log_checkpoint";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
select * from t1;
i	f	c
drop table t1;
use test;
create table t (i int, j int) engine=innodb;
insert into t values (1,1), (2,2), (3,3);
select * from t;
i	j
1	1
2	2
3	3
set session debug="+d,ib_err_trunc_oom_logging";
truncate table t;
ERROR HY000: Got error 168 from storage engine
set session debug="-d,ib_err_trunc_oom_logging";
select * from t;
i	j
1	1
2	2
3	3
select * from t;
i	j
1	1
2	2
3	3
set session debug="+d,ib_err_trunc_writing_magic_number";
truncate table t;
select * from t;
i	j
insert into t values (1,1), (2,2), (3,3);
select * from t;
i	j
1	1
2	2
3	3
# Restart the MySQL server
# restart
select * from t;
i	j
1	1
2	2
3	3
drop table t;
use test;
create table t (i int, j int, primary key pk(i), index idx(j)) engine=innodb;
insert into t values (1,1), (2,2), (3,3);
select * from t;
i	j
1	1
2	2
3	3
set session debug="+d,ib_trunc_crash_after_updating_magic_no";
truncate table t;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
select * from t;
i	j
drop table t;
use test;
set global innodb_file_per_table = 0;
create table t1 (i int, primary key pk(i)) engine=innodb;
create table t2 (j int) engine=innodb;
insert into t1 values (1), (2), (3), (4), (5);
insert into t2 values (1), (2), (3), (4), (5);
select * from t1;
i
1
2
3
4
5
select * from t2;
j
1
2
3
4
5
use test;
use test;
select * from t1;
i
1
2
3
4
5
set DEBUG_SYNC='RESET';
set DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL trunc_completing WAIT_FOR trunc_continue';
truncate table t1;
set DEBUG_SYNC='now WAIT_FOR trunc_completing';
select * from t2;
j
1
2
3
4
5
truncate table t2;
select * from t2;
j
set DEBUG_SYNC='now SIGNAL trunc_continue';
select * from t1;
i
set DEBUG_SYNC='RESET';
drop table t1;
drop table t2;
use test;
set global innodb_file_per_table = 1;
create table t1 (a int, b char(100), c char(100)) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
begin;
call populate_t1();
commit;
set session debug="+d,ib_trunc_crash_after_truncate_done";
begin;
update t1 set a = a + 1000;
commit;
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
select count(*) from t1;
count(*)
0
drop procedure populate_t1;
drop table t1;
use test;
set global innodb_file_per_table = 1;
create table t1 (a int, b char(100), c char(100)) engine = innodb;
create table t2 (a int, b char(100), c char(100)) engine = innodb;
create table t3 (a int, b char(100), c char(100)) engine = innodb;
create procedure populate_t1()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t1 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t2()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t2 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
create procedure populate_t3()
begin
declare i int default 1;
while (i <= 2000) DO
insert into t3 values (i, 'a', 'b');
set i = i + 1;
end while;
end|
begin;
call populate_t1();
call populate_t2();
call populate_t3();
commit;
select count(*) from t1;
count(*)
2000
truncate table t1;
select count(*) from t1;
count(*)
0
select count(*) from t2;
count(*)
2000
truncate table t2;
select count(*) from t2;
count(*)
0
select count(*) from t3;
count(*)
2000
set session debug="+d,ib_trunc_crash_after_truncate_done";
truncate table t3;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
select count(*) from t1;
count(*)
0
select count(*) from t2;
count(*)
0
select count(*) from t3;
count(*)
0
begin;
call populate_t1();
call populate_t2();
call populate_t3();
commit;
select count(*) from t1;
count(*)
2000
select count(*) from t2;
count(*)
2000
select count(*) from t3;
count(*)
2000
truncate table t1;
truncate table t1;
set session debug="+d,ib_trunc_crash_after_truncate_done";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# Restart the MySQL server
select count(*) from t1;
count(*)
0
drop procedure populate_t1;
drop procedure populate_t2;
drop procedure populate_t3;
drop table t1, t2, t3;
create table ibstd_33 (
a int not null,
d varchar(40) not null,
b text not null,
c text,
index(d),
index(a),
primary key (b(16), a, d),
fulltext ftsic(c)) engine=InnoDB row_format=dynamic;
insert into ibstd_33 (a,d,b,c) values ('1','6',
repeat('0.350557460150547arrclolullcocuraalaulloooclrcoulrccaoocourcrorooruruooauuauarrouccuoucrooaaouullrularcoarclloraaac','367'),
repeat('0.0836047279001129oaalolrllcoulaoococrolooullocuaacocoaoloclouallruaalolaruucaloluraocorrlouuoaorloarrluaaorucu','534'));
select count(*) from ibstd_33;
count(*)
1
set session debug = "+d,ib_truncate_crash_while_fts_cleanup";
truncate table ibstd_33;
ERROR HY000: Lost connection to MySQL server during query
# restart
select count(*) from ibstd_33;
ERROR 42S02: Table 'test.ibstd_33' doesn't exist
drop table ibstd_33;
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT INDEX ft1(a,b(200))) ENGINE = InnoDB;
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
select * from t1 where MATCH(a,b) AGAINST ("collections");
a	b
Full-text indexes	are called collections
Only MyISAM tables	support collections
select * from t1 where MATCH(a,b) AGAINST ("indexes");
a	b
Full-text indexes	are called collections
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
a	b
Full-text indexes	are called collections
Only MyISAM tables	support collections
select * from t1 where MATCH(a,b) AGAINST ("only");
a	b
Only MyISAM tables	support collections
ALTER TABLE t1 DROP INDEX ft1;
set session debug = "+d,ib_truncate_crash_while_fts_cleanup";
truncate table t1;
ERROR HY000: Lost connection to MySQL server during query
# restart
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
ERROR 42S02: Table 'test.t1' doesn't exist
select * from t1 where MATCH(a,b) AGAINST ("collections");
ERROR 42S02: Table 'test.t1' doesn't exist
drop table t1;
set global innodb_file_per_table = default;
set global innodb_strict_mode = default;
