From 6c06defb5f6ddccba1a3d7b03ba34dbb83c7ef69 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 19 Aug 2019 14:17:38 +0200 Subject: [PATCH] MDEV-15458 Segfault in heap_scan() upon UPDATE after ADD SYSTEM VERSIONING heap_scan() makes info->next_block to be either an integer number of share->block.records_in_block's or the total number of records in the table. So when this total number or records changes, info->next_block needs to be recalculated to take it into account. This is a different fix for "Fixes a problem with heap when scanning and insert rows at the same time" --- storage/heap/hp_scan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/heap/hp_scan.c b/storage/heap/hp_scan.c index 3315cb05b3f..f07efe6cf67 100644 --- a/storage/heap/hp_scan.c +++ b/storage/heap/hp_scan.c @@ -50,7 +50,9 @@ int heap_scan(register HP_INFO *info, uchar *record) } else { - info->next_block+=share->block.records_in_block; + /* increase next_block to the next records_in_block boundary */ + ulong rem= info->next_block % share->block.records_in_block; + info->next_block+=share->block.records_in_block - rem; if (info->next_block >= share->records+share->deleted) { info->next_block= share->records+share->deleted;