# MDEV-33101 Server crashes when starting the server with
# innodb-force-recovery=6 and enabling the
# innodb_truncate_temporary_tablespace_now variable
# restart: --innodb-force-recovery=6
SHOW VARIABLES LIKE "innodb_read_only";
Variable_name	Value
innodb_read_only	ON
SET GLOBAL innodb_truncate_temporary_tablespace_now=1;
# restart
CREATE TEMPORARY TABLE t1(f1 INT NOT NULL,
f2 INT NOT NULL)ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_65536;
DROP TABLE t1;
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE=4294967294;
NAME	FILE_SIZE
innodb_temporary	72351744
SET GLOBAL INNODB_TRUNCATE_TEMPORARY_TABLESPACE_NOW= 0;
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE=4294967294;
NAME	FILE_SIZE
innodb_temporary	72351744
SET GLOBAL INNODB_TRUNCATE_TEMPORARY_TABLESPACE_NOW= 1;
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE= 4294967294;
NAME	FILE_SIZE
innodb_temporary	5242880
CREATE TEMPORARY TABLE t1(f1 INT NOT NULL,
f2 INT NOT NULL)ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_65536;
connect con1,localhost,root,,,;
CREATE TEMPORARY TABLE t2(f1 INT NOT NULL,
f2 INT NOT NULL)ENGINE=InnoDB;
INSERT INTO t2 SELECT seq, seq FROM seq_1_to_65536;
DROP TABLE t2;
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE=4294967294;
NAME	FILE_SIZE
innodb_temporary	72351744
SET GLOBAL INNODB_TRUNCATE_TEMPORARY_TABLESPACE_NOW= 1;
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE= 4294967294;
NAME	FILE_SIZE
innodb_temporary	7340032
connection default;
COMMIT;
SELECT COUNT(*) FROM t1;
COUNT(*)
65536
DROP TABLE t1;
