<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9070">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_odbc: NODATA if SQLNumResultCols returned 0 columns on readsql<br><br>The functions acf_odbc_read/cli_odbc_read ignore a number of columns<br>returned by the SQLNumResultCols.<br>If the number of columns is zero it means no data.<br>In this case, a SQLFetch function has to be not called,<br>because it will cause an error.<br><br>ASTERISK-27888 #close<br><br>Change-Id: Ie0f7bdac6c405aa5bbd38932c7b831f90729ee19<br>---<br>M funcs/func_odbc.c<br>1 file changed, 25 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/70/9070/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c<br>index d19b56f..36e8a92 100644<br>--- a/funcs/func_odbc.c<br>+++ b/funcs/func_odbc.c<br>@@ -859,6 +859,23 @@<br> return -1;<br> }<br> <br>+ if (colcount <= 0) {<br>+ ast_verb(4, "Returned %d columns [%s]\n", colcount, ast_str_buffer(sql));<br>+ buf[0] = '\0';<br>+ ast_copy_string(rowcount, "0", sizeof(rowcount));<br>+ status = "NODATA";<br>+ SQLCloseCursor(stmt);<br>+ SQLFreeHandle (SQL_HANDLE_STMT, stmt);<br>+ release_obj_or_dsn (&obj, &dsn);<br>+ if (!bogus_chan) {<br>+ pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);<br>+ pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);<br>+ ast_autoservice_stop(chan);<br>+ }<br>+ odbc_datastore_free(resultset);<br>+ return 0;<br>+ }<br>+<br> res = SQLFetch(stmt);<br> if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {<br> int res1 = -1;<br>@@ -1522,6 +1539,14 @@<br> return CLI_SUCCESS;<br> }<br> <br>+ if (colcount <= 0) {<br>+ SQLCloseCursor(stmt);<br>+ SQLFreeHandle (SQL_HANDLE_STMT, stmt);<br>+ release_obj_or_dsn (&obj, &dsn);<br>+ ast_cli(a->fd, "Returned %d columns. Query executed on handle %d:%s [%s]\n", colcount, dsn_num, query->readhandle[dsn_num], ast_str_buffer(sql));<br>+ break;<br>+ }<br>+<br> res = SQLFetch(stmt);<br> if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {<br> SQLCloseCursor(stmt);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9070">change 9070</a>. To unsubscribe, 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/9070"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie0f7bdac6c405aa5bbd38932c7b831f90729ee19 </div>
<div style="display:none"> Gerrit-Change-Number: 9070 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>