Skip to content

Commit e760a6d

Browse files
FooBarriormidenok
authored andcommitted
MDEV-35343 ha_heap: recover the cursor after failed ha_update_row
1 parent 0dcd301 commit e760a6d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

storage/heap/hp_update.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
2222
{
2323
HP_KEYDEF *keydef, *end, *p_lastinx;
24-
uchar *pos;
24+
uchar *pos, *recovery_ptr;
25+
struct st_hp_hash_info *recovery_hash_ptr;
2526
my_bool auto_key_changed= 0, key_changed= 0;
2627
HP_SHARE *share= info->s;
2728
DBUG_ENTER("heap_update");
@@ -34,6 +35,10 @@ int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
3435
if (--(share->records) < share->blength >> 1) share->blength>>= 1;
3536
share->changed=1;
3637

38+
// Save the cursor position to recover if insert fails.
39+
recovery_ptr= info->current_ptr;
40+
recovery_hash_ptr= info->current_hash_ptr;
41+
3742
p_lastinx= share->keydef + info->lastinx;
3843
for (keydef= share->keydef, end= keydef + share->keys; keydef < end; keydef++)
3944
{
@@ -84,6 +89,8 @@ int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new)
8489
}
8590
keydef--;
8691
}
92+
info->current_ptr= recovery_ptr;
93+
info->current_hash_ptr= recovery_hash_ptr;
8794
}
8895
if (++(share->records) == share->blength)
8996
share->blength+= share->blength;

0 commit comments

Comments
 (0)