1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
3 |
*
|
|
1812.3.2
by Brian Aker
Merge with trunk. |
4 |
<<<<<<< TREE
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
5 |
* Copyright (C) 2010 Brian Aker
|
6 |
*
|
|
7 |
* This program is free software; you can redistribute it and/or modify
|
|
8 |
* it under the terms of the GNU General Public License as published by
|
|
9 |
* the Free Software Foundation; either version 2 of the License, or
|
|
10 |
* (at your option) any later version.
|
|
11 |
*
|
|
12 |
* This program is distributed in the hope that it will be useful,
|
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
* GNU General Public License for more details.
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License
|
|
18 |
* along with this program; if not, write to the Free Software
|
|
19 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1812.3.2
by Brian Aker
Merge with trunk. |
20 |
=======
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
21 |
* Copyright (C) 2008 Sun Microsystems
|
22 |
*
|
|
23 |
* This program is free software; you can redistribute it and/or modify
|
|
24 |
* it under the terms of the GNU General Public License as published by
|
|
25 |
* the Free Software Foundation; version 2 of the License.
|
|
26 |
*
|
|
27 |
* This program is distributed in the hope that it will be useful,
|
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30 |
* GNU General Public License for more details.
|
|
31 |
*
|
|
32 |
* You should have received a copy of the GNU General Public License
|
|
33 |
* along with this program; if not, write to the Free Software
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
34 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
1812.3.2
by Brian Aker
Merge with trunk. |
35 |
>>>>>>> MERGE-SOURCE
|
971.3.12
by Eric Day
Started abstracting Protocol, removed init_connect, init_file. |
36 |
*/
|
1
by brian
clean slate |
37 |
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
38 |
|
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
39 |
#include "config.h" |
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
40 |
#include <drizzled/gettext.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
41 |
#include <drizzled/error.h> |
971.3.61
by Eric Day
Removed setRandom from Protocol class. |
42 |
#include <drizzled/query_id.h> |
468
by Monty Taylor
Repaced sql_state stuff with template function and c++ algorithm. |
43 |
#include <drizzled/sql_state.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
44 |
#include <drizzled/session.h> |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
45 |
#include "drizzled/internal/my_sys.h" |
46 |
#include "drizzled/internal/m_string.h" |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
47 |
#include <algorithm> |
1633.6.2
by Vijay Samuel
Reverted changes. |
48 |
#include <iostream> |
49 |
#include <boost/program_options.hpp> |
|
50 |
#include <drizzled/module/option_map.h> |
|
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
51 |
#include "drizzle_protocol.h" |
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
52 |
#include "plugin/drizzle_protocol/status_table.h" |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
53 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
54 |
namespace po= boost::program_options; |
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
55 |
using namespace drizzled; |
1067.4.8
by Nathan Williams
Converted all usages of cmin/cmax in plugin directory to std::min/max. |
56 |
using namespace std; |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
57 |
|
58 |
namespace drizzle_protocol |
|
59 |
{
|
|
60 |
||
971.7.8
by Eric Day
Moved port options into protocol plugin and added MySQL protocol support. |
61 |
static uint32_t port; |
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
62 |
static uint32_t connect_timeout; |
63 |
static uint32_t read_timeout; |
|
64 |
static uint32_t write_timeout; |
|
65 |
static uint32_t retry_count; |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
66 |
static uint32_t buffer_length; |
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
67 |
static char* bind_address; |
1666.4.19
by Monty Taylor
Free strdup'd option strings. |
68 |
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
69 |
static const uint32_t DRIZZLE_TCP_PORT= 4427; |
1726.3.6
by LinuxJedi
Add data_dictionary table for drizzle protocol status |
70 |
|
1666.4.19
by Monty Taylor
Free strdup'd option strings. |
71 |
ListenDrizzleProtocol::~ListenDrizzleProtocol() |
72 |
{
|
|
73 |
/* This is strdup'd from the options */
|
|
74 |
free(bind_address); |
|
75 |
}
|
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
76 |
|
971.7.10
by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port. |
77 |
const char* ListenDrizzleProtocol::getHost(void) const |
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
78 |
{
|
79 |
return bind_address; |
|
80 |
}
|
|
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
81 |
|
971.7.10
by Eric Day
Duplicated oldlibdrizzle module, one for Drizzle protocol and one for MySQL, per Brian's request from merge proposal. Port options are now --drizzle-protocol-port and --mysql-protocol-port. |
82 |
in_port_t ListenDrizzleProtocol::getPort(void) const |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
83 |
{
|
971.7.8
by Eric Day
Moved port options into protocol plugin and added MySQL protocol support. |
84 |
return (in_port_t) port; |
971.3.48
by Eric Day
New Listen interface about done, not quite compiling yet, but need a backup. |
85 |
}
|
86 |
||
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
87 |
static int init(drizzled::module::Context &context) |
88 |
{
|
|
1633.6.2
by Vijay Samuel
Reverted changes. |
89 |
const module::option_map &vm= context.getOptions(); |
90 |
if (vm.count("port")) |
|
91 |
{
|
|
92 |
if (port > 65535) |
|
93 |
{
|
|
1633.6.5
by Vijay Samuel
Merge changes for error printing. |
94 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value of port\n")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
95 |
exit(-1); |
96 |
}
|
|
97 |
}
|
|
98 |
||
99 |
if (vm.count("connect-timeout")) |
|
100 |
{
|
|
101 |
if (connect_timeout < 1 || connect_timeout > 300) |
|
102 |
{
|
|
1633.6.5
by Vijay Samuel
Merge changes for error printing. |
103 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for connect_timeout\n")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
104 |
exit(-1); |
105 |
}
|
|
106 |
}
|
|
107 |
||
108 |
if (vm.count("read-timeout")) |
|
109 |
{
|
|
110 |
if (read_timeout < 1 || read_timeout > 300) |
|
111 |
{
|
|
1633.6.5
by Vijay Samuel
Merge changes for error printing. |
112 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for read_timeout\n")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
113 |
exit(-1); |
114 |
}
|
|
115 |
}
|
|
116 |
||
117 |
if (vm.count("write-timeout")) |
|
118 |
{
|
|
119 |
if (write_timeout < 1 || write_timeout > 300) |
|
120 |
{
|
|
1633.6.5
by Vijay Samuel
Merge changes for error printing. |
121 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for write_timeout\n")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
122 |
exit(-1); |
123 |
}
|
|
124 |
}
|
|
125 |
||
126 |
if (vm.count("retry-count")) |
|
127 |
{
|
|
128 |
if (retry_count < 1 || retry_count > 100) |
|
129 |
{
|
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
130 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for retry_count")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
131 |
exit(-1); |
132 |
}
|
|
133 |
}
|
|
134 |
||
135 |
if (vm.count("buffer-length")) |
|
136 |
{
|
|
137 |
if (buffer_length < 1024 || buffer_length > 1024*1024) |
|
138 |
{
|
|
1633.6.5
by Vijay Samuel
Merge changes for error printing. |
139 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for buffer_length\n")); |
1633.6.2
by Vijay Samuel
Reverted changes. |
140 |
exit(-1); |
141 |
}
|
|
142 |
}
|
|
143 |
||
144 |
if (vm.count("bind-address")) |
|
145 |
{
|
|
146 |
bind_address= strdup(vm["bind-address"].as<string>().c_str()); |
|
147 |
}
|
|
148 |
||
149 |
else
|
|
150 |
{
|
|
151 |
bind_address= NULL; |
|
152 |
}
|
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
153 |
|
154 |
context.add(new StatusTable); |
|
155 |
context.add(new ListenDrizzleProtocol("drizzle_protocol", true)); |
|
156 |
||
971.3.16
by Eric Day
Cleaned up Protocol plugin interface (now a class factory) and moved libdrizzlclient to oldlibdrizzle to be clear. |
157 |
return 0; |
158 |
}
|
|
159 |
||
971.7.8
by Eric Day
Moved port options into protocol plugin and added MySQL protocol support. |
160 |
static DRIZZLE_SYSVAR_UINT(port, port, PLUGIN_VAR_RQCMDARG, |
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
161 |
N_("Port number to use for connection or 0 for default to with Drizzle/MySQL protocol."), |
162 |
NULL, NULL, DRIZZLE_TCP_PORT, 0, 65535, 0); |
|
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
163 |
static DRIZZLE_SYSVAR_UINT(connect_timeout, connect_timeout, |
164 |
PLUGIN_VAR_RQCMDARG, N_("Connect Timeout."), |
|
165 |
NULL, NULL, 10, 1, 300, 0); |
|
166 |
static DRIZZLE_SYSVAR_UINT(read_timeout, read_timeout, PLUGIN_VAR_RQCMDARG, |
|
167 |
N_("Read Timeout."), NULL, NULL, 30, 1, 300, 0); |
|
168 |
static DRIZZLE_SYSVAR_UINT(write_timeout, write_timeout, PLUGIN_VAR_RQCMDARG, |
|
169 |
N_("Write Timeout."), NULL, NULL, 60, 1, 300, 0); |
|
170 |
static DRIZZLE_SYSVAR_UINT(retry_count, retry_count, PLUGIN_VAR_RQCMDARG, |
|
171 |
N_("Retry Count."), NULL, NULL, 10, 1, 100, 0); |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
172 |
static DRIZZLE_SYSVAR_UINT(buffer_length, buffer_length, PLUGIN_VAR_RQCMDARG, |
173 |
N_("Buffer length."), NULL, NULL, 16384, 1024, |
|
174 |
1024*1024, 0); |
|
175 |
static DRIZZLE_SYSVAR_STR(bind_address, bind_address, PLUGIN_VAR_READONLY, |
|
176 |
N_("Address to bind to."), NULL, NULL, NULL); |
|
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
177 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
178 |
static void init_options(drizzled::module::option_context &context) |
179 |
{
|
|
180 |
context("port", |
|
1812.3.1
by Brian Aker
This patch encapsulates the MySQL protocol around the Drizzle port so that we have access even in the event of MySQL being installed and running. |
181 |
po::value<uint32_t>(&port)->default_value(DRIZZLE_TCP_PORT), |
182 |
N_("Port number to use for connection or 0 for default to with Drizzle/MySQL protocol.")); |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
183 |
context("connect-timeout", |
184 |
po::value<uint32_t>(&connect_timeout)->default_value(10), |
|
185 |
N_("Connect Timeout.")); |
|
186 |
context("read-timeout", |
|
187 |
po::value<uint32_t>(&read_timeout)->default_value(30), |
|
188 |
N_("Read Timeout.")); |
|
189 |
context("write-timeout", |
|
190 |
po::value<uint32_t>(&write_timeout)->default_value(60), |
|
191 |
N_("Write Timeout.")); |
|
192 |
context("retry-count", |
|
193 |
po::value<uint32_t>(&retry_count)->default_value(10), |
|
194 |
N_("Retry Count.")); |
|
195 |
context("buffer-length", |
|
196 |
po::value<uint32_t>(&buffer_length)->default_value(16384), |
|
197 |
N_("Buffer length.")); |
|
198 |
context("bind-address", |
|
199 |
po::value<string>(), |
|
200 |
N_("Address to bind to.")); |
|
201 |
}
|
|
202 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
203 |
static drizzle_sys_var* sys_variables[]= { |
971.7.8
by Eric Day
Moved port options into protocol plugin and added MySQL protocol support. |
204 |
DRIZZLE_SYSVAR(port), |
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
205 |
DRIZZLE_SYSVAR(connect_timeout), |
206 |
DRIZZLE_SYSVAR(read_timeout), |
|
207 |
DRIZZLE_SYSVAR(write_timeout), |
|
208 |
DRIZZLE_SYSVAR(retry_count), |
|
971.7.1
by Eric Day
Client/Listen cleanup, moved globals, console plugin cleanup. |
209 |
DRIZZLE_SYSVAR(buffer_length), |
210 |
DRIZZLE_SYSVAR(bind_address), |
|
971.3.60
by Eric Day
Moved connect_timeout, net_*_timeout, and retry_count to plugin. |
211 |
NULL
|
212 |
};
|
|
213 |
||
1320.2.1
by Monty Taylor
Merged in drizzle_protocol namespace change. |
214 |
} /* namespace drizzle_protocol */ |
1300.5.1
by Monty Taylor
Put drizzle_protocol plugin in to its own namespace so that symbols won't |
215 |
|
1633.6.2
by Vijay Samuel
Reverted changes. |
216 |
DRIZZLE_PLUGIN(drizzle_protocol::init, drizzle_protocol::sys_variables, drizzle_protocol::init_options); |