[asterisk-addons-commits] tilghman: branch 1.6.0 r708 - in /branches/1.6.0: ./ cdr/ configs/

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


Author: tilghman
Date: Thu Dec 11 15:17:31 2008
New Revision: 708

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=708
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.0/   (props changed)
    branches/1.6.0/cdr/cdr_addon_mysql.c
    branches/1.6.0/configs/cdr_mysql.conf.sample

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
--- trunk-merged (original)
+++ trunk-merged Thu Dec 11 15:17:31 2008
@@ -1,1 +1,1 @@
-/trunk:540-559,575,579,583,586,588,590,592,594,603,607,612,615,617,627,647,653,659,662
+/trunk:540-559,575,579,583,586,588,590,592,594,603,607,612,615,617,627,647,653,659,662,707

Modified: branches/1.6.0/cdr/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.6.0/cdr/cdr_addon_mysql.c?view=diff&rev=708&r1=707&r2=708
==============================================================================
--- branches/1.6.0/cdr/cdr_addon_mysql.c (original)
+++ branches/1.6.0/cdr/cdr_addon_mysql.c Thu Dec 11 15:17:31 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.0/configs/cdr_mysql.conf.sample
URL: http://svn.digium.com/view/asterisk-addons/branches/1.6.0/configs/cdr_mysql.conf.sample?view=diff&rev=708&r1=707&r2=708
==============================================================================
--- branches/1.6.0/configs/cdr_mysql.conf.sample (original)
+++ branches/1.6.0/configs/cdr_mysql.conf.sample Thu Dec 11 15:17:31 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