diff options
author | pem@mysql.com <> | 2004-05-26 17:04:45 +0200 |
---|---|---|
committer | pem@mysql.com <> | 2004-05-26 17:04:45 +0200 |
commit | 71eddc362e7d22b9922bad9d093819592208726b (patch) | |
tree | e4e5bb1f8b9718ec195b357c050b3dc3254b447d /sql/protocol.cc | |
parent | 350d8a215bb83518519a2c7c1bc218170bb6b8a9 (diff) | |
parent | 94c0611e6b1f7a1ee93facc31a2f2876cf664e7a (diff) | |
download | mariadb-git-71eddc362e7d22b9922bad9d093819592208726b.tar.gz |
Merging 4.1 to 5.0.
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index 4d0859aed22..b2334b0f356 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -468,6 +468,7 @@ void Protocol::init(THD *thd_arg) { thd=thd_arg; packet= &thd->packet; + convert= &thd->convert_buffer; #ifndef DEBUG_OFF field_types= 0; #endif @@ -704,6 +705,26 @@ bool Protocol_simple::store_null() #endif +/* + Auxilary function to convert string to the given character set + and store in network buffer. +*/ + +bool Protocol::store_string_aux(const char *from, uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs) +{ + /* 'tocs' is set 0 when client issues SET character_set_results=NULL */ + if (tocs && !my_charset_same(fromcs, tocs) && + fromcs != &my_charset_bin && + tocs != &my_charset_bin) + { + return convert->copy(from, length, fromcs, tocs) || + net_store_data(convert->ptr(), convert->length()); + } + return net_store_data(from, length); +} + + bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) { @@ -714,15 +735,7 @@ bool Protocol_simple::store(const char *from, uint length, field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_pos++; #endif - if (tocs && !my_charset_same(fromcs, tocs) && - (fromcs != &my_charset_bin) && - (tocs != &my_charset_bin)) - { - convert.copy(from, length, fromcs, tocs); - return net_store_data(convert.ptr(), convert.length()); - } - else - return net_store_data(from, length); + return store_string_aux(from, length, fromcs, tocs); } @@ -737,15 +750,7 @@ bool Protocol_simple::store(const char *from, uint length, field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_pos++; #endif - if (tocs && !my_charset_same(fromcs, tocs) && - (fromcs != &my_charset_bin) && - (tocs != &my_charset_bin)) - { - convert.copy(from, length, fromcs, tocs); - return net_store_data(convert.ptr(), convert.length()); - } - else - return net_store_data(from, length); + return store_string_aux(from, length, fromcs, tocs); } @@ -839,15 +844,7 @@ bool Protocol_simple::store(Field *field) CHARSET_INFO *tocs= this->thd->variables.character_set_results; field->val_str(&str); - if (tocs && !my_charset_same(field->charset(), tocs) && - (field->charset() != &my_charset_bin) && - (tocs != &my_charset_bin)) - { - convert.copy(str.ptr(), str.length(), str.charset(), tocs); - return net_store_data(convert.ptr(), convert.length()); - } - else - return net_store_data(str.ptr(), str.length()); + return store_string_aux(str.ptr(), str.length(), str.charset(), tocs); } @@ -960,8 +957,9 @@ void Protocol_prep::prepare_for_resend() } -bool Protocol_prep::store(const char *from,uint length, CHARSET_INFO *cs) +bool Protocol_prep::store(const char *from, uint length, CHARSET_INFO *fromcs) { + CHARSET_INFO *tocs= thd->variables.character_set_results; #ifndef DEBUG_OFF DBUG_ASSERT(field_types == 0 || field_types[field_pos] == MYSQL_TYPE_DECIMAL || @@ -969,7 +967,7 @@ bool Protocol_prep::store(const char *from,uint length, CHARSET_INFO *cs) field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); #endif field_pos++; - return net_store_data(from, length); + return store_string_aux(from, length, fromcs, tocs); } bool Protocol_prep::store(const char *from,uint length, @@ -982,7 +980,7 @@ bool Protocol_prep::store(const char *from,uint length, field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); #endif field_pos++; - return net_store_data(from, length); + return store_string_aux(from, length, fromcs, tocs); } bool Protocol_prep::store_null() |