<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/1703/">https://reviewboard.asterisk.org/r/1703/</a>
</td>
</tr>
</table>
<br />
<p>Ship it!</p>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Looks fine to me!</pre>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/1703/diff/1/?file=23823#file23823line68" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/contrib/realtime/postgresql/realtime.sql</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">68</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="n">ipaddr</span> <span class="nb">character</span> <span class="nb">varying</span><span class="p">(</span><span class="mi"><span class="hl">4</span>0</span><span class="p">)</span> <span class="k">DEFAULT</span> <span class="s1">''</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">68</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="n">ipaddr</span> <span class="nb">character</span> <span class="nb">varying</span><span class="p">(</span><span class="mi"><span class="hl">5</span>0</span><span class="p">)</span> <span class="k">DEFAULT</span> <span class="s1">''</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Why this change?</pre>
</div>
<br />
<p>- Mark</p>
<br />
<p>On January 31st, 2012, 10:09 p.m., Terry Wilson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Terry Wilson.</div>
<p style="color: grey;"><i>Updated Jan. 31, 2012, 10:09 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">SIP realtime, upon peer destruction, tries to clear some values by updating the peer with empty string values. This works if those values are character fields or if the database automagically translates an empty string to a NULL or 0 when confronted with an integer field. PostgreSQL does not do this translation and returns an error (even if called through res_config_odbc). lastms is defined as an integer in both the mysql and postgresql realtime SQL files.
Looking at where lastms is set in chan_sip (handle_response_peerpoke) it is clear that the default value of lastms is 0 and that 0 means unknown, while -1 means unreachable. So, like regseconds, the update for destruction should be passing "0" for a value instead of "". The fields could be changed to character fields, but this would still require us to interpret an empty string as a 0 value. This patch changes the destruction update to pass a value of "0" for lastms.
Other issues in chan_sip include setting the ipaddr and port to the string "(null)" when they are null instead of an empty string which is what is expected (thanks to ast_sockaddr_stringify returning "(null)" for a null sockaddr). This patch checks the values of ast_sockaddr_isnull() and ast_sockaddr_port and passes empty strings when appropriate.
The postgresql realtime.sql file has been updated to set the correct default of '0' for lastms, lengthen the ipaddr field (which was too short for the longest possible IPv6 address), and add the missing defaultuser, fullcontact, regserver, and useragent fields.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Under res_config_pgsql and res_config_odbc, verified that registering and unregistering a peer no longer produces any SQL errors.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-19172">ASTERISK-19172</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(353501)</span></li>
<li>/branches/1.8/contrib/realtime/postgresql/realtime.sql <span style="color: grey">(353501)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/1703/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>