Can't correct restore the sql with Chinese Info.

Bug #817873 reported by yangdehua
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Data Dumper
New
Undecided
Unassigned

Bug Description

version 0.2.3 and mydumper 0.5

when i use mydumper and myloader , i was surprised that there is no any options to choose character set .

mysql and mysqldump can allowe us to choose the character set.

I am an user of MySQL in China. The Chinese contents we used to using GBK to restore data.

When i tried to use mydumper to dump data, it does well. But when i used myloader to restore the record. I found something wrong. MySQL would tell that the sql file had some error synax .

So i modified the mydumper.c and myloader.c , corrected the code " mysql_query(thrconn, "/*!40101 SET NAMES %s */",character_set)"

The source code is " mysql_query(thrconn, "/*!40101 SET NAMES binary */") "

Revision history for this message
yangdehua (yangdehua) wrote :
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Hi,

Using the binary character set is intentional, it means there is no translation of the data during dump or restore so the data should be preserved in the correct character set.

This is a bug in myloader, but I think there may be a better way to fix it so that the user doesn't need to specify character set. I will look into it.

yangdehua (yangdehua)
description: updated
Revision history for this message
yangdehua (yangdehua) wrote :

Thank you for come

Revision history for this message
yangdehua (yangdehua) wrote :

i think that i have found the better way to resolve this character problem.

i need to modify mydumper.c +431

 432 MYSQL_RES *server_character_set;
 433 MYSQL_ROW row_list;
 434 if(mysql_query(conn,"show variables like 'character_set_server'") || !(server_character_set = mysql_store_result(conn)))
     {
 435 g_critical("Unable to get character_set_server ",mysql_error(conn));
 436 exit(EXIT_FAILURE);
 437 }
 438
 439 while ((row_list=mysql_fetch_row(server_character_set))) {
 440 character_set = row_list[1];
 441 g_print("set names %s",row_list[1]);
 442 mysql_query(conn,g_strdup_printf("set names %s",row_list[1]));
 443 }
 444 mysql_free_result(server_character_set);

Revision history for this message
yangdehua (yangdehua) wrote :

one error would be told , "g_critical("Unable to get character_set_server ",mysql_error(conn));"

it should be like this"

g_critical("Unable to list databases: %s",mysql_error(conn));

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

Hi,

As I previously stated the bug will be in myloader, not mydumper. Can you please provide a test case (such as a mysqldump output) so I can reproduce this?

Revision history for this message
magicfly (553538738-9) wrote :

Hi,

Have you worked out any approach to solve the problem?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.