--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/no_valgrind_without_big.inc

#
# Note that this test may fail with an error from check-mysqld_1
# where it complains that INNODB_LOG_FILE_BUFFERING changed from
# OFF to ON.
# This error happens if the disk used for storing the innodb log
# files gets full
#

let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;

SET GLOBAL innodb_log_file_size=4194304;
SHOW VARIABLES LIKE 'innodb_log_file_size';
SELECT global_value FROM information_schema.system_variables
WHERE variable_name = 'innodb_log_file_size';

CREATE TABLE t (
  a INT PRIMARY KEY AUTO_INCREMENT,
  b CHAR(255) NOT NULL)
ENGINE=INNODB;

INSERT INTO t SELECT NULL, REPEAT('a', 255) FROM seq_1_to_20000;

--let $restart_parameters=--innodb-log-file-size=4194304
--source include/restart_mysqld.inc

SELECT COUNT(*) FROM t;

SHOW VARIABLES LIKE 'innodb_log_file_size';
let SEARCH_PATTERN = InnoDB: Resized log to 4\\.000MiB;
--source include/search_pattern_in_file.inc

--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET @save=@@global.innodb_log_file_buffering;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_log_file_buffering=OFF;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_log_file_buffering=ON;
--error 0,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_log_file_buffering=@save;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR,ER_UNKNOWN_SYSTEM_VARIABLE
SET GLOBAL innodb_log_file_mmap=OFF;

--connect con1,localhost,root
let $ID= `SELECT @id := CONNECTION_ID()`;
send SET GLOBAL innodb_log_file_size=7340032;
--connection default
let $ignore= `SELECT @id := $ID`;
KILL QUERY @id;
--connection con1
--error 0,ER_QUERY_INTERRUPTED
reap;

--connection default
send SET GLOBAL innodb_log_file_size=5242880;

--connection con1
send UPDATE t SET b='' WHERE a<10;

--connection default
reap;
SHOW VARIABLES LIKE 'innodb_log_file_size';
SELECT global_value FROM information_schema.system_variables
WHERE variable_name = 'innodb_log_file_size';

--connection con1
reap;
--disconnect con1
--connection default

--let $shutdown_timeout=0
--let $restart_parameters=
--source include/restart_mysqld.inc

SELECT * FROM t WHERE a<10;
SELECT COUNT(*),LENGTH(b) FROM t GROUP BY b;

SHOW VARIABLES LIKE 'innodb_log_file_size';
SET GLOBAL innodb_log_file_size=6291456;
SHOW VARIABLES LIKE 'innodb_log_file_size';
SET GLOBAL innodb_log_file_size=5242880;
SHOW VARIABLES LIKE 'innodb_log_file_size';
let SEARCH_PATTERN = InnoDB: Resized log to 6\\.000MiB;
--source include/search_pattern_in_file.inc

DROP TABLE t;
