17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifdef USE_PRAGMA_INTERFACE
21
#pragma interface /* gcc class implementation */
20
#ifndef DRIZZLED_PROTOCOL_H
21
#define DRIZZLED_PROTOCOL_H
23
#include <drizzled/sql_list.h>
24
#include <drizzled/item.h>
27
31
typedef struct st_drizzle_field DRIZZLE_FIELD;
28
32
typedef struct st_drizzle_rows DRIZZLE_ROWS;
33
typedef struct st_drizzle_time DRIZZLE_TIME;
36
41
uint32_t field_pos;
42
47
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
45
Protocol(THD *thd_arg) { init(thd_arg); }
50
Protocol(Session *session_arg) { init(session_arg); }
46
51
virtual ~Protocol() {}
47
void init(THD* thd_arg);
52
void init(Session* session_arg);
49
54
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
50
55
virtual bool send_fields(List<Item> *list, uint32_t flags);
52
bool store(I_List<i_string> *str_list);
53
bool store(const char *from, const CHARSET_INFO * const cs);
57
virtual bool store(I_List<i_string> *str_list);
58
virtual bool store(const char *from, const CHARSET_INFO * const cs);
54
59
String *storage_packet() { return packet; }
55
inline void free() { packet->free(); }
56
61
virtual bool write();
57
inline bool store(int from)
58
{ return store_long((int64_t) from); }
59
inline bool store(uint32_t from)
60
{ return store_long((int64_t) from); }
61
inline bool store(int64_t from)
62
virtual bool store(int from)
63
{ return store_long((int64_t) from); }
64
virtual bool store(uint32_t from)
65
{ return store_long((int64_t) from); }
66
virtual bool store(int64_t from)
62
67
{ return store_int64_t((int64_t) from, 0); }
63
inline bool store(uint64_t from)
68
virtual bool store(uint64_t from)
64
69
{ return store_int64_t((int64_t) from, 1); }
65
inline bool store(String *str)
66
{ return store((char*) str->ptr(), str->length(), str->charset()); }
70
virtual bool store(String *str);
68
virtual bool prepare_for_send(List<Item> *item_list)
72
virtual bool prepare_for_send(List<Item> *item_list)
70
74
field_count=item_list->elements;
73
77
virtual bool flush();
74
virtual void end_partial_result_set(THD *thd);
79
virtual bool init_file_descriptor(int fd)=0;
75
80
virtual void prepare_for_resend()=0;
77
82
virtual bool store_null()=0;
79
84
virtual bool store_short(int64_t from)=0;
80
85
virtual bool store_long(int64_t from)=0;
81
86
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
82
virtual bool store_decimal(const my_decimal *)=0;
87
virtual bool store_decimal(const my_decimal * dec_value)=0;
83
88
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
84
virtual bool store(const char *from, size_t length,
89
virtual bool store(const char *from, size_t length,
85
90
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
86
91
virtual bool store(float from, uint32_t decimals, String *buffer)=0;
87
92
virtual bool store(double from, uint32_t decimals, String *buffer)=0;
110
115
Protocol_text() {}
111
Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
116
Protocol_text(Session *session_arg) :Protocol(session_arg) {}
117
virtual bool init_file_descriptor(int fd);
112
118
virtual void prepare_for_resend();
119
virtual bool store(I_List<i_string> *str_list)
121
return Protocol::store(str_list);
123
virtual bool store(const char *from, const CHARSET_INFO * const cs)
125
return Protocol::store(from, cs);
113
127
virtual bool store_null();
114
128
virtual bool store_tiny(int64_t from);
115
129
virtual bool store_short(int64_t from);
116
130
virtual bool store_long(int64_t from);
117
131
virtual bool store_int64_t(int64_t from, bool unsigned_flag);
118
132
virtual bool store_decimal(const my_decimal *);
133
virtual bool store(int from)
134
{ return store_long((int64_t) from); }
135
virtual bool store(uint32_t from)
136
{ return store_long((int64_t) from); }
137
virtual bool store(int64_t from)
138
{ return store_int64_t((int64_t) from, 0); }
139
virtual bool store(uint64_t from)
140
{ return store_int64_t((int64_t) from, 1); }
141
virtual bool store(String *str)
143
return Protocol::store(str);
119
145
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
120
146
virtual bool store(const char *from, size_t length,
121
147
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
128
154
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
131
void send_warning(THD *thd, uint32_t sql_errno, const char *err=0);
132
void net_send_error(THD *thd, uint32_t sql_errno=0, const char *err=0);
133
void net_end_statement(THD *thd);
157
void send_warning(Session *session, uint32_t sql_errno, const char *err=0);
158
void net_send_error(Session *session, uint32_t sql_errno=0, const char *err=0);
159
void drizzleclient_net_end_statement(Session *session);
134
160
unsigned char *net_store_data(unsigned char *to,const unsigned char *from, size_t length);
135
161
unsigned char *net_store_data(unsigned char *to,int32_t from);
136
162
unsigned char *net_store_data(unsigned char *to,int64_t from);
164
#endif /* DRIZZLED_PROTOCOL_H */