38
38
assert(fixed == 1);
39
39
switch (hybrid_type) {
40
40
case DECIMAL_RESULT:
42
my_decimal decimal_value, *val;
43
if (!(val= decimal_op(&decimal_value)))
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);
42
my_decimal decimal_value, *val;
43
if (!(val= decimal_op(&decimal_value)))
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);
54
str->set_int(nr, unsigned_flag, &my_charset_bin);
54
str->set_int(nr, unsigned_flag, &my_charset_bin);
62
str->set_real(nr,decimals,&my_charset_bin);
62
str->set_real(nr,decimals,&my_charset_bin);
65
65
case STRING_RESULT:
66
66
return str_op(&str_value);
76
76
assert(fixed == 1);
77
77
switch (hybrid_type) {
78
78
case DECIMAL_RESULT:
80
my_decimal decimal_value, *val;
82
if (!(val= decimal_op(&decimal_value)))
83
return 0.0; // null is set
84
my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
80
my_decimal decimal_value, *val;
82
if (!(val= decimal_op(&decimal_value)))
83
return 0.0; // null is set
84
my_decimal2double(E_DEC_FATAL_ERROR, val, &result);
89
int64_t result= int_op();
90
return unsigned_flag ? (double) ((uint64_t) result) : (double) result;
89
int64_t result= int_op();
90
return unsigned_flag ? (double) ((uint64_t) result) : (double) result;
94
94
case STRING_RESULT:
98
String *res= str_op(&str_value);
99
return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
100
&end_not_used, &err_not_used) : 0.0);
98
String *res= str_op(&str_value);
99
return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
100
&end_not_used, &err_not_used) : 0.0);
111
112
assert(fixed == 1);
112
113
switch (hybrid_type) {
113
114
case DECIMAL_RESULT:
115
my_decimal decimal_value, *val;
116
if (!(val= decimal_op(&decimal_value)))
117
return 0; // null is set
119
my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
116
my_decimal decimal_value, *val;
117
if (!(val= decimal_op(&decimal_value)))
118
return 0; // null is set
120
my_decimal2int(E_DEC_FATAL_ERROR, val, unsigned_flag, &result);
124
125
case REAL_RESULT:
125
126
return (int64_t) rint(real_op());
126
127
case STRING_RESULT:
130
if (!(res= str_op(&str_value)))
131
if (!(res= str_op(&str_value)))
133
char *end= (char*) res->ptr() + res->length();
134
const CHARSET_INFO * const cs= str_value.charset();
135
return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
134
char *end= (char*) res->ptr() + res->length();
135
const CHARSET_INFO * const cs= str_value.charset();
136
return (*(cs->cset->strtoll10))(cs, res->ptr(), &end, &err_not_used);
146
147
my_decimal *val= decimal_value;
147
148
assert(fixed == 1);
148
150
switch (hybrid_type) {
149
151
case DECIMAL_RESULT:
150
152
val= decimal_op(decimal_value);
154
int64_t result= int_op();
155
int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
156
int64_t result= int_op();
157
int2my_decimal(E_DEC_FATAL_ERROR, result, unsigned_flag, decimal_value);
158
160
case REAL_RESULT:
160
double result= (double)real_op();
161
double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
162
double result= (double)real_op();
163
double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value);
164
166
case STRING_RESULT:
167
if (!(res= str_op(&str_value)))
169
if (!(res= str_op(&str_value)))
170
str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
171
res->length(), res->charset(), decimal_value);
172
str2my_decimal(E_DEC_FATAL_ERROR, (char*) res->ptr(),
173
res->length(), res->charset(), decimal_value);