Drizzled Public API Documentation

null.cc

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #include <config.h>
00021 
00022 #include <drizzled/field.h>
00023 #include <drizzled/item/null.h>
00024 #include <drizzled/lex_string.h>
00025 #include <drizzled/plugin/client.h>
00026 
00027 namespace drizzled
00028 {
00029 
00030 bool Item_null::eq(const Item *item, bool) const
00031 { return item->type() == type(); }
00032 
00033 double Item_null::val_real()
00034 {
00035   // following assert is redundant, because fixed=1 assigned in constructor
00036   assert(fixed == 1);
00037   null_value=1;
00038   return 0.0;
00039 }
00040 int64_t Item_null::val_int()
00041 {
00042   // following assert is redundant, because fixed=1 assigned in constructor
00043   assert(fixed == 1);
00044   null_value=1;
00045   return 0;
00046 }
00047 /* ARGSUSED */
00048 String *Item_null::val_str(String *)
00049 {
00050   // following assert is redundant, because fixed=1 assigned in constructor
00051   assert(fixed == 1);
00052   null_value=1;
00053   return 0;
00054 }
00055 
00056 type::Decimal *Item_null::val_decimal(type::Decimal *)
00057 {
00058   return 0;
00059 }
00060 
00061 
00062 void Item_null::print(String *str)
00063 {
00064   str->append(STRING_WITH_LEN("NULL"));
00065 }
00066 
00067 
00068 Item *Item_null::safe_charset_converter(const CHARSET_INFO * const tocs)
00069 {
00070   collation.set(tocs);
00071   return this;
00072 }
00073 
00088 int Item_null::save_in_field(Field *field, bool no_conversions)
00089 {
00090   return set_field_to_null_with_conversions(field, no_conversions);
00091 }
00092 
00104 int Item_null::save_safe_in_field(Field *field)
00105 {
00106   return set_field_to_null(field);
00107 }
00108 
00113 bool Item_null::send(plugin::Client *client, String *)
00114 {
00115   return client->store();
00116 }
00117 
00118 } /* namespace drizzled */