diff options
author | unknown <bar@mysql.com> | 2005-12-19 15:52:10 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2005-12-19 15:52:10 +0400 |
commit | e1c614134078b23934555bd76c6cdbd039d8bc28 (patch) | |
tree | 2c07c7fef70850b62144f4e7d0404fe1b900cd15 /sql/field.cc | |
parent | 52c044008508b1b445b21d780a238c9cb0b8c891 (diff) | |
download | mariadb-git-e1c614134078b23934555bd76c6cdbd039d8bc28.tar.gz |
Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
field.cc:
BLOB variations have number-in-bytes limit,
unlike CHAR/VARCHAR which have number-of-characters limits.
A tinyblob column can store up to 255 bytes.
In the case of basic Latin letters (which use 1 byte per character)
we can store up to 255 characters in a tinyblob column.
When passing an utf8 tinyblob column as an argument into
a function (e.g. COALESCE) we need to reserve 3*255 bytes.
I.e. multiply length in bytes to mbcharlen for the character set.
Although in reality a tinyblob column can never be 3*255 bytes long,
we need to set max_length to multiply to make fix_length_and_dec()
of the function-caller (e.g. COALESCE) calculate the correct max_length
for the column being created.
ctype_utf8.result, ctype_utf8.test:
Adding test case.
mysql-test/t/ctype_utf8.test:
Adding test case.
mysql-test/r/ctype_utf8.result:
Adding test case.
sql/field.cc:
Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
BLOB variations have byte limits,
unlike CHAR/VARCHAR which have number-of-character limits.
It means tinyblob can store up to 255 bytes.
All of them can be basic latin letters which use 1 byte
per character.
I.e. we can store up to 255 characters in a tinyblob column.
When passing a tinyblob column as an argument into
a function (for example COALESCE or CONCAT) we
need to reserve 3*255 bytes in the case of utf-8.
I.e. multiply length in bytes to mbcharlen for the
character set.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/field.cc b/sql/field.cc index abb5297f458..b1d9167aee2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6949,11 +6949,11 @@ uint32 Field_blob::max_length() switch (packlength) { case 1: - return 255; + return 255 * field_charset->mbmaxlen; case 2: - return 65535; + return 65535 * field_charset->mbmaxlen; case 3: - return 16777215; + return 16777215 * field_charset->mbmaxlen; case 4: return (uint32) 4294967295U; default: |