diff options
author | Mattias Jonsson <mattias.jonsson@sun.com> | 2010-03-10 12:56:05 +0100 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@sun.com> | 2010-03-10 12:56:05 +0100 |
commit | 29b39e7a4423188d99570b290127a74151805ed5 (patch) | |
tree | 4a0f89eaf8659b53bd68bdeb3add3518977b2c2c /sql/sql_partition.cc | |
parent | 25a9f5e0941b879f1558579d4718ea5c747c7d12 (diff) | |
download | mariadb-git-29b39e7a4423188d99570b290127a74151805ed5.tar.gz |
Bug#51830: Incorrect partition pruning on range partition
(regression)
Problem was that partition pruning did not exclude the
last partition if the range was beyond it
(i.e. not using MAXVALUE)
Fix was to not include the last partition if the
partitioning function value was not within the partition
range.
mysql-test/r/partition_innodb.result:
Bug#51830: Incorrect partition pruning on range partition
(regression)
Updated result
mysql-test/r/partition_pruning.result:
Bug#51830: Incorrect partition pruning on range partition
(regression)
Updated result
mysql-test/t/partition_innodb.test:
Bug#51830: Incorrect partition pruning on range partition
(regression)
Added test for pruning in InnoDB, since it does not show
for MyISAM due to 'Impossible WHERE noticed after reading
const tables'.
mysql-test/t/partition_pruning.test:
Bug#51830: Incorrect partition pruning on range partition
(regression)
Added test
sql/sql_partition.cc:
Bug#51830: Incorrect partition pruning on range partition
(regression)
Also increase the partition id if not inside the last partition
(and no MAXVALUE is defined).
Added comments and DBUG_ASSERT.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r-- | sql/sql_partition.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 275115e3cbd..163d6ae6ba3 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2876,6 +2876,7 @@ int get_partition_id_range(partition_info *part_info, *func_value= part_func_value; if (unsigned_flag) part_func_value-= 0x8000000000000000ULL; + /* Search for the partition containing part_func_value */ while (max_part_id > min_part_id) { loc_part_id= (max_part_id + min_part_id) / 2; @@ -3015,11 +3016,17 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, part_end_val= range_array[loc_part_id]; if (left_endpoint) { + DBUG_ASSERT(part_func_value > part_end_val ? + (loc_part_id == max_partition && + !part_info->defined_max_value) : + 1); /* In case of PARTITION p VALUES LESS THAN MAXVALUE - the maximum value is in the current partition. + the maximum value is in the current (last) partition. + If value is equal or greater than the endpoint, + the range starts from the next partition. */ - if (part_func_value == part_end_val && + if (part_func_value >= part_end_val && (loc_part_id < max_partition || !part_info->defined_max_value)) loc_part_id++; } |