MDEV-35343 ha_heap: recover the cursor after failed ha_update_row

This commit is contained in:
Nikita Malyavin 2025-01-13 15:40:59 +03:00 committed by Aleksey Midenkov
parent 0dcd30197a
commit e760a6dc1c

View File

@ -21,7 +21,8 @@
int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
{
HP_KEYDEF *keydef, *end, *p_lastinx;
uchar *pos;
uchar *pos, *recovery_ptr;
struct st_hp_hash_info *recovery_hash_ptr;
my_bool auto_key_changed= 0, key_changed= 0;
HP_SHARE *share= info->s;
DBUG_ENTER("heap_update");
@ -34,6 +35,10 @@ int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
if (--(share->records) < share->blength >> 1) share->blength>>= 1;
share->changed=1;
// Save the cursor position to recover if insert fails.
recovery_ptr= info->current_ptr;
recovery_hash_ptr= info->current_hash_ptr;
p_lastinx= share->keydef + info->lastinx;
for (keydef= share->keydef, end= keydef + share->keys; keydef < end; keydef++)
{
@ -84,6 +89,8 @@ int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
}
keydef--;
}
info->current_ptr= recovery_ptr;
info->current_hash_ptr= recovery_hash_ptr;
}
if (++(share->records) == share->blength)
share->blength+= share->blength;