1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
21
#define PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H
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"
30
class ListenMySQLProtocol: public drizzled::plugin::ListenTcp
33
bool using_mysql41_protocol;
34
static drizzled::plugin::TableFunction* status_table_function_ptr;
37
ListenMySQLProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
38
drizzled::plugin::ListenTcp(name_arg),
39
using_mysql41_protocol(using_mysql41_protocol_arg)
41
virtual ~ListenMySQLProtocol();
42
virtual const char* getHost(void) const;
43
virtual in_port_t getPort(void) const;
44
virtual drizzled::plugin::Client *getClient(int fd);
47
class ClientMySQLProtocol: public drizzled::plugin::Client
51
drizzled::String packet;
52
uint32_t client_capabilities;
53
bool using_mysql41_protocol;
55
bool checkConnection(void);
56
bool netStoreData(const unsigned char *from, size_t length);
57
void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
58
unsigned char *storeLength(unsigned char *packet, uint64_t length);
59
void makeScramble(char *scramble);
62
ClientMySQLProtocol(int fd, bool using_mysql41_protocol_arg);
63
virtual ~ClientMySQLProtocol();
65
static drizzled::atomic<uint64_t> connectionCount;
66
static drizzled::atomic<uint64_t> failedConnections;
67
static drizzled::atomic<uint64_t> connected;
69
virtual int getFileDescriptor(void);
70
virtual bool isConnected();
71
virtual bool isReading(void);
72
virtual bool isWriting(void);
73
virtual bool flush(void);
74
virtual void close(void);
76
virtual bool authenticate(void);
77
virtual bool readCommand(char **packet, uint32_t *packet_length);
79
virtual void sendOK(void);
80
virtual void sendEOF(void);
81
virtual void sendError(uint32_t sql_errno, const char *err);
83
virtual bool sendFields(drizzled::List<drizzled::Item> *list);
86
virtual bool store(drizzled::Field *from);
87
virtual bool store(void);
88
virtual bool store(int32_t from);
89
virtual bool store(uint32_t from);
90
virtual bool store(int64_t from);
91
virtual bool store(uint64_t from);
92
virtual bool store(double from, uint32_t decimals, drizzled::String *buffer);
93
virtual bool store(const char *from, size_t length);
95
virtual bool haveError(void);
96
virtual bool haveMoreData(void);
97
virtual bool wasAborted(void);
100
#endif /* PLUGIN_MYSQL_PROTOCOL_MYSQL_PROTOCOL_H */