diff options
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index efc42c1b73f..ec0ecc89394 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -187,7 +187,7 @@ Item_func::fix_fields(THD *thd, Item **ref) } } fix_length_and_dec(); - if (thd->net.report_error) // An error inside fix_length_and_dec occured + if (thd->is_error()) // An error inside fix_length_and_dec occured return TRUE; fixed= 1; return FALSE; @@ -1377,7 +1377,11 @@ longlong Item_func_int_div::val_int() void Item_func_int_div::fix_length_and_dec() { - max_length=args[0]->max_length - args[0]->decimals; + Item_result argtype= args[0]->result_type(); + /* use precision ony for the data type it is applicable for and valid */ + max_length=args[0]->max_length - + (argtype == DECIMAL_RESULT || argtype == INT_RESULT ? + args[0]->decimals : 0); maybe_null=1; unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; } @@ -2238,6 +2242,7 @@ void Item_func_min_max::fix_length_and_dec() else if ((cmp_type == DECIMAL_RESULT) || (cmp_type == INT_RESULT)) max_length= my_decimal_precision_to_length(max_int_part+decimals, decimals, unsigned_flag); + cached_field_type= agg_field_type(args, arg_count); } @@ -2892,6 +2897,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, if (u_d->func_init) { + char init_msg_buff[MYSQL_ERRMSG_SIZE]; char *to=num_buffer; for (uint i=0; i < arg_count; i++) { @@ -2944,10 +2950,10 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, } thd->net.last_error[0]=0; Udf_func_init init= u_d->func_init; - if ((error=(uchar) init(&initid, &f_args, thd->net.last_error))) + if ((error=(uchar) init(&initid, &f_args, init_msg_buff))) { my_error(ER_CANT_INITIALIZE_UDF, MYF(0), - u_d->name.str, thd->net.last_error); + u_d->name.str, init_msg_buff); free_udf(u_d); DBUG_RETURN(TRUE); } @@ -3619,10 +3625,17 @@ longlong Item_func_last_insert_id::val_int() thd->first_successful_insert_id_in_prev_stmt= value; return value; } - thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); return thd->read_first_successful_insert_id_in_prev_stmt(); } + +bool Item_func_last_insert_id::fix_fields(THD *thd, Item **ref) +{ + thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT); + return Item_int_func::fix_fields(thd, ref); +} + + /* This function is just used to test speed of different functions */ longlong Item_func_benchmark::val_int() @@ -4061,7 +4074,7 @@ my_decimal *user_var_entry::val_decimal(my_bool *null_value, my_decimal *val) NOTES For now it always return OK. All problem with value evaluating - will be caught by thd->net.report_error check in sql_set_variables(). + will be caught by thd->is_error() check in sql_set_variables(). RETURN FALSE OK. @@ -5592,8 +5605,13 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) #endif /* ! NO_EMBEDDED_ACCESS_CHECKS */ } + if (!m_sp->m_chistics->detistic) - used_tables_cache |= RAND_TABLE_BIT; + { + used_tables_cache |= RAND_TABLE_BIT; + const_item_cache= FALSE; + } + DBUG_RETURN(res); } @@ -5601,8 +5619,12 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) void Item_func_sp::update_used_tables() { Item_func::update_used_tables(); + if (!m_sp->m_chistics->detistic) - used_tables_cache |= RAND_TABLE_BIT; + { + used_tables_cache |= RAND_TABLE_BIT; + const_item_cache= FALSE; + } } |