Bug #3725 wrong charset at parsing dump
Submitted: 12 May 2004 13:41 Modified: 14 May 2004 20:28
Reporter: Kovacs Janos Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:4.1 OS:Solaris (Solaris 9)
Assigned to: CPU Architecture:Any

[12 May 2004 13:41] Kovacs Janos
Description:
Reloading old dumps into a clean database the used charsets are wrong!

server:  version: 4.1.2-alpha-log (from bk development tree chechked ot at Tue May 11 17:38:15 CEST 2004.)

variables:
| character_set_client            | latin2                               |
| character_set_connection        | latin2                               |
| character_set_database          | latin2                               |
| character_set_results           | latin2                               |
| character_set_server            | latin2                               |
| character_set_system            | utf8                                 |
| character_sets_dir              | /mysql/share/mysql/charsets/         |
| collation_connection            | latin2_hungarian_ci                  |
| collation_database              | latin2_hungarian_ci                  |
| collation_server                | latin2_hungarian_ci                  |

database:
create database test1 charset latin2 collate latin2_hungarian_ci;

the dump conatain:

create table test1 (
  hir_id int(11) NOT NULL auto_increment,
  hir_cim varchar(100) collate latin2_hungarian_ci default 'NULL',
  PRIMARY KEY  (hir_id),
) TYPE=MyISAM CHARSET=latin2 COLLATE=latin2_hungarian_ci;

LOCK TABLES test1 WRITE;
INSERT INTO test1 VALUES (1,'Saját vizsgák id?pontjai');

If I use mysql -D test1 < dump  the '?' becomes '?'.

If I use:

SET character_set_client = latin2;
SET character_set_connection = latin2;

at the beginning of the dump, the mysql -D test1 < dump  works great. (no characters transformed to ?)

How to repeat:
create database test1 charset latin2 collate latin2_hungarian_ci;

use this dump:

# SET character_set_client = latin2;
# SET character_set_connection = latin2;

create table test1 (
  hir_id int(11) NOT NULL auto_increment,
  hir_cim varchar(100) collate latin2_hungarian_ci default 'NULL',
  PRIMARY KEY  (hir_id),
) TYPE=MyISAM CHARSET=latin2 COLLATE=latin2_hungarian_ci;

LOCK TABLES test1 WRITE;
INSERT INTO test1 VALUES (1,'Saját vizsgák id?pontjai');

Restore this dump. For errors with commenting out the two SET, for right behaviour without comments.

Suggested fix:
mysql should get theese variables from mysqld...  or could be set in my.cnf!
[12 May 2004 13:55] Kovacs Janos
Also, mysqldump does not get default_character_set value from the server if not set in my.cnf
[14 May 2004 20:28] Alexander Keremidarski
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

mysqldump being a Client can be set with different character sets than the Server. In this case convertion between character sets takes place.

mysqldump reads [client] section of my.cnf and not [mysqld]