From 2bfd04e3145b238df5f31143b98b1df501f43d1e Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 11 Apr 2023 18:36:55 +0530 Subject: [PATCH] MDEV-31025 Redundant table alter fails when fixed column stored externally row_merge_buf_add(): Has strict assert that fixed length mismatch shouldn't happen while rebuilding the redundant row format table btr_index_rec_validate(): Fixed size column can be stored externally. So sum of inline stored length and external stored length of the column should be equal to total column length --- .../innodb/r/default_row_format_alter.result | 20 +++++++++++++++++++ .../innodb/t/default_row_format_alter.test | 17 ++++++++++++++++ storage/innobase/btr/btr0btr.cc | 2 +- storage/innobase/row/row0merge.cc | 5 ----- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/innodb/r/default_row_format_alter.result b/mysql-test/suite/innodb/r/default_row_format_alter.result index 42cbab8a5f2..33936b59003 100644 --- a/mysql-test/suite/innodb/r/default_row_format_alter.result +++ b/mysql-test/suite/innodb/r/default_row_format_alter.result @@ -129,5 +129,25 @@ SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1'; ROW_FORMAT Dynamic DROP TABLE t1; +# +# MDEV-31025 Redundant table alter fails when fixed column +# stored externally +# +set @old_sql_mode = @@sql_mode; +SET @@sql_mode=''; +CREATE TABLE t1(pk INT,c CHAR(255),c2 CHAR(255),c3 CHAR(255), +c4 char(255), c5 char(255), c6 char(255), +c7 char(255), c8 char(255), primary key(pk) +)Engine=InnoDB character set utf32 ROW_FORMAT=REDUNDANT; +INSERT INTO t1(pk, c) VALUES (1, repeat('a', 255)); +ALTER TABLE t1 FORCE; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +SELECT LENGTH(c) FROM t1; +LENGTH(c) +1020 +DROP TABLE t1; +set @@sql_mode = @old_sql_mode; # End of 10.4 tests SET GLOBAL innodb_default_row_format = @row_format; diff --git a/mysql-test/suite/innodb/t/default_row_format_alter.test b/mysql-test/suite/innodb/t/default_row_format_alter.test index f5dd246efb5..5f2170454f3 100644 --- a/mysql-test/suite/innodb/t/default_row_format_alter.test +++ b/mysql-test/suite/innodb/t/default_row_format_alter.test @@ -150,6 +150,23 @@ ALTER TABLE t1 DROP b; SELECT ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1'; DROP TABLE t1; +--echo # +--echo # MDEV-31025 Redundant table alter fails when fixed column +--echo # stored externally +--echo # +set @old_sql_mode = @@sql_mode; +SET @@sql_mode=''; +CREATE TABLE t1(pk INT,c CHAR(255),c2 CHAR(255),c3 CHAR(255), + c4 char(255), c5 char(255), c6 char(255), + c7 char(255), c8 char(255), primary key(pk) + )Engine=InnoDB character set utf32 ROW_FORMAT=REDUNDANT; +INSERT INTO t1(pk, c) VALUES (1, repeat('a', 255)); +ALTER TABLE t1 FORCE; +CHECK TABLE t1; +SELECT LENGTH(c) FROM t1; +DROP TABLE t1; +set @@sql_mode = @old_sql_mode; + --echo # End of 10.4 tests SET GLOBAL innodb_default_row_format = @row_format; diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index f54a8e1125a..2df94715750 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -4713,7 +4713,7 @@ n_field_mismatch: len -= BTR_EXTERN_FIELD_REF_SIZE; ulint extern_len = mach_read_from_4( data + len + BTR_EXTERN_LEN + 4); - if (fixed_size == extern_len) { + if (fixed_size == extern_len + len) { goto next_field; } } diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 9d755ce6f1e..f0aed489f22 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -681,11 +681,6 @@ error: row_field, field, col->len, old_table->space->zip_size(), conv_heap); - } else { - /* Field length mismatch should not - happen when rebuilding redundant row - format table. */ - ut_ad(index->table->not_redundant()); } } }