837
by Brian Aker
Reworked some classes out of session.h |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
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.
|
|
9 |
*
|
|
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.
|
|
14 |
*
|
|
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
|
|
18 |
*/
|
|
19 |
||
20 |
||
21 |
#ifndef DRIZZLED_SELECT_SEND_H
|
|
22 |
#define DRIZZLED_SELECT_SEND_H
|
|
23 |
||
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
24 |
#include <drizzled/plugin/client.h> |
25 |
||
837
by Brian Aker
Reworked some classes out of session.h |
26 |
class select_send :public select_result { |
27 |
/**
|
|
28 |
True if we have sent result set metadata to the client.
|
|
29 |
In this case the client always expects us to end the result
|
|
30 |
set with an eof or error packet
|
|
31 |
*/
|
|
32 |
bool is_result_set_started; |
|
33 |
public: |
|
34 |
select_send() :is_result_set_started(false) {} |
|
35 |
bool send_eof() |
|
36 |
{
|
|
37 |
/*
|
|
38 |
We may be passing the control from mysqld to the client: release the
|
|
39 |
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
|
|
40 |
by session
|
|
41 |
*/
|
|
1152.1.4
by Brian Aker
Remove wrappers from SE |
42 |
drizzled::plugin::StorageEngine::releaseTemporaryLatches(session); |
837
by Brian Aker
Reworked some classes out of session.h |
43 |
|
44 |
/* Unlock tables before sending packet to gain some speed */
|
|
45 |
if (session->lock) |
|
46 |
{
|
|
47 |
mysql_unlock_tables(session, session->lock); |
|
48 |
session->lock= 0; |
|
49 |
}
|
|
50 |
session->my_eof(); |
|
51 |
is_result_set_started= 0; |
|
52 |
return false; |
|
53 |
}
|
|
54 |
||
971.3.63
by Eric Day
Removed protocol field flags. |
55 |
bool send_fields(List<Item> &list) |
837
by Brian Aker
Reworked some classes out of session.h |
56 |
{
|
57 |
bool res; |
|
971.6.4
by Eric Day
Merged cleanup from my merge branch. |
58 |
if (! (res= session->client->sendFields(&list))) |
837
by Brian Aker
Reworked some classes out of session.h |
59 |
is_result_set_started= 1; |
60 |
return res; |
|
61 |
}
|
|
62 |
||
63 |
void abort() |
|
64 |
{
|
|
65 |
return; |
|
66 |
}
|
|
67 |
||
68 |
||
69 |
/**
|
|
70 |
Cleanup an instance of this class for re-use
|
|
71 |
at next execution of a prepared statement/
|
|
72 |
stored procedure statement.
|
|
73 |
*/
|
|
74 |
||
75 |
virtual void cleanup() |
|
76 |
{
|
|
77 |
is_result_set_started= false; |
|
78 |
}
|
|
79 |
||
80 |
/* Send data to client. Returns 0 if ok */
|
|
81 |
||
82 |
bool send_data(List<Item> &items) |
|
83 |
{
|
|
84 |
if (unit->offset_limit_cnt) |
|
85 |
{ // using limit offset,count |
|
86 |
unit->offset_limit_cnt--; |
|
87 |
return false; |
|
88 |
}
|
|
89 |
||
90 |
/*
|
|
91 |
We may be passing the control from mysqld to the client: release the
|
|
92 |
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
|
|
93 |
by session
|
|
94 |
*/
|
|
1152.1.4
by Brian Aker
Remove wrappers from SE |
95 |
drizzled::plugin::StorageEngine::releaseTemporaryLatches(session); |
837
by Brian Aker
Reworked some classes out of session.h |
96 |
|
97 |
List_iterator_fast<Item> li(items); |
|
98 |
char buff[MAX_FIELD_WIDTH]; |
|
99 |
String buffer(buff, sizeof(buff), &my_charset_bin); |
|
100 |
||
101 |
Item *item; |
|
102 |
while ((item=li++)) |
|
103 |
{
|
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
104 |
if (item->send(session->client, &buffer)) |
837
by Brian Aker
Reworked some classes out of session.h |
105 |
{
|
106 |
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); |
|
107 |
break; |
|
108 |
}
|
|
109 |
}
|
|
110 |
session->sent_row_count++; |
|
111 |
if (session->is_error()) |
|
112 |
return true; |
|
971.6.1
by Eric Day
Renamed Protocol to Client, cleaned up some unnecessary methods along the way. |
113 |
return session->client->flush(); |
837
by Brian Aker
Reworked some classes out of session.h |
114 |
}
|
115 |
};
|
|
116 |
||
117 |
#endif /* DRIZZLED_SELECT_SEND_H */ |