revision-id: 4968049799193394d442f26b4e3a8d95b185be72 (mariadb-10.3.6-70-g4968049) parent(s): 9df0eab32792adb436a3fda82b175b82f4d6b393 committer: Alexey Botchkov timestamp: 2018-04-28 15:16:45 +0400 message: MDEV-11084 Select statement with partition selection against MyISAM table opens all partitions. Not-used partitions are not closed now. --- sql/ha_partition.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 30d4b33..92357ae 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8351,7 +8351,7 @@ int ha_partition::open_read_partitions(char *name_buff, size_t name_buff_size) { handler **file; char *name_buffer_ptr; - int error; + int error= 0; name_buffer_ptr= m_name_buffer_ptr; file= m_file; @@ -8362,13 +8362,20 @@ int ha_partition::open_read_partitions(char *name_buff, size_t name_buff_size) int is_open= bitmap_is_set(&m_opened_partitions, n_file); int should_be_open= bitmap_is_set(&m_part_info->read_partitions, n_file); - if (is_open && !should_be_open) - { - if ((error= (*file)->ha_close())) - goto err_handler; - bitmap_clear_bit(&m_opened_partitions, n_file); - } - else if (!is_open && should_be_open) + /* + TODO: we can close some opened partitions if they're not + used in the query. It probably should be syncronized with the + table_open_cache value. + + if (is_open && !should_be_open) + { + if ((error= (*file)->ha_close())) + goto err_handler; + bitmap_clear_bit(&m_opened_partitions, n_file); + } + else + */ + if (!is_open && should_be_open) { LEX_CSTRING save_connect_string= table->s->connect_string; if ((error= create_partition_name(name_buff, name_buff_size,