From b2cfcf1d1f260756cceb4f19e330b4955c381f98 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Fri, 19 Aug 2022 11:24:51 +0400 Subject: MDEV-21134 Crash with partitioned table, PARTITION syntax, and index_merge. When the partition table is cloned, the handlers for the partitions that were not opened should anyway be created (but not opened). --- sql/ha_partition.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sql') diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0a8cf3b9532..1b265d7e05f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3637,7 +3637,22 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) for (i= 0; i < m_tot_parts; i++) { if (!bitmap_is_set(&m_is_clone_of->m_opened_partitions, i)) + { + /* Here we should just create the handler instance, not open it. */ + if (!(m_file[i]= get_new_handler(table->s, m_clone_mem_root, + file[i]->ht))) + { + error= HA_ERR_INITIALIZATION; + file= &m_file[i]; + goto err_handler; + } + if (m_file[i]->set_ha_share_ref(file[i]->ha_share)) + { + error= HA_ERR_INITIALIZATION; + goto err_handler; + } continue; + } if (unlikely((error= create_partition_name(name_buff, sizeof(name_buff), name, name_buffer_ptr, -- cgit v1.2.1