~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/numhybrid.cc

  • Committer: Brian Aker
  • Date: 2010-12-23 22:20:46 UTC
  • mto: (2026.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2027.
  • Revision ID: brian@tangent.org-20101223222046-152kydsd1cyexfme
Update to tests, we just want to look at our own tables, not global.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
#include <math.h>
22
22
#include <drizzled/function/numhybrid.h>
23
23
 
39
39
  switch (hybrid_type) {
40
40
  case DECIMAL_RESULT:
41
41
    {
42
 
      type::Decimal decimal_value, *val;
 
42
      my_decimal decimal_value, *val;
43
43
      if (!(val= decimal_op(&decimal_value)))
44
44
        return 0;                                 // null is set
45
 
      class_decimal_round(E_DEC_FATAL_ERROR, val, decimals, false, val);
46
 
      class_decimal2string(val, 0, str);
 
45
      my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, false, val);
 
46
      my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str);
47
47
      break;
48
48
    }
49
49
  case INT_RESULT:
77
77
  switch (hybrid_type) {
78
78
  case DECIMAL_RESULT:
79
79
    {
80
 
      type::Decimal decimal_value, *val;
 
80
      my_decimal decimal_value, *val;
81
81
      double result;
82
82
      if (!(val= decimal_op(&decimal_value)))
83
83
        return 0.0;                               // null is set
84
 
      class_decimal2double(E_DEC_FATAL_ERROR, val, &result);
 
84
      my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
85
85
      return result;
86
86
    }
87
87
  case INT_RESULT:
113
113
  switch (hybrid_type) {
114
114
  case DECIMAL_RESULT:
115
115
    {
116
 
      type::Decimal decimal_value, *val;
 
116
      my_decimal decimal_value, *val;
117
117
      if (!(val= decimal_op(&decimal_value)))
118
118
        return 0;                                 // null is set
119
119
      int64_t result;
120
 
      val->val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
 
120
      my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
121
121
      return result;
122
122
    }
123
123
  case INT_RESULT:
142
142
}
143
143
 
144
144
 
145
 
type::Decimal *Item_func_numhybrid::val_decimal(type::Decimal *decimal_value)
 
145
my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
146
146
{
147
 
  type::Decimal *val= decimal_value;
 
147
  my_decimal *val= decimal_value;
148
148
  assert(fixed == 1);
149
149
 
150
150
  switch (hybrid_type) {
154
154
  case INT_RESULT:
155
155
    {
156
156
      int64_t result= int_op();
157
 
      int2_class_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
 
157
      int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
158
158
      break;
159
159
    }
160
160
  case REAL_RESULT:
161
161
    {
162
162
      double result= (double)real_op();
163
 
      double2_class_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
 
163
      double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
164
164
      break;
165
165
    }
166
166
  case STRING_RESULT:
169
169
      if (!(res= str_op(&str_value)))
170
170
        return NULL;
171
171
 
172
 
      decimal_value->store(E_DEC_FATAL_ERROR, (char*) res->ptr(),
173
 
                           res->length(), res->charset());
 
172
      str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
 
173
                     res->length(), res->charset(), decimal_value);
174
174
      break;
175
175
    }
176
176
  case ROW_RESULT: