Commit 5239cba4 authored by unknown's avatar unknown

BUG#16002: More review fixes


mysql-test/r/partition_range.result:
  Changed test cases
mysql-test/t/partition_range.test:
  Changed test cases
sql/partition_info.cc:
  Changes to resue signed integer code for unsigned integer partition functions
  Basic idea is to store value - 0x8000000000000000 in list_array and range_int_array
  and also perform this subtraction before applying get_partition_id_range and so
  forth.
sql/sql_partition.cc:
  Changes to resue signed integer code for unsigned integer partition functions
  Basic idea is to store value - 0x8000000000000000 in list_array and range_int_array
  and also perform this subtraction before applying get_partition_id_range and so
  forth.
parent e05d2d06
...@@ -365,13 +365,28 @@ COUNT(*) ...@@ -365,13 +365,28 @@ COUNT(*)
DROP TABLE t1; DROP TABLE t1;
create table t1 (a bigint unsigned) create table t1 (a bigint unsigned)
partition by range (a) partition by range (a)
(partition p0 values less than (10),
partition p1 values less than (0));
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (0), (partition p0 values less than (0),
partition p1 values less than (10)); partition p1 values less than (10));
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (0) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM)
drop table t1;
create table t1 (a bigint unsigned) create table t1 (a bigint unsigned)
partition by range (a) partition by range (a)
(partition p0 values less than (2), (partition p0 values less than (2),
partition p1 values less than (10)); partition p1 values less than (10));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (a) (PARTITION p0 VALUES LESS THAN (2) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (10) ENGINE = MyISAM)
insert into t1 values (0xFFFFFFFFFFFFFFFF); insert into t1 values (0xFFFFFFFFFFFFFFFF);
ERROR HY000: Table has no partition for value 18446744073709551615 ERROR HY000: Table has no partition for value 18446744073709551615
drop table t1; drop table t1;
...@@ -392,16 +392,24 @@ DROP TABLE t1; ...@@ -392,16 +392,24 @@ DROP TABLE t1;
# BUG 16002: Unsigned partition functions not handled correctly # BUG 16002: Unsigned partition functions not handled correctly
# #
--error ER_RANGE_NOT_INCREASING_ERROR --error ER_RANGE_NOT_INCREASING_ERROR
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (10),
partition p1 values less than (0));
create table t1 (a bigint unsigned) create table t1 (a bigint unsigned)
partition by range (a) partition by range (a)
(partition p0 values less than (0), (partition p0 values less than (0),
partition p1 values less than (10)); partition p1 values less than (10));
show create table t1;
drop table t1;
create table t1 (a bigint unsigned) create table t1 (a bigint unsigned)
partition by range (a) partition by range (a)
(partition p0 values less than (2), (partition p0 values less than (2),
partition p1 values less than (10)); partition p1 values less than (10));
show create table t1;
--error ER_NO_PARTITION_FOR_GIVEN_VALUE --error ER_NO_PARTITION_FOR_GIVEN_VALUE
insert into t1 values (0xFFFFFFFFFFFFFFFF); insert into t1 values (0xFFFFFFFFFFFFFFFF);
drop table t1; drop table t1;
...@@ -444,9 +444,9 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts) ...@@ -444,9 +444,9 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts)
bool partition_info::check_range_constants() bool partition_info::check_range_constants()
{ {
partition_element* part_def; partition_element* part_def;
longlong current_largest_int= LONGLONG_MIN; longlong current_largest;
ulonglong current_largest_uint= 0; longlong part_range_value;
longlong part_range_value_int; bool first= TRUE;
uint i; uint i;
List_iterator<partition_element> it(partitions); List_iterator<partition_element> it(partitions);
bool result= TRUE; bool result= TRUE;
...@@ -465,33 +465,26 @@ bool partition_info::check_range_constants() ...@@ -465,33 +465,26 @@ bool partition_info::check_range_constants()
do do
{ {
part_def= it++; part_def= it++;
if (signed_flag) if ((i != (no_parts - 1)) || !defined_max_value)
{ {
if ((i != (no_parts - 1)) || !defined_max_value) part_range_value= part_def->range_value;
part_range_value_int= part_def->range_value; if (!signed_flag)
else part_range_value-= 0x8000000000000000ULL;
part_range_value_int= LONGLONG_MAX; }
if (likely(current_largest_int < part_range_value_int)) else
{ part_range_value= LONGLONG_MAX;
current_largest_int= part_range_value_int; if (first)
range_int_array[i]= part_range_value_int; {
} current_largest= part_range_value;
else range_int_array[0]= part_range_value;
{ first= FALSE;
my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0));
goto end;
}
} }
else else
{ {
ulonglong upart_range_value_int; if (likely(current_largest < part_range_value))
if ((i == (no_parts - 1)) && defined_max_value)
part_def->range_value= ULONGLONG_MAX;
upart_range_value_int= part_def->range_value;
if (likely(current_largest_uint < upart_range_value_int))
{ {
current_largest_uint= upart_range_value_int; current_largest= part_range_value;
range_int_array[i]= part_range_value_int; range_int_array[i]= part_range_value;
} }
else else
{ {
...@@ -533,18 +526,6 @@ int partition_info::list_part_cmp(const void* a, const void* b) ...@@ -533,18 +526,6 @@ int partition_info::list_part_cmp(const void* a, const void* b)
return 0; return 0;
} }
int partition_info::list_part_cmp_unsigned(const void* a, const void* b)
{
ulonglong a1= ((LIST_PART_ENTRY*)a)->list_value;
ulonglong b1= ((LIST_PART_ENTRY*)b)->list_value;
if (a1 < b1)
return -1;
else if (a1 > b1)
return +1;
else
return 0;
}
/* /*
This routine allocates an array for all list constants to achieve a fast This routine allocates an array for all list constants to achieve a fast
...@@ -572,7 +553,7 @@ bool partition_info::check_list_constants() ...@@ -572,7 +553,7 @@ bool partition_info::check_list_constants()
uint list_index= 0; uint list_index= 0;
part_elem_value *list_value; part_elem_value *list_value;
bool result= TRUE; bool result= TRUE;
longlong curr_value, prev_value; longlong curr_value, prev_value, type_add, calc_value;
partition_element* part_def; partition_element* part_def;
bool found_null= FALSE; bool found_null= FALSE;
List_iterator<partition_element> list_func_it(partitions); List_iterator<partition_element> list_func_it(partitions);
...@@ -623,13 +604,22 @@ bool partition_info::check_list_constants() ...@@ -623,13 +604,22 @@ bool partition_info::check_list_constants()
} }
i= 0; i= 0;
/*
Fix to be able to reuse signed sort functions also for unsigned
partition functions.
*/
type_add= (longlong)(part_expr->unsigned_flag ?
0x8000000000000000ULL :
0ULL);
do do
{ {
part_def= list_func_it++; part_def= list_func_it++;
List_iterator<part_elem_value> list_val_it2(part_def->list_val_list); List_iterator<part_elem_value> list_val_it2(part_def->list_val_list);
while ((list_value= list_val_it2++)) while ((list_value= list_val_it2++))
{ {
list_array[list_index].list_value= list_value->value; calc_value= list_value->value - type_add;
list_array[list_index].list_value= calc_value;
list_array[list_index++].partition_id= i; list_array[list_index++].partition_id= i;
} }
} while (++i < no_parts); } while (++i < no_parts);
...@@ -637,12 +627,8 @@ bool partition_info::check_list_constants() ...@@ -637,12 +627,8 @@ bool partition_info::check_list_constants()
if (fixed) if (fixed)
{ {
bool first= TRUE; bool first= TRUE;
if (!part_expr->unsigned_flag) qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY),
qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), &list_part_cmp);
&list_part_cmp);
else
qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY),
&list_part_cmp_unsigned);
i= prev_value= 0; //prev_value initialised to quiet compiler i= prev_value= 0; //prev_value initialised to quiet compiler
do do
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment