Commit 4ca20791 authored by Sergei Golubchik's avatar Sergei Golubchik

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
parent 67937360
......@@ -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;
......@@ -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;
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment