18
17
* 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 */
20
#ifndef DRIZZLED_PROTOCOL_H
21
#define DRIZZLED_PROTOCOL_H
23
#include <drizzled/sql_list.h>
24
#include <drizzled/item.h>
31
typedef struct st_drizzle_field DRIZZLE_FIELD;
32
typedef struct st_drizzle_rows DRIZZLE_ROWS;
33
typedef struct st_drizzle_time DRIZZLE_TIME;
43
bool net_store_data(const unsigned char *from, size_t length);
44
bool net_store_data(const unsigned char *from, size_t length,
45
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
46
bool store_string_aux(const char *from, size_t length,
47
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
50
Protocol(Session *session_arg) { init(session_arg); }
51
virtual ~Protocol() {}
52
void init(Session* session_arg);
54
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
55
virtual bool send_fields(List<Item> *list, uint32_t flags);
57
bool store(I_List<i_string> *str_list);
58
bool store(const char *from, const CHARSET_INFO * const cs);
59
String *storage_packet() { return packet; }
62
inline bool store(int from)
63
{ return store_long((int64_t) from); }
64
inline bool store(uint32_t from)
65
{ return store_long((int64_t) from); }
66
inline bool store(int64_t from)
67
{ return store_int64_t((int64_t) from, 0); }
68
inline bool store(uint64_t from)
69
{ return store_int64_t((int64_t) from, 1); }
70
bool store(String *str);
72
virtual bool prepare_for_send(List<Item> *item_list)
74
field_count=item_list->elements;
78
virtual void end_partial_result_set(Session *session);
79
virtual void prepare_for_resend()=0;
81
virtual bool store_null()=0;
82
virtual bool store_tiny(int64_t from)=0;
83
virtual bool store_short(int64_t from)=0;
84
virtual bool store_long(int64_t from)=0;
85
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
86
virtual bool store_decimal(const my_decimal * dec_value)=0;
87
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
88
virtual bool store(const char *from, size_t length,
89
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
90
virtual bool store(float from, uint32_t decimals, String *buffer)=0;
91
virtual bool store(double from, uint32_t decimals, String *buffer)=0;
92
virtual bool store(DRIZZLE_TIME *time)=0;
93
virtual bool store_date(DRIZZLE_TIME *time)=0;
94
virtual bool store_time(DRIZZLE_TIME *time)=0;
95
virtual bool store(Field *field)=0;
96
void remove_last_row() {}
97
enum enum_protocol_type
99
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1
101
before adding here or change the values, consider that it is cast to a
105
virtual enum enum_protocol_type type()= 0;
109
/** Class used for the old (MySQL 4.0 protocol). */
111
class Protocol_text :public Protocol
115
Protocol_text(Session *session_arg) :Protocol(session_arg) {}
116
virtual void prepare_for_resend();
117
virtual bool store_null();
118
virtual bool store_tiny(int64_t from);
119
virtual bool store_short(int64_t from);
120
virtual bool store_long(int64_t from);
121
virtual bool store_int64_t(int64_t from, bool unsigned_flag);
122
virtual bool store_decimal(const my_decimal *);
123
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
124
virtual bool store(const char *from, size_t length,
125
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
126
virtual bool store(DRIZZLE_TIME *time);
127
virtual bool store_date(DRIZZLE_TIME *time);
128
virtual bool store_time(DRIZZLE_TIME *time);
129
virtual bool store(float nr, uint32_t decimals, String *buffer);
130
virtual bool store(double from, uint32_t decimals, String *buffer);
131
virtual bool store(Field *field);
132
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
135
void send_warning(Session *session, uint32_t sql_errno, const char *err=0);
136
void net_send_error(Session *session, uint32_t sql_errno=0, const char *err=0);
137
void net_end_statement(Session *session);
138
unsigned char *net_store_data(unsigned char *to,const unsigned char *from, size_t length);
139
unsigned char *net_store_data(unsigned char *to,int32_t from);
140
unsigned char *net_store_data(unsigned char *to,int64_t from);
142
#endif /* DRIZZLED_PROTOCOL_H */