1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
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; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
23
#define PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
25
#include <drizzled/plugin/listen_tcp.h>
26
#include <drizzled/plugin/client.h>
27
#include <drizzled/atomics.h>
28
#include <drizzled/plugin/table_function.h>
30
#include <plugin/mysql_protocol/mysql_protocol.h>
32
namespace drizzle_plugin
34
namespace drizzle_protocol
37
class ListenDrizzleProtocol: public ListenMySQLProtocol
40
ListenDrizzleProtocol(std::string name,
41
const std::string &bind_address,
42
bool using_mysql41_protocol):
43
ListenMySQLProtocol(name, bind_address, using_mysql41_protocol)
46
~ListenDrizzleProtocol();
47
in_port_t getPort(void) const;
48
static ProtocolCounters *drizzle_counters;
49
virtual ProtocolCounters *getCounters(void) const { return drizzle_counters; }
50
drizzled::plugin::Client *getClient(int fd);
53
class ClientDrizzleProtocol: public ClientMySQLProtocol
56
ClientDrizzleProtocol(int fd, ProtocolCounters *set_counters): ClientMySQLProtocol(fd, true, set_counters) {}
58
static std::vector<std::string> drizzle_admin_ip_addresses;
59
static void drizzle_compose_ip_addresses(std::vector<std::string> options);
60
bool isAdminAllowed(void);
63
} /* namespace drizzle_protocol */
64
} /* namespace drizzle_plugin */
66
#endif /* PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H */
1
/* Copyright (C) 2002-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifdef USE_PRAGMA_INTERFACE
17
#pragma interface /* gcc class implementation */
23
typedef struct st_mysql_field MYSQL_FIELD;
24
typedef struct st_mysql_rows MYSQL_ROWS;
34
bool net_store_data(const uchar *from, size_t length);
35
bool net_store_data(const uchar *from, size_t length,
36
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
37
bool store_string_aux(const char *from, size_t length,
38
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
41
Protocol(THD *thd_arg) { init(thd_arg); }
42
virtual ~Protocol() {}
43
void init(THD* thd_arg);
45
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
46
virtual bool send_fields(List<Item> *list, uint flags);
48
bool store(I_List<i_string> *str_list);
49
bool store(const char *from, CHARSET_INFO *cs);
50
String *storage_packet() { return packet; }
51
inline void free() { packet->free(); }
53
inline bool store(int from)
54
{ return store_long((int64_t) from); }
55
inline bool store(uint32 from)
56
{ return store_long((int64_t) from); }
57
inline bool store(int64_t from)
58
{ return store_int64_t((int64_t) from, 0); }
59
inline bool store(uint64_t from)
60
{ return store_int64_t((int64_t) from, 1); }
61
inline bool store(String *str)
62
{ return store((char*) str->ptr(), str->length(), str->charset()); }
64
virtual bool prepare_for_send(List<Item> *item_list)
66
field_count=item_list->elements;
70
virtual void end_partial_result_set(THD *thd);
71
virtual void prepare_for_resend()=0;
73
virtual bool store_null()=0;
74
virtual bool store_tiny(int64_t from)=0;
75
virtual bool store_short(int64_t from)=0;
76
virtual bool store_long(int64_t from)=0;
77
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
78
virtual bool store_decimal(const my_decimal *)=0;
79
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)=0;
80
virtual bool store(const char *from, size_t length,
81
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
82
virtual bool store(float from, uint32 decimals, String *buffer)=0;
83
virtual bool store(double from, uint32 decimals, String *buffer)=0;
84
virtual bool store(MYSQL_TIME *time)=0;
85
virtual bool store_date(MYSQL_TIME *time)=0;
86
virtual bool store_time(MYSQL_TIME *time)=0;
87
virtual bool store(Field *field)=0;
88
void remove_last_row() {}
89
enum enum_protocol_type
91
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1
93
before adding here or change the values, consider that it is cast to a
97
virtual enum enum_protocol_type type()= 0;
101
/** Class used for the old (MySQL 4.0 protocol). */
103
class Protocol_text :public Protocol
107
Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
108
virtual void prepare_for_resend();
109
virtual bool store_null();
110
virtual bool store_tiny(int64_t from);
111
virtual bool store_short(int64_t from);
112
virtual bool store_long(int64_t from);
113
virtual bool store_int64_t(int64_t from, bool unsigned_flag);
114
virtual bool store_decimal(const my_decimal *);
115
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
116
virtual bool store(const char *from, size_t length,
117
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
118
virtual bool store(MYSQL_TIME *time);
119
virtual bool store_date(MYSQL_TIME *time);
120
virtual bool store_time(MYSQL_TIME *time);
121
virtual bool store(float nr, uint32 decimals, String *buffer);
122
virtual bool store(double from, uint32 decimals, String *buffer);
123
virtual bool store(Field *field);
124
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
127
void send_warning(THD *thd, uint sql_errno, const char *err=0);
128
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
129
void net_end_statement(THD *thd);
130
uchar *net_store_data(uchar *to,const uchar *from, size_t length);
131
uchar *net_store_data(uchar *to,int32 from);
132
uchar *net_store_data(uchar *to,int64_t from);