mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for bug#19829:make test Failed in mysql_client_test
*with --with-charset=utf8* Problem: wrong LONG TEXT field length is sent to a client when multibyte server character set used. Fix: always limit field length sent to a client to 2^32, as we store it in 4 byte slot. Note: mysql_client_test changed accordingly. sql/protocol.cc: Fix for bug#19829:make test Failed in mysql_client_test *with --with-charset=utf8* - limit field length sent to client to UINT_MAX32 as it may exceeds 32 bit slot for LONG TEXT fields if thd_charset->mbmaxlen > 1. tests/mysql_client_test.c: Fix for bug#19829:make test Failed in mysql_client_test *with --with-charset=utf8* - checking field members have in mind that field length is limited to UINT_MAX32.
This commit is contained in:
@ -616,7 +616,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
|
||||
@ -627,12 +628,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);
|
||||
|
Reference in New Issue
Block a user