584
585
char_count * mbmaxlen, where character count is taken from the
585
586
definition of the column. In other words, the maximum number
586
587
of characters here is limited by the column definition.
589
When one has a LONG TEXT column with a single-byte
590
character set, and the connection character set is multi-byte, the
591
client may get fields longer than UINT_MAX32, due to
592
<character set column> -> <character set connection> conversion.
593
In that case column max length does not fit into the 4 bytes
594
reserved for it in the protocol.
588
max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
589
field.type <= (int) MYSQL_TYPE_BLOB) ?
590
field.length / item->collation.collation->mbminlen :
591
field.length / item->collation.collation->mbmaxlen;
592
int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
596
max_length= (field.type >= MYSQL_TYPE_TINY_BLOB &&
597
field.type <= MYSQL_TYPE_BLOB) ?
598
field.length / item->collation.collation->mbminlen :
599
field.length / item->collation.collation->mbmaxlen;
600
max_length*= thd_charset->mbmaxlen;
601
field_length= (max_length > UINT_MAX32) ?
602
UINT_MAX32 : (uint32) max_length;
603
int4store(pos + 2, field_length);
594
605
pos[6]= field.type;
595
606
int2store(pos+7,field.flags);