1 #ifndef PROTOCOL_INCLUDED
2 #define PROTOCOL_INCLUDED
19 #include "sql_error.h"
37 enum enum_field_types *field_types;
40 #ifndef EMBEDDED_LIBRARY
41 bool net_store_data(
const uchar *from,
size_t length);
43 virtual bool net_store_data(
const uchar *from,
size_t length);
48 bool net_store_data(
const uchar *from,
size_t length,
53 virtual bool send_ok(uint server_status, uint statement_warn_count,
54 ulonglong affected_rows, ulonglong last_insert_id,
57 virtual bool send_eof(uint server_status, uint statement_warn_count);
59 virtual bool send_error(uint sql_errno,
const char *err_msg,
60 const char *sql_state);
64 Protocol(THD *thd_arg) { init(thd_arg); }
66 void init(THD* thd_arg);
68 enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
74 String *storage_packet() {
return packet; }
75 inline void free() { packet->free(); }
77 inline bool store(
int from)
78 {
return store_long((longlong) from); }
79 inline bool store(uint32 from)
80 {
return store_long((longlong) from); }
81 inline bool store(longlong from)
82 {
return store_longlong((longlong) from, 0); }
83 inline bool store(ulonglong from)
84 {
return store_longlong((longlong) from, 1); }
86 {
return store((
char*) str->ptr(), str->length(), str->charset()); }
88 virtual bool prepare_for_send(uint num_columns)
90 field_count= num_columns;
95 virtual void prepare_for_resend()=0;
97 virtual bool store_null()=0;
98 virtual bool store_tiny(longlong from)=0;
99 virtual bool store_short(longlong from)=0;
100 virtual bool store_long(longlong from)=0;
101 virtual bool store_longlong(longlong from,
bool unsigned_flag)=0;
102 virtual bool store_decimal(
const my_decimal *)=0;
103 virtual bool store(
const char *from,
size_t length,
105 virtual bool store(
const char *from,
size_t length,
108 virtual bool store(
float from, uint32 decimals,
String *buffer)=0;
109 virtual bool store(
double from, uint32 decimals,
String *buffer)=0;
112 virtual bool store_time(
MYSQL_TIME *time, uint precision)=0;
116 #ifdef EMBEDDED_LIBRARY
118 virtual void remove_last_row() {}
120 void remove_last_row() {}
122 enum enum_protocol_type
128 PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1, PROTOCOL_LOCAL= 2
130 virtual enum enum_protocol_type type()= 0;
143 virtual void prepare_for_resend();
144 virtual bool store_null();
145 virtual bool store_tiny(longlong from);
146 virtual bool store_short(longlong from);
147 virtual bool store_long(longlong from);
148 virtual bool store_longlong(longlong from,
bool unsigned_flag);
149 virtual bool store_decimal(
const my_decimal *);
150 virtual bool store(
const char *from,
size_t length,
const CHARSET_INFO *cs);
151 virtual bool store(
const char *from,
size_t length,
154 virtual bool store(
MYSQL_TIME *time, uint precision);
156 virtual bool store_time(
MYSQL_TIME *time, uint precision);
157 virtual bool store(
float nr, uint32 decimals,
String *buffer);
158 virtual bool store(
double from, uint32 decimals,
String *buffer);
159 virtual bool store(
Field *field);
162 #ifdef EMBEDDED_LIBRARY
163 void remove_last_row();
165 virtual enum enum_protocol_type type() {
return PROTOCOL_TEXT; };
176 virtual bool prepare_for_send(uint num_columns);
177 virtual void prepare_for_resend();
178 #ifdef EMBEDDED_LIBRARY
179 virtual bool write();
180 bool net_store_data(
const uchar *from,
size_t length);
182 virtual bool store_null();
183 virtual bool store_tiny(longlong from);
184 virtual bool store_short(longlong from);
185 virtual bool store_long(longlong from);
186 virtual bool store_longlong(longlong from,
bool unsigned_flag);
187 virtual bool store_decimal(
const my_decimal *);
188 virtual bool store(
const char *from,
size_t length,
const CHARSET_INFO *cs);
189 virtual bool store(
const char *from,
size_t length,
191 virtual bool store(
MYSQL_TIME *time, uint precision);
193 virtual bool store_time(
MYSQL_TIME *time, uint precision);
194 virtual bool store(
float nr, uint32 decimals,
String *buffer);
195 virtual bool store(
double from, uint32 decimals,
String *buffer);
196 virtual bool store(
Field *field);
200 virtual enum enum_protocol_type type() {
return PROTOCOL_BINARY; };
203 void send_warning(THD *thd, uint sql_errno,
const char *err=0);
205 const char* sqlstate);
206 uchar *net_store_data(uchar *
to,
const uchar *from,
size_t length);
207 uchar *net_store_data(uchar *
to,int32 from);
208 uchar *net_store_data(uchar *
to,longlong from);