Drizzled Public API Documentation

select_result.h

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 
00021 #pragma once
00022 
00023 #include <drizzled/current_session.h>
00024 
00025 namespace drizzled
00026 {
00027 
00028 class Join;
00029 class Select_Lex_Unit;
00030 
00031 class select_result :public memory::SqlAlloc {
00032 protected:
00033   Session *session;
00034   Select_Lex_Unit *unit;
00035 
00036 public:
00037   select_result()
00038   {
00039     session= current_session;
00040   }
00041   virtual ~select_result() {}
00042   virtual int prepare(List<Item> &,
00043                       Select_Lex_Unit *u)
00044   {
00045     unit= u;
00046     return 0;
00047   }
00048   /*
00049     Because of peculiarities of prepared statements protocol
00050     we need to know number of columns in the result set (if
00051     there is a result set) apart from sending columns metadata.
00052   */
00053   virtual uint32_t field_count(List<Item> &fields) const
00054   { return fields.size(); }
00055   virtual bool send_fields(List<Item> &list)=0;
00056   virtual bool send_data(List<Item> &items)=0;
00057   virtual bool initialize_tables (Join *)
00058   { return 0; }
00059   virtual bool send_eof()=0;
00060   virtual void abort() {}
00061   void set_session(Session *session_arg) { session= session_arg; }
00062   void begin_dataset() {}
00063 
00064   /*****************************************************************************
00065    ** Functions to provide a interface to select results
00066    *****************************************************************************/
00067 
00068   virtual void send_error(drizzled::error_t errcode, const char *err);
00069 
00070   /*
00071     Cleanup instance of this class for next execution of a prepared
00072     statement/stored procedure.
00073   */
00074   virtual void cleanup()
00075   {
00076     /* do nothing */
00077   }
00078 
00079 };
00080 
00081 } /* namespace drizzled */
00082