diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index fdc9320..fea4bfb 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -3372,6 +3372,7 @@ static bool set_PF_fields_in_key(KEY *key_info, uint key_length) { SYNOPSIS check_part_func_bound() + table The table object ptr Array of fields NULL terminated (partition fields) RETURN VALUE @@ -3379,12 +3380,13 @@ static bool set_PF_fields_in_key(KEY *key_info, uint key_length) { false Not all fields in partition function are set */ -static bool check_part_func_bound(Field **ptr) { +static bool check_part_func_bound(const TABLE *table, Field **ptr) { bool result = true; DBUG_TRACE; for (; *ptr; ptr++) { - if (!(*ptr)->is_flag_set(GET_FIXED_FIELDS_FLAG)) { + if (!(*ptr)->is_flag_set(GET_FIXED_FIELDS_FLAG) + || (table->read_set && !bitmap_is_set(table->read_set, (*ptr)->field_index()))) { result = false; break; } @@ -3735,7 +3737,7 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, */ if ((found_part_field = set_PF_fields_in_key(key_info, key_spec->length))) { - if (check_part_func_bound(part_info->full_part_field_array)) { + if (check_part_func_bound(table, part_info->full_part_field_array)) { /* We were able to bind all fields in the partition function even by using only a part of the key. Calculate the partition to use. @@ -3749,14 +3751,14 @@ void get_partition_set(const TABLE *table, uchar *buf, const uint index, return; } if (part_info->is_sub_partitioned()) { - if (check_part_func_bound(part_info->subpart_field_array)) { + if (check_part_func_bound(table, part_info->subpart_field_array)) { if (get_sub_part_id_from_key(table, buf, key_info, key_spec, &sub_part)) { part_spec->start_part = num_parts; clear_indicator_in_key_fields(key_info); return; } - } else if (check_part_func_bound(part_info->part_field_array)) { + } else if (check_part_func_bound(table, part_info->part_field_array)) { if (get_part_id_from_key(table, buf, key_info, key_spec, &part_part)) { part_spec->start_part = num_parts;