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

Terry Wilson twilson at digium.com
Thu Oct 7 16:06:23 CDT 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/964/#review2815
-----------------------------------------------------------

Ship it!


Looks good. Great work!

- Terry


On 2010-10-07 15:57:51, Erin Spiceland wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/964/
> -----------------------------------------------------------
> 
> (Updated 2010-10-07 15:57:51)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> 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
> -----
> 
>   /branches/1.4/apps/app_addon_sql_mysql.c 1132 
>   /branches/1.4/cdr/cdr_addon_mysql.c 1132 
>   /branches/1.4/configs/cdr_mysql.conf.sample 1132 
>   /branches/1.4/configs/res_mysql.conf.sample 1132 
>   /branches/1.4/res/res_config_mysql.c 1132 
> 
> Diff: https://reviewboard.asterisk.org/r/964/diff
> 
> 
> Testing
> -------
> 
> 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.
> 
> 
> Thanks,
> 
> Erin
> 
>




More information about the asterisk-dev mailing list