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
17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
21
#include <drizzled/session.h>
23
#include <drizzled/internal/m_string.h>
24
#include <drizzled/user_var_entry.h>
22
#include "drizzled/internal/m_string.h"
38
36
return *(double*) value;
41
38
return (double) *(int64_t*) value;
43
39
case DECIMAL_RESULT:
46
class_decimal2double(E_DEC_FATAL_ERROR, (type::Decimal *)value, &result);
42
my_decimal2double(E_DEC_FATAL_ERROR, (my_decimal *)value, &result);
50
45
case STRING_RESULT:
51
46
return internal::my_atof(value); // This is null terminated
54
48
assert(1); // Impossible
70
64
return (int64_t) *(double*) value;
73
66
return *(int64_t*) value;
75
67
case DECIMAL_RESULT:
78
((type::Decimal *)(value))->val_int32(E_DEC_FATAL_ERROR, 0, &result);
70
my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, &result);
82
73
case STRING_RESULT:
85
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
89
79
assert(1); // Impossible
93
82
return 0L; // Impossible
107
96
str->set_real(*(double*) value, decimals, &my_charset_bin);
111
99
if (!unsigned_flag)
112
100
str->set(*(int64_t*) value, &my_charset_bin);
114
102
str->set(*(uint64_t*) value, &my_charset_bin);
117
104
case DECIMAL_RESULT:
118
class_decimal2string((type::Decimal *)value, 0, str);
105
my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str);
121
107
case STRING_RESULT:
122
108
if (str->copy(value, length, collation.collation))
123
109
str= 0; // EOM error
126
111
assert(1); // Impossible
133
117
/** Get the value of a variable as a decimal. */
135
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)
137
121
if ((*null_value= (value == 0)))
141
125
case REAL_RESULT:
142
double2_class_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
126
double2my_decimal(E_DEC_FATAL_ERROR, *(double*) value, val);
146
int2_class_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
129
int2my_decimal(E_DEC_FATAL_ERROR, *(int64_t*) value, 0, val);
149
131
case DECIMAL_RESULT:
150
val= (type::Decimal *)value;
132
val= (my_decimal *)value;
153
134
case STRING_RESULT:
154
val->store(E_DEC_FATAL_ERROR, value, length, collation.collation);
135
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
158
138
assert(1); // Impossible
220
199
memcpy(value, ptr, arg_length);
221
200
if (arg_type == DECIMAL_RESULT)
222
((type::Decimal*)value)->fix_buffer_pointer();
201
((my_decimal*)value)->fix_buffer_pointer();
223
202
length= arg_length;
224
203
collation.set(cs, dv);
225
204
unsigned_flag= unsigned_arg;