~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/null.cc

  • Committer: Monty Taylor
  • Date: 2009-09-30 07:01:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090930070132-b1ol1xu1rpajdddy
Small namespace cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/plugin/client.h>
 
23
#include <drizzled/item/null.h>
 
24
#include <drizzled/lex_string.h>
 
25
 
 
26
using namespace drizzled;
 
27
 
 
28
bool Item_null::eq(const Item *item, bool) const
 
29
{ return item->type() == type(); }
 
30
 
 
31
double Item_null::val_real()
 
32
{
 
33
  // following assert is redundant, because fixed=1 assigned in constructor
 
34
  assert(fixed == 1);
 
35
  null_value=1;
 
36
  return 0.0;
 
37
}
 
38
int64_t Item_null::val_int()
 
39
{
 
40
  // following assert is redundant, because fixed=1 assigned in constructor
 
41
  assert(fixed == 1);
 
42
  null_value=1;
 
43
  return 0;
 
44
}
 
45
/* ARGSUSED */
 
46
String *Item_null::val_str(String *)
 
47
{
 
48
  // following assert is redundant, because fixed=1 assigned in constructor
 
49
  assert(fixed == 1);
 
50
  null_value=1;
 
51
  return 0;
 
52
}
 
53
 
 
54
my_decimal *Item_null::val_decimal(my_decimal *)
 
55
{
 
56
  return 0;
 
57
}
 
58
 
 
59
 
 
60
void Item_null::print(String *str, enum_query_type)
 
61
{
 
62
  str->append(STRING_WITH_LEN("NULL"));
 
63
}
 
64
 
 
65
 
 
66
Item *Item_null::safe_charset_converter(const CHARSET_INFO * const tocs)
 
67
{
 
68
  collation.set(tocs);
 
69
  return this;
 
70
}
 
71
 
 
72
/**
 
73
  Store null in field.
 
74
 
 
75
  This is used on INSERT.
 
76
  Allow NULL to be inserted in timestamp and auto_increment values.
 
77
 
 
78
  @param field          Field where we want to store NULL
 
79
 
 
80
  @retval
 
81
    0   ok
 
82
  @retval
 
83
    1   Field doesn't support NULL values and can't handle 'field = NULL'
 
84
*/
 
85
 
 
86
int Item_null::save_in_field(Field *field, bool no_conversions)
 
87
{
 
88
  return set_field_to_null_with_conversions(field, no_conversions);
 
89
}
 
90
 
 
91
/**
 
92
  Store null in field.
 
93
 
 
94
  @param field          Field where we want to store NULL
 
95
 
 
96
  @retval
 
97
    0    OK
 
98
  @retval
 
99
    1    Field doesn't support NULL values
 
100
*/
 
101
 
 
102
int Item_null::save_safe_in_field(Field *field)
 
103
{
 
104
  return set_field_to_null(field);
 
105
}
 
106
 
 
107
/**
 
108
  Pack data in buffer for sending.
 
109
*/
 
110
 
 
111
bool Item_null::send(plugin::Client *client, String *)
 
112
{
 
113
  return client->store();
 
114
}