static int get_part_iter_for_interval_cols_via_map(partition_info *part_info,
                           bool is_subpart, uint32 *store_length_array,
                           uchar *min_value, uchar *max_value,
                           uint min_len, uint max_len,
                           uint flags, PARTITION_ITERATOR *part_iter)
{
  bool can_match_multiple_values;
  uint32 nparts;
  get_col_endpoint_func  UNINIT_VAR(get_col_endpoint);
  uint full_length= 0;
  DBUG_ENTER("get_part_iter_for_interval_cols_via_map");

  if (part_info->part_type == RANGE_PARTITION || part_info->part_type == VERSIONING_PARTITION)
  {
    get_col_endpoint= get_partition_id_cols_range_for_endpoint;
    part_iter->get_next= get_next_partition_id_range;
  }
  else if (part_info->part_type == LIST_PARTITION)
  {
    if (part_info->has_default_partititon() &&
        part_info->num_parts == 1)
      DBUG_RETURN(-1); //only DEFAULT partition
    get_col_endpoint= get_partition_id_cols_list_for_endpoint;
    part_iter->get_next= get_next_partition_id_list;
    part_iter->part_info= part_info;
    DBUG_ASSERT(part_info->num_list_values);
  }
  else
    assert(0);

  for (uint32 i= 0; i < part_info->num_columns; i++)
    full_length+= store_length_array[i];

  can_match_multiple_values= ((flags &
                               (NO_MIN_RANGE | NO_MAX_RANGE | NEAR_MIN |
                                NEAR_MAX)) ||
                              (min_len != max_len) ||
                              (min_len != full_length) ||
                              memcmp(min_value, max_value, min_len));
  DBUG_ASSERT(can_match_multiple_values || (flags & EQ_RANGE) || flags == 0);
  if (can_match_multiple_values && part_info->has_default_partititon())
    part_iter->ret_default_part= part_iter->ret_default_part_orig= TRUE;

  if (flags & NO_MIN_RANGE)
    part_iter->part_nums.start= part_iter->part_nums.cur= 0;
  else
  {
    // Copy from min_value to record
    nparts= store_tuple_to_record(part_info->part_field_array,
                                  store_length_array,
                                  min_value,
                                  min_value + min_len);
    part_iter->part_nums.start= part_iter->part_nums.cur=
      get_col_endpoint(part_info, TRUE, !(flags & NEAR_MIN),
                       nparts);
  }
  if (flags & NO_MAX_RANGE)
  {
    if (part_info->part_type == RANGE_PARTITION || part_info->part_type == VERSIONING_PARTITION)
      part_iter->part_nums.end= part_info->num_parts;
    else /* LIST_PARTITION */
    {
      DBUG_ASSERT(part_info->part_type == LIST_PARTITION);
      part_iter->part_nums.end= part_info->num_list_values;
    }
  }
  else
  {
    // Copy from max_value to record
    nparts= store_tuple_to_record(part_info->part_field_array,
                                  store_length_array,
                                  max_value,
                                  max_value + max_len);
    part_iter->part_nums.end= get_col_endpoint(part_info, FALSE,
                                               !(flags & NEAR_MAX),
                                               nparts);
  }
  if (part_iter->part_nums.start == part_iter->part_nums.end)
  {
    // No matching partition found.
    if (part_info->has_default_partititon())
    {
      part_iter->ret_default_part= part_iter->ret_default_part_orig= TRUE;
      DBUG_RETURN(1);
    }
    DBUG_RETURN(0);
  }
  DBUG_RETURN(1);
}