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