<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16271] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16271">16271</a></dd>
<dt>Author</dt> <dd>brian</dd>
<dt>Date</dt> <dd>2010-01-12 19:40:11 -0600 (Tue, 12 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>SCA tweaks</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_odbch">freeswitch/trunk/src/include/switch_odbc.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec">freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc">freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc">freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkey_odbcmod_spidermonkey_odbcc">freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sqldbc">freeswitch/trunk/src/switch_core_sqldb.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_odbcc">freeswitch/trunk/src/switch_odbc.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_odbch"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_odbc.h (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_odbc.h        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/include/switch_odbc.h        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -56,11 +56,12 @@
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_handle_t *handle);
</span><span class="cx"> SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep);
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle);
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t * rstmt);
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err);
</ins><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle,
</span><span class="cx">                                                                                                                                         const char *sql,
</span><span class="cx">                                                                                                                                         char *resbuf,
</span><del>-                                                                                                                                        size_t len);
</del><ins>+                                                                                                                                        size_t len,
+                                                                                                                                        char **err);
</ins><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_odbc_available(void);
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t * stmt);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -152,10 +152,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.db_dsn);
</span><span class="cx">                 if (!globals.custom_query){
</span><del>-                        if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from numbers", NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from numbers", NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot find SQL Database! (Where\'s the numbers table\?\?)\n");
</span><span class="cx">                         }
</span><del>-                        if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from gateways", NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from gateways", NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot find SQL Database! (Where\'s the gateways table\?\?)\n");
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">         switch_snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account, billaccount);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
</span><span class="cx">
</span><del>-        if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 char *err_str;
</span><span class="cx">                 err_str = switch_odbc_handle_get_error(globals.master_odbc, stmt);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -271,7 +271,7 @@
</span><span class="cx">
</span><span class="cx">         if (switch_odbc_available() && profile->odbc_dsn) {
</span><span class="cx">                 switch_odbc_statement_handle_t stmt;
</span><del>-                if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                         char *err_str;
</span><span class="cx">                         err_str = switch_odbc_handle_get_error(profile->master_odbc, stmt);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
</span><span class="lines">@@ -2432,7 +2432,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
</span><del>-                                switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL, NULL);
</ins><span class="cx">                                 //mdl_execute_sql(profile, sub_sql, NULL);
</span><span class="cx">                         } else {
</span><span class="cx">                                 if ((db = switch_core_db_open_file(profile->dbname))) {
</span><span class="lines">@@ -2581,7 +2581,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
</span><del>-                                switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(profile->master_odbc, sub_sql, NULL, NULL);
</ins><span class="cx">                                 //mdl_execute_sql(profile, sub_sql, NULL);
</span><span class="cx">                         } else {
</span><span class="cx">                                 if ((db = switch_core_db_open_file(profile->dbname))) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -3436,7 +3436,7 @@
</span><span class="cx">                                 if (sip &&
</span><span class="cx">                                         sip->sip_from && sip->sip_from->a_url && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
</span><span class="cx">                                         sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
</span><del>-                                        sql = switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 && hostname='%q' and event='call-info' and "
</del><ins>+                                        sql = switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
</ins><span class="cx">                                                                                  "sub_to_user='%q' and sub_to_host='%q'",
</span><span class="cx">                                                                                  mod_sofia_globals.hostname, sip->sip_to->a_url->url_user, sip->sip_from->a_url->url_host);
</span><span class="cx">                                         sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, buf, sizeof(buf));
</span><span class="lines">@@ -4242,9 +4242,20 @@
</span><span class="cx">                                                                 switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
</span><span class="cx">                                                         }
</span><span class="cx">                                                 } else if (switch_stristr("sendonly", r_sdp)) {
</span><ins>+                                                        const char *msg = "hold";
+                                                        
+                                                        if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
+                                                                const char *info = switch_channel_get_variable(channel, "presence_call_info");
+                                                                if (info) {
+                                                                        if (switch_stristr("private", info)) {
+                                                                                msg = "hold-private";
+                                                                        }
+                                                                }
+                                                        }
+
</ins><span class="cx">                                                         sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                                                         switch_channel_set_flag(channel, CF_LEG_HOLDING);
</span><del>-                                                        switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
</del><ins>+                                                        switch_channel_presence(tech_pvt->channel, "unknown", msg, NULL);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         
</span><span class="cx">                                                 switch_core_session_queue_message(other_session, msg);
</span><span class="lines">@@ -5693,6 +5704,11 @@
</span><span class="cx">         if (!destination_number && sip->sip_to && sip->sip_to->a_url) {
</span><span class="cx">                 destination_number = sip->sip_to->a_url->url_user;
</span><span class="cx">         }
</span><ins>+
+        /* The human network, OH THE HUMANITY!!! lets send invites with no number! */
+        if (!destination_number && sip->sip_from && sip->sip_from->a_url) {
+                destination_number = sip->sip_from->a_url->url_user;
+        }
</ins><span class="cx">         
</span><span class="cx">         if (destination_number) {
</span><span class="cx">                 check_decode(destination_number, session);
</span><span class="lines">@@ -5957,20 +5973,36 @@
</span><span class="cx">                 char cid[512] = "";
</span><span class="cx">                 char *str;
</span><span class="cx">                 char *p = NULL;
</span><ins>+                const char *user = NULL, *host = NULL;
+                
+                if (sip->sip_to && sip->sip_to->a_url) {
+                        user = sip->sip_to->a_url->url_user;
+                        host = sip->sip_to->a_url->url_host;
+                }
</ins><span class="cx">
</span><ins>+                if (!user || !host) {
+                        if (sip->sip_from && sip->sip_from->a_url) {
+                                if (!user) user = sip->sip_from->a_url->url_user;
+                                if (!host) host = sip->sip_from->a_url->url_host;
+                        }
+                }
</ins><span class="cx">
</span><del>-                if (sip->sip_to && sip->sip_to->a_url) {
</del><ins>+                if (user && host) {
</ins><span class="cx">                         if ((p = strchr(call_info_str, ';'))) {
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><ins>+                        
+                        sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null",
+                                                                 switch_str_nil(p), user, host);
</ins><span class="cx">
</span><del>-                        sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q'",
-                                                                 switch_str_nil(p), sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
-                        
</del><span class="cx">                         if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
</span><span class="cx">                                 bnh = nua_handle_by_call_id(nua, str);
</span><span class="cx">                         }
</span><span class="cx">
</span><ins>+                        if (mod_sofia_globals.debug_sla > 1) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PICK SQL %s [%s] [%s] %d\n", sql, str, cid, !!bnh);
+                        }
+                        
</ins><span class="cx">                         free(sql);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -5991,7 +6023,7 @@
</span><span class="cx">                                 private_object_t *b_tech_pvt = NULL;
</span><span class="cx">                                 const char *app = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_VARIABLE);
</span><span class="cx">                                 const char *data = switch_channel_get_variable(b_channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (app && data && !strcasecmp(app, "conference")) {
</span><span class="cx">                                         destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s", data);
</span><span class="cx">                                         dialplan = "inline";
</span><span class="lines">@@ -5999,7 +6031,7 @@
</span><span class="cx">                                         if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
</span><span class="cx">                                                 b_tech_pvt = switch_core_session_get_private(b_session);
</span><span class="cx">                                         }
</span><del>-
</del><ins>+                                        
</ins><span class="cx">                                         if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                                 switch_channel_set_variable(b_channel, "presence_call_info", NULL);
</span><span class="cx">                                                 one_leg = 0;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -3934,9 +3934,6 @@
</span><span class="cx">                         "create index ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
</span><span class="cx">                         "create index ssa_aor on sip_shared_appearance_subscriptions (aor)",
</span><span class="cx">                         "create index ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
</span><del>-                        "create index ssd_contact on sip_shared_appearance_dialogs (contact)",
-                        "create index ssd_presence_id on sip_shared_appearance_dialogs (presence_id)",
-                        "create index ssd_presence_data on sip_shared_appearance_dialogs (presence_data)",
</del><span class="cx">                         "create index ssd_hostname on sip_shared_appearance_dialogs (hostname)",
</span><span class="cx">                         "create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
</span><span class="cx">                         "create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
</span><span class="lines">@@ -3963,9 +3960,9 @@
</span><span class="cx">                                                                  "like '%%' and mwi_user like '%%' and mwi_host like '%%'",
</span><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_registrations", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, reg_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -3973,7 +3970,7 @@
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
</span><span class="cx">                         char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
</span><span class="cx">
</span><del>-                        if (switch_odbc_handle_exec(odbc_dbh, test2, NULL) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(odbc_dbh, test2, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
</span><span class="cx">                                                                  "If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
</span><span class="cx">                                 sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
</span><span class="lines">@@ -3988,55 +3985,55 @@
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
</span><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_subscriptions", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_subscriptions", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, sub_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 free(test_sql);
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires > 0", mod_sofia_globals.hostname);
</span><span class="cx">
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, dialog_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_presence where hostname='%q' ", mod_sofia_globals.hostname);
</span><span class="cx">
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_presence", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, pres_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 free(test_sql);
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_authentication where hostname='%q' or last_nc >= 0", mod_sofia_globals.hostname);
</span><span class="cx">
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_authentication", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_authentication", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, auth_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str='' or hostname='%q' and network_ip like '%%'",
</span><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_subscriptions", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_subscriptions", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str='' or hostname='%q' and network_ip like '%%'",
</span><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><del>-                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
-                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_dialogs", NULL);
-                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL);
</del><ins>+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_shared_appearance_dialogs", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, shared_appearance_dialogs_sql, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 for (x = 0; indexes[x]; x++) {
</span><del>-                        switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL);
</del><ins>+                        switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -599,25 +599,37 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (call_info) {
</span><ins>+                        const char *uuid = switch_event_get_header(event, "unique-id");
</ins><span class="cx">                         
</span><ins>+
</ins><span class="cx"> #if 0
</span><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA EVENT:\n");
</span><span class="cx">                                 DUMP_EVENT(event);
</span><span class="cx">                         }
</span><span class="cx"> #endif
</span><del>-                        
-                        sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
-                                                                 "and sip_dialogs.sip_from_host='%q' and call_info='%q'",
-                                                                 call_info_state,
-                                                                 mod_sofia_globals.hostname,
-                                                                 euser, host, call_info);
</del><span class="cx">
</span><ins>+                        if (uuid) {
+                                sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and uuid='%q'",
+                                                                         call_info_state,
+                                                                         mod_sofia_globals.hostname,
+                                                                         uuid);
+                        } else {
+                                sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
+                                                                         "and sip_dialogs.sip_from_host='%q' and call_info='%q'",
+                                                                         call_info_state,
+                                                                         mod_sofia_globals.hostname,
+                                                                         euser, host, call_info);
+                                
+                        }
+
</ins><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STATE SQL %s\n", sql);
</span><span class="cx">                         }
</span><span class="cx">                         sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                         
</span><ins>+
+
</ins><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PROCESS PRESENCE EVENT\n");
</span><span class="cx">                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -768,14 +768,23 @@
</span><span class="cx">         authorization = sip->sip_authorization;
</span><span class="cx">         contact = sip->sip_contact;
</span><span class="cx">         to = sip->sip_to;
</span><ins>+        from = sip->sip_from;
</ins><span class="cx">
</span><ins>+        if (from) {
+                from_user = from->a_url->url_user;
+                from_host = from->a_url->url_host;
+        }
+        
</ins><span class="cx">         if (to) {
</span><span class="cx">                 to_user = to->a_url->url_user;
</span><span class="cx">                 to_host = to->a_url->url_host;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (!to_user) to_user = from_user;
+        if (!to_host) to_host = from_host;
+
</ins><span class="cx">         if (!to_user || !to_host) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete from header\n");
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header\n");
</ins><span class="cx">                 nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">                 switch_goto_int(r, 1, end);
</span><span class="cx">         }
</span><span class="lines">@@ -784,13 +793,6 @@
</span><span class="cx">                 reg_host = to_host;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        from = sip->sip_from;
-
-        if (from) {
-                from_user = from->a_url->url_user;
-                from_host = from->a_url->url_host;
-        }
-
</del><span class="cx">         if (contact->m_url) {
</span><span class="cx">                 const char *port = contact->m_url->url_port;
</span><span class="cx">                 char new_port[25] = "";
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkey_odbcmod_spidermonkey_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx">
</span><span class="cx">         sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
</span><span class="cx">
</span><del>-        if (switch_odbc_handle_exec(odbc_obj->handle, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(odbc_obj->handle, sql, &stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[ODBC] Execute failed for: %s\n", sql);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -253,7 +253,7 @@
</span><span class="cx">
</span><span class="cx">         sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
</span><span class="cx">
</span><del>-        if (switch_odbc_handle_exec(odbc_obj->handle, sql, &odbc_obj->stmt) != SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(odbc_obj->handle, sql, &odbc_obj->stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[ODBC] query failed: %s\n", sql);
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_channel.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -505,6 +505,8 @@
</span><span class="cx">                                 call_info_state = "idle";
</span><span class="cx">                         } else if (!strcasecmp(status, "hold")) {
</span><span class="cx">                                 call_info_state = "held";
</span><ins>+                        } else if (!strcasecmp(status, "hold-private")) {
+                                call_info_state = "held-private";
</ins><span class="cx">                         } else if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                                 if (channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                                         call_info_state = "progressing";
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -380,7 +380,7 @@
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="cx">                         switch_odbc_statement_handle_t stmt = NULL;
</span><del>-                        if ((status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, &stmt)) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if ((status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, &stmt, NULL)) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 errmsg = switch_odbc_handle_get_error(dbh->native_handle.odbc_dbh, stmt);
</span><span class="cx">                         }
</span><span class="cx">                         switch_odbc_statement_handle_free(&stmt);
</span><span class="lines">@@ -548,7 +548,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><del>-                        status = switch_odbc_handle_exec_string(dbh->native_handle.odbc_dbh, sql, str, len);
</del><ins>+                        status = switch_odbc_handle_exec_string(dbh->native_handle.odbc_dbh, sql, str, len, err);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="lines">@@ -738,12 +738,12 @@
</span><span class="cx">         switch (dbh->type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><del>-                        if (switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, test_sql, NULL) != SWITCH_ODBC_SUCCESS) {
</del><ins>+                        if (switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                                 r = SWITCH_FALSE;
</span><span class="cx">                                 if (drop_sql) {
</span><del>-                                        switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, drop_sql, NULL);
</del><ins>+                                        switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, drop_sql, NULL, NULL);
</ins><span class="cx">                                 }
</span><del>-                                switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, reactive_sql, NULL);
</del><ins>+                                switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, reactive_sql, NULL, NULL);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_odbc.c (16270 => 16271)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_odbc.c        2010-01-13 01:32:01 UTC (rev 16270)
+++ freeswitch/trunk/src/switch_odbc.c        2010-01-13 01:40:11 UTC (rev 16271)
</span><span class="lines">@@ -344,7 +344,8 @@
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle,
</span><span class="cx">                                                                                                                                         const char *sql,
</span><span class="cx">                                                                                                                                         char *resbuf,
</span><del>-                                                                                                                                        size_t len)
</del><ins>+                                                                                                                                        size_t len,
+                                                                                                                                        char **err)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         switch_odbc_status_t sstatus = SWITCH_ODBC_FAIL;
</span><span class="lines">@@ -352,21 +353,27 @@
</span><span class="cx">         SQLCHAR name[1024];
</span><span class="cx">         SQLLEN m = 0;
</span><span class="cx">
</span><del>-        if (switch_odbc_handle_exec(handle, sql, &stmt) == SWITCH_ODBC_SUCCESS) {
</del><ins>+        if (switch_odbc_handle_exec(handle, sql, &stmt, err) == SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
</span><span class="cx">                 SQLULEN ColumnSize;
</span><ins>+                int result;
+                
</ins><span class="cx">                 SQLRowCount(stmt, &m);
</span><span class="cx">
</span><span class="cx">                 if (m <= 0) {
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (SQLFetch(stmt) != SQL_SUCCESS) {
</del><ins>+                result = SQLExecute(stmt);
+                result = SQLFetch(stmt);
+                
+                if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO && result != SQL_NO_DATA) {
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-
</del><ins>+                
</ins><span class="cx">                 SQLDescribeCol(stmt, 1, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
</span><span class="cx">                 SQLGetData(stmt, 1, SQL_C_CHAR, (SQLCHAR *) resbuf, (SQLLEN) len, NULL);
</span><ins>+                
</ins><span class="cx">                 sstatus = SWITCH_ODBC_SUCCESS;
</span><span class="cx">         } else {
</span><span class="cx">                 return sstatus;
</span><span class="lines">@@ -380,11 +387,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t * rstmt)
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         SQLHSTMT stmt = NULL;
</span><span class="cx">         int result;
</span><ins>+        char *err_str = NULL;
</ins><span class="cx">
</span><span class="cx">         if (!db_is_up(handle)) {
</span><span class="cx">                 goto error;
</span><span class="lines">@@ -413,6 +421,22 @@
</span><span class="cx">         return SWITCH_ODBC_SUCCESS;
</span><span class="cx">
</span><span class="cx"> error:
</span><ins>+
+        if (stmt) {
+                err_str = switch_odbc_handle_get_error(handle, stmt);
+        }
+
+        if (err_str) {
+                if (!switch_stristr("already exists", err_str)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
+                }
+                if (err) {
+                        *err = err_str;
+                } else {
+                        free(err_str);
+                }
+        }
+
</ins><span class="cx">         if (rstmt) {
</span><span class="cx">                 *rstmt = stmt;
</span><span class="cx">         } else if (stmt) {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>