Index: driver/utility.c =================================================================== --- driver/utility.c (revision 990) +++ driver/utility.c (working copy) @@ -756,17 +756,6 @@ if (result) result++; used_chars+= 1; - - if (result && result == result_end) - { - if (stmt->getdata.dst_bytes != (ulong)~0L) - { - stmt->getdata.source+= cnvres; - break; - } - *result= 0; - result= NULL; - } } else { @@ -799,6 +788,17 @@ } else if (chars > 1) continue; + + if (result && result == result_end) + { + if (stmt->getdata.dst_bytes != (ulong)~0L) + { + stmt->getdata.source+= cnvres; + break; + } + *result= 0; + result= NULL; + } } if (result) Index: test/my_result.c =================================================================== --- test/my_result.c (revision 990) +++ test/my_result.c (working copy) @@ -2147,6 +2147,36 @@ } +/* + Bug#32684 - chunked retrieval of SQL_C_WCHAR fails +*/ +DECLARE_TEST(t_bug32684) +{ + SQLWCHAR wbuf[20]; + SQLCHAR abuf[20]; + SQLINTEGER wlen; + SQLINTEGER alen; + ok_sql(hstmt, "select repeat('x', 100), repeat('y', 100)"); + ok_stmt(hstmt, SQLFetch(hstmt)); + + do + { + ok_stmt(hstmt, SQLGetData(hstmt, 1, SQL_C_CHAR, abuf, + 20, &alen)); + printMessage("data= %s, len=%d\n", abuf, alen); + } while(alen > 20); + + do + { + ok_stmt(hstmt, SQLGetData(hstmt, 2, SQL_C_WCHAR, wbuf, + 20 * sizeof(SQLWCHAR), &wlen)); + printMessage("data= %ls, len=%d\n", wbuf, wlen); + } while(wlen > 20 * sizeof(SQLWCHAR)); + + return OK; +} + + BEGIN_TESTS ADD_TEST(my_resultset) ADD_TEST(t_convert_type) @@ -2177,6 +2207,7 @@ ADD_TEST(t_bug13776) ADD_TEST(t_bug13776_auto) ADD_TEST(t_bug28617) + ADD_TEST(t_bug32684) END_TESTS Index: driver/results.c =================================================================== --- driver/results.c (revision 990) +++ driver/results.c (working copy) @@ -186,7 +186,8 @@ case SQL_C_WCHAR: return copy_wchar_result(stmt, - (SQLWCHAR *)rgbValue, cbValueMax, pcbValue, + (SQLWCHAR *)rgbValue, + cbValueMax / sizeof(SQLWCHAR), pcbValue, field, value, length); case SQL_C_BIT: