23
23
#include <drizzled/field/num.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/table.h>
26
26
#include <drizzled/session.h>
27
#include "drizzled/internal/my_sys.h"
27
#include <drizzled/internal/my_sys.h>
28
#include <drizzled/util/test.h>
29
#include <drizzled/create_field.h>
33
34
Numeric fields base class constructor.
35
Field_num::Field_num(unsigned char *ptr_arg,uint32_t len_arg, unsigned char *null_ptr_arg,
36
unsigned char null_bit_arg, utype unireg_check_arg,
36
Field_num::Field_num(unsigned char *ptr_arg,
38
unsigned char *null_ptr_arg,
39
unsigned char null_bit_arg,
40
utype unireg_check_arg,
37
41
const char *field_name_arg,
38
uint8_t dec_arg, bool zero_arg, bool unsigned_arg)
39
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
40
unireg_check_arg, field_name_arg),
41
dec(dec_arg),decimal_precision(zero_arg), unsigned_flag(unsigned_arg)
52
decimal_precision(zero_arg),
53
unsigned_flag(unsigned_arg)
65
77
2 error: garbage at the end of string.
68
int Field_num::check_int(const CHARSET_INFO * const cs, const char *str, int length,
80
int Field_num::check_int(const charset_info_st * const cs, const char *str, int length,
69
81
const char *int_end, int error)
71
83
/* Test if we get an empty string or wrong integer */
72
if (str == int_end || error == MY_ERRNO_EDOM)
84
if (str == int_end || error == EDOM)
75
87
String tmp(buff, (uint32_t) sizeof(buff), system_charset_info);
116
bool Field_num::get_int(const CHARSET_INFO * const cs, const char *from, uint32_t len,
128
bool Field_num::get_int(const charset_info_st * const cs, const char *from, uint32_t len,
117
129
int64_t *rnd, uint64_t ,
118
130
int64_t signed_min, int64_t signed_max)
177
190
pointer to decimal buffer with value of field
180
my_decimal* Field_num::val_decimal(my_decimal *decimal_value)
193
type::Decimal* Field_num::val_decimal(type::Decimal *decimal_value) const
182
195
assert(result_type() == INT_RESULT);
184
197
int64_t nr= val_int();
185
int2my_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
198
int2_class_decimal(E_DEC_FATAL_ERROR, nr, false, decimal_value);
186
199
return decimal_value;
211
224
uint32_t Field_num::is_equal(CreateField *new_field_ptr)
213
226
return ((new_field_ptr->sql_type == real_type()) &&
214
((new_field_ptr->flags & UNSIGNED_FLAG) ==
215
(uint32_t) (flags & UNSIGNED_FLAG)) &&
216
((new_field_ptr->flags & AUTO_INCREMENT_FLAG) ==
217
(uint32_t) (flags & AUTO_INCREMENT_FLAG)) &&
227
((new_field_ptr->flags & UNSIGNED_FLAG) == (uint32_t) (flags & UNSIGNED_FLAG)) &&
228
((new_field_ptr->flags & AUTO_INCREMENT_FLAG) == (uint32_t) (flags & AUTO_INCREMENT_FLAG)) &&
218
229
(new_field_ptr->length <= max_display_length()));