Skip to content

Commit

Permalink
BUG#26848813: INDEXED COLUMN CAN'T BE CHANGED FROM VARCHAR(15)
Browse files Browse the repository at this point in the history
              TO VARCHAR(40) INSTANTANEOUSLY

Analysis
========

Indexed VARCHAR columns are not expanded instantaneously (without index rebuild)for
InnoDB tables using INPLACE algorithm. The other problems uncovered as part of this
bug are:
a) Indexed VARCHAR columns when converted from unpacked
   keys to packed keys(key size > 8 bytes) by expanding
   the VARCHAR column was not instantaneous for InnoDB
   tables using INPLACE algorithm even though pack keys
   is a no-op for InnoDB tables.
b) CREATE/ALTER of InnoDB tables where the index size
   exceeds the SE limit of 767 bytes for COMPACT or
   REDUNDANT row_format did not report error in STRICT
   mode and warning in non-strict mode.

SQL layer determines if there has been a change in index definition and sets the
appropriate handler flags which helps the SE to determine whether a index rebuild
needs to be performed. The 'has_index_def_changed()' did not check if the change
in length had a compatible packed data representation and marked it as a change in
index by setting the handler flags DROP_INDEX and ADD_INDEX triggering a recreation
of indexes in InnoDB.

When 'PACK_KEYS' option is not specified, indexes on columns with string types are
marked for packing through HA_PACK_KEY. Currently only MyISAM engine supports it.
Indexes on columns with length greater than 8 bytes were marked for packing
irrespective of the storage engine. Converting the indexes from non-packed to packed
i.e expanding the varchar column from lesser than 8 chars to more than 8 chars using
ALTER was marked as a change in index definition during the check in
'has_index_def_changed()' even though InnoDB does not support packed keys.

The handler API ha_innobase::max_supported_key_part_length() returned an incorrect
maximum support key part length since the row format of the table was not taken into
account. Hence creation of tables using REDUNDANT/COMPACT row format with index size
exceeding the SE limit were allowed.

Fix:
===
a) A new handler flag 'Alter_inplace_info::ALTER_COLUMN_INDEX_LENGTH"
   is introduced. This is set in 'has_index_def_changed()' when the
   index length differs due to column modification and has compatible
   packed data representation while determining if the index definition
   has changed.

b) Introduced a handlerton flag 'HTON_SUPPORTS_PACKED_KEYS' to check for
   'PACK_KEYS' support which is currently set for MyISAM engine since it
   is the only engine which supports packed keys. The 'HTON_SUPPORTS_PACKED_KEYS'
   is checked prior to setting the index flag 'HA_BINARY_PACK_KEY' for packed keys.
   Hence for InnoDB the packed key flag for indexes is not set.

c) The handler API max_supported_key_part_length() has been modified to take 'create_info'
   as a parameter from which the row_format can be fetched and appropriate index limit can
   be computed and returned by the InnoDB implementation of the handler API. More details
   on the behavior is mentioned in the table below.

   - Since the index limit is computed correctly and checked at the SQL layer,
     the error message 'ER_TOO_LONG_KEY' is reported at the SQL layer instead of
     'ER_INDEX_COLUMN_TOO_LONG' (which was reported by the handler interface
     after mapping the error returned by SE).
   - For COMPACT and REDUNDANT row format, when the index size exceeds 767 bytes,
     a warning is reported in non-STRICT mode and the index is truncated to fit
     767 bytes. In a STRICT mode, an error is reported.

This table describes the behavior of INDEX limit, Type of INDEX and
behavior under STRICT and NON_STRICT mode.
IL===> Index Limit.
-------------------------------------------------------------------------------|
  Row Format          |INDEX LIMIT | STRICT MODE(>IL) | NON-STRICT MODE(>IL)   |
----------------------|--------------------------------------------------------|
Compact/Redundant     |  767 bytes |    Error         | Index truncation(767)  |
(Non Unique Index)    |            |                  | and warning.           |
--------------------------------------------------------------------------------
Compact/Redundant     |  767 bytes |    Error         | Error                  |
(Unique/Primary Index)|            |                  |                        |
--------------------------------------------------------------------------------
Dynamic/Compressed    |  3072 byes |    Error         | Index truncation(3072) |
(Non Unique Index)    |            |                  | and warning            |
--------------------------------------------------------------------------------
Dynamic/Compressed    |  3072 bytes|    Error         | Error                  |
(Unique/Primary Index)|            |                  |                        |
--------------------------------------------------------------------------------

(cherry picked from commit bdc97b75674ade0251bdbc3ea2dc7d36871f73cd)
  • Loading branch information
Nisha Gopalakrishnan authored and gipulla committed Jun 8, 2018
1 parent 3e38cf4 commit 913071c
Show file tree
Hide file tree
Showing 36 changed files with 432 additions and 87 deletions.
103 changes: 103 additions & 0 deletions mysql-test/r/alter_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -3683,3 +3683,106 @@ ERROR 22004: Invalid use of NULL value
ALTER TABLE t2 MODIFY fld0 POINT NOT NULL;
ERROR 22004: Invalid use of NULL value
DROP TABLE t1, t2;
#
# BUG#26848813: INDEXED COLUMN CAN'T BE CHANGED FROM VARCHAR(15)
# TO VARCHAR(40) INSTANTANEOUSLY
SET @orig_sql_mode= @@sql_mode;
SET @orig_innodb_large_prefix= @@global.innodb_large_prefix;
SET GLOBAL innodb_large_prefix= ON;
Warnings:
Warning 131 Using innodb_large_prefix 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
# Tests where an error is reported under strict mode when the index
# limit exceeds the maximum supported length by SE.
CREATE TABLE t1 (fld1 VARCHAR(768), KEY(fld1)) CHARSET latin1 ENGINE =InnoDB
ROW_FORMAT= COMPACT;
ERROR 42000: Specified key was too long; max key length is 767 bytes
CREATE TABLE t2 (fld1 VARCHAR(3073), KEY(fld1)) CHARSET latin1 ENGINE= InnoDB;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
# Test with innodb prefix indexes where the index limit is 767 bytes
CREATE TABLE t1 (fld1 VARCHAR(767), KEY(fld1)) CHARSET latin1 ENGINE=INNODB
ROW_FORMAT=COMPACT;
ALTER TABLE t1 MODIFY fld1 VARCHAR(768), ALGORITHM= INPLACE;
ERROR 42000: Specified key was too long; max key length is 767 bytes
ALTER TABLE t1 MODIFY fld1 VARCHAR(768), ALGORITHM= COPY;
ERROR 42000: Specified key was too long; max key length is 767 bytes
# Test with innodb prefix indexes where the index limit is 3072 bytes
CREATE TABLE t2 (fld1 VARCHAR(3072), KEY(fld1)) CHARSET latin1 ENGINE=INNODB
ROW_FORMAT=DYNAMIC;
ALTER TABLE t2 MODIFY fld1 VARCHAR(3073), ALGORITHM= INPLACE;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
ALTER TABLE t2 MODIFY fld1 VARCHAR(3073), ALGORITHM= COPY;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
# Tests with innodb_large_prefix disabled and strict mode.
SET GLOBAL innodb_large_prefix= OFF;
Warnings:
Warning 131 Using innodb_large_prefix 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 t3 (fld1 VARCHAR(3072), KEY(fld1)) CHARSET latin1 ENGINE= InnoDB;
ERROR 42000: Specified key was too long; max key length is 767 bytes
DROP TABLE t1, t2;
SET sql_mode= '';
Warnings:
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
SET GLOBAL innodb_large_prefix= ON;
Warnings:
Warning 131 Using innodb_large_prefix 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
# Test where the indexes are truncated to fit the index limit and
# a warning is reported under non-strict mode when the index exceeds
# the SE limit.
CREATE TABLE t1 (fld1 VARCHAR(768), KEY(fld1)) ENGINE= InnoDB
ROW_FORMAT=COMPACT;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
CREATE TABLE t2 (fld1 VARCHAR(3073), KEY(fld1)) ENGINE= InnoDB;
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
# Test with innodb prefix indexes where the index limit is 767 bytes.
CREATE TABLE t3 (fld1 VARCHAR(767), KEY(fld1))ENGINE=INNODB ROW_FORMAT=COMPACT;
ALTER TABLE t3 MODIFY fld1 VARCHAR(768), ALGORITHM= INPLACE;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
ALTER TABLE t3 MODIFY fld1 VARCHAR(800), ALGORITHM= COPY;
# Test with innodb prefix indexes where the index limit is 3072 bytes.
CREATE TABLE t4 (fld1 VARCHAR(3072), KEY(fld1))ENGINE=INNODB
ROW_FORMAT=DYNAMIC;
ALTER TABLE t4 MODIFY fld1 VARCHAR(3073), ALGORITHM= INPLACE;
Warnings:
Warning 1071 Specified key was too long; max key length is 3072 bytes
ALTER TABLE t4 MODIFY fld1 VARCHAR(3074), ALGORITHM= COPY;
# For unique and primary keys, an error is reported even in non-strict
# mode.
CREATE TABLE t5(fld1 VARCHAR(768) PRIMARY KEY) ENGINE= InnoDB
ROW_FORMAT=COMPACT;
ERROR 42000: Specified key was too long; max key length is 767 bytes
CREATE TABLE t5(fld1 VARCHAR(3073), UNIQUE KEY(fld1)) ENGINE= InnoDB;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
# Tests with innodb_large_prefix disabled and strict mode.
SET GLOBAL innodb_large_prefix= OFF;
Warnings:
Warning 131 Using innodb_large_prefix 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 t5 (fld1 VARCHAR(3072), KEY(fld1)) CHARSET latin1 ENGINE= InnoDB;
Warnings:
Warning 1071 Specified key was too long; max key length is 767 bytes
DROP TABLE t1, t2, t3, t4, t5;
SET sql_mode= @orig_sql_mode;
SET GLOBAL innodb_large_prefix= ON;
# Tests added for coverage.
CREATE TABLE t1(fld1 VARCHAR(3), KEY(fld1)) ENGINE=MYISAM;
# Conversion of unpacked keys to packed keys reports
# error for INPLACE Alter.
ALTER TABLE t1 MODIFY fld1 VARCHAR(10), ALGORITHM=INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY.
# Succeeds with index rebuild.
ALTER TABLE t1 MODIFY fld1 VARCHAR(10), ALGORITHM=COPY;
# Succeeds since the row format is dynamic.
CREATE TABLE t2(fld1 VARCHAR(768), KEY(fld1)) ENGINE= InnoDB ROW_FORMAT= DYNAMIC;
# An error is reported when the index exceeds the column size
# in both strict and non-strict mode.
ALTER TABLE t2 ADD INDEX idx1(fld1(769));
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
SET sql_mode= '';
ALTER TABLE t2 ADD INDEX idx1(fld1(769));
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
# Cleanup.
DROP TABLE t1, t2;
SET sql_mode= @orig_sql_mode;
SET GLOBAL innodb_large_prefix= @orig_innodb_large_prefix;
19 changes: 19 additions & 0 deletions mysql-test/r/innodb_mysql_sync.result
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,22 @@ ALTER TABLE t1 MODIFY fld1 CHAR(20);
#cleanup
DROP TABLE t1;
SET debug="-d,innodb_index_drop_count_zero";
#
# BUG#26848813: INDEXED COLUMN CAN'T BE CHANGED FROM VARCHAR(15)
# TO VARCHAR(40) INSTANTANEOUSLY
CREATE TABLE t1(fld1 VARCHAR(5), KEY(fld1)) ENGINE= InnoDB;
SET DEBUG="+d,innodb_index_drop_count_zero";
# Without patch, an error is reported.
ALTER TABLE t1 MODIFY fld1 VARCHAR(7), ALGORITHM= INPLACE;
# Scenario where non-packed keys is converted to packed keys
# before the patch, an error is reported.
ALTER TABLE t1 MODIFY fld1 VARCHAR(9), ALGORITHM= INPLACE;
SET DEBUG="-d,innodb_index_drop_count_zero";
# Tests added for covering cases where rebuild is required.
# Reducing the size of the field.
ALTER TABLE t1 MODIFY fld1 VARCHAR(3), ALGORITHM= INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
# Increasing the size of the field to boundary condition.
ALTER TABLE t1 MODIFY fld1 VARCHAR(256), ALGORITHM= INPLACE;
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
DROP TABLE t1;
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Table Name Tablespace Table Flags Columns Row Format Zip Size Space Type
test/tab test/tab 33 5 Dynamic 0 Single
SET GLOBAL innodb_default_row_format=COMPACT;
ALTER TABLE tab ROW_FORMAT=COMPACT;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
DROP TABLE tab;
SET GLOBAL innodb_default_row_format=Default;
SELECT @@innodb_default_row_format;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/innodb/r/innodb-large-prefix.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ CREATE TABLE t1(a int not null,key(a,a)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ERROR 42S21: Duplicate column name 'a'
CREATE TABLE t1(a int,b text,key(b(768))) ENGINE=InnoDB DEFAULT CHARSET=latin1
ROW_FORMAT=COMPACT;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
CREATE TABLE t1(a int not null,b text) ENGINE=InnoDB DEFAULT CHARSET=latin1
ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES (1,''),(2,''),(3,''),(4,''),(5,''),(6,''),(7,'');
CREATE INDEX t1aa ON t1(a,a);
ERROR 42S21: Duplicate column name 'a'
CREATE INDEX t1b ON t1(b(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
Expand All @@ -35,7 +35,7 @@ INSERT INTO t2 VALUES (1,''),(2,''),(3,''),(4,''),(5,''),(6,''),(7,'');
CREATE INDEX t2aa ON t2(a,a);
ERROR 42S21: Duplicate column name 'a'
CREATE INDEX t2b ON t2(b(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
SELECT * FROM t2;
a b
1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ SELECT * FROM tab;
SET GLOBAL innodb_default_row_format=COMPACT;

# Check error ERROR 1709 (HY000): Index column size too large
-- error ER_INDEX_COLUMN_TOO_LONG
--error ER_TOO_LONG_KEY
ALTER TABLE tab ROW_FORMAT=COMPACT;

# Cleanup
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/innodb/t/innodb-large-prefix.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

--error ER_DUP_FIELDNAME
CREATE TABLE t1(a int not null,key(a,a)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
CREATE TABLE t1(a int,b text,key(b(768))) ENGINE=InnoDB DEFAULT CHARSET=latin1
ROW_FORMAT=COMPACT;
CREATE TABLE t1(a int not null,b text) ENGINE=InnoDB DEFAULT CHARSET=latin1
ROW_FORMAT=COMPACT;
INSERT INTO t1 VALUES (1,''),(2,''),(3,''),(4,''),(5,''),(6,''),(7,'');
--error ER_DUP_FIELDNAME
CREATE INDEX t1aa ON t1(a,a);
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
CREATE INDEX t1b ON t1(b(768));
SHOW CREATE TABLE t1;
SELECT * FROM t1;
Expand All @@ -28,7 +28,7 @@ ROW_FORMAT=COMPACT;
INSERT INTO t2 VALUES (1,''),(2,''),(3,''),(4,''),(5,''),(6,''),(7,'');
--error ER_DUP_FIELDNAME
CREATE INDEX t2aa ON t2(a,a);
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
CREATE INDEX t2b ON t2(b(768));
SELECT * FROM t2;
DROP TABLE t2;
8 changes: 4 additions & 4 deletions mysql-test/suite/innodb_zip/r/index_large_prefix.result
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,11 @@ drop table worklog5743;
### Test 6 ###
create table worklog5743(a TEXT not null, primary key (a(1000)))
row_format=compact;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create table worklog5743(a TEXT)
row_format=compact;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx on worklog5743(a(767));
insert into worklog5743 values(repeat("a", 20000));
begin;
Expand Down Expand Up @@ -546,12 +546,12 @@ drop table worklog5743;
SET sql_mode= default;
create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
SET GLOBAL innodb_file_per_table=1;
6 changes: 3 additions & 3 deletions mysql-test/suite/innodb_zip/r/index_large_prefix_4k.result
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ create table worklog5743(a TEXT not null, primary key (a(1000)));
ERROR 42000: Specified key was too long; max key length is 768 bytes
create table worklog5743(a TEXT) ROW_FORMAT=COMPACT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx on worklog5743(a(767));
insert into worklog5743 values(repeat("a", 20000));
begin;
Expand Down Expand Up @@ -417,12 +417,12 @@ insert into worklog5743 values(repeat("a", 768));
drop table worklog5743;
create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
SET GLOBAL innodb_file_per_table=1;
8 changes: 4 additions & 4 deletions mysql-test/suite/innodb_zip/r/index_large_prefix_8k.result
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ drop table worklog5743;
### Test 6 ###
create table worklog5743(a TEXT not null, primary key (a(1000)))
row_format=compact;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create table worklog5743(a TEXT) row_format=compact;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx on worklog5743(a(767));
insert into worklog5743 values(repeat("a", 20000));
begin;
Expand Down Expand Up @@ -455,12 +455,12 @@ worklog5743 CREATE TABLE `worklog5743` (
drop table worklog5743;
create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT;
create index idx on worklog5743(a(768));
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create index idx2 on worklog5743(a(767));
drop table worklog5743;
SET GLOBAL innodb_file_per_table=1;
4 changes: 2 additions & 2 deletions mysql-test/suite/innodb_zip/r/prefix_index_liftedlimit.result
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ col_1_varchar = REPEAT("c", 4000)
0
1
ALTER TABLE worklog5743 ROW_FORMAT=REDUNDANT;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
ALTER TABLE worklog5743 ROW_FORMAT=COMPACT;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
ALTER TABLE worklog5743 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
DROP TABLE worklog5743;
CREATE TABLE worklog5743 (
Expand Down
7 changes: 4 additions & 3 deletions mysql-test/suite/innodb_zip/r/wl6469.result
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,17 @@ SET sql_mode = default;
set global innodb_large_prefix = 1;
Warnings:
Warning 131 Using innodb_large_prefix 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
SET sql_mode='NO_ENGINE_SUBSTITUTION';
SET sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
Warnings:
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
SET innodb_strict_mode=OFF;
create temporary table t (
a int not null,
b blob not null,
index sk (b(3021))
) row_format = compact engine=innodb;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create temporary table t (
a int not null,
b blob not null,
Expand All @@ -299,7 +300,7 @@ a int not null,
b blob not null,
index sk (b(3021))
) row_format = compact engine=innodb;
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
ERROR 42000: Specified key was too long; max key length is 767 bytes
create temporary table t (
a int not null,
b blob not null,
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/innodb_zip/t/index_large_prefix.test
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,15 @@ drop table worklog5743;

-- echo ### Test 6 ###
# Create a table with old format, and the limit is 768 bytes.
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create table worklog5743(a TEXT not null, primary key (a(1000)))
row_format=compact;

create table worklog5743(a TEXT)
row_format=compact;

# Excercise the column length check in ha_innobase::add_index()
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));

# This should be successful
Expand Down Expand Up @@ -426,13 +426,13 @@ SET sql_mode= default;

# We have a limit of 767 bytes for Antelope tables
create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT;
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));
create index idx2 on worklog5743(a(767));
drop table worklog5743;

create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT;
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));
create index idx2 on worklog5743(a(767));
drop table worklog5743;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/innodb_zip/t/index_large_prefix_4k.test
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ create table worklog5743(a TEXT not null, primary key (a(1000)));
create table worklog5743(a TEXT) ROW_FORMAT=COMPACT;

# Excercise the column length check in ha_innobase::add_index()
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));

# This should be successful
Expand Down Expand Up @@ -385,13 +385,13 @@ drop table worklog5743;

# We have a limit of 767 bytes for Antelope tables
create table worklog5743(a TEXT not null) ROW_FORMAT=REDUNDANT;
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));
create index idx2 on worklog5743(a(767));
drop table worklog5743;

create table worklog5743(a TEXT not null) ROW_FORMAT=COMPACT;
-- error ER_INDEX_COLUMN_TOO_LONG
-- error ER_TOO_LONG_KEY
create index idx on worklog5743(a(768));
create index idx2 on worklog5743(a(767));
drop table worklog5743;
Expand Down
Loading

0 comments on commit 913071c

Please sign in to comment.