MDEV-18190 A table with variable-length PRIMARY KEY is unaccessible after instant DROP COLUMN

btr_cur_instant_init_low(): Fix the typo in the computation
of the trx_id_offset of a metadata record.
This commit is contained in:
Marko Mäkelä 2019-01-09 19:50:48 +02:00
parent 65083ba64c
commit 6bd5c555d9
3 changed files with 24 additions and 3 deletions
mysql-test/suite/innodb
storage/innobase/btr

View file

@ -154,6 +154,9 @@ alter table t2 add column f6 char(100) default repeat('a', 99), algorithm=instan
create table t3(f1 int, f2 int not null)engine=innodb;
insert into t3 values(1, 2);
alter table t3 drop column f2, add column f3 int default 1, add column f4 int default 4, algorithm=instant;
create table t4(a varchar(1), b int, c int, primary key(a,b))engine=innodb;
insert into t4 values('4',5,6);
alter table t4 drop column c;
select * from t1;
f5 f3
10 19
@ -185,7 +188,16 @@ select * from t3;
f1 f3 f4
1 1 4
alter table t3 add column f5 char(100) default repeat('a', 99), algorithm=instant;
select * from t4;
a b
4 5
alter table t4 add column d varchar(5) default 'fubar';
insert into t4 values('',0,'snafu');
select * from t3;
f1 f3 f4 f5
1 1 4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
drop table t1,t2,t3;
select * from t4;
a b d
0 snafu
4 5 fubar
drop table t1,t2,t3,t4;

View file

@ -80,6 +80,10 @@ create table t3(f1 int, f2 int not null)engine=innodb;
insert into t3 values(1, 2);
alter table t3 drop column f2, add column f3 int default 1, add column f4 int default 4, algorithm=instant;
create table t4(a varchar(1), b int, c int, primary key(a,b))engine=innodb;
insert into t4 values('4',5,6);
alter table t4 drop column c;
--source include/restart_mysqld.inc
select * from t1;
alter table t1 add column f6 int default 9,drop column f5, algorithm = instant;
@ -94,6 +98,11 @@ show create table t2;
select * from t3;
alter table t3 add column f5 char(100) default repeat('a', 99), algorithm=instant;
select * from t4;
alter table t4 add column d varchar(5) default 'fubar';
insert into t4 values('',0,'snafu');
--source include/restart_mysqld.inc
select * from t3;
drop table t1,t2,t3;
select * from t4;
drop table t1,t2,t3,t4;

View file

@ -486,7 +486,7 @@ incompatible:
always written with zero length. The DB_TRX_ID will
start right after any fixed-length columns. */
for (uint i = index->n_uniq; i--; ) {
trx_id_offset += index->fields[0].fixed_len;
trx_id_offset += index->fields[i].fixed_len;
}
}