<p>Boris P. Korzun has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12812">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">odbc:  acf_odbc_read() and cli_odbc_read() unicode support<br><br>Added ast_odbc_ast_str_SQLGetData() considers column type for correct<br>allocating the buffer.<br><br>ASTERISK-28497 #close<br><br>Change-Id: I50e86c8a277996f13d4a4b9b318ece0d60b279bf<br>---<br>M funcs/func_odbc.c<br>1 file changed, 13 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/12812/1</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..b6b5281 100644</span><br><span>--- a/funcs/func_odbc.c</span><br><span>+++ b/funcs/func_odbc.c</span><br><span>@@ -921,13 +921,18 @@</span><br><span>                       if (y == 0) {</span><br><span>                                char colname[256];</span><br><span>                           SQLULEN maxcol = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                           SQLSMALLINT coltype;</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(120, 100%, 40%);">+                          res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, &coltype, &maxcol, NULL, NULL);</span><br><span>                                 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>                               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(120, 100%, 40%);">+                         if ((coltype <= SQL_WCHAR) && (coltype >= SQL_WLONGVARCHAR)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                  maxcol = maxcol * 2;</span><br><span style="color: hsl(120, 100%, 40%);">+                          }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                          ast_str_make_space(&coldata, maxcol + 1);</span><br><span> </span><br><span>                            if (ast_str_strlen(colnames)) {</span><br><span>@@ -1497,7 +1502,7 @@</span><br><span>              int dsn_num, executed = 0;</span><br><span>           SQLHSTMT stmt;</span><br><span>               int rows = 0, res, x;</span><br><span style="color: hsl(0, 100%, 40%);">-           SQLSMALLINT colcount = 0, collength;</span><br><span style="color: hsl(120, 100%, 40%);">+          SQLSMALLINT colcount = 0, collength, coltype;</span><br><span>                SQLLEN indicator;</span><br><span>            struct ast_str *coldata = ast_str_thread_get(&coldata_buf, 16);</span><br><span>          char colname[256];</span><br><span>@@ -1562,12 +1567,17 @@</span><br><span>                                 for (x = 0; x < colcount; x++) {</span><br><span>                                  maxcol = 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(120, 100%, 40%);">+                                  res = SQLDescribeCol(stmt, x + 1, (unsigned char *)colname, sizeof(colname), &collength, &coltype, &maxcol, 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(120, 100%, 40%);">+                                 if ((coltype <= SQL_WCHAR) && (coltype >= SQL_WLONGVARCHAR)) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                          maxcol = maxcol * 2;</span><br><span style="color: hsl(120, 100%, 40%);">+                                  }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                                  res = ast_odbc_ast_str_SQLGetData(&coldata, maxcol, stmt, x + 1, SQL_CHAR, &indicator);</span><br><span style="color: hsl(120, 100%, 40%);">+</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/+/12812">change 12812</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/+/12812"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I50e86c8a277996f13d4a4b9b318ece0d60b279bf </div>
<div style="display:none"> Gerrit-Change-Number: 12812 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Boris P. Korzun <drtr0jan@yandex.ru> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>