Commit 6bd5c555 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 65083ba6
...@@ -154,6 +154,9 @@ alter table t2 add column f6 char(100) default repeat('a', 99), algorithm=instan ...@@ -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; create table t3(f1 int, f2 int not null)engine=innodb;
insert into t3 values(1, 2); 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; 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; select * from t1;
f5 f3 f5 f3
10 19 10 19
...@@ -185,7 +188,16 @@ select * from t3; ...@@ -185,7 +188,16 @@ select * from t3;
f1 f3 f4 f1 f3 f4
1 1 4 1 1 4
alter table t3 add column f5 char(100) default repeat('a', 99), algorithm=instant; 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; select * from t3;
f1 f3 f4 f5 f1 f3 f4 f5
1 1 4 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 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;
...@@ -80,6 +80,10 @@ create table t3(f1 int, f2 int not null)engine=innodb; ...@@ -80,6 +80,10 @@ create table t3(f1 int, f2 int not null)engine=innodb;
insert into t3 values(1, 2); 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; 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 --source include/restart_mysqld.inc
select * from t1; select * from t1;
alter table t1 add column f6 int default 9,drop column f5, algorithm = instant; alter table t1 add column f6 int default 9,drop column f5, algorithm = instant;
...@@ -94,6 +98,11 @@ show create table t2; ...@@ -94,6 +98,11 @@ show create table t2;
select * from t3; select * from t3;
alter table t3 add column f5 char(100) default repeat('a', 99), algorithm=instant; 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 --source include/restart_mysqld.inc
select * from t3; select * from t3;
drop table t1,t2,t3; select * from t4;
drop table t1,t2,t3,t4;
...@@ -486,7 +486,7 @@ static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr) ...@@ -486,7 +486,7 @@ static dberr_t btr_cur_instant_init_low(dict_index_t* index, mtr_t* mtr)
always written with zero length. The DB_TRX_ID will always written with zero length. The DB_TRX_ID will
start right after any fixed-length columns. */ start right after any fixed-length columns. */
for (uint i = index->n_uniq; i--; ) { for (uint i = index->n_uniq; i--; ) {
trx_id_offset += index->fields[0].fixed_len; trx_id_offset += index->fields[i].fixed_len;
} }
} }
......
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