[ 
https://issues.apache.org/jira/browse/TRAFODION-2375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15730060#comment-15730060
 ] 

ASF GitHub Bot commented on TRAFODION-2375:
-------------------------------------------

Github user selvaganesang commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/871#discussion_r91397853
  
    --- Diff: win-odbc64/odbcclient/drvr35/cdiag.cpp ---
    @@ -389,8 +389,8 @@ SQLRETURN CDiagRec::GetDiagRec(SQLSMALLINT      
RecNumber,
                                        translateLengthMax/2, (int 
*)&translateLength, (char *)errorMsg)) != SQL_SUCCESS )
                                rc = SQL_SUCCESS_WITH_INFO; //ERROR;
     
    -                   strLen = translateLength; 
    -                   ((wchar_t *)MessageText)[strLen] = L'\0' ; 
    +                   ((wchar_t *)MessageText)[translateLength] = L'\0';
    +                   strLen = tmpStrLen;
    --- End diff --
    
    As per the ODBC specification, if the MessageText is NULL, the 
TextLengthPtr should give the caller the number of characters that will be 
returned. 
    
    Usually, the ODBC applications are expected to get the number of characters 
needed for the error message by passing in MessageText as NULL, then allocate 
that many characters in their space and then request for the error message by 
passing the pointer to the buffer allocated as the MessageText.  
    
    It looks like the logic of returning the actual number of characters needed 
when MessageText is NULL is missing


> SQLGetDiagRec API didn't return correct text length
> ---------------------------------------------------
>
>                 Key: TRAFODION-2375
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2375
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: client-odbc-windows
>    Affects Versions: 2.2-incubating
>         Environment: Distro Version: HDP2.4, Trafodion Version: R22, OS: Win10
>            Reporter: 苏锦佩
>            Assignee: Zhang,Xiang
>
> SQLRETURN SQLGetDiagRec(
>      SQLSMALLINT HandleType,
>      SQLHANDLE Handle,
>      SQLSMALLINT RecNumber,
>      SQLCHAR * SQLState,
>      SQLINTEGER * NativeErrorPtr,
>      SQLCHAR * MessageText,
>      SQLSMALLINT BufferLength,
>      SQLSMALLINT * TextLengthPtr);
> Acoording to API reference, TextLengthPtr should return total number of 
> characters available, but it return number of truncated characters when 
> BufferLength is not enough to receive all MessageText; 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to