Bug #8420 charset bug
Submitted: 10 Feb 2005 16:58 Modified: 23 Jun 2005 13:35
Reporter: [ name withheld ] Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:4.1.x OS:Microsoft Windows (Win32)
Assigned to: CPU Architecture:Any

[10 Feb 2005 16:58] [ name withheld ]
Description:
<?php 
$link = mysql_connect('localhost:3307', 'root', ''); 
$set = mysql_query('SET NAMES CP1251',$link);
$set = mysql_query('SET COLLATION_CONNECTION=CP1251_GENERAL_CI',$link);
$charset = mysql_client_encoding($link); 
printf ("current character set is %s\n", $charset); 
?>
echoes 
"File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 22)
Character set '#51' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file
current character set is latin1"

There is an obvious bug in every win32 distribution of MySQL 4.1.x.

There is no sense to setting such options as:
character-sets-dir=c:/mysql/share/charsets 
default-character-set=cp1251

In any case as result - something like this:
File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 22)
Character set '#51' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file

...In spite of the fact that directory C:\mysql41\share\charsets contains all necessary files.

By the way, they change format of "index" and "*.conf" files
No mo "conf" — current 4.1.x releases contains *.xml based  description of charset. So 'c:\mysql\share\charsets\?.conf ... blah-blah-blah' message looks like shit.

How to repeat:
<?php 
$link = mysql_connect('localhost:3307', 'root', ''); 
$set = mysql_query('SET NAMES CP1251',$link);
$set = mysql_query('SET COLLATION_CONNECTION=CP1251_GENERAL_CI',$link);
$charset = mysql_client_encoding($link); 
printf ("current character set is %s\n", $charset); 
?>
echoes 
"File 'c:\mysql\share\charsets\?.conf' not found (Errcode: 22)
Character set '#51' is not a compiled character set and is not specified in the 'c:\mysql\share\charsets\Index' file
current character set is latin1"

Suggested fix:
recompile binary distribution
[12 Feb 2005 4:10] [ name withheld ]
I have addidional information regarding situation with charsets.

First:
Temporary solution is to add attribute flag="primary" to <collation name="cp1251_bulgarian_ci" id="14"> in section <charset name="cp1251">. It's prevents MySQL from trying set collation cp1251_general_ci as primary. 

There is no such collation as:
cp1251_general_ci (id 51)
cp1251_ukrainian_ci (id 23)
cp1251_bin (id 50)
cp1251_general_cs (id 52).

Second:
SHOW COLLATION query result shows
that no one of cp1251 collation is not compiled (including cp1251_bulgarian_ci).
Nevertheless collation cp1251_bulgarian_ci works whereas other collation if set as primary cause error. Moreover if any of this collations excluding cp1251_bulgarian_ci is set as primary client connects current character set for client (mysql.exe or any front end or php) became latin1 and collation latin1_swedish_ci even 
SET NAMES CP1251
SET COLLATION_CONNECTION=CP1251_GENERAL_CI 
queries is executed.

Third:
libmySQL.dll is client library and if it used with mySQL front-end applications such as EMS MySQL manager, MySQL-Front client character set became latin1 and collation latin1_swedish_ci even mysql configuration file [client] and [server] sections has
character-sets-dir="[my path to dir]"
default-character-set=cp1251
...or...
SET NAMES CP1251
SET COLLATION_CONNECTION=CP1251_GENERAL_CI 
queries is executed.

And last:
If field in table is set to CP1251_GENERAL_CI collation all database became unreadable for mysql! 

All described cause loosing data in all tables! Records in cp1251 became like "???? ???? ???"
[12 Feb 2005 4:16] [ name withheld ]
caused data loss
[17 Feb 2005 14:39] [ name withheld ]
just tested on FreeBSD - MySQL 4.1.9 compiled with all charsets. same as on win32
[20 Mar 2005 4:43] Michael Kostenko
It is not the server bug in Windows. It is ODBC driver v3.5.11 bug. V3.5.9 works nice! You have some problems with new user library (4.1.x). All strings in cp1251 become like "?????????" in databse.
[20 Mar 2005 13:55] [ name withheld ]
Michael Kostenko wrote:
It is not the server bug in Windows. It is ODBC driver v3.5.11 bug.
V3.5.9 works nice! You have some problems with new user library
(4.1.x). All strings in cp1251 become like "?????????" in databse.

There is no ODBC, because  PHP does not use ODBC in mysql_* function. I have discovered that problem in PHP mysql library. Windows version of PHP 4.x.x compiled with old libmysqlclient - 3.xx.xx. Moreover, it has hardcoded path to mysql charset dir.
[23 May 2005 13:35] Miguel Solorzano
Are you tested using PHP 5 ?
[23 Jun 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".