diff options
Diffstat (limited to 'sql/protocol.h')
-rw-r--r-- | sql/protocol.h | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/sql/protocol.h b/sql/protocol.h index f8e7f490d1b..1a649a252e5 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -1,4 +1,6 @@ -/* Copyright (C) 2002-2006 MySQL AB +/* + Copyright (c) 2002-2007 MySQL AB, 2009 Sun Microsystems, Inc. + Use is subject to license terms. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,7 +13,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ @@ -35,14 +38,14 @@ protected: #endif uint field_count; #ifndef EMBEDDED_LIBRARY - bool net_store_data(const char *from, uint length); + bool net_store_data(const uchar *from, size_t length); #else - virtual bool net_store_data(const char *from, uint length); + virtual bool net_store_data(const uchar *from, size_t length); char **next_field; MYSQL_FIELD *next_mysql_field; MEM_ROOT *alloc; #endif - bool store_string_aux(const char *from, uint length, + bool store_string_aux(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); public: Protocol() {} @@ -58,6 +61,8 @@ public: String *storage_packet() { return packet; } inline void free() { packet->free(); } virtual bool write(); + inline bool store(int from) + { return store_long((longlong) from); } inline bool store(uint32 from) { return store_long((longlong) from); } inline bool store(longlong from) @@ -73,6 +78,7 @@ public: return 0; } virtual bool flush(); + virtual void end_partial_result_set(THD *thd); virtual void prepare_for_resend()=0; virtual bool store_null()=0; @@ -81,8 +87,8 @@ public: virtual bool store_long(longlong from)=0; virtual bool store_longlong(longlong from, bool unsigned_flag)=0; virtual bool store_decimal(const my_decimal *)=0; - virtual bool store(const char *from, uint length, CHARSET_INFO *cs)=0; - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)=0; + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0; virtual bool store(float from, uint32 decimals, String *buffer)=0; virtual bool store(double from, uint32 decimals, String *buffer)=0; @@ -96,16 +102,25 @@ public: #else void remove_last_row() {} #endif + enum enum_protocol_type + { + PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1 + /* + before adding here or change the values, consider that it is cast to a + bit in sql_cache.cc. + */ + }; + virtual enum enum_protocol_type type()= 0; }; -/* Class used for the old (MySQL 4.0 protocol) */ +/** Class used for the old (MySQL 4.0 protocol). */ -class Protocol_simple :public Protocol +class Protocol_text :public Protocol { public: - Protocol_simple() {} - Protocol_simple(THD *thd_arg) :Protocol(thd_arg) {} + Protocol_text() {} + Protocol_text(THD *thd_arg) :Protocol(thd_arg) {} virtual void prepare_for_resend(); virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -113,8 +128,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store_decimal(const my_decimal *); - virtual bool store(const char *from, uint length, CHARSET_INFO *cs); - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs); + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(MYSQL_TIME *time); virtual bool store_date(MYSQL_TIME *time); @@ -125,21 +140,22 @@ public: #ifdef EMBEDDED_LIBRARY void remove_last_row(); #endif + virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; }; }; -class Protocol_prep :public Protocol +class Protocol_binary :public Protocol { private: uint bit_fields; public: - Protocol_prep() {} - Protocol_prep(THD *thd_arg) :Protocol(thd_arg) {} + Protocol_binary() {} + Protocol_binary(THD *thd_arg) :Protocol(thd_arg) {} virtual bool prepare_for_send(List<Item> *item_list); virtual void prepare_for_resend(); #ifdef EMBEDDED_LIBRARY virtual bool write(); - bool net_store_data(const char *from, uint length); + bool net_store_data(const uchar *from, size_t length); #endif virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -147,8 +163,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store_decimal(const my_decimal *); - virtual bool store(const char *from,uint length, CHARSET_INFO *cs); - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs); + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(MYSQL_TIME *time); virtual bool store_date(MYSQL_TIME *time); @@ -156,16 +172,14 @@ public: virtual bool store(float nr, uint32 decimals, String *buffer); virtual bool store(double from, uint32 decimals, String *buffer); virtual bool store(Field *field); + virtual enum enum_protocol_type type() { return PROTOCOL_BINARY; }; }; void send_warning(THD *thd, uint sql_errno, const char *err=0); -void net_printf_error(THD *thd, uint sql_errno, ...); -void net_send_error(THD *thd, uint sql_errno=0, const char *err=0); -void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, - const char *info=0); -void send_eof(THD *thd); +bool net_send_error(THD *thd, uint sql_errno=0, const char *err=0); +void net_end_statement(THD *thd); bool send_old_password_request(THD *thd); -char *net_store_data(char *to,const char *from, uint length); -char *net_store_data(char *to,int32 from); -char *net_store_data(char *to,longlong from); +uchar *net_store_data(uchar *to,const uchar *from, size_t length); +uchar *net_store_data(uchar *to,int32 from); +uchar *net_store_data(uchar *to,longlong from); |