You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by DaveBirdsall <gi...@git.apache.org> on 2018/02/05 19:59:25 UTC

[GitHub] trafodion pull request #1310: [TRAFODION-2816] ODBC data convert function sp...

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

    https://github.com/apache/trafodion/pull/1310#discussion_r166072144
  
    --- Diff: core/conn/unixodbc/odbc/odbcclient/unixcli/cli/ctosqlconv.cpp ---
    @@ -157,852 +157,982 @@ unsigned long ODBC::Ascii_To_Interval_Helper(char *source,
     
     
     unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
    -							SQLSMALLINT	CDataType,
    -							SQLPOINTER	srcDataPtr,
    -							SQLINTEGER	srcLength,
    -							SQLSMALLINT	ODBCDataType,
    -							SQLSMALLINT	SQLDataType,
    -							SQLSMALLINT	SQLDatetimeCode,
    -							SQLPOINTER	targetDataPtr,
    -							SQLINTEGER	targetLength,
    -							SQLINTEGER	targetPrecision,
    -							SQLSMALLINT	targetScale,
    -							SQLSMALLINT targetUnsigned,
    -							SQLINTEGER      targetCharSet,
    -							BOOL		byteSwap,
    -//							FPSQLDriverToDataSource fpSQLDriverToDataSource,
    -//							DWORD		translateOption,
    -							ICUConverter* iconv,
    -							UCHAR		*errorMsg,
    -							SWORD		errorMsgMax,
    -							SQLINTEGER	EnvironmentType,
    -							BOOL		RWRSFormat,
    -							SQLINTEGER	datetimeIntervalPrecision)
    +        SQLSMALLINT	CDataType,
    +        SQLPOINTER	srcDataPtr,
    +        SQLINTEGER	srcLength,
    +        SQLPOINTER	targetDataPtr,
    +        CDescRec    *targetDescPtr,
    +        BOOL		byteSwap,
    +#ifdef unixcli
    +        ICUConverter* iconv,
    +#else
    +        FPSQLDriverToDataSource fpSQLDriverToDataSource,
    +        DWORD		translateOption,
    +#endif
    +        UCHAR		*errorMsg,
    +        SWORD		errorMsgMax,
    +        SQLINTEGER	EnvironmentType,
    +        BOOL		RWRSFormat,
    +        SQLINTEGER	datetimeIntervalPrecision)
     {
     
    -	unsigned long retCode = SQL_SUCCESS;
    -	SQLPOINTER		DataPtr = NULL;
    -	SQLPOINTER		outDataPtr = targetDataPtr;
    -	SQLINTEGER		DataLen = DRVR_PENDING;
    -	short			Offset = 0;	// Used for VARCHAR fields
    -	SQLINTEGER		OutLen = targetLength;
    -	short targetType = 0;  //for bignum datatype
    +    unsigned long   retCode = SQL_SUCCESS;
    +    if(pdwGlobalTraceVariable && *pdwGlobalTraceVariable){
    +        TraceOut(TR_ODBC_DEBUG,"ConvertCToSQL(%d, %d, %#x, %d, %d, %d, %d, %#x, %d, %d, %d, %d, %d, %d, %#x, %d, %d, %d)",
    +                ODBCAppVersion,
    +                CDataType,
    +                srcDataPtr,
    +                srcLength,
    +                targetDescPtr->m_ODBCDataType,
    +                targetDescPtr->m_SQLDataType,
    +                targetDescPtr->m_SQLDatetimeCode,
    +                targetDataPtr,
    +                targetDescPtr->m_SQLOctetLength,
    +                targetDescPtr->m_ODBCPrecision,
    +                targetDescPtr->m_ODBCScale,
    +                targetDescPtr->m_SQLUnsigned,
    +                targetDescPtr->m_SQLCharset,
    +                byteSwap,
    +                errorMsg,
    +                errorMsgMax,
    +                EnvironmentType,
    +                RWRSFormat);
    +    }
    +    else
    +        RESET_TRACE();
     
    +    if (CDataType == SQL_C_DEFAULT)
    +    {
    +        retCode = getCDefault(targetDescPtr->m_ODBCDataType, ODBCAppVersion, targetDescPtr->m_SQLCharset, CDataType);
    +        if (retCode != SQL_SUCCESS)
    +            return retCode;
    +    }
     
    -	int			dec;
    -	int			sign;
    -	int			tempLen;
    -	int			tempLen1;
    -	int			temp;
    +    if (errorMsg)
    +        *errorMsg = '\0';
    +    
    +    switch (targetDescPtr->m_ODBCDataType)
    +    {
    +        case SQL_VARCHAR:
    +        case SQL_LONGVARCHAR:
    +        case SQL_WVARCHAR:
    +        case SQL_CHAR:
    +            if( targetDescPtr->m_SQLDataType == SQLTYPECODE_BOOLEAN )
    +            {
    +                retCode = convToSQLBool(srcDataPtr,srcLength, CDataType, targetDataPtr);
    +                break;
    +            }
    +        case SQL_WCHAR:
    --- End diff --
    
    Why does SQL_WVARCHAR get converted to boolean via convToSQLBool, but SQL_WCHAR doesn't?


---