532
void Item_func::fix_num_length_and_dec()
534
uint32_t fl_length= 0;
536
for (uint32_t i=0 ; i < arg_count ; i++)
538
set_if_bigger(decimals,args[i]->decimals);
539
set_if_bigger(fl_length, args[i]->max_length);
541
max_length=float_length(decimals);
542
if (fl_length > max_length)
544
decimals= NOT_FIXED_DEC;
545
max_length= float_length(NOT_FIXED_DEC);
550
Set max_length/decimals of function if function is fixed point and
551
result length/precision depends on argument ones.
554
void Item_func::count_decimal_length()
559
for (uint32_t i=0 ; i < arg_count ; i++)
561
set_if_bigger(decimals, args[i]->decimals);
562
set_if_bigger(max_int_part, args[i]->decimal_int_part());
563
set_if_smaller(unsigned_flag, args[i]->unsigned_flag);
565
int precision= cmin(max_int_part + decimals, DECIMAL_MAX_PRECISION);
566
max_length= my_decimal_precision_to_length(precision, decimals,
572
Set max_length of if it is maximum length of its arguments.
575
void Item_func::count_only_length()
579
for (uint32_t i=0 ; i < arg_count ; i++)
581
set_if_bigger(max_length, args[i]->max_length);
582
set_if_bigger(unsigned_flag, args[i]->unsigned_flag);
588
Set max_length/decimals of function if function is floating point and
589
result length/precision depends on argument ones.
592
void Item_func::count_real_length()
597
for (uint32_t i=0 ; i < arg_count ; i++)
599
if (decimals != NOT_FIXED_DEC)
601
set_if_bigger(decimals, args[i]->decimals);
602
set_if_bigger(length, (args[i]->max_length - args[i]->decimals));
604
set_if_bigger(max_length, args[i]->max_length);
606
if (decimals != NOT_FIXED_DEC)
610
if (length < max_length) // If previous operation gave overflow
611
max_length= UINT32_MAX;
619
void Item_func::signal_divide_by_null()
621
Session *session= current_session;
622
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DIVISION_BY_ZERO, ER(ER_DIVISION_BY_ZERO));
627
Item *Item_func::get_tmp_table_item(Session *session)
629
if (!with_sum_func && !const_item() && functype() != SUSERVAR_FUNC)
630
return new Item_field(result_field);
631
return copy_or_same(session);