~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/mysql_protocol.h

  • Committer: Stewart Smith
  • Author(s): Marko Mäkelä
  • Date: 2010-12-20 03:21:44 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101220032144-7aqh2z403u7d7bdp
Merge Revision revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0 from MySQL InnoDB

Original revid:marko.makela@oracle.com-20101104131215-pfxnpidlrzd4krg0

Original Authors: Marko Mäkelä <marko.makela@oracle.com>
Original commit message:
row_ins_index_entry(): Note that only CREATE INDEX sets foreign=FALSE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
 
21
#define PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
 
22
 
 
23
#include <drizzled/plugin/listen_tcp.h>
 
24
#include <drizzled/plugin/client.h>
 
25
#include <drizzled/atomics.h>
 
26
#include "drizzled/plugin/table_function.h"
 
27
 
 
28
#include "net_serv.h"
 
29
 
 
30
namespace drizzle_plugin
 
31
{
 
32
class ProtocolCounters
 
33
{
 
34
  public:
 
35
    ProtocolCounters():
 
36
      max_connections(1000)
 
37
    { }
 
38
    drizzled::atomic<uint64_t> connectionCount;
 
39
    drizzled::atomic<uint64_t> failedConnections;
 
40
    drizzled::atomic<uint64_t> connected;
 
41
    uint32_t max_connections;
 
42
};
 
43
 
 
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
 
 
48
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp
 
49
{
 
50
private:
 
51
  const std::string _hostname;
 
52
  bool _using_mysql41_protocol;
 
53
 
 
54
public:
 
55
  ListenMySQLProtocol(std::string name,
 
56
                      const std::string &hostname,
 
57
                      bool using_mysql41_protocol):
 
58
   drizzled::plugin::ListenTcp(name),
 
59
   _hostname(hostname),
 
60
   _using_mysql41_protocol(using_mysql41_protocol)
 
61
  { }
 
62
  virtual ~ListenMySQLProtocol();
 
63
  virtual const std::string getHost(void) const;
 
64
  virtual in_port_t getPort(void) const;
 
65
  virtual drizzled::plugin::Client *getClient(int fd);
 
66
  static ProtocolCounters *mysql_counters;
 
67
  virtual ProtocolCounters *getCounters(void) const { return mysql_counters; }
 
68
};
 
69
 
 
70
class ClientMySQLProtocol: public drizzled::plugin::Client
 
71
{
 
72
private:
 
73
  NET net;
 
74
  drizzled::String packet;
 
75
  uint32_t client_capabilities;
 
76
  bool _using_mysql41_protocol;
 
77
 
 
78
  bool checkConnection(void);
 
79
  bool netStoreData(const unsigned char *from, size_t length);
 
80
  void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
 
81
  unsigned char *storeLength(unsigned char *packet, uint64_t length);
 
82
  void makeScramble(char *scramble);
 
83
 
 
84
public:
 
85
  ClientMySQLProtocol(int fd, bool _using_mysql41_protocol, ProtocolCounters *set_counters);
 
86
  virtual ~ClientMySQLProtocol();
 
87
 
 
88
  ProtocolCounters *counters;
 
89
 
 
90
  virtual int getFileDescriptor(void);
 
91
  virtual bool isConnected();
 
92
  virtual bool isReading(void);
 
93
  virtual bool isWriting(void);
 
94
  virtual bool flush(void);
 
95
  virtual void close(void);
 
96
 
 
97
  virtual bool authenticate(void);
 
98
  virtual bool readCommand(char **packet, uint32_t *packet_length);
 
99
 
 
100
  virtual void sendOK(void);
 
101
  virtual void sendEOF(void);
 
102
  virtual void sendError(uint32_t sql_errno, const char *err);
 
103
 
 
104
  virtual bool sendFields(drizzled::List<drizzled::Item> *list);
 
105
 
 
106
  using Client::store;
 
107
  virtual bool store(drizzled::Field *from);
 
108
  virtual bool store(void);
 
109
  virtual bool store(int32_t from);
 
110
  virtual bool store(uint32_t from);
 
111
  virtual bool store(int64_t from);
 
112
  virtual bool store(uint64_t from);
 
113
  virtual bool store(double from, uint32_t decimals, drizzled::String *buffer);
 
114
  virtual bool store(const char *from, size_t length);
 
115
 
 
116
  virtual bool haveError(void);
 
117
  virtual bool haveMoreData(void);
 
118
  virtual bool wasAborted(void);
 
119
};
 
120
 
 
121
} /* namespace drizzle_plugin */
 
122
 
 
123
#endif /* PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H */