diff options
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r-- | sql/sql_partition.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 143073a67b5..114c6fd0681 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,13 +3016,18 @@ 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 || - (part_func_value == part_end_val && - (loc_part_id < max_partition || !part_info->defined_max_value))) + if (part_func_value >= part_end_val && + (loc_part_id < max_partition || !part_info->defined_max_value)) loc_part_id++; } else @@ -4274,6 +4280,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, { DBUG_ENTER("prep_alter_part_table"); + /* Foreign keys on partitioned tables are not supported, waits for WL#148 */ + if (table->part_info && (alter_info->flags & ALTER_FOREIGN_KEY)) + { + my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0)); + DBUG_RETURN(TRUE); + } /* We are going to manipulate the partition info on the table object so we need to ensure that the data structure of the table object |