MDEV-18486 Database crash on a table with indexed virtual column

don't do anything special for stored generated columns
in MyISAM repair code.

add an assert that if there are virtual indexed columns, they
_must_ be beyond the file->s->base.reclength boundary
This commit is contained in:
Sergei Golubchik 2019-03-01 13:23:34 -05:00
parent 6793736009
commit 4ca2079142
3 changed files with 25 additions and 3 deletions

View File

@ -375,3 +375,11 @@ repair table t1 extended;
Table Op Msg_type Msg_text
test.t1 repair status OK
drop table t1;
create table t1 ( id int primary key,
hexid varchar(10) generated always as (hex(id)) stored,
key (hexid)) engine=myisam;
insert into t1 (id) select 100;
select * from t1;
id hexid
100 64
drop table t1;

View File

@ -262,3 +262,13 @@ create table t1 (
insert into t1 values (null, 0);
repair table t1 extended;
drop table t1;
#
# MDEV-18486 Database crash on a table with indexed virtual column
#
create table t1 ( id int primary key,
hexid varchar(10) generated always as (hex(id)) stored,
key (hexid)) engine=myisam;
insert into t1 (id) select 100;
select * from t1;
drop table t1;

View File

@ -934,14 +934,18 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param)
ulong new_vreclength= file->s->vreclength;
for (Field **vf= table->vfield; *vf; vf++)
{
uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
set_if_bigger(new_vreclength, vf_end);
indexed_vcols|= (*vf)->flags & PART_KEY_FLAG;
if (!(*vf)->stored_in_db())
{
uint vf_end= (*vf)->offset(table->record[0]) + (*vf)->pack_length_in_rec();
set_if_bigger(new_vreclength, vf_end);
indexed_vcols|= (*vf)->flags & PART_KEY_FLAG;
}
}
if (!indexed_vcols)
return;
file->s->vreclength= new_vreclength;
}
DBUG_ASSERT(file->s->base.reclength < file->s->vreclength);
param->fix_record= compute_vcols;
table->use_all_columns();
table->vcol_set= &table->s->all_set;