summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 4c916d78378..d537f9cf829 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -537,10 +537,18 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
pos= (char*) local_packet->ptr()+local_packet->length();
*pos++= 12; // Length of packed fields
if (item->collation.collation == &my_charset_bin || thd_charset == NULL)
+ {
+ /* No conversion */
int2store(pos, field.charsetnr);
+ int4store(pos+2, field.length);
+ }
else
- int2store(pos, thd_charset->number);
- int4store(pos+2, field.length);
+ {
+ /* With conversion */
+ int2store(pos, thd_charset->number);
+ uint char_len= field.length / item->collation.collation->mbmaxlen;
+ int4store(pos+2, char_len * thd_charset->mbmaxlen);
+ }
pos[6]= field.type;
int2store(pos+7,field.flags);
pos[9]= (char) field.decimals;