Bug #12371 executing prepared statement fails (illegal mix of collations)
Submitted: 4 Aug 2005 11:17 Modified: 23 Oct 2005 0:42
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.11 OS:Linux (Linux)
Assigned to: Alexander Barkov CPU Architecture:Any

[4 Aug 2005 11:17] Georg Richter
Description:
When client character set is utf8 and table character set is latin1, an execute of a simple prepared statement fails with "illegal mix of collations" error.

Coercibility for @a is 2 (=Implicit) but error message says it's coercibile :-(

How to repeat:
set names utf8;

create table t1 (a char(3), b varchar(10));
insert into t1 values ('bar','kostja');
prepare my_stmt from "select * from t1 where a=?";
set @a:='bar';
execute my_stmt using @a;
ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='

select charset(@a), coercibility(@a);
+-------------+------------------+
| charset(@a) | coercibility(@a) |
+-------------+------------------+
| utf8        |                2 |
+-------------+------------------+
[6 Aug 2005 12:03] 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/internals/27958
[29 Aug 2005 11:53] 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/internals/28969
[5 Sep 2005 12:40] Michael Widenius
Bug fixed in 4.1; For 5.0 we need another solution
[22 Sep 2005 9:46] 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/internals/30195
[12 Oct 2005 1:28] William Leung
The problem is exists in mysql 4.1.14
but it is ok in mysql 4.1.12/4.1.13.

Please see bug #13633
[21 Oct 2005 12:12] Alexander Barkov
Fixed in 5.0.16.

In 4.1 it was fixed earlier.
[23 Oct 2005 0:42] Paul DuBois
Noted in 4.1.15, 5.0.16 changelogs.