~drizzle-trunk/drizzle/development

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
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.
20
#ifndef PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
21
#define PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_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.
22
23
#include <drizzled/plugin/listen_tcp.h>
24
#include <drizzled/plugin/client.h>
1726.3.4 by LinuxJedi
Add a data_dictionary table for the MySQL protocol plugin
25
#include <drizzled/atomics.h>
26
#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.
27
28
#include "net_serv.h"
29
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
30
namespace drizzle_plugin
31
{
1960.2.6 by Andrew Hutchings
Add ip address limitation for admin connections
32
void compose_ip_addresses(std::vector<std::string> options);
33
1953.2.6 by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant
34
class ProtocolCounters
35
{
36
  public:
37
    ProtocolCounters():
38
      max_connections(1000)
39
    { }
40
    drizzled::atomic<uint64_t> connectionCount;
1960.2.5 by Andrew Hutchings
Fix counters
41
    drizzled::atomic<uint64_t> adminConnectionCount;
1953.2.6 by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant
42
    drizzled::atomic<uint64_t> failedConnections;
43
    drizzled::atomic<uint64_t> connected;
1960.2.5 by Andrew Hutchings
Fix counters
44
    drizzled::atomic<uint64_t> adminConnected;
1953.2.6 by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant
45
    uint32_t max_connections;
46
};
1953.2.2 by Andrew Hutchings
Add Drizzle protocol support for max-connections (shared with MySQL protocol for now as other stats are shared)
47
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
48
typedef drizzled::constrained_check<uint32_t, 300, 1> timeout_constraint;
49
typedef drizzled::constrained_check<uint32_t, 300, 1> retry_constraint;
50
typedef drizzled::constrained_check<uint32_t, 1048576, 1024, 1024> buffer_constraint;
51
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.
52
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp
53
{
1960.2.6 by Andrew Hutchings
Add ip address limitation for admin connections
54
protected:
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
55
  const std::string _hostname;
56
  bool _using_mysql41_protocol;
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
58
public:
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
59
  ListenMySQLProtocol(std::string name,
60
                      const std::string &hostname,
61
                      bool using_mysql41_protocol):
62
   drizzled::plugin::ListenTcp(name),
63
   _hostname(hostname),
64
   _using_mysql41_protocol(using_mysql41_protocol)
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.
65
  { }
1666.4.19 by Monty Taylor
Free strdup'd option strings.
66
  virtual ~ListenMySQLProtocol();
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
67
  virtual const std::string getHost(void) 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.
68
  virtual in_port_t getPort(void) const;
69
  virtual drizzled::plugin::Client *getClient(int fd);
1953.2.6 by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant
70
  static ProtocolCounters *mysql_counters;
71
  virtual ProtocolCounters *getCounters(void) const { return mysql_counters; }
2131.7.1 by Andrew Hutchings
Add protocol counters table
72
  void addCountersToTable(void);
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.
73
};
74
75
class ClientMySQLProtocol: public drizzled::plugin::Client
76
{
1960.2.6 by Andrew Hutchings
Add ip address limitation for admin connections
77
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.
78
  NET net;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
79
  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.
80
  uint32_t client_capabilities;
1960.2.1 by Andrew Hutchings
Add admin connection to client/server protocols
81
  bool is_admin_connection;
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
82
  bool _using_mysql41_protocol;
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.
83
84
  bool checkConnection(void);
85
  bool netStoreData(const unsigned char *from, size_t length);
86
  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.
87
  unsigned char *storeLength(unsigned char *packet, uint64_t length);
1337.4.5 by Eric Day
Added MySQL password hash support.
88
  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.
89
90
public:
1953.2.7 by Andrew Hutchings
Merge with trunk
91
  ClientMySQLProtocol(int fd, bool _using_mysql41_protocol, ProtocolCounters *set_counters);
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.
92
  virtual ~ClientMySQLProtocol();
93
1953.2.6 by Andrew Hutchings
Completely redo max-connections so it is independant per-protocol. Also make counters independant
94
  ProtocolCounters *counters;
1726.3.4 by LinuxJedi
Add a data_dictionary table for the MySQL protocol plugin
95
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.
96
  virtual int getFileDescriptor(void);
97
  virtual bool isConnected();
98
  virtual bool isReading(void);
99
  virtual bool isWriting(void);
100
  virtual bool flush(void);
101
  virtual void close(void);
102
103
  virtual bool authenticate(void);
104
  virtual bool readCommand(char **packet, uint32_t *packet_length);
105
106
  virtual void sendOK(void);
107
  virtual void sendEOF(void);
2126.3.4 by Brian Aker
Additional error cleanup (passing error correctly to the client code).
108
  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.
109
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
110
  virtual bool sendFields(drizzled::List<drizzled::Item> *list);
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.
111
112
  using Client::store;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
113
  virtual bool store(drizzled::Field *from);
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.
114
  virtual bool store(void);
115
  virtual bool store(int32_t from);
116
  virtual bool store(uint32_t from);
117
  virtual bool store(int64_t from);
118
  virtual bool store(uint64_t from);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
119
  virtual bool store(double from, uint32_t decimals, drizzled::String *buffer);
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.
120
  virtual bool store(const char *from, size_t length);
121
122
  virtual bool haveError(void);
123
  virtual bool haveMoreData(void);
124
  virtual bool wasAborted(void);
1960.2.6 by Andrew Hutchings
Add ip address limitation for admin connections
125
  virtual bool isAdminAllowed(void);
126
  static std::vector<std::string> mysql_admin_ip_addresses;
127
  static void mysql_compose_ip_addresses(std::vector<std::string> options);
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.
128
};
129
1964.2.9 by Monty Taylor
All protocol stuff except for the buffer_length. WTF?
130
} /* namespace drizzle_plugin */
131
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.
132
#endif /* PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H */