diff options
author | konstantin@mysql.com <> | 2006-01-18 22:50:31 +0300 |
---|---|---|
committer | konstantin@mysql.com <> | 2006-01-18 22:50:31 +0300 |
commit | 4ca48591f154b625bdeb2c29bd2c52bfc4d04d04 (patch) | |
tree | b5c59dd9f326cc1228a43e3927586332f07403ad /sql/protocol.cc | |
parent | 75bc48a8d7c4c5a0d5a31247d88e72c135996e18 (diff) | |
download | mariadb-git-4ca48591f154b625bdeb2c29bd2c52bfc4d04d04.tar.gz |
A fix and a test case for Bug#15613 "libmysqlclient API function
mysql_stmt_prepare returns wrong field length"
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r-- | sql/protocol.cc | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc index 6a17ae2f95b..a2287740f1e 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -565,9 +565,23 @@ bool Protocol::send_fields(List<Item> *list, uint flag) else { /* With conversion */ + uint max_char_len; int2store(pos, thd_charset->number); - uint char_len= field.length / item->collation.collation->mbmaxlen; - int4store(pos+2, char_len * thd_charset->mbmaxlen); + /* + For TEXT/BLOB columns, field_length describes the maximum data + length in bytes. There is no limit to the number of characters + that a TEXT column can store, as long as the data fits into + the designated space. + For the rest of textual columns, field_length is evaluated as + 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. + */ + 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); } pos[6]= field.type; int2store(pos+7,field.flags); |