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. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
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. |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
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. |
21 |
|
22 |
#include <drizzled/plugin/listen_tcp.h> |
|
23 |
#include <drizzled/plugin/client.h> |
|
1726.3.4
by LinuxJedi
Add a data_dictionary table for the MySQL protocol plugin |
24 |
#include <drizzled/atomics.h> |
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
25 |
#include <drizzled/plugin/table_function.h> |
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. |
26 |
|
27 |
#include "net_serv.h" |
|
28 |
||
2281.6.1
by Olaf van der Spek
Return void |
29 |
namespace drizzle_plugin { |
30 |
||
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
31 |
class ProtocolCounters |
32 |
{
|
|
2318.3.8
by Olaf van der Spek
Refactor |
33 |
public: |
34 |
ProtocolCounters() : |
|
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
35 |
max_connections(1000) |
2318.3.8
by Olaf van der Spek
Refactor |
36 |
{ } |
37 |
||
38 |
drizzled::atomic<uint64_t> connectionCount; |
|
39 |
drizzled::atomic<uint64_t> failedConnections; |
|
40 |
drizzled::atomic<uint64_t> connected; |
|
41 |
uint32_t max_connections; |
|
1953.2.6
by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant |
42 |
};
|
1953.2.2
by Andrew Hutchings
Add Drizzle protocol support for max-connections (shared with MySQL protocol for now as other stats are shared) |
43 |
|
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
44 |
typedef drizzled::constrained_check<uint32_t, 300, 1> timeout_constraint; |
45 |
typedef drizzled::constrained_check<uint32_t, 300, 1> retry_constraint; |
|
46 |
typedef drizzled::constrained_check<uint32_t, 1048576, 1024, 1024> buffer_constraint; |
|
47 |
||
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. |
48 |
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp |
49 |
{
|
|
50 |
public: |
|
2318.2.40
by Olaf van der Spek
Refactor |
51 |
ListenMySQLProtocol(std::string name, const std::string &hostname) : |
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
52 |
drizzled::plugin::ListenTcp(name), |
2318.2.40
by Olaf van der Spek
Refactor |
53 |
_hostname(hostname) |
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. |
54 |
{ } |
2318.3.1
by Olaf van der Spek
Refactor |
55 |
virtual const std::string getHost() const; |
56 |
virtual in_port_t getPort() const; |
|
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. |
57 |
virtual drizzled::plugin::Client *getClient(int fd); |
2318.3.1
by Olaf van der Spek
Refactor |
58 |
static ProtocolCounters mysql_counters; |
2318.3.5
by Olaf van der Spek
Refactor |
59 |
virtual ProtocolCounters& getCounters() const { return mysql_counters; } |
2318.3.1
by Olaf van der Spek
Refactor |
60 |
void addCountersToTable(); |
2318.2.41
by Olaf van der Spek
Refactor |
61 |
protected: |
62 |
const std::string _hostname; |
|
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. |
63 |
};
|
64 |
||
65 |
class ClientMySQLProtocol: public drizzled::plugin::Client |
|
66 |
{
|
|
1960.2.6
by Andrew Hutchings
Add ip address limitation for admin connections |
67 |
protected: |
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. |
68 |
NET net; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
69 |
drizzled::String packet; |
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. |
70 |
uint32_t client_capabilities; |
2191.1.2
by Brian Aker
Adding SESSION table and adding back in the mysql interactive flag. |
71 |
bool _is_interactive; |
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. |
72 |
|
2318.3.1
by Olaf van der Spek
Refactor |
73 |
bool checkConnection(); |
2318.2.19
by Olaf van der Spek
Merge trunk |
74 |
void netStoreData(const void*, size_t); |
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. |
75 |
void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count); |
1337.4.1
by Eric Day
Removed unused functions and extra complexity in MySQL module. Not rewriting any code here (yet?), just reshuffling to make it easier to manage. |
76 |
unsigned char *storeLength(unsigned char *packet, uint64_t length); |
1337.4.5
by Eric Day
Added MySQL password hash support. |
77 |
void makeScramble(char *scramble); |
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. |
78 |
|
79 |
public: |
|
2318.2.39
by Olaf van der Spek
Refactor |
80 |
ClientMySQLProtocol(int fd, ProtocolCounters&); |
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. |
81 |
virtual ~ClientMySQLProtocol(); |
82 |
||
2191.1.4
by Brian Aker
Add in interactive mode back to protocol. |
83 |
bool isInteractive() const |
2191.1.2
by Brian Aker
Adding SESSION table and adding back in the mysql interactive flag. |
84 |
{
|
85 |
return _is_interactive; |
|
86 |
}
|
|
87 |
||
2318.3.6
by Olaf van der Spek
Refactor |
88 |
ProtocolCounters& counters; |
1726.3.4
by LinuxJedi
Add a data_dictionary table for the MySQL protocol plugin |
89 |
|
2318.2.20
by Olaf van der Spek
Refactor |
90 |
virtual int getFileDescriptor(); |
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. |
91 |
virtual bool isConnected(); |
2318.2.20
by Olaf van der Spek
Refactor |
92 |
virtual bool flush(); |
93 |
virtual void close(); |
|
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. |
94 |
|
2318.2.20
by Olaf van der Spek
Refactor |
95 |
virtual bool authenticate(); |
2312.1.4
by Brian Aker
Fix packet length, no pointer to using a pointer there. |
96 |
virtual bool readCommand(char **packet, uint32_t& packet_length); |
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. |
97 |
|
2318.2.20
by Olaf van der Spek
Refactor |
98 |
virtual void sendOK(); |
99 |
virtual void sendEOF(); |
|
2126.3.4
by Brian Aker
Additional error cleanup (passing error correctly to the client code). |
100 |
virtual void sendError(const drizzled::error_t sql_errno, const char *err); |
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. |
101 |
|
2318.3.8
by Olaf van der Spek
Refactor |
102 |
virtual void sendFields(drizzled::List<drizzled::Item>&); |
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. |
103 |
|
104 |
using Client::store; |
|
2318.2.23
by Olaf van der Spek
Refactor |
105 |
virtual void store(drizzled::Field*); |
2313.3.6
by Olaf van der Spek
Return void |
106 |
virtual void store(); |
107 |
virtual void store(int32_t from); |
|
108 |
virtual void store(uint32_t from); |
|
109 |
virtual void store(int64_t from); |
|
110 |
virtual void store(uint64_t from); |
|
111 |
virtual void store(double from, uint32_t decimals, drizzled::String *buffer); |
|
2318.2.23
by Olaf van der Spek
Refactor |
112 |
virtual void store(const char*, size_t); |
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. |
113 |
|
2318.2.20
by Olaf van der Spek
Refactor |
114 |
virtual bool haveError(); |
115 |
virtual bool wasAborted(); |
|
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. |
116 |
};
|
117 |
||
1964.2.9
by Monty Taylor
All protocol stuff except for the buffer_length. WTF? |
118 |
} /* namespace drizzle_plugin */ |
119 |