summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2009-02-26 16:14:33 +0400
committerRamil Kalimullin <ramil@mysql.com>2009-02-26 16:14:33 +0400
commit3a29b7afaa40e40d33a3448dc07700f8ea3e5dca (patch)
treea04236518f50d9fb95b4f8fe1f0bcbb58f5f128f /sql/protocol.cc
parent40d4b5778519d552dd94a922397209b97587fe90 (diff)
parentce78a8bd50f39472df7efa6194f48080a32b8878 (diff)
downloadmariadb-git-3a29b7afaa40e40d33a3448dc07700f8ea3e5dca.tar.gz
Auto-merge
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 4177cd0054d..6699196fbc7 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -573,7 +573,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
else
{
/* With conversion */
- uint max_char_len;
+ ulonglong max_length;
+ uint32 field_length;
int2store(pos, thd_charset->number);
/*
For TEXT/BLOB columns, field_length describes the maximum data
@@ -584,12 +585,21 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
char_count * mbmaxlen, where character count is taken from the
definition of the column. In other words, the maximum number
of characters here is limited by the column definition.
+
+ When one has a LONG TEXT column with a single-byte
+ character set, and the connection character set is multi-byte, the
+ client may get fields longer than UINT_MAX32, due to
+ <character set column> -> <character set connection> conversion.
+ In that case column max length does not fit into the 4 bytes
+ reserved for it in the protocol.
*/
- max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
- field.type <= (int) MYSQL_TYPE_BLOB) ?
- field.length / item->collation.collation->mbminlen :
- field.length / item->collation.collation->mbmaxlen;
- int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
+ max_length= (field.type >= MYSQL_TYPE_TINY_BLOB &&
+ field.type <= MYSQL_TYPE_BLOB) ?
+ field.length / item->collation.collation->mbminlen :
+ field.length / item->collation.collation->mbmaxlen;
+ max_length*= thd_charset->mbmaxlen;
+ field_length= (max_length > UINT_MAX32) ? UINT_MAX32 : max_length;
+ int4store(pos + 2, field_length);
}
pos[6]= field.type;
int2store(pos+7,field.flags);