CeBe
03.06.2009, 18:58:31
Moin Leute!
auf MySQL 5.4 und 5.1.34 getestet.
Die Problematik verfolgt mich nun schon mehrere Wochen. Das Problem tritt, soweit ich es bisher eingrenzen konnte mit Prozeduren auf, die PREPARE-Statements verwenden, ich vermute allerdings, dass es noch irgendwo im Server eine versteckte Config übersehen hab.
Der SQL-Query wird in folgender Reihenfolge ausgeführt:
SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
USE testdb;
CALL proc_statistic_list_activities_select ( '5' , '0000-00-00 00:00:00' , '2009-06-03 17:02:20' , 5 );
dieser wirft folgenden Error:
ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,COERCIBLE) and (utf8_unicode_ci,COERCIBLE) for operation '<>'
Meine Config:
mysql> SHOW VARIABLES LIKE 'character_set%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
Auszug aus /etc/mysql/my.cnf
[mysqld]
[...]
# encoding settings
default-character-set=utf8
default-collation=utf8_unicode_ci
character-set-server=utf8
collation-server=utf8_unicode_ci
character-set-server=utf8
collation-server=utf8_unicode_ci
Obwohl in der my.cnf die default-collation=utf8_unicode_ci gesetzt ist, findet sich in der Tabelle information_schema.COLLATIONS ein Eintrag bei Default auf utf8_general_ci und alle Tabellen in der Datenbank mysql und information_schema sind auf utf8_unicode_ci gesetzt.
mysql> SELECT * FROM information_schema.COLLATIONS;
+--------------------+--------------------+-----+------------+-------------+---------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
+--------------------+--------------------+-----+------------+-------------+---------+
[...]
| utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
| utf8_bin | utf8 | 83 | | Yes | 1 |
| utf8_unicode_ci | utf8 | 192 | | Yes | 8 |
[...]
| binary | binary | 63 | Yes | Yes | 1 |
+--------------------+--------------------+-----+------------+-------------+---------+
30 rows in set (0.00 sec)
Wenn noch Infos fehlen, einfach nachfragen!
Bin für jeden Ansatz dankbar!
MfG
Carsten
auf MySQL 5.4 und 5.1.34 getestet.
Die Problematik verfolgt mich nun schon mehrere Wochen. Das Problem tritt, soweit ich es bisher eingrenzen konnte mit Prozeduren auf, die PREPARE-Statements verwenden, ich vermute allerdings, dass es noch irgendwo im Server eine versteckte Config übersehen hab.
Der SQL-Query wird in folgender Reihenfolge ausgeführt:
SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
USE testdb;
CALL proc_statistic_list_activities_select ( '5' , '0000-00-00 00:00:00' , '2009-06-03 17:02:20' , 5 );
dieser wirft folgenden Error:
ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,COERCIBLE) and (utf8_unicode_ci,COERCIBLE) for operation '<>'
Meine Config:
mysql> SHOW VARIABLES LIKE 'character_set%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'collation%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
Auszug aus /etc/mysql/my.cnf
[mysqld]
[...]
# encoding settings
default-character-set=utf8
default-collation=utf8_unicode_ci
character-set-server=utf8
collation-server=utf8_unicode_ci
character-set-server=utf8
collation-server=utf8_unicode_ci
Obwohl in der my.cnf die default-collation=utf8_unicode_ci gesetzt ist, findet sich in der Tabelle information_schema.COLLATIONS ein Eintrag bei Default auf utf8_general_ci und alle Tabellen in der Datenbank mysql und information_schema sind auf utf8_unicode_ci gesetzt.
mysql> SELECT * FROM information_schema.COLLATIONS;
+--------------------+--------------------+-----+------------+-------------+---------+
| COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
+--------------------+--------------------+-----+------------+-------------+---------+
[...]
| utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
| utf8_bin | utf8 | 83 | | Yes | 1 |
| utf8_unicode_ci | utf8 | 192 | | Yes | 8 |
[...]
| binary | binary | 63 | Yes | Yes | 1 |
+--------------------+--------------------+-----+------------+-------------+---------+
30 rows in set (0.00 sec)
Wenn noch Infos fehlen, einfach nachfragen!
Bin für jeden Ansatz dankbar!
MfG
Carsten