Ticket #90 (closed defect: fixed)

Opened 19 months ago

Last modified 14 months ago

jabber lives in utf8 world, and the mysql must know it explicitly

Reported by: don_oles Owned by: smoku
Priority: critical Component: storage
Version: 2.1 Keywords: utf8 mysql reconnect
Cc: Tracforge_linkmap:
Blocking: Blocked By:

Description

Long time ago, since MySQL 4.1, the use of my.cnf to set the client character set is very very deprecated, and the right way to put data to MySQL is explicitly specifying client character set. This is done by issuing SET NAMES, which in our case should be SET NAMES 'utf8'. Without that the national character set encoded data like names etc goes into MySQL as utf8 but it thinks that it is in default 'latin7' encoding, and the data becomes in very useless encoding to any other application.

Attachments

jabberd-mysql-utf8.patch.txt (0.6 KB) - added by don_oles 19 months ago.
the patch

Change History

Changed 19 months ago by don_oles

the patch

Changed 19 months ago by smoku

  • status changed from new to closed
  • resolution set to fixed

(In [238]) Merged MySQL connection setting to UTF-8 patch by Oles Hnatkevych. Fixes #90

Changed 19 months ago by smoku

(In [239]) Added DEFAULT CHARSET=UTF8 to tools/db-setup.mysql DB creation. Together with see #90 it fixes #88

Changed 14 months ago by uvi

  • keywords utf8 mysql reconnect added
  • priority changed from major to critical
  • component changed from General to storage
  • type changed from enhancement to defect

According to http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html "If you are using the mysql client with auto-reconnect enabled (which is not recommended), it is preferable to use the charset command rather than SET NAMES". It's true. After some idle storage_mysql.c reconnects with auto-reconnect and libmysql fallback to latin1 instead of utf8. Solution is to use http://dev.mysql.com/doc/refman/5.0/en/mysql-set-character-set.html, this do set names and also set mysql->charset. After reconnect utf8 preserved.

//mysql_query(conn, "SET NAMES 'utf8'"); if (mysql_set_character_set(conn, "utf8")) {

log_write(drv->st->sm->log, LOG_ERR, "mysql: cannot set character set: %s", mysql_

error(conn));

mysql_close(conn); return st_FAILED;

}

Note: See TracTickets for help on using tickets.