1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
36
36
return *(double*) value;
39
38
return (double) *(int64_t*) value;
41
39
case DECIMAL_RESULT:
44
class_decimal2double(E_DEC_FATAL_ERROR, (type::Decimal *)value, &result);
42
my_decimal2double(E_DEC_FATAL_ERROR, (my_decimal *)value, &result);
48
45
case STRING_RESULT:
49
46
return internal::my_atof(value); // This is null terminated
52
48
assert(1); // Impossible
68
64
return (int64_t) *(double*) value;
71
66
return *(int64_t*) value;
73
67
case DECIMAL_RESULT:
76
((type::Decimal *)(value))->val_int32(E_DEC_FATAL_ERROR, 0, &result);
70
my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, &result);
80
73
case STRING_RESULT:
83
return internal::my_strtoll10(value, (char**) 0, &error);// String is null terminated
76
return internal::my_strtoll10(value, (char**) 0, &error);// String is null terminated
87
79
assert(1); // Impossible
91
82
return 0L; // Impossible
105
96
str->set_real(*(double*) value, decimals, &my_charset_bin);
109
99
if (!unsigned_flag)
110
100
str->set(*(int64_t*) value, &my_charset_bin);
112
102
str->set(*(uint64_t*) value, &my_charset_bin);
115
104
case DECIMAL_RESULT:
116
class_decimal2string((type::Decimal *)value, 0, str);
105
my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str);
119
107
case STRING_RESULT:
120
108
if (str->copy(value, length, collation.collation))
121
109
str= 0; // EOM error
124
111
assert(1); // Impossible
131
117
/** Get the value of a variable as a decimal. */
133
type::Decimal *user_var_entry::val_decimal(bool *null_value, type::Decimal *val)
119
my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
135
121
if ((*null_value= (value == 0)))
139
125
case REAL_RESULT:
140
double2_class_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
126
double2my_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
144
int2_class_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
129
int2my_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
147
131
case DECIMAL_RESULT:
148
val= (type::Decimal *)value;
132
val= (my_decimal *)value;
151
134
case STRING_RESULT:
152
val->store(E_DEC_FATAL_ERROR, value, length, collation.collation);
135
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
156
138
assert(1); // Impossible
218
199
memcpy(value, ptr, arg_length);
219
200
if (arg_type == DECIMAL_RESULT)
220
((type::Decimal*)value)->fix_buffer_pointer();
201
((my_decimal*)value)->fix_buffer_pointer();
221
202
length= arg_length;
222
203
collation.set(cs, dv);
223
204
unsigned_flag= unsigned_arg;