~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • Committer: Monty Taylor
  • Date: 2008-10-02 01:31:53 UTC
  • mfrom: (398.1.6 codestyle-new)
  • Revision ID: monty@inaugust.com-20081002013153-b097om921cd3j1pn
MergedĀ fromĀ stdint-includes-fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
Hybrid_type_traits_decimal::fix_length_and_dec(Item *item, Item *arg) const
68
68
{
69
69
  item->decimals= arg->decimals;
70
 
  item->max_length= min(arg->max_length + DECIMAL_LONGLONG_DIGITS,
 
70
  item->max_length= cmin(arg->max_length + DECIMAL_LONGLONG_DIGITS,
71
71
                        (unsigned int)DECIMAL_MAX_STR_LENGTH);
72
72
}
73
73
 
434
434
  Item_result restype= result_type();
435
435
 
436
436
  if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
437
 
    return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
 
437
    return cmin(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
438
438
               (unsigned int)DECIMAL_MAX_PRECISION);
439
 
  return min(max_length, (uint32_t)DECIMAL_MAX_PRECISION);
 
439
  return cmin(max_length, (uint32_t)DECIMAL_MAX_PRECISION);
440
440
}
441
441
 
442
442
 
722
722
                                   &res_length);
723
723
  }
724
724
  else
725
 
    name= sql_strmake(str, (name_length= min(length,(unsigned int)MAX_ALIAS_NAME)));
 
725
    name= sql_strmake(str, (name_length= cmin(length,(unsigned int)MAX_ALIAS_NAME)));
726
726
}
727
727
 
728
728
 
2226
2226
    the fact that even wrong value sent over binary protocol fits into
2227
2227
    MAX_DATE_STRING_REP_LENGTH buffer.
2228
2228
*/
2229
 
void Item_param::set_time(DRIZZLE_TIME *tm, timestamp_type time_type,
 
2229
void Item_param::set_time(DRIZZLE_TIME *tm,
 
2230
                          enum enum_drizzle_timestamp_type time_type,
2230
2231
                          uint32_t max_length_arg)
2231
2232
2232
2233
  value.time= *tm;
4498
4499
  // following assert is redundant, because fixed=1 assigned in constructor
4499
4500
  assert(fixed == 1);
4500
4501
  char *end=(char*) str_value.ptr()+str_value.length(),
4501
 
       *ptr=end-min(str_value.length(),(uint32_t)sizeof(int64_t));
 
4502
       *ptr=end-cmin(str_value.length(),(uint32_t)sizeof(int64_t));
4502
4503
 
4503
4504
  uint64_t value=0;
4504
4505
  for (; ptr != end ; ptr++)
4552
4553
                            enum_query_type query_type __attribute__((unused)))
4553
4554
{
4554
4555
  char *end= (char*) str_value.ptr() + str_value.length(),
4555
 
       *ptr= end - min(str_value.length(), (uint32_t)sizeof(int64_t));
 
4556
       *ptr= end - cmin(str_value.length(), (uint32_t)sizeof(int64_t));
4556
4557
  str->append("0x");
4557
4558
  for (; ptr != end ; ptr++)
4558
4559
  {
6244
6245
    /* fix variable decimals which always is NOT_FIXED_DEC */
6245
6246
    if (Field::result_merge_type(fld_type) == INT_RESULT)
6246
6247
      item_decimals= 0;
6247
 
    decimals= max((int)decimals, item_decimals);
 
6248
    decimals= cmax((int)decimals, item_decimals);
6248
6249
  }
6249
6250
  if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
6250
6251
  {
6251
 
    decimals= min((int)max(decimals, item->decimals), DECIMAL_MAX_SCALE);
6252
 
    int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
 
6252
    decimals= cmin((int)cmax(decimals, item->decimals), DECIMAL_MAX_SCALE);
 
6253
    int precision= cmin(cmax(prev_decimal_int_part, item->decimal_int_part())
6253
6254
                       + decimals, DECIMAL_MAX_PRECISION);
6254
6255
    unsigned_flag&= item->unsigned_flag;
6255
6256
    max_length= my_decimal_precision_to_length(precision, decimals,
6280
6281
     */
6281
6282
    if (collation.collation != &my_charset_bin)
6282
6283
    {
6283
 
      max_length= max(old_max_chars * collation.collation->mbmaxlen,
 
6284
      max_length= cmax(old_max_chars * collation.collation->mbmaxlen,
6284
6285
                      display_length(item) /
6285
6286
                      item->collation.collation->mbmaxlen *
6286
6287
                      collation.collation->mbmaxlen);
6295
6296
    {
6296
6297
      int delta1= max_length_orig - decimals_orig;
6297
6298
      int delta2= item->max_length - item->decimals;
6298
 
      max_length= max(delta1, delta2) + decimals;
 
6299
      max_length= cmax(delta1, delta2) + decimals;
6299
6300
      if (fld_type == DRIZZLE_TYPE_DOUBLE && max_length > DBL_DIG + 2) 
6300
6301
      {
6301
6302
        max_length= DBL_DIG + 7;
6307
6308
    break;
6308
6309
  }
6309
6310
  default:
6310
 
    max_length= max(max_length, display_length(item));
 
6311
    max_length= cmax(max_length, display_length(item));
6311
6312
  };
6312
6313
  maybe_null|= item->maybe_null;
6313
6314
  get_full_info(item);