~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/null.cc

  • Committer: Jim Winstead
  • Date: 2008-07-19 02:56:45 UTC
  • mto: (202.1.8 codestyle)
  • mto: This revision was merged to the branch mainline in revision 207.
  • Revision ID: jimw@mysql.com-20080719025645-w2pwytebgzusjzjb
Various fixes to enable compilation on Mac OS X, and remove the glib dependency.
Temporarily disables tab-completion in the drizzle client until an appropriate
autoconf check can be added/enabled.

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