diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f6fee04e776..7120fa21189 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -296,15 +296,22 @@ int TABLE::delete_row() store_record(this, record[1]); vers_update_end(); - int err= file->ha_update_row(record[1], record[0]); - /* - MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got history - row with same trx_id which is the result of foreign key action, so we - don't need one more history row. - */ - if (err == HA_ERR_FOREIGN_DUPLICATE_KEY) - return file->ha_delete_row(record[0]); - return err; + int err; + if ((err= file->extra(HA_EXTRA_REMEMBER_POS))) + return err; + if ((err= file->ha_update_row(record[1], record[0]))) + { + /* + MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got + history row with same trx_id which is the result of foreign key action, + so we don't need one more history row. + */ + if (err == HA_ERR_FOREIGN_DUPLICATE_KEY) + file->ha_delete_row(record[0]); + else + return err; + } + return file->extra(HA_EXTRA_RESTORE_POS); } diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index ba8583cacc8..80cd0c416e3 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -89,7 +89,7 @@ int maria_write(MARIA_HA *info, const uchar *record) MARIA_SHARE *share= info->s; uint i; int save_errno; - MARIA_RECORD_POS filepos, oldpos= info->cur_row.lastpos; + MARIA_RECORD_POS filepos; uchar *buff; my_bool lock_tree= share->lock_key_trees; my_bool fatal_error; @@ -303,7 +303,7 @@ int maria_write(MARIA_HA *info, const uchar *record) share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; info->state->changed= 1; - info->cur_row.lastpos= oldpos; + info->cur_row.lastpos= filepos; _ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE); if (info->invalidator != 0) { diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 71d4b62026b..57fa58cfb24 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -153,6 +153,7 @@ int mi_write(MI_INFO *info, const uchar *record) info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN | HA_STATE_ROW_CHANGED); info->state->records++; + info->lastpos=filepos; myisam_log_record(MI_LOG_WRITE,info,record,filepos,0); (void) _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE); if (info->invalidator != 0)