[asterisk-addons-commits] tilghman: branch 1.6.1 r709 - in /branches/1.6.1: ./ cdr/ configs/

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Thu Dec 11 15:18:19 CST 2008


Author: tilghman
Date: Thu Dec 11 15:18:19 2008
New Revision: 709

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=709
Log:
Merged revisions 707 via svnmerge from 
https://origsvn.digium.com/svn/asterisk-addons/trunk

........
  r707 | tilghman | 2008-12-11 15:16:11 -0600 (Thu, 11 Dec 2008) | 6 lines
  
  Allow setting the MySQL character set on each connect.
  (closes issue #13775)
   Reported by: sergee
   Patches: 
         cdr_mysql_charset-r679-v2.diff uploaded by sergee (license 138)
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/cdr/cdr_addon_mysql.c
    branches/1.6.1/configs/cdr_mysql.conf.sample

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
--- trunk-merged (original)
+++ trunk-merged Thu Dec 11 15:18:19 2008
@@ -1,1 +1,1 @@
-/trunk:1-690
+/trunk:1-690,707

Modified: branches/1.6.1/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.6.1/cdr/cdr_addon_mysql.c?view=diff&rev=709&r1=708&r2=709
==============================================================================
--- branches/1.6.1/cdr/cdr_addon_mysql.c (original)
+++ branches/1.6.1/cdr/cdr_addon_mysql.c Thu Dec 11 15:18:19 2008
@@ -59,7 +59,7 @@
 static char *name = "mysql";
 static char *config = "cdr_mysql.conf";
 
-static struct ast_str *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL;
+static struct ast_str *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL, *dbcharset = NULL;
 
 static struct ast_str *ssl_ca = NULL, *ssl_cert = NULL, *ssl_key = NULL;
 
@@ -185,6 +185,11 @@
 			connected = 1;
 			connect_time = time(NULL);
 			records = 0;
+			if (dbcharset) {
+				snprintf(sql1, sizeof(sql1), "SET NAMES '%s'", dbcharset->str);
+				mysql_real_query(&mysql, sql1, strlen(sql1));
+				ast_debug(1, "SQL command as follows: %s\n", sql1);
+			}
 		} else {
 			ast_log(LOG_ERROR, "Cannot connect to database server %s: (%d) %s\n", hostname->str, mysql_errno(&mysql), mysql_error(&mysql));
 			connected = 0;
@@ -443,6 +448,8 @@
 	res |= my_load_config_string(cfg, "global", "table", &dbtable, "cdr");
 	res |= my_load_config_string(cfg, "global", "password", &password, "");
 
+	res |= my_load_config_string(cfg, "global", "charset", &dbcharset, "");
+
 	res |= my_load_config_string(cfg, "global", "ssl_ca", &ssl_ca, "");
 	res |= my_load_config_string(cfg, "global", "ssl_cert", &ssl_cert, "");
 	res |= my_load_config_string(cfg, "global", "ssl_key", &ssl_key, "");
@@ -474,6 +481,10 @@
 	ast_debug(1, "Got dbname of %s\n", dbname->str);
 	ast_debug(1, "Got password of %s\n", password->str);
 	ast_debug(1, "%sunning in calldate compatibility mode\n", calldate_compat ? "R" : "Not r");
+
+	if (dbcharset) {
+		ast_debug(1, "Got DB charste of %s\n", dbcharset->str);
+	}
 
 	mysql_init(&mysql);
 
@@ -501,6 +512,11 @@
 		connected = 1;
 		records = 0;
 		connect_time = time(NULL);
+		if (dbcharset) {
+			snprintf(sqldesc, sizeof(sqldesc), "SET NAMES '%s'", dbcharset->str);
+			mysql_real_query(&mysql, sqldesc, strlen(sqldesc));
+			ast_debug(1, "SQL command as follows: %s\n", sqldesc);
+		}
 
 		/* Get table description */
 		snprintf(sqldesc, sizeof(sqldesc), "DESC %s", dbtable ? dbtable->str : "cdr");

Modified: branches/1.6.1/configs/cdr_mysql.conf.sample
URL: http://svn.digium.com/view/asterisk-addons/branches/1.6.1/configs/cdr_mysql.conf.sample?view=diff&rev=709&r1=708&r2=709
==============================================================================
--- branches/1.6.1/configs/cdr_mysql.conf.sample (original)
+++ branches/1.6.1/configs/cdr_mysql.conf.sample Thu Dec 11 15:18:19 2008
@@ -18,6 +18,11 @@
 ;user=asteriskcdruser
 ;port=3306
 ;sock=/tmp/mysql.sock
+;
+; If your system's locale differs from mysql database character set,
+; cdr_mysql can damage non-latin characters in CDR variables. Use this
+; option to protect your data.
+;charset=koi8r
 ;
 ; Older versions of cdr_mysql set the calldate field to whenever the
 ; record was posted, rather than the start date of the call.  This flag




More information about the asterisk-addons-commits mailing list