# Tests for setting innodb-page-size=8k

--source include/have_innodb.inc
--source include/have_innodb_8k.inc
SET default_storage_engine=InnoDB;

--disable_query_log
let $MYSQLD_DATADIR= `select @@datadir`;

# These values can change during the test
let $innodb_file_format_orig = `SELECT @@innodb_file_format`;
let $innodb_file_format_max_orig = `SELECT @@innodb_file_format_max`;
let $innodb_file_per_table_orig = `SELECT @@innodb_file_per_table`;
let $innodb_large_prefix_orig = `SELECT @@innodb_large_prefix`;
let $innodb_strict_mode_orig = `SELECT @@session.innodb_strict_mode`;
--enable_query_log

SET GLOBAL innodb_file_format = `Barracuda`;
SET GLOBAL innodb_file_per_table = ON;

--echo # Test 1) Show the page size from Information Schema
SELECT variable_value FROM information_schema.global_status
       WHERE LOWER(variable_name) = 'innodb_page_size';

--echo # Test 2) The number of buffer pool pages is dependent upon the page size.
--replace_result 1023 {1023_or_1024} 1024 {1023_or_1024}
SELECT variable_value FROM information_schema.global_status
       WHERE LOWER(variable_name) = 'innodb_buffer_pool_pages_total';

--echo # Test 3) Query some information_shema tables that are dependent upon
--echo #         the page size.
# Pulled from innodb-system-table-view.test
# The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats are
# unpredictable, probably they on whether mtr has created the database for
# this test from scratch or is using a previously created database where
# those tables have been dropped and recreated. If we can force mtr to
# use a freshly created database for this test then the following
# complications can be removed and the test be reverted to the version
# it was before the patch that adds this comment.
--disable_query_log
--let table_stats_id = `SELECT table_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/innodb_table_stats'`
--let index_stats_id = `SELECT table_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/innodb_index_stats'`
--let $rep_table_1 = `SELECT table_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/slave_master_info'`
--let $rep_table_2 = `SELECT table_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/slave_relay_log_info'`
--let $rep_table_3 = `SELECT table_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/slave_worker_info'`
--eval SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES WHERE table_id NOT IN ($table_stats_id, $index_stats_id, $rep_table_1, $rep_table_2, $rep_table_3)
--enable_query_log
CREATE TABLE t1 (a INT KEY, b TEXT) ROW_FORMAT=REDUNDANT ENGINE=innodb;
CREATE TABLE t2 (a INT KEY, b TEXT) ROW_FORMAT=COMPACT ENGINE=innodb;
CREATE TABLE t3 (a INT KEY, b TEXT) ROW_FORMAT=COMPRESSED ENGINE=innodb;
CREATE TABLE t4 (a INT KEY, b TEXT) ROW_FORMAT=DYNAMIC ENGINE=innodb;
--replace_column 1 {id} 5 {id}
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
       WHERE name LIKE 'test%' ORDER BY table_id;
--replace_column 1 {id}
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES
       WHERE name LIKE 'test%' ORDER BY space;
--replace_column 1 {id}
--replace_result  ./ MYSQLD_DATADIR/  $MYSQLD_DATADIR MYSQLD_DATADIR
SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_DATAFILES
       WHERE path LIKE '%test%' ORDER BY space;
DROP TABLE t1, t2, t3, t4;

--echo # Test 4) The maximum row size is dependent upon the page size.
--echo #         Redundant: 4027, Compact: 4030.
--echo #         Compressed: 4030, Dynamic: 4030.
--echo #         Each row format has its own amount of overhead that
--echo #         varies depending on number of fields and other overhead.

SET SESSION innodb_strict_mode = ON;

# Redundant table; 3955 bytes with 20 CHAR fields
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(155)
) ROW_FORMAT=redundant;
DROP TABLE t1;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(156)
) ROW_FORMAT=redundant;

# Compact table; 4002 bytes with 20 CHAR fields
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(202)
) ROW_FORMAT=compact;
DROP TABLE t1;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(203)
) ROW_FORMAT=compact;

# Compressed table; 3905 bytes with 20 CHAR fields
# Bug#13391353 Limit is 3903 on 32-Linux only
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(103)
) ROW_FORMAT=compressed;
DROP TABLE t1;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(106)
) ROW_FORMAT=compressed;

# Dynamic table; 4002 bytes with 20 CHAR fields
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(202)
) ROW_FORMAT=dynamic;
DROP TABLE t1;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1 (
c01 char(200), c02 char(200), c03 char(200), c04 char(200), c05 char(200),
c06 char(200), c07 char(200), c08 char(200), c09 char(200), c10 char(200),
c11 char(200), c12 char(200), c13 char(200), c14 char(200), c15 char(200),
c16 char(200), c17 char(200), c18 char(200), c19 char(200), c20 char(203)
) ROW_FORMAT=dynamic;

#
# Test the maximum key length
# Moved from innodb-index.test since each page size has its own max key length.
# Max Key Length is 1536 for 8k pages.
#
# InnoDB assumes 3 bytes for each UTF8 character.
#
CREATE TABLE t1 (a varchar(128) character set utf8,
                 b varchar(128) character set utf8,
                 c varchar(128) character set utf8,
                 d varchar(128) character set utf8,
                 PRIMARY KEY (a,b,c,d))
		 ENGINE=innodb;
DROP TABLE t1;
--error ER_TOO_LONG_KEY
CREATE TABLE t1 (a varchar(128) character set utf8,
                 b varchar(128) character set utf8,
                 c varchar(128) character set utf8,
                 d varchar(129) character set utf8,
                 PRIMARY KEY (a,b,c,d))
		 ENGINE=innodb;
CREATE TABLE t1 (a varchar(128) character set utf8,
                 b varchar(128) character set utf8,
                 c varchar(128) character set utf8,
                 d varchar(128) character set utf8,
                 e varchar(128) character set utf8,
                 PRIMARY KEY (a), KEY (b,c,d,e))
		 ENGINE=innodb;
DROP TABLE t1;
--error ER_TOO_LONG_KEY
CREATE TABLE t1 (a varchar(128) character set utf8,
                 b varchar(128) character set utf8,
                 c varchar(128) character set utf8,
                 d varchar(128) character set utf8,
                 e varchar(129) character set utf8,
                 PRIMARY KEY (a), KEY (b,c,d,e))
		 ENGINE=innodb;

--echo # Test 5) Make sure that KEY_BLOCK_SIZE=8, 4, 2 & 1 are all 
--echo #         accepted and that KEY_BLOCK_SIZE=16 is rejected in
--echo #         strict mode and converted to 8 in non-strict mode.

SET SESSION innodb_strict_mode = ON;

--error ER_ILLEGAL_HA
CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;

CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=2;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=0;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;

SET SESSION innodb_strict_mode = OFF;

CREATE TABLE t1 (i int) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;

CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;

CREATE TABLE t1 ( i INT ) ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=2;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=1;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';

ALTER TABLE t1 KEY_BLOCK_SIZE=0;
SHOW WARNINGS;
SELECT table_name, row_format, create_options
   FROM information_schema.tables WHERE table_name = 't1';
DROP TABLE t1;


--echo # Test 6) Make sure that KEY_BLOCK_SIZE = 8 and 16
--echo # are rejected when innodb_file_per_table=OFF
# Moved from innodb-zip.test
SET SESSION innodb_strict_mode = ON;
SET GLOBAL innodb_file_per_table = OFF;
SHOW VARIABLES LIKE 'innodb_file_per_table';
--error ER_ILLEGAL_HA
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_per_table = ON;
SET GLOBAL innodb_file_format = `Antelope`;
SHOW VARIABLES LIKE 'innodb_file%';
--error ER_ILLEGAL_HA
CREATE TABLE t4 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=8;
SHOW WARNINGS;
--error ER_ILLEGAL_HA
CREATE TABLE t5 (id int PRIMARY KEY) ENGINE=innodb KEY_BLOCK_SIZE=16;
SHOW WARNINGS;
SET GLOBAL innodb_file_format = `Barracuda`;


--echo # Test 7) Not included here; 16k only


--echo # Test 8) Test creating a table that could lead to undo log overflow.
CREATE TABLE t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,
                h blob,i blob,j blob,k blob,l blob,m blob,n blob,
		o blob,p blob,q blob,r blob,s blob,t blob,u blob)
		ENGINE=InnoDB ROW_FORMAT=dynamic;
SET @a = repeat('a', 767);
SET @b = repeat('b', 767);
SET @c = repeat('c', 767);
SET @d = repeat('d', 767);
SET @e = repeat('e', 767);

# With no indexes defined, we can update all columns to max key part length.
INSERT INTO t1 VALUES (@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a,@a);
UPDATE t1 SET a=@b,b=@b,c=@b,d=@b,e=@b,f=@b,g=@b,h=@b,i=@b,j=@b,
              k=@b,l=@b,m=@b,n=@b,o=@b,p=@b,q=@b,r=@b,s=@b,t=@b,u=@b;

# With this many indexes defined, we can still update all fields.
CREATE INDEX t1a ON t1 (a(767));
CREATE INDEX t1b ON t1 (b(767));
UPDATE t1 SET a=@c,b=@c,c=@c,d=@c,e=@c,f=@c,g=@c,h=@c,i=@c,j=@c,
              k=@c,l=@c,m=@c,n=@c,o=@c,p=@c,q=@c,r=@c,s=@c,t=@c,u=@c;

# Add one more index and the UNDO record becomes too big to update all columns.
# But a single transaction can update the columns in separate statements.
# because the UNDO records will be smaller.
CREATE INDEX t1c ON t1 (c(767));
--error ER_UNDO_RECORD_TOO_BIG
UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d,f=@d,g=@d,h=@d,i=@d,j=@d,
              k=@d,l=@d,m=@d,n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d;
BEGIN;
UPDATE t1 SET a=@d,b=@d,c=@d,d=@d,e=@d;
UPDATE t1 SET f=@d,g=@d,h=@d,i=@d,j=@d,k=@d,l=@d,m=@d,
              n=@d,o=@d,p=@d,q=@d,r=@d,s=@d,t=@d,u=@d;
COMMIT;

# More indexes can still be added and a single field can still be updated
CREATE INDEX t1d ON t1 (d(767));
UPDATE t1 SET d=@e;
CREATE INDEX t1e ON t1 (e(767));
UPDATE t1 SET e=@e;
CREATE INDEX t1f ON t1 (f(767));
UPDATE t1 SET f=@e;
CREATE INDEX t1g ON t1 (g(767));
UPDATE t1 SET g=@e;
CREATE INDEX t1h ON t1 (h(767));
UPDATE t1 SET h=@e;
CREATE INDEX t1i ON t1 (i(767));
UPDATE t1 SET i=@e;

# The function dict_index_too_big_for_undo() prevents us from adding
# one more index that is 767 bytes long.
--replace_regex /> [0-9]*/> max_row_size/
-- error ER_TOO_BIG_ROWSIZE
CREATE INDEX t1j ON t1 (j(767));

# But it does allow a 500 byte index.  And with this, we cannot
# update the record. This is a problem.  It means that the DDL is
# allowed to create a table and a record that CANNOT be updated.
# See bug#12953735
CREATE INDEX t1j ON t1 (j(500));
--error ER_UNDO_RECORD_TOO_BIG
UPDATE t1 SET j=@e;
SHOW CREATE TABLE t1;
DROP TABLE t1;

#
# Bug #13336585 - INNODB: CHANGE BUFFERING WITH 4K PAGES CAN ASSERT
#                 IF SECONDARY KEY IS NEAR MAX
# If the secondary index tuple is close to half the page size,
# ibuf_insert_low() could return DB_TOO_BIG_RECORD, which is not expected
# in ibuf_insert().  In order to insure this does not happen, WL5756
# imposes a maximum key length of 768 for 4k pages and 1536 for 8k pages.
# The existing max key Size for 16k pages is 3072.
#

#-- disable_query_log
# The flag innodb_change_buffering_debug is only available in debug builds.
# It instructs InnoDB to try to evict pages from the buffer pool when
# change buffering is possible, so that the change buffer will be used
# whenever possible.
#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
#SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
#SET GLOBAL innodb_change_buffering_debug = 1;
#-- enable_query_log

# make sure the largest possible key entry can be added to the insert buffer.
# Make enough records so that the root page is not a leaf page.
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(
   pk01 varchar(96), pk02 varchar(96), pk03 varchar(96), pk04 varchar(96),
   pk05 varchar(96), pk06 varchar(96), pk07 varchar(96), pk08 varchar(96),
   pk09 varchar(96), pk10 varchar(96), pk11 varchar(96), pk12 varchar(96),
   pk13 varchar(96), pk14 varchar(96), pk15 varchar(96), pk16 varchar(96),
   sk01 varchar(96), sk02 varchar(96), sk03 varchar(96), sk04 varchar(96),
   sk05 varchar(96), sk06 varchar(96), sk07 varchar(96), sk08 varchar(96),
   sk09 varchar(96), sk10 varchar(96), sk11 varchar(96), sk12 varchar(96),
   sk13 varchar(96), sk14 varchar(96), sk15 varchar(96), sk16 varchar(96),
   PRIMARY KEY pk(pk01,pk02,pk03,pk04,pk05,pk06,pk07,pk08,
                  pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
   KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
          sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
   ROW_FORMAT=Redundant ENGINE=InnoDB;
SET @r = repeat('a', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('b', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('c', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('d', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('e', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
DELETE from t1;
DROP TABLE t1;

# Compressed tables do not compress parent pages.  So the whole uncompressed
# secondary tuple including the primary key must be able to fit in half the
# compressed page size. This record length is enforced at index creation.
# So the only way to get an ibuf tuple too big is to make the KEY_BLOCK_SIZE
# the same as the page size. 
CREATE TABLE t1(
   pk01 varchar(96), pk02 varchar(96), pk03 varchar(96), pk04 varchar(96),
   pk05 varchar(96), pk06 varchar(96), pk07 varchar(96), pk08 varchar(96),
   pk09 varchar(96), pk10 varchar(96), pk11 varchar(96), pk12 varchar(96),
   pk13 varchar(96), pk14 varchar(96), pk15 varchar(96), pk16 varchar(96),
   sk01 varchar(96), sk02 varchar(96), sk03 varchar(96), sk04 varchar(96),
   sk05 varchar(96), sk06 varchar(96), sk07 varchar(96), sk08 varchar(96),
   sk09 varchar(96), sk10 varchar(96), sk11 varchar(96), sk12 varchar(96),
   sk13 varchar(96), sk14 varchar(96), sk15 varchar(96), sk16 varchar(96),
   PRIMARY KEY pk(pk01,pk02,pk03,pk04,pk05,pk06,pk07,pk08,
                  pk09,pk10,pk11,pk12,pk13,pk14,pk15,pk16),
   KEY pk(sk01,sk02,sk03,sk04,sk05,sk06,sk07,sk08,
          sk09,sk10,sk11,sk12,sk13,sk14,sk15,sk16))
   ROW_FORMAT=Compressed KEY_BLOCK_SIZE=8 ENGINE=InnoDB;
SET @r = repeat('a', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('b', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('c', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('d', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
SET @r = repeat('e', 96);
INSERT INTO t1 VALUES(@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,
                      @r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r,@r);
DELETE from t1;
DROP TABLE t1;

#-- disable_query_log
#-- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
#SET GLOBAL innodb_change_buffering_debug = 0;
#-- enable_query_log

# The following should fail in non-strict mode too.
# (The fix of Bug #50945 only affects REDUNDANT and COMPACT tables.)
SET SESSION innodb_strict_mode = off;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(
	c text NOT NULL, d text NOT NULL,
	PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(
	c text NOT NULL, d text NOT NULL,
	PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2 CHARSET=ASCII;
CREATE TABLE t1(
	c text NOT NULL, d text NOT NULL,
	PRIMARY KEY (c(767),d(767)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 CHARSET=ASCII;
drop table t1;
--replace_regex /> [0-9]*/> max_row_size/
--error ER_TOO_BIG_ROWSIZE
CREATE TABLE t1(c text, PRIMARY KEY (c(440)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
CREATE TABLE t1(c text, PRIMARY KEY (c(438)))
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1 CHARSET=ASCII;
INSERT INTO t1 VALUES(REPEAT('A',512)),(REPEAT('B',512));
DROP TABLE t1;

#
# restore environment to the state it was before this test execution
#

--disable_query_log
EVAL SET GLOBAL innodb_file_format = $innodb_file_format_orig;
EVAL SET GLOBAL innodb_file_format_max = $innodb_file_format_max_orig;
EVAL SET GLOBAL innodb_file_per_table = $innodb_file_per_table_orig;
EVAL SET GLOBAL innodb_large_prefix = $innodb_large_prefix_orig;
EVAL SET SESSION innodb_strict_mode = $innodb_strict_mode_orig;
#-- error 0, ER_UNKNOWN_SYSTEM_VARIABLE
#EVAL SET GLOBAL innodb_change_buffering_debug = @innodb_change_buffering_debug_orig;
--enable_query_log
