Ticket #177: mysql-utf8.patch

File mysql-utf8.patch, 0.9 KB (added by harry, 11 months ago)

use utf8 on reconnect

  • storage/storage_mysql.c

    diff --git a/storage/storage_mysql.c b/storage/storage_mysql.c
    index 18f5947..8d8c61f 100644
    a b  
    623623    mysql_options(conn, MYSQL_READ_DEFAULT_GROUP, "jabberd"); 
    624624#endif 
    625625 
     626    mysql_options(conn, MYSQL_SET_CHARSET_NAME, "utf8"); 
     627 
    626628    /* connect with CLIENT_INTERACTIVE to get a (possibly) higher timeout value than default */ 
    627629    if(mysql_real_connect(conn, host, user, pass, dbname, atoi(port), NULL, CLIENT_INTERACTIVE) == NULL) { 
    628630        log_write(drv->st->sm->log, LOG_ERR, "mysql: connection to database failed: %s", mysql_error(conn)); 
     
    630632        return st_FAILED; 
    631633    } 
    632634 
    633     mysql_query(conn, "SET NAMES 'utf8'"); 
    634  
    635635    /* Set reconnect flag to 1 (set to 0 by default from mysql 5 on) */ 
    636636    conn->reconnect = 1; 
    637637