~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/numhybrid.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

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
 
      my_decimal decimal_value, *val;
 
42
      type::Decimal decimal_value, *val;
43
43
      if (!(val= decimal_op(&decimal_value)))
44
44
        return 0;                                 // null is set
45
 
      my_decimal_round(E_DEC_FATAL_ERROR, val, decimals, false, val);
46
 
      my_decimal2string(E_DEC_FATAL_ERROR, val, 0, 0, 0, str);
 
45
      class_decimal_round(E_DEC_FATAL_ERROR, val, decimals, false, val);
 
46
      class_decimal2string(val, 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
 
      my_decimal decimal_value, *val;
 
80
      type::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
 
      my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
 
84
      class_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
 
      my_decimal decimal_value, *val;
 
116
      type::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
 
      my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
 
120
      val->val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
121
121
      return result;
122
122
    }
123
123
  case INT_RESULT:
132
132
        return 0;
133
133
 
134
134
      char *end= (char*) res->ptr() + res->length();
135
 
      const CHARSET_INFO * const cs= str_value.charset();
 
135
      const charset_info_st * const cs= str_value.charset();
136
136
      return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
137
137
    }
138
138
  case ROW_RESULT:
142
142
}
143
143
 
144
144
 
145
 
my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
 
145
type::Decimal *Item_func_numhybrid::val_decimal(type::Decimal *decimal_value)
146
146
{
147
 
  my_decimal *val= decimal_value;
 
147
  type::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
 
      int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
 
157
      int2_class_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
 
      double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
 
163
      double2_class_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
 
      str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
173
 
                     res->length(), res->charset(), decimal_value);
 
172
      decimal_value->store(E_DEC_FATAL_ERROR, (char*) res->ptr(),
 
173
                           res->length(), res->charset());
174
174
      break;
175
175
    }
176
176
  case ROW_RESULT: