00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <drizzled/plugin/client.h>
00024 #include <drizzled/plugin/query_cache.h>
00025 #include <drizzled/plugin/transactional_storage_engine.h>
00026 #include <drizzled/select_result.h>
00027 #include <drizzled/sql_lex.h>
00028
00029 namespace drizzled
00030 {
00031
00032 class select_send :public select_result {
00038 bool is_result_set_started;
00039 public:
00040 select_send() :is_result_set_started(false) {}
00041 bool send_eof()
00042 {
00043
00044
00045
00046
00047
00048 plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
00049
00050
00051 if (session->lock)
00052 {
00053 session->unlockTables(session->lock);
00054 session->lock= 0;
00055 }
00056 session->my_eof();
00057 is_result_set_started= 0;
00058 return false;
00059 }
00060
00061 bool send_fields(List<Item> &list)
00062 {
00063 bool res;
00064 if (! (res= session->getClient()->sendFields(&list)))
00065 is_result_set_started= 1;
00066 return res;
00067 }
00068
00069 void abort()
00070 {
00071 return;
00072 }
00073
00074
00081 virtual void cleanup()
00082 {
00083 is_result_set_started= false;
00084 }
00085
00086
00087
00088 bool send_data(List<Item> &items)
00089 {
00090 if (unit->offset_limit_cnt)
00091 {
00092 unit->offset_limit_cnt--;
00093 return false;
00094 }
00095
00096
00097
00098
00099
00100
00101 plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
00102
00103 List<Item>::iterator li(items.begin());
00104 char buff[MAX_FIELD_WIDTH];
00105 String buffer(buff, sizeof(buff), &my_charset_bin);
00106
00107 Item *item;
00108 while ((item=li++))
00109 {
00110 if (item->send(session->getClient(), &buffer))
00111 {
00112 my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
00113 break;
00114 }
00115 }
00116
00117 if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
00118 plugin::QueryCache::insertRecord(session, items);
00119
00120 session->sent_row_count++;
00121 if (session->is_error())
00122 return true;
00123 return session->getClient()->flush();
00124 }
00125 };
00126
00127 }
00128