From: Date: November 26 2007 7:28am Subject: bk commit into 5.1 tree (ramil:1.2627) BUG#29258 List-Archive: http://lists.mysql.com/commits/38467 X-Bug: 29258 Message-Id: <20071126062830.845C03400074@ramil.myoffice.izhnet.ru> Below is the list of changes that have just been committed into a local 5.1 repository of ram. When ram does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-11-26 10:28:25+04:00, ramil@stripped +4 -0 Fix for bug #29258: Partitions: search fails for maximum unsigned bigint Problems: 1. looking for a matching partition we miss the fact that the maximum allowed value is in the PARTITION p LESS THAN MAXVALUE. 2. one can insert maximum value if numeric maximum value is the last range. (should only work if LESS THAN MAXVALUE). 3. one cannot have both numeric maximum value and MAXVALUE string as ranges (the same value, but different meanings). Fix: consider the maximum value as a supremum. mysql-test/r/partition.result@stripped, 2007-11-26 10:28:24+04:00, ramil@stripped +47 -0 Fix for bug #29258: Partitions: search fails for maximum unsigned bigint - test result. mysql-test/t/partition.test@stripped, 2007-11-26 10:28:24+04:00, ramil@stripped +39 -0 Fix for bug #29258: Partitions: search fails for maximum unsigned bigint - test case. sql/partition_info.cc@stripped, 2007-11-26 10:28:24+04:00, ramil@stripped +7 -0 Fix for bug #29258: Partitions: search fails for maximum unsigned bigint - In case of PARTITION p VALUES LESS THAN MAXVALUE consider the maximium value as a supremum. sql/sql_partition.cc@stripped, 2007-11-26 10:28:24+04:00, ramil@stripped +9 -3 Fix for bug #29258: Partitions: search fails for maximum unsigned bigint - In case of PARTITION p VALUES LESS THAN MAXVALUE consider the maximium value as a supremum. diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result --- a/mysql-test/r/partition.result 2007-11-16 17:07:54 +04:00 +++ b/mysql-test/r/partition.result 2007-11-26 10:28:24 +04:00 @@ -1297,4 +1297,51 @@ create table t1 partition by key(s1) partitions 3; insert into t1 values (null,null); drop table t1; +CREATE TABLE t1 (s1 BIGINT UNSIGNED) +PARTITION BY RANGE (s1) ( +PARTITION p0 VALUES LESS THAN (0), +PARTITION p1 VALUES LESS THAN (1), +PARTITION p2 VALUES LESS THAN (18446744073709551615) +); +INSERT INTO t1 VALUES (0), (18446744073709551614); +INSERT INTO t1 VALUES (18446744073709551615); +ERROR HY000: Table has no partition for value 18446744073709551615 +DROP TABLE t1; +CREATE TABLE t1 (s1 BIGINT UNSIGNED) +PARTITION BY RANGE (s1) ( +PARTITION p0 VALUES LESS THAN (0), +PARTITION p1 VALUES LESS THAN (1), +PARTITION p2 VALUES LESS THAN (18446744073709551614), +PARTITION p3 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (-1), (0), (18446744073709551613), +(18446744073709551614), (18446744073709551615); +Warnings: +Warning 1264 Out of range value for column 's1' at row 1 +SELECT * FROM t1; +s1 +0 +0 +18446744073709551613 +18446744073709551614 +18446744073709551615 +SELECT * FROM t1 WHERE s1 = 0; +s1 +0 +0 +SELECT * FROM t1 WHERE s1 = 18446744073709551614; +s1 +18446744073709551614 +SELECT * FROM t1 WHERE s1 = 18446744073709551615; +s1 +18446744073709551615 +DROP TABLE t1; +CREATE TABLE t1 (s1 BIGINT UNSIGNED) +PARTITION BY RANGE (s1) ( +PARTITION p0 VALUES LESS THAN (0), +PARTITION p1 VALUES LESS THAN (1), +PARTITION p2 VALUES LESS THAN (18446744073709551615), +PARTITION p3 VALUES LESS THAN MAXVALUE +); +DROP TABLE t1; End of 5.1 tests diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test --- a/mysql-test/t/partition.test 2007-11-16 17:07:55 +04:00 +++ b/mysql-test/t/partition.test 2007-11-26 10:28:24 +04:00 @@ -1541,4 +1541,43 @@ while ($cnt) --enable_query_log drop table t1; + +# +# Bug #29258: Partitions: search fails for maximum unsigned bigint +# +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551615) +); +INSERT INTO t1 VALUES (0), (18446744073709551614); +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +INSERT INTO t1 VALUES (18446744073709551615); +DROP TABLE t1; + +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551614), + PARTITION p3 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (-1), (0), (18446744073709551613), + (18446744073709551614), (18446744073709551615); +SELECT * FROM t1; +SELECT * FROM t1 WHERE s1 = 0; +SELECT * FROM t1 WHERE s1 = 18446744073709551614; +SELECT * FROM t1 WHERE s1 = 18446744073709551615; +DROP TABLE t1; + +CREATE TABLE t1 (s1 BIGINT UNSIGNED) + PARTITION BY RANGE (s1) ( + PARTITION p0 VALUES LESS THAN (0), + PARTITION p1 VALUES LESS THAN (1), + PARTITION p2 VALUES LESS THAN (18446744073709551615), + PARTITION p3 VALUES LESS THAN MAXVALUE +); +DROP TABLE t1; + --echo End of 5.1 tests diff -Nrup a/sql/partition_info.cc b/sql/partition_info.cc --- a/sql/partition_info.cc 2007-08-13 18:11:12 +05:00 +++ b/sql/partition_info.cc 2007-11-26 10:28:24 +04:00 @@ -524,6 +524,13 @@ bool partition_info::check_range_constan current_largest= part_range_value; range_int_array[i]= part_range_value; } + else if (defined_max_value && + current_largest == part_range_value && + part_range_value == LONGLONG_MAX && + i == (no_parts - 1)) + { + range_int_array[i]= part_range_value; + } else { my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); diff -Nrup a/sql/sql_partition.cc b/sql/sql_partition.cc --- a/sql/sql_partition.cc 2007-11-16 17:07:55 +04:00 +++ b/sql/sql_partition.cc 2007-11-26 10:28:24 +04:00 @@ -2834,8 +2834,8 @@ int get_partition_id_range(partition_inf loc_part_id++; *part_id= (uint32)loc_part_id; if (loc_part_id == max_partition && - range_array[loc_part_id] != LONGLONG_MAX && - part_func_value >= range_array[loc_part_id]) + part_func_value >= range_array[loc_part_id] && + !part_info->defined_max_value) DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); DBUG_PRINT("exit",("partition: %d", *part_id)); @@ -2941,7 +2941,13 @@ uint32 get_partition_id_range_for_endpoi } if (left_endpoint) { - if (part_func_value >= range_array[loc_part_id]) + longlong bound= range_array[loc_part_id]; + /* + In case of PARTITION p VALUES LESS THAN MAXVALUE + the maximum value is in the current partition. + */ + if (part_func_value > bound || + (part_func_value == bound && !part_info->defined_max_value)) loc_part_id++; } else