Skip to content
Snippets Groups Projects
Commit b088a178 authored by Friendly Automation's avatar Friendly Automation Committed by Gerrit Code Review
Browse files

Merge "cdr_pgsql: fix error in connection string"

parents bcaa01b0 e61f2af8
No related branches found
No related tags found
No related merge requests found
...@@ -184,15 +184,27 @@ static void pgsql_reconnect(void) ...@@ -184,15 +184,27 @@ static void pgsql_reconnect(void)
conn = NULL; conn = NULL;
} }
ast_str_set(&conn_info, 0, "host=%s port=%s dbname=%s user=%s", if (!ast_strlen_zero(pghostname)) {
pghostname, pgdbport, pgdbname, pgdbuser); ast_str_append(&conn_info, 0, "host=%s ", pghostname);
}
if (!ast_strlen_zero(pgdbport)) {
ast_str_append(&conn_info, 0, "port=%s ", pgdbport);
}
if (!ast_strlen_zero(pgdbname)) {
ast_str_append(&conn_info, 0, "dbname=%s ", pgdbname);
}
if (!ast_strlen_zero(pgdbuser)) {
ast_str_append(&conn_info, 0, "user=%s ", pgdbuser);
}
if (!ast_strlen_zero(pgappname)) { if (!ast_strlen_zero(pgappname)) {
ast_str_append(&conn_info, 0, " application_name=%s", pgappname); ast_str_append(&conn_info, 0, "application_name=%s ", pgappname);
} }
if (!ast_strlen_zero(pgpassword)) { if (!ast_strlen_zero(pgpassword)) {
ast_str_append(&conn_info, 0, " password=%s", pgpassword); ast_str_append(&conn_info, 0, "password=%s", pgpassword);
}
if (ast_str_strlen(conn_info) == 0) {
ast_log(LOG_ERROR, "Connection string is blank.\n");
return;
} }
conn = PQconnectdb(ast_str_buffer(conn_info)); conn = PQconnectdb(ast_str_buffer(conn_info));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment