[MDEV-18190] A table with variable-length PRIMARY KEY is unaccessible after instant DROP COLUMN Created: 2019-01-09  Updated: 2019-01-10  Resolved: 2019-01-09

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4.0
Fix Version/s: 10.4.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: instant, regression

Issue Links:
Problem/Incident
is caused by MDEV-15562 Instant DROP COLUMN or changing the o... Closed
Relates
relates to MDEV-18124 PK on inplace-enlarged type fails Closed

 Description   

As noted by midenok, there was a typo in the code introduced by MDEV-15562:

diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 9e951f8f78b..5fe71a5eb4d 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -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
 			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;
 			}
 		}
 

Before the above fix, the following test case change would fail to find the table t4 after the first server restart:

diff --git a/mysql-test/suite/innodb/t/instant_drop.test b/mysql-test/suite/innodb/t/instant_drop.test
index cb1aabce94b..566ac02b314 100644
--- a/mysql-test/suite/innodb/t/instant_drop.test
+++ b/mysql-test/suite/innodb/t/instant_drop.test
@@ -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;


Generated at Thu Feb 08 08:42:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.