diff options
author | gluh@eagle.intranet.mysql.r18.ru <> | 2006-03-28 17:25:19 +0500 |
---|---|---|
committer | gluh@eagle.intranet.mysql.r18.ru <> | 2006-03-28 17:25:19 +0500 |
commit | 9c82b6746a6da5f69053806c7b3431e00b92876e (patch) | |
tree | 4c11c702a95f21bb362555e3a85cedee371924c4 /sql | |
parent | 3c6d2e322cdca189d29be2bc5855f618f145a38e (diff) | |
download | mariadb-git-9c82b6746a6da5f69053806c7b3431e00b92876e.tar.gz |
Bug#18053 Partitions: crash if null
Bug#18070 Partitions: wrong result on WHERE ... IS NULL
removed unnecessary code
added handling of NULL values
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_range.cc | 1 | ||||
-rw-r--r-- | sql/sql_partition.cc | 23 | ||||
-rw-r--r-- | sql/sql_partition.h | 2 |
3 files changed, 22 insertions, 4 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e9ebd9cbccb..36de27ef3e3 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2296,6 +2296,7 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond) RANGE_OPT_PARAM *range_par= &prune_param.range_param; prune_param.part_info= part_info; + prune_param.part_iter.has_null_value= FALSE; init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); range_par->mem_root= &alloc; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 682c74dc31e..d8a886d2227 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2868,9 +2868,6 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, /* Get the partitioning function value for the endpoint */ longlong part_func_value= part_val_int(part_info->part_expr); - if (part_info->part_expr->null_value) - DBUG_RETURN(0); - while (max_part_id > min_part_id) { loc_part_id= (max_part_id + min_part_id + 1) >> 1; @@ -5745,6 +5742,19 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, else DBUG_ASSERT(0); + if (field->real_maybe_null() && part_info->has_null_value) + { + if (*min_value) + { + if (*max_value && !(flags & (NO_MIN_RANGE | NO_MAX_RANGE))) + { + init_single_partition_iterator(part_info->has_null_part_id, part_iter); + return 1; + } + if (!(flags & NEAR_MIN)) + part_iter->has_null_value= TRUE; + } + } /* Find minimum */ if (flags & NO_MIN_RANGE) part_iter->part_nums.start= 0; @@ -5956,7 +5966,14 @@ uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter) uint32 get_next_partition_id_list(PARTITION_ITERATOR *part_iter) { if (part_iter->part_nums.start == part_iter->part_nums.end) + { + if (part_iter->has_null_value) + { + part_iter->has_null_value= FALSE; + return part_iter->part_info->has_null_part_id; + } return NOT_A_PARTITION_ID; + } else return part_iter->part_info->list_array[part_iter-> part_nums.start++].partition_id; diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 4982b1fcf1f..c214be81ae4 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -124,7 +124,7 @@ typedef uint32 (*partition_iter_func)(st_partition_iter* part_iter); typedef struct st_partition_iter { partition_iter_func get_next; - + bool has_null_value; struct st_part_num_range { uint32 start; |