summaryrefslogtreecommitdiff
path: root/cdr
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2010-09-22 15:18:49 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2010-09-22 15:18:49 +0000
commitd5b09e2a36c995d1d21e7dd2092b57580f0fb8d9 (patch)
tree9e5cca06df31da4db367ac080fa238ede59be97f /cdr
parentc5f5c24103b35818d81c4598c4743ac45e631012 (diff)
Merged revisions 288268 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r288268 | tilghman | 2010-09-22 10:14:02 -0500 (Wed, 22 Sep 2010) | 30 lines Merged revisions 288267 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r288267 | tilghman | 2010-09-22 10:11:09 -0500 (Wed, 22 Sep 2010) | 23 lines 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 ........ ................ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@288278 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_pgsql.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 83c7d2e82..ee5842d15 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -52,7 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static const char name[] = "pgsql";
static const 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;
@@ -110,6 +110,9 @@ static int pgsql_log(struct ast_cdr *cdr)
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);
@@ -449,6 +452,19 @@ static int config_module(int reload)
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");
@@ -469,6 +485,9 @@ static int config_module(int reload)
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) {