~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.cc

  • Committer: Brian Aker
  • Date: 2010-12-27 23:56:33 UTC
  • mfrom: (2034.2.5 clean)
  • Revision ID: brian@tangent.org-20101227235633-9wwf7j35lkf0g262
Merge in additional encapsulation of Decimal

Show diffs side-by-side

added added

removed removed

Lines of Context:
683
683
    break;
684
684
  case DECIMAL_RESULT:
685
685
    max_length= item->max_length;
686
 
    class_decimal_set_zero(&sum_dec);
 
686
    sum_dec.set_zero();
687
687
    break;
688
688
  case REAL_RESULT:
689
689
    max_length= float_length(decimals);
784
784
  if (hybrid_type == DECIMAL_RESULT)
785
785
  {
786
786
    curr_dec_buff= 0;
787
 
    class_decimal_set_zero(dec_buffs);
 
787
    dec_buffs->set_zero();
788
788
  }
789
789
  else
790
790
    sum= 0.0;
811
811
                                                 unsigned_flag);
812
812
      curr_dec_buff= 0;
813
813
      hybrid_type= DECIMAL_RESULT;
814
 
      class_decimal_set_zero(dec_buffs);
 
814
      dec_buffs->set_zero();
815
815
      break;
816
816
    }
817
817
  case ROW_RESULT:
849
849
  if (hybrid_type == DECIMAL_RESULT)
850
850
  {
851
851
    int64_t result;
852
 
    class_decimal2int(E_DEC_FATAL_ERROR, dec_buffs + curr_dec_buff, unsigned_flag,
853
 
                   &result);
 
852
    (dec_buffs + curr_dec_buff)->val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
854
853
    return result;
855
854
  }
856
855
  return (int64_t) rint(val_real());
1603
1602
    sum_int= 0;
1604
1603
    break;
1605
1604
  case DECIMAL_RESULT:
1606
 
    class_decimal_set_zero(&sum_dec);
 
1605
    sum_dec.set_zero();
1607
1606
    break;
1608
1607
  case REAL_RESULT:
1609
1608
    sum= 0.0;
1656
1655
  case DECIMAL_RESULT:
1657
1656
  {
1658
1657
    int64_t result;
1659
 
    class_decimal2int(E_DEC_FATAL_ERROR, &sum_dec, unsigned_flag, &result);
 
1658
    sum_dec.val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
1660
1659
    return sum_int;
1661
1660
  }
1662
1661
  default:
1673
1672
 
1674
1673
  switch (hybrid_type) {
1675
1674
  case STRING_RESULT:
1676
 
    string2_class_decimal(E_DEC_FATAL_ERROR, &value, val);
 
1675
    val->store(E_DEC_FATAL_ERROR, &value);
1677
1676
    break;
1678
1677
  case REAL_RESULT:
1679
1678
    double2_class_decimal(E_DEC_FATAL_ERROR, sum, val);
2080
2079
    }
2081
2080
    else
2082
2081
      tmp= 1;
2083
 
    class_decimal2binary(E_DEC_FATAL_ERROR, arg_dec, res, f_precision, f_scale);
 
2082
    arg_dec->val_binary(E_DEC_FATAL_ERROR, res, f_precision, f_scale);
2084
2083
    res+= dec_bin_size;
2085
2084
    int8store(res, tmp);
2086
2085
  }
2183
2182
                        dec_buffs + 1, f_precision, f_scale);
2184
2183
      field_count= sint8korr(res + dec_bin_size);
2185
2184
      class_decimal_add(E_DEC_FATAL_ERROR, dec_buffs, arg_val, dec_buffs + 1);
2186
 
      class_decimal2binary(E_DEC_FATAL_ERROR, dec_buffs,
2187
 
                        res, f_precision, f_scale);
 
2185
      dec_buffs->val_binary(E_DEC_FATAL_ERROR, res, f_precision, f_scale);
2188
2186
      res+= dec_bin_size;
2189
2187
      field_count++;
2190
2188
      int8store(res, field_count);