diff options
author | unknown <mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-05-30 00:08:48 -0400 |
---|---|---|
committer | unknown <mikael@c-870ae253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2006-05-30 00:08:48 -0400 |
commit | 10c5b8b6fd63365d5d3812964912752a6a89510b (patch) | |
tree | 09d13c65f19b8447af078c3fc5cea2d85df632dc /sql/partition_info.cc | |
parent | e05d55de5ff6c95143fb1096da8019ab5fb7c6a2 (diff) | |
download | mariadb-git-10c5b8b6fd63365d5d3812964912752a6a89510b.tar.gz |
BUG#19801: Valgrind error in check_list_constants
Needed some special handling of the case when no_list_values == 0
mysql-test/r/partition.result:
Added a couple of new test cases
mysql-test/t/partition.test:
Added a couple of new test cases
sql/partition_info.cc:
Rearranged some code to handle case where no_list_values == 0 which
happens when one partition with only one value == NULL.
sql/sql_partition.cc:
Rearranged code to remove compiler warning and also since we
now have handled the case where no_list_values == 0 in a special
case before coming here
Added code for handling the special case where no_list_values == 0
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r-- | sql/partition_info.cc | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 0924a8adf6e..6e3023289d8 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -612,7 +612,8 @@ bool partition_info::check_list_constants() no_list_values++; } while (++i < no_parts); list_func_it.rewind(); - list_array= (LIST_PART_ENTRY*)sql_alloc(no_list_values*sizeof(LIST_PART_ENTRY)); + list_array= (LIST_PART_ENTRY*)sql_alloc((no_list_values+1) * + sizeof(LIST_PART_ENTRY)); if (unlikely(list_array == NULL)) { mem_alloc_error(no_list_values * sizeof(LIST_PART_ENTRY)); @@ -631,25 +632,29 @@ bool partition_info::check_list_constants() } } while (++i < no_parts); - qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), - &list_part_cmp); - - not_first= FALSE; - i= prev_value= 0; //prev_value initialised to quiet compiler - do + if (no_list_values) { - curr_value= list_array[i].list_value; - if (likely(!not_first || prev_value != curr_value)) - { - prev_value= curr_value; - not_first= TRUE; - } - else + qsort((void*)list_array, no_list_values, sizeof(LIST_PART_ENTRY), + &list_part_cmp); + + not_first= FALSE; + i= prev_value= 0; //prev_value initialised to quiet compiler + do { - my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); - goto end; - } - } while (++i < no_list_values); + DBUG_ASSERT(i < no_list_values); + curr_value= list_array[i].list_value; + if (likely(!not_first || prev_value != curr_value)) + { + prev_value= curr_value; + not_first= TRUE; + } + else + { + my_error(ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR, MYF(0)); + goto end; + } + } while (++i < no_list_values); + } result= FALSE; end: DBUG_RETURN(result); |