diff options
author | unknown <mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-06-14 09:22:27 -0400 |
---|---|---|
committer | unknown <mikael@c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-06-14 09:22:27 -0400 |
commit | 7d119734cec557778638f5a486c832d5e7ce5d50 (patch) | |
tree | 02a2dd41039db545f708bfc18489a5d93985bf96 /sql/partition_info.cc | |
parent | 179c979937bf8fafef7931ce79304fd66a1eaff3 (diff) | |
parent | e6170de4c01edaf6a39bd94d84be935f228332dc (diff) | |
download | mariadb-git-7d119734cec557778638f5a486c832d5e7ce5d50.tar.gz |
Merge c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/bug19801
into c-0409e253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/bug16002
mysql-test/r/partition.result:
Auto merged
mysql-test/t/partition.test:
Auto merged
sql/partition_info.cc:
manual merge
sql/sql_partition.cc:
manual merge
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r-- | sql/partition_info.cc | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 8ebc8e871a7..51230a0f5c0 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -476,11 +476,13 @@ bool partition_info::check_engine_mix(handlerton **engine_array, uint no_parts) bool partition_info::check_range_constants() { partition_element* part_def; - longlong current_largest_int= LONGLONG_MIN; - longlong part_range_value_int; + longlong current_largest; + longlong part_range_value; + bool first= TRUE; uint i; List_iterator<partition_element> it(partitions); bool result= TRUE; + bool signed_flag= !part_expr->unsigned_flag; DBUG_ENTER("partition_info::check_range_constants"); DBUG_PRINT("enter", ("INT_RESULT with %d parts", no_parts)); @@ -496,18 +498,31 @@ bool partition_info::check_range_constants() { part_def= it++; if ((i != (no_parts - 1)) || !defined_max_value) - part_range_value_int= part_def->range_value; + { + part_range_value= part_def->range_value; + if (!signed_flag) + part_range_value-= 0x8000000000000000ULL; + } else - part_range_value_int= LONGLONG_MAX; - if (likely(current_largest_int < part_range_value_int)) + part_range_value= LONGLONG_MAX; + if (first) { - current_largest_int= part_range_value_int; - range_int_array[i]= part_range_value_int; + current_largest= part_range_value; + range_int_array[0]= part_range_value; + first= FALSE; } else { - my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); - goto end; + if (likely(current_largest < part_range_value)) + { + current_largest= part_range_value; + range_int_array[i]= part_range_value; + } + else + { + my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); + goto end; + } } } while (++i < no_parts); result= FALSE; @@ -517,8 +532,8 @@ end: /* - A support routine for check_list_constants used by qsort to sort the - constant list expressions. + Support routines for check_list_constants used by qsort to sort the + constant list expressions. One routine for unsigned and one for signed. SYNOPSIS list_part_cmp() @@ -568,9 +583,9 @@ bool partition_info::check_list_constants() { uint i; uint list_index= 0; - longlong *list_value; + part_elem_value *list_value; bool result= TRUE; - longlong curr_value, prev_value; + longlong curr_value, prev_value, type_add, calc_value; partition_element* part_def; bool found_null= FALSE; List_iterator<partition_element> list_func_it(partitions); @@ -608,7 +623,7 @@ bool partition_info::check_list_constants() has_null_part_id= i; found_null= TRUE; } - List_iterator<longlong> list_val_it1(part_def->list_val_list); + List_iterator<part_elem_value> list_val_it1(part_def->list_val_list); while (list_val_it1++) no_list_values++; } while (++i < no_parts); @@ -622,18 +637,27 @@ bool partition_info::check_list_constants() } 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 { part_def= list_func_it++; - List_iterator<longlong> 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++)) { - list_array[list_index].list_value= *list_value; + calc_value= list_value->value - type_add; + list_array[list_index].list_value= calc_value; list_array[list_index++].partition_id= i; } } while (++i < no_parts); - if (no_list_values) + if (fixed && no_list_values) { bool first= TRUE; qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), @@ -683,7 +707,7 @@ end: */ -bool partition_info::check_partition_info(handlerton **eng_type, +bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, handler *file, ulonglong max_rows) { handlerton **engine_array= NULL; @@ -790,9 +814,12 @@ bool partition_info::check_partition_info(handlerton **eng_type, list constants. */ - if (unlikely((part_type == RANGE_PARTITION && check_range_constants()) || - (part_type == LIST_PARTITION && check_list_constants()))) - goto end; + if (fixed) + { + if (unlikely((part_type == RANGE_PARTITION && check_range_constants()) || + (part_type == LIST_PARTITION && check_list_constants()))) + goto end; + } result= FALSE; end: my_free((char*)engine_array,MYF(MY_ALLOW_ZERO_PTR)); |