35
35
typedef struct st_drizzle_rows DRIZZLE_ROWS;
36
36
typedef struct st_drizzle_time DRIZZLE_TIME;
38
class Protocol_libdrizzleclient :public Protocol
43
struct rand_struct rand;
44
char scramble[SCRAMBLE_LENGTH+1];
45
46
uint32_t field_pos;
46
47
uint32_t field_count;
48
bool net_store_data(const unsigned char *from, size_t length);
49
bool net_store_data(const unsigned char *from, size_t length,
50
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
51
bool store_string_aux(const char *from, size_t length,
52
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
55
Protocol(Session *session_arg) { init(session_arg); }
56
virtual ~Protocol() {}
57
void init(Session* session_arg);
60
void end_statement(void);
61
void set_read_timeout(uint32_t timeout);
62
void set_write_timeout(uint32_t timeout);
63
void set_retry_count(uint32_t count);
64
void set_error(char error);
65
bool have_error(void);
66
bool was_aborted(void);
67
bool have_compression(void);
68
void enable_compression(void);
69
bool have_more_data(void);
70
bool is_reading(void);
71
bool is_writing(void);
72
void disable_results(void);
73
void enable_results(void);
75
virtual bool init_file_descriptor(int fd)=0;
76
virtual int file_descriptor(void)=0;
77
virtual void init_random(uint64_t, uint64_t) {};
78
virtual bool authenticate(void)=0;
79
virtual bool read_command(char **packet, uint32_t *packet_length)=0;
80
virtual void send_error(uint32_t sql_errno, const char *err)=0;
81
virtual void send_error_packet(uint32_t sql_errno, const char *err)=0;
82
virtual void close(void) {};
84
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
85
virtual bool send_fields(List<Item> *list, uint32_t flags);
87
virtual bool store(I_List<i_string> *str_list);
88
virtual bool store(const char *from, const CHARSET_INFO * const cs);
89
String *storage_packet() { return packet; }
92
virtual bool store(int from)
93
{ return store_long((int64_t) from); }
94
virtual bool store(uint32_t from)
95
{ return store_long((int64_t) from); }
96
virtual bool store(int64_t from)
97
{ return store_int64_t((int64_t) from, 0); }
98
virtual bool store(uint64_t from)
99
{ return store_int64_t((int64_t) from, 1); }
100
virtual bool store(String *str);
102
virtual bool prepare_for_send(List<Item> *item_list)
104
field_count=item_list->elements;
107
virtual bool flush();
109
virtual void prepare_for_resend()=0;
111
virtual bool store_null()=0;
112
virtual bool store_tiny(int64_t from)=0;
113
virtual bool store_short(int64_t from)=0;
114
virtual bool store_long(int64_t from)=0;
115
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
116
virtual bool store_decimal(const my_decimal * dec_value)=0;
117
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
118
virtual bool store(const char *from, size_t length,
119
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
120
virtual bool store(float from, uint32_t decimals, String *buffer)=0;
121
virtual bool store(double from, uint32_t decimals, String *buffer)=0;
122
virtual bool store(DRIZZLE_TIME *time)=0;
123
virtual bool store_date(DRIZZLE_TIME *time)=0;
124
virtual bool store_time(DRIZZLE_TIME *time)=0;
125
virtual bool store(Field *field)=0;
126
void remove_last_row() {}
127
enum enum_protocol_type
129
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1
131
before adding here or change the values, consider that it is cast to a
135
virtual enum enum_protocol_type type()= 0;
139
/** Class used for the old (MySQL 4.0 protocol). */
141
class Protocol_text :public Protocol
144
struct rand_struct _rand;
145
char _scramble[SCRAMBLE_LENGTH+1];
48
bool netStoreData(const unsigned char *from, size_t length);
49
bool netStoreData(const unsigned char *from, size_t length,
50
const CHARSET_INFO * const fromcs,
51
const CHARSET_INFO * const tocs);
52
bool storeStringAux(const char *from, size_t length,
53
const CHARSET_INFO * const fromcs,
54
const CHARSET_INFO * const tocs);
148
57
* Performs handshake with client and authorizes user.
150
59
* Returns true is the connection is valid and the
151
60
* user is authorized, otherwise false.
153
bool _check_connection(void);
62
bool checkConnection(void);
156
Protocol_text() { _scramble[0]= 0; }
157
Protocol_text(Session *session_arg) :Protocol(session_arg) {}
65
Protocol_libdrizzleclient();
67
virtual void setSession(Session *session_arg);
69
virtual bool isConnected();
71
virtual void set_read_timeout(uint32_t timeout);
72
virtual void set_write_timeout(uint32_t timeout);
73
virtual void set_retry_count(uint32_t count);
74
virtual void set_error(char error);
75
virtual bool have_error(void);
76
virtual bool was_aborted(void);
77
virtual bool have_compression(void);
78
virtual void enable_compression(void);
79
virtual bool have_more_data(void);
80
virtual bool is_reading(void);
81
virtual bool is_writing(void);
158
82
virtual bool init_file_descriptor(int fd);
159
83
virtual int file_descriptor(void);
160
84
virtual void init_random(uint64_t seed1, uint64_t seed2);
161
85
virtual bool authenticate(void);
162
86
virtual bool read_command(char **packet, uint32_t *packet_length);
163
virtual void send_error(uint32_t sql_errno, const char *err);
164
virtual void send_error_packet(uint32_t sql_errno, const char *err);
87
virtual void sendOK();
88
virtual void sendEOF();
89
virtual void sendError(uint32_t sql_errno, const char *err);
90
virtual void sendErrorPacket(uint32_t sql_errno, const char *err);
165
91
virtual void close(void);
166
92
virtual void prepare_for_resend();
167
virtual bool store(I_List<i_string> *str_list)
169
return Protocol::store(str_list);
171
virtual bool store(const char *from, const CHARSET_INFO * const cs)
173
return Protocol::store(from, cs);
96
virtual bool send_fields(List<Item> *list, uint32_t flags);
97
virtual bool store(I_List<i_string> *str_list);
98
virtual bool store(const char *from, const CHARSET_INFO * const cs);
175
99
virtual bool store_null();
176
100
virtual bool store_tiny(int64_t from);
177
101
virtual bool store_short(int64_t from);