1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
22
#include <drizzled/item/int.h>
25
Create an item from a string we KNOW points to a valid int64_t
26
end \\0 terminated number string.
27
This is always 'signed'. Unsigned values are created with Item_uint()
30
Item_int::Item_int(const char *str_arg, uint32_t length)
32
char *end_ptr= (char*) str_arg + length;
34
value= my_strtoll10(str_arg, &end_ptr, &error);
35
max_length= (uint) (end_ptr - str_arg);
36
name= (char*) str_arg;
40
my_decimal *Item_int::val_decimal(my_decimal *decimal_value)
42
int2my_decimal(E_DEC_FATAL_ERROR, value, unsigned_flag, decimal_value);
46
String *Item_int::val_str(String *str)
48
// following assert is redundant, because fixed=1 assigned in constructor
50
str->set(value, &my_charset_bin);
54
void Item_int::print(String *str, enum_query_type)
56
// my_charset_bin is good enough for numbers
57
str_value.set(value, &my_charset_bin);
58
str->append(str_value);
61
int Item_int::save_in_field(Field *field, bool)
65
return set_field_to_null(field);
67
return field->store(nr, unsigned_flag);
70
bool Item_int::eq(const Item *arg, bool) const
72
/* No need to check for null value as basic constant can't be NULL */
73
if (arg->basic_const_item() && arg->type() == type())
76
We need to cast off const to call val_int(). This should be OK for
79
Item *item= (Item*) arg;
80
return item->val_int() == value && item->unsigned_flag == unsigned_flag;