Skip to content
Snippets Groups Projects
  • Sean Bright's avatar
    bae301c1
    cdr_mysql: Make sure connection charset is always set · bae301c1
    Sean Bright authored
    When the MYSQL_OPT_RECONNECT option is enabled, the MySQL client API
    will transparently reconnect when it needs to. Ideally this simplifies
    our code, but when this reconnection occurs all connection state is
    lost. Because we are not notified that this has happened, we don't know
    to set our character set again (with "SET NAMES 'xyz'").
    
    Rather than calling SET NAMES, we instead set the MYSQL_SET_CHARSET_NAME
    option which will do it for us under the hood on each connect. This
    option has been present in the MySQL C API for at least 15 years, so it
    should be safe for most installations.
    
    I also snuck a few other changes into this patch:
    
    * Default the MySQL port to MYSQL_PORT (3306) instead of 0 if it's not
      defined.
    
    * Fix some erroneous and/or silly checks on the contents of the
      configuration ast_str values.
    
    ASTERISK-27366 #close
    Reported by: Halil İbrahim YILDIZ
    
    Change-Id: I36bf8dc5d5f83584e803b3b1a151dea9396ab8f5
    bae301c1
    History
    cdr_mysql: Make sure connection charset is always set
    Sean Bright authored
    When the MYSQL_OPT_RECONNECT option is enabled, the MySQL client API
    will transparently reconnect when it needs to. Ideally this simplifies
    our code, but when this reconnection occurs all connection state is
    lost. Because we are not notified that this has happened, we don't know
    to set our character set again (with "SET NAMES 'xyz'").
    
    Rather than calling SET NAMES, we instead set the MYSQL_SET_CHARSET_NAME
    option which will do it for us under the hood on each connect. This
    option has been present in the MySQL C API for at least 15 years, so it
    should be safe for most installations.
    
    I also snuck a few other changes into this patch:
    
    * Default the MySQL port to MYSQL_PORT (3306) instead of 0 if it's not
      defined.
    
    * Fix some erroneous and/or silly checks on the contents of the
      configuration ast_str values.
    
    ASTERISK-27366 #close
    Reported by: Halil İbrahim YILDIZ
    
    Change-Id: I36bf8dc5d5f83584e803b3b1a151dea9396ab8f5
cdr_mysql.c 22.08 KiB