truncate.test 1.5 KB
--source include/have_innodb.inc
--source include/have_debug.inc

--echo #
--echo # Bug#25053705 - INVALID I/O ON TABLE AFTER TRUNCATE
--echo #

CREATE TABLE t1 (a INT, d INT, b VARCHAR(198), c CHAR(158), FULLTEXT fts1(c,b),
FULLTEXT fts2(c));

TRUNCATE TABLE t1;

INSERT INTO t1 (a,d,b,c) VALUES (
'79795','6',repeat('uololoaroolccaaruolraloouuoocorrcorurlu','1'),
repeat('orouculcaocuocloooolooloooaorlroclouulrrucclulalouaulrluorooaclllluuorc
cuullucocraloracurooulrooauuar','1'));

# The following CREATE TABLE and INSERTs are used to remove the pages related to table t1
# from the buffer pool.
CREATE TABLE t2 (a INT, d INT, b VARCHAR(198), c CHAR(158), FULLTEXT fts1(c,b));

INSERT INTO t2 VALUES (1, 1, repeat('uololoaroolccaaruolraloouuoocorrcorurlu','1'),
repeat('orouculcaocuocloooolooloooaorlroclouulrrucclulalouaulrluorooaclllluuorccuullucocraloracurooulrooauuar','1'));

delimiter |;
create procedure insert_t2(IN total int)
begin
        declare i int default 1;
        while (i <= total) DO
                insert into t2 select * from t2;
                set i = i + 1;
        end while;
end|
delimiter ;|

CALL insert_t2(15);

SET @save_dbug = @@SESSION.DEBUG_DBUG;
SET DEBUG_DBUG = '+d,innodb_invalid_read_after_truncate';

INSERT INTO t1 (a,d,b,c) VALUES (
'7795','6',repeat('uololoaroolccaaruolraloouuoocorrcorurlu','1'),
repeat('orouculcaocuocloooolooloooaorlroclouulrrucclulalouaulrluorooaclllluuorc
cuullucocraloracurooulrooauuar','1'));

SET DEBUG_DBUG = @save_dbug;

DROP PROCEDURE insert_t2;

DROP TABLE t1,t2;