diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2020-05-29 16:18:50 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2020-05-29 16:19:15 +0300 |
commit | 4783494a5e21939424ecca92bf23d2df65528266 (patch) | |
tree | b8b8752717639bdf6c58f33be82f848caba6299a /sql/ha_partition.cc | |
parent | d74e3a56e768ab9c983ce9b44d2acb89d382cf61 (diff) | |
download | mariadb-git-4783494a5e21939424ecca92bf23d2df65528266.tar.gz |
MDEV-22283 Server crashes in key_copy or unexpected error 156
(The table already existed in the storage engine)
Wrong algorithm of closing partitions on error doesn't close last
partition.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index af60ca68c82..6af69fc67b6 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3657,11 +3657,13 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) err_handler: DEBUG_SYNC(ha_thd(), "partition_open_error"); - file= &m_file[m_tot_parts - 1]; - while (file-- != m_file) + DBUG_ASSERT(m_tot_parts > 0); + for (uint i= m_tot_parts - 1; ; --i) { - if (bitmap_is_set(&m_opened_partitions, (uint)(file - m_file))) - (*file)->ha_close(); + if (bitmap_is_set(&m_opened_partitions, i)) + m_file[i]->ha_close(); + if (!i) + break; } err_alloc: free_partition_bitmaps(); |