[asterisk-dev] [Code Review] Correct character encoding for MySQL connections in Realtime w/ MySQL

Erin Spiceland espiceland at digium.com
Fri Oct 1 16:28:12 CDT 2010

This is an automatically generated e-mail. To reply, visit:

(Updated 2010-10-01 16:28:12.232264)

Review request for Asterisk Developers.




MySQL connection code used in res_config_mysql did not specify a character set, so data retrieved from the database was encoded incorrectly. I have added an optional configuration value which goes in res_mysql.conf which tells MySQL what character set to use when transmitting the data.  This bug was also present in the MYSQL dialplan application, so I have fixed it there as well.  Connection code both places now sends the specified character set (or "latin1" by default, as MySQL.com says this is the most commonly used character set) during connection and executes "SET NAME charset" immediately after connecting. Executing "SET NAMES charset" is necessary because it sets "character_set_connection" and "collation_connection" to the requested charsets instead of leaving them set to the default for the database which is being used.

Diffs (updated)

  /branches/1.4/apps/app_addon_sql_mysql.c 1132 
  /branches/1.4/res/res_config_mysql.c 1132 

Diff: https://reviewboard.asterisk.org/r/964/diff


Tested with 'utf8', 'latin1', and '' specified with utf8 and latin1 data. I also wrote an external test to test the dialplan application. I tested with valid and invalid charset names.  MySQL connection fails when the charset is not valid or is not supported.



More information about the asterisk-dev mailing list