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