Index: mysql-test/innodb-semi-consistent.result =================================================================== --- mysql-test/innodb-semi-consistent.result (revision 4398) +++ mysql-test/innodb-semi-consistent.result (revision 4399) @@ -38,3 +38,10 @@ 11 7 drop table t1; +create table t1 (a int, b int) engine=myisam; +create table t2 (c int, d int, key (c)) engine=innodb; +insert into t1 values (1,1); +insert into t2 values (1,2); +set session transaction isolation level read committed; +delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1); +drop table t1, t2; Index: mysql-test/innodb-semi-consistent.test =================================================================== --- mysql-test/innodb-semi-consistent.test (revision 4398) +++ mysql-test/innodb-semi-consistent.test (revision 4399) @@ -53,3 +53,16 @@ connection default; disconnect a; disconnect b; + +# Bug 39320 +create table t1 (a int, b int) engine=myisam; +create table t2 (c int, d int, key (c)) engine=innodb; +insert into t1 values (1,1); +insert into t2 values (1,2); +connect (a,localhost,root,,); +connection a; +set session transaction isolation level read committed; +delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1); +connection default; +disconnect a; +drop table t1, t2; Index: row/row0sel.c =================================================================== --- row/row0sel.c (revision 4398) +++ row/row0sel.c (revision 4399) @@ -2901,8 +2901,9 @@ func_exit: *out_rec = clust_rec; - if (prebuilt->select_lock_type == LOCK_X) { - /* We may use the cursor in update: store its position */ + if (prebuilt->select_lock_type != LOCK_NONE) { + /* We may use the cursor in update or in unlock_row(): + store its position */ btr_pcur_store_position(prebuilt->clust_pcur, mtr); }