<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13531">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_odbc: acf_odbc_read() and cli_odbc_read() unicode support<br><br>Added ast_odbc_ast_str_SQLGetData() considers SQL_DESC_OCTET_LENGTH<br>column attribute for correct allocating the buffer.<br><br>ASTERISK-28497 #close<br><br>Change-Id: I50e86c8a277996f13d4a4b9b318ece0d60b279bf<br>---<br>M funcs/func_odbc.c<br>1 file changed, 12 insertions(+), 10 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c</span><br><span>index 126a339..f9fa971 100644</span><br><span>--- a/funcs/func_odbc.c</span><br><span>+++ b/funcs/func_odbc.c</span><br><span>@@ -920,15 +920,17 @@</span><br><span> </span><br><span> if (y == 0) {</span><br><span> char colname[256];</span><br><span style="color: hsl(0, 100%, 40%);">- SQLULEN maxcol = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLLEN octetlength = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, NULL, &maxcol, NULL, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(3, "Got collength of %d and maxcol of %d for column '%s' (offset %d)\n", (int)collength, (int)maxcol, colname, x);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, NULL, NULL, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(3, "Got collength of %d for column '%s' (offset %d)\n", (int)collength, colname, x);</span><br><span> if (((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) || collength == 0) {</span><br><span> snprintf(colname, sizeof(colname), "field%d", x);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_make_space(&coldata, maxcol + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLColAttribute(stmt, x + 1, SQL_DESC_OCTET_LENGTH, NULL, 0, NULL, &octetlength);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_make_space(&coldata, octetlength + 1);</span><br><span> </span><br><span> if (ast_str_strlen(colnames)) {</span><br><span> ast_str_append(&colnames, 0, ",");</span><br><span>@@ -1498,10 +1500,9 @@</span><br><span> SQLHSTMT stmt;</span><br><span> int rows = 0, res, x;</span><br><span> SQLSMALLINT colcount = 0, collength;</span><br><span style="color: hsl(0, 100%, 40%);">- SQLLEN indicator;</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLLEN indicator, octetlength;</span><br><span> struct ast_str *coldata = ast_str_thread_get(&coldata_buf, 16);</span><br><span> char colname[256];</span><br><span style="color: hsl(0, 100%, 40%);">- SQLULEN maxcol;</span><br><span> </span><br><span> if (!coldata) {</span><br><span> AST_RWLIST_UNLOCK(&queries);</span><br><span>@@ -1560,14 +1561,15 @@</span><br><span> }</span><br><span> for (;;) {</span><br><span> for (x = 0; x < colcount; x++) {</span><br><span style="color: hsl(0, 100%, 40%);">- maxcol = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, NULL, &maxcol, NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, NULL, NULL, NULL, NULL);</span><br><span> if (((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) || collength == 0) {</span><br><span> snprintf(colname, sizeof(colname), "field%d", x);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_odbc_ast_str_SQLGetData(&coldata, maxcol, stmt, x + 1, SQL_CHAR, &indicator);</span><br><span style="color: hsl(120, 100%, 40%);">+ octetlength = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ SQLColAttribute(stmt, x + 1, SQL_DESC_OCTET_LENGTH, NULL, 0, NULL, &octetlength);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_odbc_ast_str_SQLGetData(&coldata, octetlength + 1, stmt, x + 1, SQL_CHAR, &indicator);</span><br><span> if (indicator == SQL_NULL_DATA) {</span><br><span> ast_str_set(&coldata, 0, "(nil)");</span><br><span> res = SQL_SUCCESS;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13531">change 13531</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/+/13531"/><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: I50e86c8a277996f13d4a4b9b318ece0d60b279bf </div>
<div style="display:none"> Gerrit-Change-Number: 13531 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Boris P. Korzun <drtr0jan@yandex.ru> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>