Drizzled Public API Documentation

select_dumpvar.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/select_dumpvar.h>
00023 #include <drizzled/sql_lex.h>
00024 #include <drizzled/session.h>
00025 #include <drizzled/var.h>
00026 
00027 namespace drizzled {
00028 
00029 bool select_dumpvar::send_data(List<Item> &items)
00030 {
00031   if (unit->offset_limit_cnt)
00032   {           // using limit offset,count
00033     unit->offset_limit_cnt--;
00034     return 0;
00035   }
00036   if (row_count++)
00037   {
00038     my_message(ER_TOO_MANY_ROWS, ER(ER_TOO_MANY_ROWS), MYF(0));
00039     return 1;
00040   }
00041   List<Item>::iterator it(items.begin());
00042   BOOST_FOREACH(var* current_var, var_list)
00043   {
00044     Item* item= it++;
00045     if (not item)
00046       break;
00047     if (current_var->local)
00048       continue;
00049     Item_func_set_user_var *suv= new Item_func_set_user_var(current_var->s, item);
00050     suv->fix_fields(session, 0);
00051     suv->check(0);
00052     suv->update();
00053   }
00054   return session->is_error();
00055 }
00056 
00057 bool select_dumpvar::send_eof()
00058 {
00059   if (not row_count)
00060     push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_SP_FETCH_NO_DATA, ER(ER_SP_FETCH_NO_DATA));
00061   /*
00062     In order to remember the value of affected rows for ROW_COUNT()
00063     function, SELECT INTO has to have an own SQLCOM.
00064     @TODO split from SQLCOM_SELECT
00065   */
00066   session->my_ok(row_count);
00067   return 0;
00068 }
00069 
00070 int select_dumpvar::prepare(List<Item> &list, Select_Lex_Unit *u)
00071 {
00072   unit= u;
00073   if (var_list.size() == list.size())
00074     return 0;
00075   my_message(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, ER(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT), MYF(0));
00076   return 1;
00077 }
00078 
00079 } // namespace drizzled