diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/event_data_objects.cc | 2 | ||||
-rw-r--r-- | sql/ha_partition.cc | 14 | ||||
-rw-r--r-- | sql/item.cc | 12 | ||||
-rw-r--r-- | sql/item.h | 4 | ||||
-rw-r--r-- | sql/partition_info.cc | 7 | ||||
-rw-r--r-- | sql/sql_insert.cc | 4 | ||||
-rw-r--r-- | sql/sql_partition.cc | 14 | ||||
-rw-r--r-- | sql/sql_partition.h | 1 |
8 files changed, 46 insertions, 12 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index adac2b596c1..f4b64ab3012 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1649,8 +1649,6 @@ err: void Event_queue_element::mark_last_executed(THD *thd) { - thd->set_current_time(); - last_executed= (my_time_t) thd->query_start(); last_executed_changed= TRUE; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 1400d9da753..95eae4378c3 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1531,6 +1531,14 @@ int ha_partition::copy_partitions(ulonglong *copied, ulonglong *deleted) longlong func_value; DBUG_ENTER("ha_partition::copy_partitions"); + if (m_part_info->linear_hash_ind) + { + if (m_part_info->part_type == HASH_PARTITION) + set_linear_hash_mask(m_part_info, m_part_info->no_parts); + else + set_linear_hash_mask(m_part_info, m_part_info->no_subparts); + } + while (reorg_part < m_reorged_parts) { handler *file= m_reorged_file[reorg_part]; @@ -3983,7 +3991,8 @@ int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) } else if (!(error= file->index_next(buf))) { - if (compare_key(end_range) <= 0) + if (!(file->table_flags() & HA_READ_ORDER) || + compare_key(end_range) <= 0) { m_last_part= m_part_spec.start_part; DBUG_RETURN(0); // Row was in range @@ -4060,7 +4069,8 @@ int ha_partition::handle_unordered_scan_next_partition(uchar * buf) } if (!error) { - if (compare_key(end_range) <= 0) + if (!(file->table_flags() & HA_READ_ORDER) || + compare_key(end_range) <= 0) { m_last_part= i; DBUG_RETURN(0); diff --git a/sql/item.cc b/sql/item.cc index c8ec2206f02..364b27d9972 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1240,7 +1240,17 @@ bool Item_name_const::is_null() Item::Type Item_name_const::type() const { - return value_item->type(); + /* + As + 1. one can try to create the Item_name_const passing non-constant + arguments, although it's incorrect and + 2. the type() method can be called before the fix_fields() to get + type information for a further type cast, e.g. + if (item->type() == FIELD_ITEM) + ((Item_field *) item)->... + we return NULL_ITEM in the case to avoid wrong casting. + */ + return valid_args ? value_item->type() : NULL_ITEM; } diff --git a/sql/item.h b/sql/item.h index 379eb8a24be..2219153616b 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1242,11 +1242,13 @@ class Item_name_const : public Item { Item *value_item; Item *name_item; + bool valid_args; public: Item_name_const(Item *name_arg, Item *val): value_item(val), name_item(name_arg) { - if(!value_item->basic_const_item()) + if (!(valid_args= name_item->basic_const_item() & + value_item->basic_const_item())) my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST"); Item::maybe_null= TRUE; } diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 86d50cdf524..3b580422da1 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -524,6 +524,13 @@ bool partition_info::check_range_constants() current_largest= part_range_value; range_int_array[i]= part_range_value; } + else if (defined_max_value && + current_largest == part_range_value && + part_range_value == LONGLONG_MAX && + i == (no_parts - 1)) + { + range_int_array[i]= part_range_value; + } else { my_error(ER_RANGE_NOT_INCREASING_ERROR, MYF(0)); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 425c5a33329..9f2bc0b14ff 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -574,7 +574,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, bool log_on= ((thd->options & OPTION_BIN_LOG) || (!(thd->security_ctx->master_access & SUPER_ACL))); #endif - thr_lock_type lock_type = table_list->lock_type; + thr_lock_type lock_type; Item *unused_conds= 0; DBUG_ENTER("mysql_insert"); @@ -609,6 +609,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); } + lock_type= table_list->lock_type; thd->proc_info="init"; thd->used_tables=0; @@ -626,7 +627,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, /* mysql_prepare_insert set table_list->table if it was not set */ table= table_list->table; - lock_type= table_list->lock_type; context= &thd->lex->select_lex.context; /* diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 64f96f342df..04b7703ef88 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1402,7 +1402,7 @@ static void set_up_partition_func_pointers(partition_info *part_info) NONE */ -static void set_linear_hash_mask(partition_info *part_info, uint no_parts) +void set_linear_hash_mask(partition_info *part_info, uint no_parts) { uint mask; @@ -2834,8 +2834,8 @@ int get_partition_id_range(partition_info *part_info, loc_part_id++; *part_id= (uint32)loc_part_id; if (loc_part_id == max_partition && - range_array[loc_part_id] != LONGLONG_MAX && - part_func_value >= range_array[loc_part_id]) + part_func_value >= range_array[loc_part_id] && + !part_info->defined_max_value) DBUG_RETURN(HA_ERR_NO_PARTITION_FOUND); DBUG_PRINT("exit",("partition: %d", *part_id)); @@ -2941,7 +2941,13 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, } if (left_endpoint) { - if (part_func_value >= range_array[loc_part_id]) + longlong bound= range_array[loc_part_id]; + /* + In case of PARTITION p VALUES LESS THAN MAXVALUE + the maximum value is in the current partition. + */ + if (part_func_value > bound || + (part_func_value == bound && !part_info->defined_max_value)) loc_part_id++; } else diff --git a/sql/sql_partition.h b/sql/sql_partition.h index 56f24181b93..282e24f1853 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -65,6 +65,7 @@ int get_part_for_delete(const uchar *buf, const uchar *rec0, void prune_partition_set(const TABLE *table, part_id_range *part_spec); bool check_partition_info(partition_info *part_info,handlerton **eng_type, TABLE *table, handler *file, HA_CREATE_INFO *info); +void set_linear_hash_mask(partition_info *part_info, uint no_parts); bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind); char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, |