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);
75
78
virtual void prepare_for_resend()=0;
77
80
virtual bool store_null()=0;
79
82
virtual bool store_short(int64_t from)=0;
80
83
virtual bool store_long(int64_t from)=0;
81
84
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
82
virtual bool store_decimal(const my_decimal *)=0;
85
virtual bool store_decimal(const my_decimal * dec_value)=0;
83
86
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,
87
virtual bool store(const char *from, size_t length,
85
88
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
86
89
virtual bool store(float from, uint32_t decimals, String *buffer)=0;
87
90
virtual bool store(double from, uint32_t decimals, String *buffer)=0;
110
113
Protocol_text() {}
111
Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
114
Protocol_text(Session *session_arg) :Protocol(session_arg) {}
112
115
virtual void prepare_for_resend();
116
virtual bool store(I_List<i_string> *str_list)
118
return Protocol::store(str_list);
120
virtual bool store(const char *from, const CHARSET_INFO * const cs)
122
return Protocol::store(from, cs);
113
124
virtual bool store_null();
114
125
virtual bool store_tiny(int64_t from);
115
126
virtual bool store_short(int64_t from);
116
127
virtual bool store_long(int64_t from);
117
128
virtual bool store_int64_t(int64_t from, bool unsigned_flag);
118
129
virtual bool store_decimal(const my_decimal *);
130
virtual bool store(int from)
131
{ return store_long((int64_t) from); }
132
virtual bool store(uint32_t from)
133
{ return store_long((int64_t) from); }
134
virtual bool store(int64_t from)
135
{ return store_int64_t((int64_t) from, 0); }
136
virtual bool store(uint64_t from)
137
{ return store_int64_t((int64_t) from, 1); }
138
virtual bool store(String *str)
140
return Protocol::store(str);
119
142
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
120
143
virtual bool store(const char *from, size_t length,
121
144
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
128
151
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);
154
void send_warning(Session *session, uint32_t sql_errno, const char *err=0);
155
void net_send_error(Session *session, uint32_t sql_errno=0, const char *err=0);
156
void drizzleclient_net_end_statement(Session *session);
134
157
unsigned char *net_store_data(unsigned char *to,const unsigned char *from, size_t length);
135
158
unsigned char *net_store_data(unsigned char *to,int32_t from);
136
159
unsigned char *net_store_data(unsigned char *to,int64_t from);
161
#endif /* DRIZZLED_PROTOCOL_H */