1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_SELECT_SEND_H
22
#define DRIZZLED_SELECT_SEND_H
24
#include <drizzled/plugin/client.h>
25
#include <drizzled/plugin/query_cache.h>
26
#include <drizzled/plugin/transactional_storage_engine.h>
31
class select_send :public select_result {
33
True if we have sent result set metadata to the client.
34
In this case the client always expects us to end the result
35
set with an eof or error packet
37
bool is_result_set_started;
39
select_send() :is_result_set_started(false) {}
43
We may be passing the control from mysqld to the client: release the
44
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
47
plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
49
/* Unlock tables before sending packet to gain some speed */
52
session->unlockTables(session->lock);
56
is_result_set_started= 0;
60
bool send_fields(List<Item> &list)
63
if (! (res= session->client->sendFields(&list)))
64
is_result_set_started= 1;
75
Cleanup an instance of this class for re-use
76
at next execution of a prepared statement/
77
stored procedure statement.
80
virtual void cleanup()
82
is_result_set_started= false;
85
/* Send data to client. Returns 0 if ok */
87
bool send_data(List<Item> &items)
89
if (unit->offset_limit_cnt)
90
{ // using limit offset,count
91
unit->offset_limit_cnt--;
96
We may be passing the control from mysqld to the client: release the
97
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
100
plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
102
List_iterator_fast<Item> li(items);
103
char buff[MAX_FIELD_WIDTH];
104
String buffer(buff, sizeof(buff), &my_charset_bin);
109
if (item->send(session->client, &buffer))
111
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
115
/* Insert this record to the Resultset into the cache */
116
if (session->query_cache_key != "" && session->getResultsetMessage() != NULL)
117
plugin::QueryCache::insertRecord(session, items);
119
session->sent_row_count++;
120
if (session->is_error())
122
return session->client->flush();
126
} /* namespace drizzled */
128
#endif /* DRIZZLED_SELECT_SEND_H */