[asterisk-commits] tilghman: branch 1.6.2 r288267 - in /branches/1.6.2: ./ cdr/ configs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 22 10:11:14 CDT 2010


Author: tilghman
Date: Wed Sep 22 10:11:09 2010
New Revision: 288267

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=288267
Log:
Merged revisions 288265-288266 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r288265 | tilghman | 2010-09-22 09:48:04 -0500 (Wed, 22 Sep 2010) | 9 lines
  
  Allow the encoding to be set, in case local charset does not agree with database.
  
  (closes issue #16940)
   Reported by: jamicque
   Patches: 
         20100827__issue16940.diff.txt uploaded by tilghman (license 14)
         20100921__issue16940__1.6.2.diff.txt uploaded by tilghman (license 14)
   Tested by: jamicque
........
  r288266 | tilghman | 2010-09-22 10:04:52 -0500 (Wed, 22 Sep 2010) | 5 lines
  
  Document addition of encoding parameter.
  
  (issue #16940)
  Reported by: jamicque
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/UPGRADE.txt
    branches/1.6.2/cdr/cdr_pgsql.c
    branches/1.6.2/configs/cdr_pgsql.conf.sample

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: branches/1.6.2/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/UPGRADE.txt?view=diff&rev=288267&r1=288266&r2=288267
==============================================================================
--- branches/1.6.2/UPGRADE.txt (original)
+++ branches/1.6.2/UPGRADE.txt Wed Sep 22 10:11:09 2010
@@ -126,6 +126,11 @@
 * The cdr.conf file must exist and be configured correctly in order for CDR
   records to be written.
 
+* cdr_pgsql now assumes the encoding of strings it is handed are in LATIN9,
+  which should cover most uses of the extended ASCII set.  If your strings
+  use a different encoding in Asterisk, the "encoding" parameter may be set
+  to specify the correct character set.
+
 From 1.6.0.1 to 1.6.1:
 
 * The ast_agi_register_multiple() and ast_agi_unregister_multiple()

Modified: branches/1.6.2/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/cdr/cdr_pgsql.c?view=diff&rev=288267&r1=288266&r2=288267
==============================================================================
--- branches/1.6.2/cdr/cdr_pgsql.c (original)
+++ branches/1.6.2/cdr/cdr_pgsql.c Wed Sep 22 10:11:09 2010
@@ -54,7 +54,7 @@
 
 static char *name = "pgsql";
 static char *config = "cdr_pgsql.conf";
-static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL;
+static char *pghostname = NULL, *pgdbname = NULL, *pgdbuser = NULL, *pgpassword = NULL, *pgdbport = NULL, *table = NULL, *encoding = NULL;
 static int connected = 0;
 static int maxsize = 512, maxsize2 = 512;
 
@@ -112,6 +112,9 @@
 		conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
 		if (PQstatus(conn) != CONNECTION_BAD) {
 			connected = 1;
+			if (PQsetClientEncoding(conn, encoding)) {
+				ast_log(LOG_WARNING, "Failed to set encoding to '%s'.  Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+			}
 		} else {
 			pgerror = PQerrorMessage(conn);
 			ast_log(LOG_ERROR, "Unable to connect to database server %s.  Calls will not be logged!\n", pghostname);
@@ -452,6 +455,19 @@
 		return -1;
 	}
 
+	if (!(tmp = ast_variable_retrieve(cfg, "global", "encoding"))) {
+		ast_log(LOG_WARNING, "Encoding not specified.  Assuming LATIN9\n");
+		tmp = "LATIN9";
+	}
+
+	if (encoding) {
+		ast_free(encoding);
+	}
+	if (!(encoding = ast_strdup(tmp))) {
+		ast_config_destroy(cfg);
+		return -1;
+	}
+
 	if (option_debug) {
 		if (ast_strlen_zero(pghostname)) {
 			ast_debug(1, "using default unix socket\n");
@@ -472,6 +488,9 @@
 		int i, rows, version;
 		ast_debug(1, "Successfully connected to PostgreSQL database.\n");
 		connected = 1;
+		if (PQsetClientEncoding(conn, encoding)) {
+			ast_log(LOG_WARNING, "Failed to set encoding to '%s'.  Encoding set to default '%s'\n", encoding, pg_encoding_to_char(PQclientEncoding(conn)));
+		}
 		version = PQserverVersion(conn);
 
 		if (version >= 70300) {

Modified: branches/1.6.2/configs/cdr_pgsql.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/configs/cdr_pgsql.conf.sample?view=diff&rev=288267&r1=288266&r2=288267
==============================================================================
--- branches/1.6.2/configs/cdr_pgsql.conf.sample (original)
+++ branches/1.6.2/configs/cdr_pgsql.conf.sample Wed Sep 22 10:11:09 2010
@@ -7,3 +7,4 @@
 ;password=password
 ;user=postgres
 ;table=cdr		;SQL table where CDRs will be inserted
+;encoding=LATIN9	; Encoding of logged characters in Asterisk




More information about the asterisk-commits mailing list