<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11441">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
Sean Bright: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr_pgsql: fix error in connection string<br><br>Fixes an error occurring in function pgsql_reconnect() caused when value of<br>hostname is blank. Which in turn will cause the connection string to look<br>like this: "host= port=xx", which creates a sintax error. This fix now checks<br>if the corresponding values for host, port, dbname, and user are blank. Note<br>that since this is a reconnect function the database library will replace any<br>missing value pairs with default ones.<br><br>ASTERISK-28435<br><br>Change-Id: I0a921f99bbd265768be08cd492f04b30855b8423<br>---<br>M cdr/cdr_pgsql.c<br>1 file changed, 19 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c</span><br><span>index a4919d5..1a3f9d6 100644</span><br><span>--- a/cdr/cdr_pgsql.c</span><br><span>+++ b/cdr/cdr_pgsql.c</span><br><span>@@ -184,15 +184,27 @@</span><br><span> conn = NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_set(&conn_info, 0, "host=%s port=%s dbname=%s user=%s",</span><br><span style="color: hsl(0, 100%, 40%);">- pghostname, pgdbport, pgdbname, pgdbuser);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(pgappname)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&conn_info, 0, " application_name=%s", pgappname);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pghostname)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "host=%s ", pghostname);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pgdbport)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "port=%s ", pgdbport);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pgdbname)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "dbname=%s ", pgdbname);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pgdbuser)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "user=%s ", pgdbuser);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(pgappname)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "application_name=%s ", pgappname);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> if (!ast_strlen_zero(pgpassword)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(&conn_info, 0, " password=%s", pgpassword);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(&conn_info, 0, "password=%s", pgpassword);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_str_strlen(conn_info) == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Connection string is blank.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return;</span><br><span> }</span><br><span> </span><br><span> conn = PQconnectdb(ast_str_buffer(conn_info));</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11441">change 11441</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11441"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I0a921f99bbd265768be08cd492f04b30855b8423 </div>
<div style="display:none"> Gerrit-Change-Number: 11441 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Christian Savinovich <csavinovich@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>