Bug #32566 Range partitioning: Insert of maximum value should fail LESS THAN (numeric max)
Submitted: 21 Nov 2007 11:32 Modified: 29 Nov 2007 12:49
Reporter: Mattias Jonsson Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[21 Nov 2007 11:32] Mattias Jonsson
Description:
It is possible to insert the maximum value not only if MAXVALUE (the supremum) is used for the last partition, but also if the maximum value is used in its numerical form.
CREATE TABLE t1 (s1 BIGINT UNSIGNED)
ENGINE=MyISAM
PARTITION BY RANGE (s1) (
PARTITION p2 VALUES LESS THAN (18446744073709551615)
);
INSERT INTO t1 VALUES (18446744073709551615);

It should only work for:
CREATE TABLE t1 (s1 BIGINT UNSIGNED)
ENGINE=MyISAM
PARTITION BY RANGE (s1) (
PARTITION p2 VALUES LESS THAN MAXVALUE
);
INSERT INTO t1 VALUES (18446744073709551615);

How to repeat:
See above.

Suggested fix:
change the following lines (from sql_partition.cc:2837):
  if (loc_part_id == max_partition &&
      range_array[loc_part_id] != LONGLONG_MAX &&
      part_func_value >= range_array[loc_part_id])
    DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND);

to this:
 if (loc_part_id == max_partition &&
     part_func_value >= range_array[loc_part_id] &&
     !part_info->defined_max_value)
   DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND);

(see fix for bug#29258)
[22 Nov 2007 14:16] Mattias Jonsson
Please look at http://lists.mysql.com/commits/38274 where the fix is.
[29 Nov 2007 12:49] Mattias Jonsson
Duplicate of Bug#29258.