~drizzle-trunk/drizzle/development

642.1.4 by Lee
move functions from item.cc/item.h to item directory
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
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.
9
 *
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.
14
 *
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
18
 */
19
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
20
#include "config.h"
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
21
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
22
#include <drizzled/plugin/client.h>
642.1.4 by Lee
move functions from item.cc/item.h to item directory
23
#include <drizzled/item/null.h>
670.2.4 by Monty Taylor
Removed more stuff from the headers.
24
#include <drizzled/lex_string.h>
642.1.4 by Lee
move functions from item.cc/item.h to item directory
25
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
26
namespace drizzled
27
{
971.3.65 by Eric Day
Namespace cleanup for Protocol and Listen.
28
642.1.4 by Lee
move functions from item.cc/item.h to item directory
29
bool Item_null::eq(const Item *item, bool) const
30
{ return item->type() == type(); }
31
32
double Item_null::val_real()
33
{
34
  // following assert is redundant, because fixed=1 assigned in constructor
35
  assert(fixed == 1);
36
  null_value=1;
37
  return 0.0;
38
}
39
int64_t Item_null::val_int()
40
{
41
  // following assert is redundant, because fixed=1 assigned in constructor
42
  assert(fixed == 1);
43
  null_value=1;
44
  return 0;
45
}
46
/* ARGSUSED */
47
String *Item_null::val_str(String *)
48
{
49
  // following assert is redundant, because fixed=1 assigned in constructor
50
  assert(fixed == 1);
51
  null_value=1;
52
  return 0;
53
}
54
55
my_decimal *Item_null::val_decimal(my_decimal *)
56
{
57
  return 0;
58
}
59
670.2.4 by Monty Taylor
Removed more stuff from the headers.
60
61
void Item_null::print(String *str, enum_query_type)
62
{
63
  str->append(STRING_WITH_LEN("NULL"));
64
}
65
66
642.1.4 by Lee
move functions from item.cc/item.h to item directory
67
Item *Item_null::safe_charset_converter(const CHARSET_INFO * const tocs)
68
{
69
  collation.set(tocs);
70
  return this;
71
}
72
73
/**
74
  Store null in field.
75
76
  This is used on INSERT.
77
  Allow NULL to be inserted in timestamp and auto_increment values.
78
79
  @param field          Field where we want to store NULL
80
81
  @retval
82
    0   ok
83
  @retval
84
    1   Field doesn't support NULL values and can't handle 'field = NULL'
85
*/
86
87
int Item_null::save_in_field(Field *field, bool no_conversions)
88
{
89
  return set_field_to_null_with_conversions(field, no_conversions);
90
}
91
92
/**
93
  Store null in field.
94
95
  @param field          Field where we want to store NULL
96
97
  @retval
98
    0    OK
99
  @retval
100
    1    Field doesn't support NULL values
101
*/
102
103
int Item_null::save_safe_in_field(Field *field)
104
{
105
  return set_field_to_null(field);
106
}
107
108
/**
109
  Pack data in buffer for sending.
110
*/
111
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
112
bool Item_null::send(plugin::Client *client, String *)
642.1.4 by Lee
move functions from item.cc/item.h to item directory
113
{
971.6.1 by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way.
114
  return client->store();
642.1.4 by Lee
move functions from item.cc/item.h to item directory
115
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
116
117
} /* namespace drizzled */