Bug #29205 truncation when using binary in union
Submitted: 19 Jun 2007 11:05 Modified: 4 Jul 2007 1:59
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.42, 5.1 OS:Any
Assigned to: Gleb Shchepa CPU Architecture:Any

[19 Jun 2007 11:05] Georg Richter
Description:
When mixing binary and utf8 character set in a union, fields lenghts are not set correctly, which leads to truncation.

This might be related to the union problems in bug #28577.

How to repeat:
set names utf8;
select "нещо на кирилица утф8";
select "нещо на кирилица утф8" union select _binary "foo";

Output:

+----------------------------------------+
| нещо на кирилица утф8 |
+----------------------------------------+
| нещо на кирилица утф8 |
+----------------------------------------+
1 row in set (0.00 sec)

+----------------------------------------+
| нещо на кирилица утф8 |
+----------------------------------------+
| нещо на кир�                 |
| foo                                    |
+----------------------------------------+

field len for first statement is 63,
field len for second statement is 21
[19 Jun 2007 12:11] MySQL Verification Team
Thank you for the bug report. Verified as described.
[29 Jun 2007 18:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/29979

ChangeSet@1.2508, 2007-06-29 23:26:40+05:00, gshchepa@gleb.loc +3 -0
  Fixed bug #29205.
  When the UNION statement forced conversion of an UTF8
  charset value to a binary charset value, a byte
  length of the resulting value was truncated to the
  CHAR_LENGTH of the original UTF8 value.
[29 Jun 2007 21:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/29985

ChangeSet@1.2508, 2007-06-30 02:09:50+05:00, gshchepa@gleb.loc +3 -0
  Fixed bug #29205.
  When a UNION statement forced conversion of an UTF8
  charset value to a binary charset value, the byte
  length of the result values was truncated to the
  CHAR_LENGTH of the original UTF8 value.
[1 Jul 2007 19:57] Bugs System
Pushed into 5.1.21-beta
[1 Jul 2007 20:01] Bugs System
Pushed into 5.0.46
[4 Jul 2007 1:59] Paul DuBois
Noted in 5.0.46, 5.1.21 changelogs.

Mixing binary and utf8 columns in a union caused field lengths to be
calculated incorrectly, resulting in truncation.