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 #pragma once 00021 00022 #include <drizzled/charset_info.h> 00023 #include <drizzled/item/basic_constant.h> 00024 00025 namespace drizzled 00026 { 00027 00028 class Item_null :public Item_basic_constant 00029 { 00030 public: 00031 00032 Item_null(char *name_par=0) 00033 { 00034 maybe_null= null_value= true; 00035 max_length= 0; 00036 name= name_par ? name_par : (char*) "NULL"; 00037 fixed= 1; 00038 collation.set(&my_charset_bin, DERIVATION_IGNORABLE); 00039 } 00040 enum Type type() const { return NULL_ITEM; } 00041 bool eq(const Item *item, bool binary_cmp) const; 00042 double val_real(); 00043 int64_t val_int(); 00044 String *val_str(String *str); 00045 type::Decimal *val_decimal(type::Decimal *); 00046 int save_in_field(Field *field, bool no_conversions); 00047 int save_safe_in_field(Field *field); 00048 bool send(plugin::Client *client, String *str); 00049 enum Item_result result_type () const { return STRING_RESULT; } 00050 enum_field_types field_type() const { return DRIZZLE_TYPE_NULL; } 00051 bool basic_const_item() const { return 1; } 00052 Item *clone_item() { return new Item_null(name); } 00053 bool is_null() { return true; } 00054 00055 virtual void print(String *str); 00056 00057 Item *safe_charset_converter(const CHARSET_INFO * const tocs); 00058 }; 00059 00060 class Item_null_result :public Item_null 00061 { 00062 public: 00063 Field *result_field; 00064 Item_null_result() : Item_null(), result_field(0) {} 00065 bool is_result_field() { return result_field != 0; } 00066 void save_in_result_field(bool no_conversions) 00067 { 00068 save_in_field(result_field, no_conversions); 00069 } 00070 }; 00071 00072 } /* namespace drizzled */ 00073