Drizzled Public API Documentation

user_var_as_out_param.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 <cassert>
00023 
00024 #include <drizzled/function/user_var_as_out_param.h>
00025 #include <drizzled/user_var_entry.h>
00026 #include <drizzled/session.h>
00027 
00028 namespace drizzled
00029 {
00030 
00031 bool Item_user_var_as_out_param::fix_fields(Session *session, Item **ref)
00032 {
00033   assert(fixed == 0);
00034   if (Item::fix_fields(session, ref) ||
00035       !(entry= session->getVariable(name, true)))
00036     return true;
00037   entry->type= STRING_RESULT;
00038   /*
00039     Let us set the same collation which is used for loading
00040     of fields in LOAD DATA INFILE.
00041     (Since Item_user_var_as_out_param is used only there).
00042   */
00043   entry->collation.set(default_charset_info);
00044   entry->update_query_id= session->getQueryId();
00045   return false;
00046 }
00047 
00048 void Item_user_var_as_out_param::set_null_value(const CHARSET_INFO * const cs)
00049 {
00050   entry->update_hash(true, 0, 0, STRING_RESULT, cs,
00051                      DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
00052 }
00053 
00054 
00055 void Item_user_var_as_out_param::set_value(const char *str, uint32_t length,
00056                                            const CHARSET_INFO * const cs)
00057 {
00058   entry->update_hash(false, (void*)str, length, STRING_RESULT, cs,
00059                 DERIVATION_IMPLICIT, 0 /* unsigned_arg */);
00060 }
00061 
00062 double Item_user_var_as_out_param::val_real()
00063 {
00064   assert(0);
00065   return 0.0;
00066 }
00067 
00068 
00069 int64_t Item_user_var_as_out_param::val_int()
00070 {
00071   assert(0);
00072   return 0;
00073 }
00074 
00075 
00076 String* Item_user_var_as_out_param::val_str(String *)
00077 {
00078   assert(0);
00079   return 0;
00080 }
00081 
00082 type::Decimal* Item_user_var_as_out_param::val_decimal(type::Decimal *)
00083 {
00084   assert(0);
00085   return 0;
00086 }
00087 
00088 
00089 void Item_user_var_as_out_param::print(String *str)
00090 {
00091   str->append('@');
00092   str->append(name.str,name.length);
00093 }
00094 
00095 } /* namespace drizzled */