Commit 244906a0 authored by Sergei Golubchik's avatar Sergei Golubchik

Revert "MDEV-15458 Segfault in heap_scan() upon UPDATE after ADD SYSTEM VERSIONING"

This partially reverts 43623f04

Engines have to set ::position() after ::write_row(), otherwise
the server won't be able to refer to the row just inserted.
This is important for high-level indexes.

heap part isn't reverted, so heap doesn't support high-level indexes.
to fix this, it'll need info->lastpos in addition to info->current_ptr
parent bbea4fa9
...@@ -296,15 +296,22 @@ int TABLE::delete_row() ...@@ -296,15 +296,22 @@ int TABLE::delete_row()
store_record(this, record[1]); store_record(this, record[1]);
vers_update_end(); vers_update_end();
int err= file->ha_update_row(record[1], record[0]); int err;
/* if ((err= file->extra(HA_EXTRA_REMEMBER_POS)))
MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got history return err;
row with same trx_id which is the result of foreign key action, so we if ((err= file->ha_update_row(record[1], record[0])))
don't need one more history row. {
*/ /*
if (err == HA_ERR_FOREIGN_DUPLICATE_KEY) MDEV-23644: we get HA_ERR_FOREIGN_DUPLICATE_KEY iff we already got
return file->ha_delete_row(record[0]); history row with same trx_id which is the result of foreign key action,
return err; 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);
} }
......
...@@ -89,7 +89,7 @@ int maria_write(MARIA_HA *info, const uchar *record) ...@@ -89,7 +89,7 @@ int maria_write(MARIA_HA *info, const uchar *record)
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
uint i; uint i;
int save_errno; int save_errno;
MARIA_RECORD_POS filepos, oldpos= info->cur_row.lastpos; MARIA_RECORD_POS filepos;
uchar *buff; uchar *buff;
my_bool lock_tree= share->lock_key_trees; my_bool lock_tree= share->lock_key_trees;
my_bool fatal_error; my_bool fatal_error;
...@@ -303,7 +303,7 @@ int maria_write(MARIA_HA *info, const uchar *record) ...@@ -303,7 +303,7 @@ int maria_write(MARIA_HA *info, const uchar *record)
share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED; share->state.changed|= STATE_NOT_MOVABLE | STATE_NOT_ZEROFILLED;
info->state->changed= 1; info->state->changed= 1;
info->cur_row.lastpos= oldpos; info->cur_row.lastpos= filepos;
_ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE); _ma_writeinfo(info, WRITEINFO_UPDATE_KEYFILE);
if (info->invalidator != 0) if (info->invalidator != 0)
{ {
......
...@@ -153,6 +153,7 @@ int mi_write(MI_INFO *info, const uchar *record) ...@@ -153,6 +153,7 @@ int mi_write(MI_INFO *info, const uchar *record)
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN | info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
HA_STATE_ROW_CHANGED); HA_STATE_ROW_CHANGED);
info->state->records++; info->state->records++;
info->lastpos=filepos;
myisam_log_record(MI_LOG_WRITE,info,record,filepos,0); myisam_log_record(MI_LOG_WRITE,info,record,filepos,0);
(void) _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE); (void) _mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE);
if (info->invalidator != 0) if (info->invalidator != 0)
......
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