From b6a3917b0555a0fdaee7c3f13423009f4f4b878d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 24 Jan 2017 00:01:25 +0100 Subject: [PATCH] MDEV-11750 Assertion `vfield' failed in TABLE::update_virtual_fields after crash recovery on corrupted MyISAM table Adjust the length of the BIT field (same as in _mi_put_key_in_record()) --- mysql-test/suite/vcol/r/vcol_keys_myisam.result | 10 ++++++++++ mysql-test/suite/vcol/t/vcol_keys_myisam.test | 13 +++++++++++++ storage/myisam/mi_open.c | 2 ++ 3 files changed, 25 insertions(+) diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result index 594f87bf4d385..bd013da9b03f8 100644 --- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result @@ -365,3 +365,13 @@ ALTER TABLE t1 ADD INDEX(col_enum,vcol_int); SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR ALTER TABLE t1 ADD INDEX(col_year); DROP TABLE t1; +create table t1 ( +pk int primary key auto_increment, +b bit default null, +key(b) +) engine=myisam; +insert into t1 values (null, 0); +repair table t1 extended; +Table Op Msg_type Msg_text +test.t1 repair status OK +drop table t1; diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test index fe7b8de8ef049..337d14c3074e2 100644 --- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test +++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test @@ -249,3 +249,16 @@ SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR ALTER TABLE t1 ADD INDEX(col_year); --enable_warnings DROP TABLE t1; + +# +# MDEV-11750 Assertion `vfield' failed in TABLE::update_virtual_fields after crash recovery on corrupted MyISAM table +# +create table t1 ( + pk int primary key auto_increment, + b bit default null, + key(b) +) engine=myisam; + +insert into t1 values (null, 0); +repair table t1 extended; +drop table t1; diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 604dd1674ae34..5bd5554db514d 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -376,6 +376,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) { uint real_length= pos->flag & HA_BLOB_PART ? pos->bit_start : pos->length; + if (pos->type == HA_KEYTYPE_BIT && pos->bit_length) + real_length--; set_if_bigger(share->vreclength, pos->start + real_length); } }