971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
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 |
#ifndef DRIZZLED_PLUGIN_NULL_CLIENT_H
|
|
21 |
#define DRIZZLED_PLUGIN_NULL_CLIENT_H
|
|
22 |
||
23 |
#include <drizzled/plugin/client.h> |
|
1921.4.3
by Brian Aker
Merge in changes for multi-string |
24 |
#include<boost/tokenizer.hpp> |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
25 |
#include <vector> |
26 |
#include <queue> |
|
27 |
#include <string> |
|
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
28 |
|
29 |
namespace drizzled |
|
30 |
{
|
|
31 |
namespace plugin |
|
32 |
{
|
|
33 |
||
34 |
/**
|
|
35 |
* This class is an empty client implementation for internal used.
|
|
36 |
*/
|
|
37 |
class NullClient: public Client |
|
38 |
{
|
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
39 |
typedef std::vector<char> Bytes; |
40 |
typedef std::queue <Bytes> Queue; |
|
41 |
Queue to_execute; |
|
42 |
bool is_dead; |
|
43 |
Bytes packet_buffer; |
|
44 |
||
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
45 |
public: |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
46 |
|
47 |
NullClient() : |
|
48 |
is_dead(false) |
|
49 |
{
|
|
50 |
}
|
|
51 |
||
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
52 |
virtual int getFileDescriptor(void) { return -1; } |
53 |
virtual bool isConnected(void) { return true; } |
|
54 |
virtual bool isReading(void) { return false; } |
|
55 |
virtual bool isWriting(void) { return false; } |
|
56 |
virtual bool flush(void) { return false; } |
|
57 |
virtual void close(void) {} |
|
58 |
virtual bool authenticate(void) { return true; } |
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
59 |
|
60 |
virtual bool readCommand(char **packet, uint32_t *packet_length) |
|
61 |
{
|
|
62 |
while(not to_execute.empty()) |
|
63 |
{
|
|
64 |
Queue::value_type next= to_execute.front(); |
|
65 |
packet_buffer.resize(next.size()); |
|
66 |
memcpy(&packet_buffer[0], &next[0], next.size()); |
|
67 |
||
68 |
*packet= &packet_buffer[0]; |
|
69 |
||
70 |
*packet_length= next.size(); |
|
71 |
||
72 |
to_execute.pop(); |
|
73 |
||
74 |
return true; |
|
75 |
}
|
|
76 |
||
77 |
if (not is_dead) |
|
78 |
{
|
|
79 |
packet_buffer.resize(1); |
|
80 |
*packet_length= 1; |
|
81 |
*packet= &packet_buffer[0]; |
|
82 |
is_dead= true; |
|
83 |
||
84 |
return true; |
|
85 |
}
|
|
86 |
||
87 |
*packet_length= 0; |
|
88 |
return false; |
|
89 |
}
|
|
90 |
||
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
91 |
virtual void sendOK(void) {} |
92 |
virtual void sendEOF(void) {} |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
93 |
virtual void sendError(uint32_t, const char*) {} |
94 |
virtual bool sendFields(List<Item>*) { return false; } |
|
95 |
virtual bool store(Field *) { return false; } |
|
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
96 |
virtual bool store(void) { return false; } |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
97 |
virtual bool store(int32_t) { return false; } |
98 |
virtual bool store(uint32_t) { return false; } |
|
99 |
virtual bool store(int64_t) { return false; } |
|
100 |
virtual bool store(uint64_t) { return false; } |
|
101 |
virtual bool store(double, uint32_t, String*) { return false; } |
|
102 |
virtual bool store(const DRIZZLE_TIME*) { return false; } |
|
103 |
virtual bool store(const char*) { return false; } |
|
104 |
virtual bool store(const char*, size_t) { return false; } |
|
1245.2.4
by Monty Taylor
Fixed the store methods to take std::string properly. |
105 |
virtual bool store(const std::string &) { return false; } |
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
106 |
virtual bool haveMoreData(void) { return false;} |
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
107 |
virtual bool haveError(void) { return false; } |
108 |
virtual bool wasAborted(void) { return false; } |
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
109 |
|
110 |
void pushSQL(const std::string &arg) |
|
111 |
{
|
|
112 |
Bytes byte; |
|
1921.4.3
by Brian Aker
Merge in changes for multi-string |
113 |
typedef boost::tokenizer<boost::escaped_list_separator<char> > Tokenizer; |
114 |
Tokenizer tok(arg, boost::escaped_list_separator<char>("\\", ";", "\"")); |
|
115 |
||
116 |
for (Tokenizer::iterator iter= tok.begin(); iter != tok.end(); ++iter) |
|
117 |
{
|
|
118 |
byte.resize((*iter).size() +1); // +1 for the COM_QUERY |
|
119 |
byte[0]= COM_QUERY; |
|
120 |
memcpy(&byte[1], (*iter).c_str(), (*iter).size()); |
|
121 |
to_execute.push(byte); |
|
122 |
}
|
|
1921.4.2
by Brian Aker
Adding in concurrent execute support. |
123 |
}
|
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
124 |
};
|
125 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
126 |
} /* namespace plugin */ |
127 |
} /* namespace drizzled */ |
|
971.6.10
by Eric Day
Added NULL client for rm_tmp_table. |
128 |
|
129 |
#endif /* DRIZZLED_PLUGIN_NULL_CLIENT_H */ |