[MDEV-24712] get_partition_set is never executed in ha_partition::multi_range_key_create_key due to bitwise & with 0 constant Created: 2021-01-27  Updated: 2023-10-20  Resolved: 2023-07-07

Status: Closed
Project: MariaDB Server
Component/s: Partitioning
Affects Version/s: 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.1, 11.2
Fix Version/s: 10.4.31, 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Bug Priority: Critical
Reporter: Yury Chaikou Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-32534 Assertion `marked_for_read()' fails i... Open

 Description   

/sql/ha_partition.cc : 6261

HA_READ_KEY_EXACT is defined as 0, so bitwise & gives 0 regardless of start_key->flag value and the whole if condition is always false. As a result get_partition_set is never executed, which might affect performance.

if (start_key->key && (start_key->flag & HA_READ_KEY_EXACT))
get_partition_set(table, table->record[0], active_index,
start_key, &m_part_spec);
else

{ m_part_spec.start_part= 0; m_part_spec.end_part= m_tot_parts - 1; }

To fix that we need to compare using == instead of &:
if (start_key->key && (start_key->flag == HA_READ_KEY_EXACT))



 Comments   
Comment by Oleksandr Byelkin [ 2023-07-07 ]

present in very early versions

Comment by Oleksandr Byelkin [ 2023-07-07 ]

commit c6979762686d78a8bc2de760820d96eae2952809 (HEAD -> bb-10.4-MDEV-24712, origin/bb-10.4-MDEV-24712)
Author: Yury Chaikou <yury.chaikou@servicenow.com>
Date:   Fri Jul 7 10:33:47 2023 +0200
 
    MDEV-24712 get_partition_set is never executed in ha_partition::multi_range_key_create_key due to bitwise & with 0 constant
    
    use == to compare enum (despite the name it is not a bit flag)

Generated at Thu Feb 08 09:32:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.