1
/* Copyright (C) 2002-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifdef USE_PRAGMA_INTERFACE
17
#pragma interface /* gcc class implementation */
23
typedef struct st_mysql_field MYSQL_FIELD;
24
typedef struct st_mysql_rows MYSQL_ROWS;
34
enum enum_field_types *field_types;
37
#ifndef EMBEDDED_LIBRARY
38
bool net_store_data(const uchar *from, size_t length);
40
virtual bool net_store_data(const uchar *from, size_t length);
42
MYSQL_FIELD *next_mysql_field;
45
bool store_string_aux(const char *from, size_t length,
46
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
49
Protocol(THD *thd_arg) { init(thd_arg); }
50
virtual ~Protocol() {}
51
void init(THD* thd_arg);
53
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
54
virtual bool send_fields(List<Item> *list, uint flags);
56
bool store(I_List<i_string> *str_list);
57
bool store(const char *from, CHARSET_INFO *cs);
58
String *storage_packet() { return packet; }
59
inline void free() { packet->free(); }
61
inline bool store(int from)
62
{ return store_long((longlong) from); }
63
inline bool store(uint32 from)
64
{ return store_long((longlong) from); }
65
inline bool store(longlong from)
66
{ return store_longlong((longlong) from, 0); }
67
inline bool store(ulonglong from)
68
{ return store_longlong((longlong) from, 1); }
69
inline bool store(String *str)
70
{ return store((char*) str->ptr(), str->length(), str->charset()); }
72
virtual bool prepare_for_send(List<Item> *item_list)
74
field_count=item_list->elements;
78
virtual void end_partial_result_set(THD *thd);
79
virtual void prepare_for_resend()=0;
81
virtual bool store_null()=0;
82
virtual bool store_tiny(longlong from)=0;
83
virtual bool store_short(longlong from)=0;
84
virtual bool store_long(longlong from)=0;
85
virtual bool store_longlong(longlong from, bool unsigned_flag)=0;
86
virtual bool store_decimal(const my_decimal *)=0;
87
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)=0;
88
virtual bool store(const char *from, size_t length,
89
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
90
virtual bool store(float from, uint32 decimals, String *buffer)=0;
91
virtual bool store(double from, uint32 decimals, String *buffer)=0;
92
virtual bool store(MYSQL_TIME *time)=0;
93
virtual bool store_date(MYSQL_TIME *time)=0;
94
virtual bool store_time(MYSQL_TIME *time)=0;
95
virtual bool store(Field *field)=0;
96
#ifdef EMBEDDED_LIBRARY
98
virtual void remove_last_row() {}
100
void remove_last_row() {}
102
enum enum_protocol_type
104
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1
106
before adding here or change the values, consider that it is cast to a
110
virtual enum enum_protocol_type type()= 0;
114
/** Class used for the old (MySQL 4.0 protocol). */
116
class Protocol_text :public Protocol
120
Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
121
virtual void prepare_for_resend();
122
virtual bool store_null();
123
virtual bool store_tiny(longlong from);
124
virtual bool store_short(longlong from);
125
virtual bool store_long(longlong from);
126
virtual bool store_longlong(longlong from, bool unsigned_flag);
127
virtual bool store_decimal(const my_decimal *);
128
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
129
virtual bool store(const char *from, size_t length,
130
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
131
virtual bool store(MYSQL_TIME *time);
132
virtual bool store_date(MYSQL_TIME *time);
133
virtual bool store_time(MYSQL_TIME *time);
134
virtual bool store(float nr, uint32 decimals, String *buffer);
135
virtual bool store(double from, uint32 decimals, String *buffer);
136
virtual bool store(Field *field);
137
#ifdef EMBEDDED_LIBRARY
138
void remove_last_row();
140
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
144
class Protocol_binary :public Protocol
150
Protocol_binary(THD *thd_arg) :Protocol(thd_arg) {}
151
virtual bool prepare_for_send(List<Item> *item_list);
152
virtual void prepare_for_resend();
153
#ifdef EMBEDDED_LIBRARY
154
virtual bool write();
155
bool net_store_data(const uchar *from, size_t length);
157
virtual bool store_null();
158
virtual bool store_tiny(longlong from);
159
virtual bool store_short(longlong from);
160
virtual bool store_long(longlong from);
161
virtual bool store_longlong(longlong from, bool unsigned_flag);
162
virtual bool store_decimal(const my_decimal *);
163
virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
164
virtual bool store(const char *from, size_t length,
165
CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
166
virtual bool store(MYSQL_TIME *time);
167
virtual bool store_date(MYSQL_TIME *time);
168
virtual bool store_time(MYSQL_TIME *time);
169
virtual bool store(float nr, uint32 decimals, String *buffer);
170
virtual bool store(double from, uint32 decimals, String *buffer);
171
virtual bool store(Field *field);
172
virtual enum enum_protocol_type type() { return PROTOCOL_BINARY; };
175
void send_warning(THD *thd, uint sql_errno, const char *err=0);
176
bool net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
177
void net_end_statement(THD *thd);
178
bool send_old_password_request(THD *thd);
179
uchar *net_store_data(uchar *to,const uchar *from, size_t length);
180
uchar *net_store_data(uchar *to,int32 from);
181
uchar *net_store_data(uchar *to,longlong from);