Skip to content

Commit 3287d33

Browse files
author
Aditya A
committed
Bug #32507117 INDEX SIZE LARGER THAN 767 BYTES ALLOWED FOR INNODB WITH REDUNDANT ROW_FORMAT
PROBLEM ------- 1. When doing an alter on a table which was built with one specific row type the alter checks the validity of size on the index with the row format defined by the global variable innodb_default_row_format which is different than the one with which table was built on. FIX --- 1. Check with the correct format of row type with which the table was built in case of inplace 2. In case of copy chose the row format not specified by the user choose the format defined by innodb_default_row_format #rb 26179 Reviewed by : Kevin Lewis <kevin.lewis@oracle.com>
1 parent cdad2cf commit 3287d33

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Bug #32507117 INDEX SIZE LARGER THAN 767 BYTES ALLOWED FOR INNODB WITH REDUNDANT ROW_FORMAT
3+
#
4+
SET @orig_default_row_format = @@global.innodb_default_row_format;
5+
set global innodb_default_row_format='redundant';
6+
CREATE TABLE `t1` (
7+
`id` int unsigned NOT NULL AUTO_INCREMENT,
8+
`comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT
9+
NULL DEFAULT '',
10+
PRIMARY KEY (`id`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12+
CREATE TABLE `t2` (
13+
`id` int unsigned NOT NULL AUTO_INCREMENT,
14+
`comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT
15+
NULL DEFAULT '',
16+
PRIMARY KEY (`id`)
17+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18+
insert into t1(comment) values('k');
19+
insert into t2(comment) values('k');
20+
create index idx123 on t1 (`comment`);
21+
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
22+
set global innodb_default_row_format='dynamic';
23+
create index idx123 on t1 (`comment`);
24+
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
25+
alter table t1 add index idx123 (`comment`);
26+
ERROR HY000: Index column size too large. The maximum column size is 767 bytes.
27+
alter table t1 add index idx123 (`comment`), algorithm=copy ;
28+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1';
29+
ROW_FORMAT
30+
Dynamic
31+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t2';
32+
ROW_FORMAT
33+
Redundant
34+
alter table t2 ROW_FORMAT=dynamic;
35+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t2';
36+
ROW_FORMAT
37+
Dynamic
38+
drop table t1,t2;
39+
SET @@global.innodb_default_row_format=@orig_default_row_format;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--echo #
2+
--echo # Bug #32507117 INDEX SIZE LARGER THAN 767 BYTES ALLOWED FOR INNODB WITH REDUNDANT ROW_FORMAT
3+
--echo #
4+
SET @orig_default_row_format = @@global.innodb_default_row_format;
5+
set global innodb_default_row_format='redundant';
6+
7+
CREATE TABLE `t1` (
8+
`id` int unsigned NOT NULL AUTO_INCREMENT,
9+
`comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT
10+
NULL DEFAULT '',
11+
PRIMARY KEY (`id`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
13+
14+
15+
CREATE TABLE `t2` (
16+
`id` int unsigned NOT NULL AUTO_INCREMENT,
17+
`comment` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT
18+
NULL DEFAULT '',
19+
PRIMARY KEY (`id`)
20+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21+
22+
insert into t1(comment) values('k');
23+
insert into t2(comment) values('k');
24+
25+
--error ER_INDEX_COLUMN_TOO_LONG
26+
create index idx123 on t1 (`comment`);
27+
28+
set global innodb_default_row_format='dynamic';
29+
--error ER_INDEX_COLUMN_TOO_LONG
30+
create index idx123 on t1 (`comment`);
31+
32+
--error ER_INDEX_COLUMN_TOO_LONG
33+
alter table t1 add index idx123 (`comment`);
34+
35+
alter table t1 add index idx123 (`comment`), algorithm=copy ;
36+
37+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t1';
38+
39+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t2';
40+
alter table t2 ROW_FORMAT=dynamic;
41+
SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME LIKE 'test/t2';
42+
43+
drop table t1,t2;
44+
SET @@global.innodb_default_row_format=@orig_default_row_format;

storage/innobase/handler/handler0alter.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -5691,7 +5691,17 @@ ha_innobase::prepare_inplace_alter_table(
56915691
goto err_exit_no_heap;
56925692
}
56935693

5694-
max_col_len = DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(info.flags());
5694+
5695+
/* The copy algorithm uses the default row format while
5696+
in-place uses the current format. Find the limit for
5697+
the resulting format.*/
5698+
if (innobase_need_rebuild(ha_alter_info)) {
5699+
max_col_len =
5700+
DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(info.flags());
5701+
} else {
5702+
max_col_len =
5703+
DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(m_prebuilt->table->flags);
5704+
}
56955705

56965706
/* Check each index's column length to make sure they do not
56975707
exceed limit */

0 commit comments

Comments
 (0)