~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/oldlibdrizzle.h

  • Committer: Brian Aker
  • Date: 2010-03-15 21:50:05 UTC
  • mto: This revision was merged to the branch mainline in revision 1343.
  • Revision ID: brian@gaz-20100315215005-oqoblpbll9n0albj
Merge of table cache/def DD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
21
 
#define PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
 
20
#ifndef PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H
 
21
#define PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H
22
22
 
23
23
#include <drizzled/plugin/listen_tcp.h>
24
24
#include <drizzled/plugin/client.h>
25
 
#include <drizzled/atomics.h>
26
 
#include "drizzled/plugin/table_function.h"
27
25
 
28
26
#include "net_serv.h"
29
27
 
30
 
namespace drizzle_plugin
31
 
{
32
 
void compose_ip_addresses(std::vector<std::string> options);
33
 
 
34
 
class ProtocolCounters
35
 
{
36
 
  public:
37
 
    ProtocolCounters():
38
 
      max_connections(1000)
39
 
    { }
40
 
    drizzled::atomic<uint64_t> connectionCount;
41
 
    drizzled::atomic<uint64_t> adminConnectionCount;
42
 
    drizzled::atomic<uint64_t> failedConnections;
43
 
    drizzled::atomic<uint64_t> connected;
44
 
    drizzled::atomic<uint64_t> adminConnected;
45
 
    uint32_t max_connections;
46
 
};
47
 
 
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
 
 
52
28
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp
53
29
{
54
 
protected:
55
 
  const std::string _hostname;
56
 
  bool _using_mysql41_protocol;
 
30
private:
 
31
  bool using_mysql41_protocol;
57
32
 
58
33
public:
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)
 
34
  ListenMySQLProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
 
35
   drizzled::plugin::ListenTcp(name_arg),
 
36
   using_mysql41_protocol(using_mysql41_protocol_arg)
65
37
  { }
66
 
  virtual ~ListenMySQLProtocol();
67
 
  virtual const std::string getHost(void) const;
 
38
  virtual const char* getHost(void) const;
68
39
  virtual in_port_t getPort(void) const;
69
40
  virtual drizzled::plugin::Client *getClient(int fd);
70
 
  static ProtocolCounters *mysql_counters;
71
 
  virtual ProtocolCounters *getCounters(void) const { return mysql_counters; }
72
 
  void addCountersToTable(void);
73
41
};
74
42
 
75
43
class ClientMySQLProtocol: public drizzled::plugin::Client
76
44
{
77
 
protected:
 
45
private:
78
46
  NET net;
79
47
  drizzled::String packet;
80
48
  uint32_t client_capabilities;
81
 
  bool is_admin_connection;
82
 
  bool _using_mysql41_protocol;
 
49
  bool using_mysql41_protocol;
83
50
 
84
51
  bool checkConnection(void);
85
52
  bool netStoreData(const unsigned char *from, size_t length);
86
53
  void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
87
 
  unsigned char *storeLength(unsigned char *packet, uint64_t length);
88
 
  void makeScramble(char *scramble);
89
54
 
90
55
public:
91
 
  ClientMySQLProtocol(int fd, bool _using_mysql41_protocol, ProtocolCounters *set_counters);
 
56
  ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg);
92
57
  virtual ~ClientMySQLProtocol();
93
58
 
94
 
  ProtocolCounters *counters;
95
 
 
96
59
  virtual int getFileDescriptor(void);
97
60
  virtual bool isConnected();
98
61
  virtual bool isReading(void);
105
68
 
106
69
  virtual void sendOK(void);
107
70
  virtual void sendEOF(void);
108
 
  virtual void sendError(const drizzled::error_t sql_errno, const char *err);
 
71
  virtual void sendError(uint32_t sql_errno, const char *err);
109
72
 
110
73
  virtual bool sendFields(drizzled::List<drizzled::Item> *list);
111
74
 
122
85
  virtual bool haveError(void);
123
86
  virtual bool haveMoreData(void);
124
87
  virtual bool wasAborted(void);
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);
128
88
};
129
89
 
130
 
} /* namespace drizzle_plugin */
131
 
 
132
 
#endif /* PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H */
 
90
#endif /* PLUGIN_MYSQL_PROTOCOL_OLDLIBDRIZZLE_H */