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

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

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

    https://github.com/apache/trafodion/pull/1310#discussion_r168056053
  
    --- Diff: core/conn/unixodbc/odbc/odbcclient/unixcli/cli/ctosqlconv.cpp ---
    @@ -1036,2500 +1166,3031 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER    
ODBCAppVersion,
                             DataLen = sizeof(SCHAR);
                         }
                         break;
    -                           case SQL_SMALLINT:
    -                                   if (targetUnsigned)
    -                                   {
    -                                           if ( dTmp < 0 )
    -                                                   return IDS_22_003_02;  
//negValue in unsigned column
    -                                           if (dTmp > USHRT_MAX)
    -                                                   return IDS_22_003;
    -                                           usTmp = (USHORT)dTmp;
    -                                           if  (dTmp != usTmp)
    -                                                   retCode = IDS_01_S07;
    -                                           DataPtr = &usTmp;
    -                                           DataLen = sizeof(usTmp);
    -                                   }
    -                                   else
    -                                   {
    -                                           if (unsignedInteger)
    -                                           {
    -                                                   if (dTmp < 0 || dTmp > 
USHRT_MAX)
    -                                                           return 
IDS_22_003;
    -                                                   sTmp = (SHORT)dTmp;
    -                                           }
    -                                           else
    -                                           {
    -                                                   if (dTmp < SHRT_MIN || 
dTmp > SHRT_MAX)
    -                                                           return 
IDS_22_003;
    -                                                   sTmp = (SHORT)dTmp;
    -                                                   if  (dTmp != sTmp)
    -                                                           retCode = 
IDS_01_S07;
    -                                           }
    -                                           DataPtr = &sTmp;
    -                                           DataLen = sizeof(sTmp);
    -                                   }
    -                                   break;
    -                           case SQL_INTEGER:
    -                                   if (targetUnsigned)
    -                                   {
    -                                           if (dTmp < 0)
    -                                                   return 
IDS_22_003_02;//negValue in unsigned col error
    -                                           if (dTmp > UINT_MAX )
    -                                                   return IDS_22_003;
    -                                           ulTmp = (ULONG_P)dTmp;
    -                                           if  (dTmp != ulTmp)
    -                                                   retCode = IDS_01_S07;
    -                                           DataPtr = &ulTmp;
    -                                           DataLen = sizeof(ulTmp);
    -                                   }
    -                                   else
    -                                   {
    -                                           if (unsignedInteger)
    -                                           {
    -                                                   if (dTmp < 0 || dTmp > 
UINT_MAX )
    -                                                           return 
IDS_22_003;
    -                                                   lTmp = (LONG)dTmp;
    -                                           }
    -                                           else
    -                                           {
    -                                                   if (dTmp < LONG_MIN || 
dTmp > INT_MAX)
    -                                                           return 
IDS_22_003;
    -                                                   lTmp = (LONG)dTmp;
    -                                                   if  (dTmp != lTmp)
    -                                                           retCode = 
IDS_01_S07;
    -                                           }
    -                                           DataPtr = &lTmp;
    -                                           DataLen = sizeof(lTmp);
    -                                   }
    -                                   break;
    -                           case SQL_REAL:
    -                                   if (dTmp < -FLT_MAX || dTmp > FLT_MAX)
    -                                           return IDS_22_003;
    -                                   fltTmp = (SFLOAT)dTmp;
    -                                   DataPtr = &fltTmp;
    -                                   DataLen = sizeof(fltTmp);
    -                                   break;
    -                           case SQL_DOUBLE:
    -                           case SQL_FLOAT:
    -                                   DataPtr = &dTmp;
    -                                   DataLen = sizeof(dTmp);
    -                                   break;
    -                           case SQL_DECIMAL:
    -                                   if (targetPrecision >= sizeof(cTmpBuf))
    -                                           return IDS_22_003;
    -#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || 
MXSUNSPARC
    -                                   dTmp1 = 
pow((double)10,targetPrecision-targetScale+1);
    -#else
    -                                   dTmp1 = 
pow(10,targetPrecision-targetScale+1);
    -#endif
    -                                   if (targetUnsigned)
    -                                   {
    -                                           if ( dTmp < 0 )
    -                                                   return IDS_22_003_02;  
//negValue in unsigned column
    -                                           if (dTmp > dTmp1)
    -                                                   return IDS_22_003;
    -
    -                                           tempPtr = _fcvt(dTmp, 
targetScale, &dec, &sign);
    -                                           tempLen = strlen(tempPtr);
    -                                           tempLen1 = 
(short)(targetPrecision-tempLen);
    -
    -                                           if (tempLen1 < 0)
    -                                                   return IDS_22_003;
    -
    -                                           memset((void *)cTmpBuf, '0', 
tempLen1);
    -                                           strncpy((char 
*)(cTmpBuf+tempLen1), tempPtr, tempLen);
    -                                   }
    -                                   else
    -                                   {
    -                                           if (dTmp < -dTmp1 || dTmp > 
dTmp1)
    -                                                   return IDS_22_003;
    -
    -                                           tempPtr = _fcvt(dTmp, 
targetScale, &dec, &sign);
    -                                           tempLen = strlen(tempPtr);
    -                                           tempLen1 = 
(short)(targetPrecision-tempLen);
    -
    -                                           if (tempLen1 < 0)
    -                                                   return IDS_22_003;
    -
    -                                           memset((void *)cTmpBuf, '0', 
tempLen1);
    -                                           strncpy((char 
*)(cTmpBuf+tempLen1), tempPtr, tempLen);
    -                                           if (sign)
    -                                                   *cTmpBuf = 
(UCHAR)(*cTmpBuf | (UCHAR)0x80);
    -                                   }
    -                                   DataPtr = cTmpBuf;
    -                                   DataLen = targetPrecision;
    -                                   break;
    -                           default:
    -                                   return IDS_07_006;
    -                           }
    -                   }
    -                   else
    -                   {
    -                           if (targetScale)
    -                           {
    -                                   for (i = 0,tempVal64 = 1; i < 
targetScale ;  i++)
    -                                           tempVal64 *= 10;
    -                                   tempVal64 = tempVal64 * integralPart;
    -                                   decimalDigits = 0;
    -                                   if (decimalPart > 0)
    -                                           decimalDigits = 
getDigitCount(decimalPart);
    -                                   scaleOffset = 0;
    -                                   if (leadZeros < targetScale)
    -                                     scaleOffset = targetScale - 
decimalDigits - leadZeros;
    -                                   if (scaleOffset < 0)
    -                                   {
    -//NUMERIC_VALUE_OUT_OF_RANGE_ERROR
    -                                           return IDS_22_003;
    -                                   }
    -                                   for (i =0, tempScaleVal64 = decimalPart 
; i < scaleOffset ; i++)
    -                                           tempScaleVal64 *= 10;
    -                                   tempVal64 += tempScaleVal64;
    -                           }
    -                           else
    -                           {
    -//NUMERIC_DATA_TRUNCATED_ERROR
    -                                   if (decimalPart != 0)
    -                                           retCode = IDS_01_S07;
    -                                   tempVal64 = integralPart;
    -                           }
    -                           if (negative)
    -                                   tempVal64 = -tempVal64;
     
    -                           switch( SQLDataType )
    -                           {
    -                case SQLTYPECODE_TINYINT_UNSIGNED:
    -                    if (tempVal64 < 0)
    -                        return IDS_22_003_02;
    -                    if (tempVal64 > UCHAR_MAX)
    -                        return IDS_22_003;
    -                    utTmp = (UCHAR)tempVal64;
    -                    if  (tempVal64 != utTmp)
    -                        retCode = IDS_01_S07;
    -                    DataPtr = &utTmp;
    -                    DataLen = sizeof(UCHAR);
    -                    break;
    -                case SQLTYPECODE_TINYINT:
    -                    if (tempVal64 < SCHAR_MIN || tempVal64 > SCHAR_MAX)
    -                        return IDS_22_003;
    -                    tTmp = (SCHAR)tempVal64;
    -                    if  (tempVal64 != tTmp)
    -                        retCode = IDS_01_S07;
    -                    DataPtr = &tTmp;
    -                    DataLen = sizeof(SCHAR);
    +                case SQL_SMALLINT:
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;  //negValue in unsigned 
column
    +                        if (dTmp > USHRT_MAX)
    +                            return IDS_22_003;
    +                        usTmp = (USHORT)dTmp;
    +                        if  (dTmp != usTmp)
    +                            retCode = IDS_01_S07;
    +                        DataPtr = &usTmp;
    +                        DataLen = sizeof(USHORT);
    +                    }
    +                    else
    +                    {
    +                        if (!signedInteger)
    +                        {
    +                            if (dTmp < 0 || dTmp > USHRT_MAX)
    +                                return IDS_22_003;
    +                            sTmp = (SHORT)dTmp;
    +                        }
    +                        else
    +                        {
    +                            if (dTmp < SHRT_MIN || dTmp > SHRT_MAX)
    +                                return IDS_22_003;
    +                            sTmp = (SHORT)dTmp;
    +                            if  (dTmp != sTmp)
    +                                retCode = IDS_01_S07;
    +                        }
    +                        DataPtr = &sTmp;
    +                        DataLen = sizeof(SHORT);
    +                    }
                         break;
    -                           case SQLTYPECODE_SMALLINT_UNSIGNED:
    -                                   if (tempVal64 < 0)
    -                                          return IDS_22_003_02;
    -                                   if ((USHORT)tempVal64 > USHRT_MAX)
    -                                           return IDS_22_003;
    -                                   usTmp = (USHORT)tempVal64;
    -                                   if  (tempVal64 != usTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &usTmp;
    -                                   DataLen = sizeof(USHORT);
    -                                   break;
    -                           case SQLTYPECODE_SMALLINT:
    -                                   if (tempVal64 < SHRT_MIN || tempVal64 > 
SHRT_MAX)
    -                                           return IDS_22_003;
    -                                   sTmp = (SHORT)tempVal64;
    -                                   if  (tempVal64 != sTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &sTmp;
    -                                   DataLen = sizeof(sTmp);
    -                                   break;
    -                           case SQLTYPECODE_INTEGER_UNSIGNED:
    -                                   if (tempVal64 < 0)
    -                                          return IDS_22_003_02;
    -                                   if ((ULONG_P)tempVal64 > ULONG_MAX)
    -                                           return IDS_22_003;
    -                                   ulTmp = (ULONG_P)tempVal64;
    -                                   if  (tempVal64 != ulTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &ulTmp;
    -                                   DataLen = sizeof(ulTmp);
    -                                   break;
    -                           case SQLTYPECODE_INTEGER:
    -                                   if (tempVal64 < LONG_MIN || tempVal64 > 
LONG_MAX)
    -                                           return IDS_22_003;
    -                                   lTmp = (LONG)tempVal64;
    -                                   if  (tempVal64 != lTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &lTmp;
    -                                   DataLen = sizeof(lTmp);
    -                                   break;
    -                           case SQLTYPECODE_IEEE_FLOAT:
    -                                   if (tempVal64 < -FLT_MAX || tempVal64 > 
FLT_MAX)
    -                                           return IDS_22_003;
    -                                   fltTmp = (FLOAT)tempVal64;
    -                                   if  (tempVal64 != fltTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &fltTmp;
    -                                   DataLen = sizeof(fltTmp);
    -                                   break;
    -                           case SQLTYPECODE_IEEE_DOUBLE:
    -                                   if (tempVal64 < -DBL_MAX || tempVal64 > 
DBL_MAX)
    -                                           return IDS_22_003;
    -                                   dTmp = (DOUBLE)tempVal64;
    -                                   if  (tempVal64 != dTmp)
    -                                           retCode = IDS_01_S07;
    -                                   DataPtr = &dTmp;
    -                                   DataLen = sizeof(dTmp);
    -                                   break;
    -                           case SQLTYPECODE_DECIMAL_UNSIGNED:
    -                           case SQLTYPECODE_DECIMAL_LARGE_UNSIGNED: // 
Tandem extension
    -                                   if(negative)
    -                                           return IDS_22_003_02;
    -                           case SQLTYPECODE_DECIMAL:
    -                           case SQLTYPECODE_DECIMAL_LARGE: // Tandem 
extension
    -                                   if(negative)
    -                                           tempVal64 = -tempVal64;
    -#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || 
MXSUNSPARC
    -                                   sprintf(cTmpBuf, "%0*lld", 
targetPrecision, tempVal64);
    -#elif defined unixcli
    -                                   sprintf(cTmpBuf, "%0*Ld", 
targetPrecision, tempVal64);
    -#else
    -                                   sprintf(cTmpBuf, "%0*I64d", 
targetPrecision, tempVal64);
    -#endif
    -                                   if (negative)
    -                                           *cTmpBuf = (UCHAR)(*cTmpBuf | 
(UCHAR)0x80);
    -                                   DataPtr = cTmpBuf;
    -                                   DataLen = strlen(cTmpBuf);
    -                                   break;
    -                           case SQLTYPECODE_LARGEINT:
    -                           default:
    -                                   DataPtr = &tempVal64;
    -                                   DataLen = sizeof(tempVal64);
    -                                   break;
    -                           }
    -                   }
    -           }
    -           else
    -           {
    -                   switch (ODBCDataType)
    -                   {
    -            case SQL_TINYINT:
    -                DataLen = sizeof(SCHAR);
    -                break;
    -                   case SQL_SMALLINT:
    -                           DataLen = sizeof(SHORT);
    -                           break;
    -                   case SQL_INTEGER:
    -                           DataLen = sizeof(LONG);
    -                           break;
    -                   case SQL_REAL:
    -                           DataLen = sizeof(FLOAT);
    -                           break;
    -                   case SQL_DOUBLE:
    -                   case SQL_FLOAT:
    -                           DataLen = sizeof(DOUBLE);
    -                           break;
    -                   default:
    -                           return IDS_07_006;
    -                   }
    -           }
    -           break;
    -   case SQL_BIGINT:
    -           switch (CDataType)
    -           {
    -           case SQL_C_WCHAR:
    -                   if (iconv->isAppUTF16())
    -                   {
    -                           if (srcLength != SQL_NTS)
    -                                   srcLength = srcLength/2;
    -                           // translate from UTF16
    -                           if (iconv->WCharToUTF8((UChar*)srcDataPtr, 
srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, 
(char*)errorMsg) != SQL_SUCCESS)
    -                                   return IDS_193_DRVTODS_ERROR;
    -                           srcDataPtr = srcDataLocale;
    -                           srcLength = translateLength;
    -                   }
    -           case SQL_C_CHAR:
    -                   {
    -                           retCode = ConvertCharToInt64(srcDataPtr, 
srcLength, tempVal64);
    -                           if (retCode != SQL_SUCCESS)
    -                                   return retCode;
    -                   }
    -                   break;
    -           case SQL_C_SHORT:
    -           case SQL_C_SSHORT:
    -                   tempVal64 = *(SSHORT *)srcDataPtr;
    -                   break;
    -           case SQL_C_USHORT:
    -                   tempVal64 = *(USHORT *)srcDataPtr;
    -                   break;
    -           case SQL_C_TINYINT:
    -           case SQL_C_STINYINT:
    -                   tempVal64 = *(SCHAR *)srcDataPtr;
    -                   break;
    -           case SQL_C_UTINYINT:
    -           case SQL_C_BIT:
    -                   tempVal64 = *(UCHAR *)srcDataPtr;
    -                   break;
    -           case SQL_C_SLONG:
    -           case SQL_C_LONG:
    -                   tempVal64 = *(SLONG_P *)srcDataPtr;
    -                   break;
    -           case SQL_C_ULONG:
    -                   tempVal64 = *(ULONG_P *)srcDataPtr;
    -                   break;
    -           case SQL_C_FLOAT:
    -                   tempVal64 = *(SFLOAT *)srcDataPtr;
    -                   break;
    -           case SQL_C_DOUBLE:
    -                   tempVal64 = *(DOUBLE *)srcDataPtr;
    -                   break;
    -           case SQL_C_BINARY:
    -                   DataPtr = srcDataPtr;
    -                   break;
    -           case SQL_C_DEFAULT:
    -                   if (ODBCAppVersion >= SQL_OV_ODBC3)
    -                           DataPtr = srcDataPtr;
    -                   else
    -                   {
    -                           retCode = ConvertCharToInt64(srcDataPtr, 
srcLength, tempVal64);
    -                           if (retCode!= SQL_SUCCESS)
    -                                   return retCode;
    -                   }
    -                   break;
    -           case SQL_C_SBIGINT:
    -                   tempVal64 = *(__int64 *)srcDataPtr;
    -                   break;
    -           case SQL_C_NUMERIC:
    -                   ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, 
cTmpBuf);
    -                   srcLength = strlen(cTmpBuf);
    -                   retCode = ConvertCharToInt64((char*)cTmpBuf, srcLength, 
tempVal64);
    -                   if (retCode != SQL_SUCCESS)
    -                           return retCode;
    -                   break;
    -           case SQL_C_INTERVAL_MONTH:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.year_month.month);
    -                   else
    -                           tempVal64 = 
intervalTmp->intval.year_month.month;
    -                   break;
    -           case SQL_C_INTERVAL_YEAR:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.year_month.year);
    -                   else
    -                           tempVal64 = intervalTmp->intval.year_month.year;
    -                   break;
    -           case SQL_C_INTERVAL_DAY:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.day_second.day);
    -                   else
    -                           tempVal64 = intervalTmp->intval.day_second.day;
    -                   break;
    -           case SQL_C_INTERVAL_HOUR:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.day_second.hour);
    -                   else
    -                           tempVal64 = intervalTmp->intval.day_second.hour;
    -                   break;
    -           case SQL_C_INTERVAL_MINUTE:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.day_second.minute);
    -                   else
    -                           tempVal64 = 
intervalTmp->intval.day_second.minute;
    -                   break;
    -           case SQL_C_INTERVAL_SECOND:
    -                   intervalTmp = (SQL_INTERVAL_STRUCT *)srcDataPtr;
    -                   if (intervalTmp->interval_sign == SQL_TRUE)
    -                           tempVal64 = 
-(intervalTmp->intval.day_second.second);
    -                   else
    -                           tempVal64 = 
intervalTmp->intval.day_second.second;
    -                   break;
    -           default:
    -                   return IDS_07_006;
    -           }
    -           if (DataPtr == NULL)
    -                   DataPtr = &tempVal64;
    -           DataLen = sizeof(tempVal64);
    -           break;
    -   case SQL_NUMERIC:
    -           // sol 10-0820-5315
    -           // for R2.3 SP2 release BigNum is only supported for the 
following data type
    -           //     SQL_C_DEFAULT, SQL_C_CHAR, SQL_C_FLOAT, SQL_C_DOUBLE
    -           // other data types will be supported in future release(?) need 
to reject them now
    -           if (((SQLDataType == SQLTYPECODE_NUMERIC) && (targetPrecision > 
18)) ||
    -                   ((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) && 
(targetPrecision > 9)))
    -           { //Bignum
    -                   switch (CDataType)
    -                   {
    -                           case SQL_C_DEFAULT:
    -                           case SQL_C_CHAR:
    -                           case SQL_C_WCHAR:
    -                           case SQL_C_FLOAT:
    -                           case SQL_C_DOUBLE:
    -                           case SQL_C_NUMERIC:
    -                                   break;
    -                           default:
    -                                   return IDS_S1_006;
    -                   }
    -           }
    -           switch (CDataType)
    -           {
    -           case SQL_C_DEFAULT:
    -                   if (ODBCAppVersion >= SQL_OV_ODBC3)
    -                   {
    -
    -                   }                                               // Want 
it fall thru and treat it like SQL_C_CHAR
    -           case SQL_C_WCHAR:
    -                   if (iconv->isAppUTF16())
    -                   {
    -                           if (srcLength != SQL_NTS)
    -                                   srcLength = srcLength/2;
    -                           // translate from UTF16
    -                           if (iconv->WCharToUTF8((UChar*)srcDataPtr, 
srcLength, srcDataLocale, sizeof(srcDataLocale), (int*)&translateLength, 
(char*)errorMsg) != SQL_SUCCESS)
    -                                   return IDS_193_DRVTODS_ERROR;
    -                           srcDataPtr = srcDataLocale;
    -                           srcLength = translateLength;
    -                   }
    -           case SQL_C_CHAR:
    -                   if (srcLength == SQL_NTS)
    -                           tempLen = strlen((const char *)srcDataPtr);
    -                   else
    -                           tempLen = srcLength;
    -
    -                   if( tempLen > sizeof( cTmpBuf ) - 1)
    -                           return IDS_22_003;
    -
    -                   strncpy(cTmpBuf,(char*)srcDataPtr, tempLen);
    -                   cTmpBuf[ tempLen ] = '\0';
    -                   rTrim(cTmpBuf);
    -                   tempLen = strlen(cTmpBuf);
    -
    -                   if( ((SQLDataType == SQLTYPECODE_NUMERIC) && 
(targetPrecision > 18)) ||
    -                           ((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) 
&& (targetPrecision > 9))) //for bignum support
    -                   { //Bignum
    -
    -                           retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -                                   tempLen,
    -                                   (char*)cTmpBuf2,
    -                                   targetLength,
    -                                   targetPrecision,
    -                                   targetScale,
    -                                   SQLDataType,
    -                                   &dataTruncatedWarning);
    -
    -                           if(retCode != SQL_SUCCESS)
    -                                   return retCode;
    -
    -                           useDouble = FALSE;
    -                           if (DataPtr == NULL)
    -//                                 DataPtr = targetDataPtr;
    -                                   DataPtr = (char*)cTmpBuf2;
    -
    -                           DataLen = targetLength;
    -
    -                   } else {
    -                           if ((retCode = ConvertCharToInt64Num(cTmpBuf, 
integralPart,
    -                                                   decimalPart, negative, 
leadZeros)) != 0)
    -                           {
    -// Return values -1 - Out of Range
    -//                          -2 - Illegal numeric value
    -
    -                                   if (retCode == -1)
    -                                           return IDS_22_003;
    -                                   if (retCode == -2)
    -                                           return IDS_22_005;
    -                           }
    -                           if(negative && targetUnsigned)
    -                                   return IDS_22_003_02;
    -                           if ((integralPart < 0) || (integralPart > 
integralMax))
    -                                   return IDS_22_003;
    -                           decimalDigits = 0;
    -                           if (decimalPart > 0)
    -                                   decimalDigits = 
getDigitCount(decimalPart);
    -                           if ((decimalPart > decimalMax) || 
((decimalDigits + leadZeros) > targetScale))
    -                           {
    -                                   retCode = IDS_01_S07;
    -                                   // sol 10-080603-3635
    -                                   // trim the decimalPart based one the 
scale
    -                                   // the number of digits in the decimal 
portion needs to be adjusted if it contain
    -                                   // leading zero(s)
    -                                   decimalPart=decimalPart/pow((double)10, 
(int)(getDigitCount(decimalPart) + leadZeros - targetScale));
    -                           }
    -                           useDouble = FALSE;
    -                   }
    -                   break;
    -           case SQL_C_NUMERIC:
    -                   ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, 
cTmpBuf);
    -                   tempLen = strlen(cTmpBuf);
    -                   if (((SQLDataType == SQLTYPECODE_NUMERIC) && 
(targetPrecision > 18)) ||
    -                           ((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) 
&& (targetPrecision > 9))) //for bignum support
    -                   { //Bignum
    -
    -                           retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -                                   tempLen,
    -                                   (char*)targetDataPtr,
    -                                   targetLength,
    -                                   targetPrecision,
    -                                   targetScale,
    -                                   SQLDataType,
    -                                   &dataTruncatedWarning);
    -
    -                           if(retCode != SQL_SUCCESS)
    -                                   return retCode;
    -
    -                           useDouble = FALSE;
    -                           if (DataPtr == NULL)
    -                                   DataPtr = targetDataPtr;
    -
    -                           DataLen = targetLength;
    -                   }
    -                   else {
    -                           if ((retCode = ConvertCharToInt64Num(cTmpBuf, 
integralPart,
    -                                                   decimalPart, negative, 
leadZeros)) != 0)
    -                           {
    -// Return values -1 - Out of Range
    -//                          -2 - Illegal numeric value
    -
    -                                   if (retCode == -1)
    -                                           return IDS_22_003;
    -                                   if (retCode == -2)
    -                                           return IDS_22_005;
    -                           }
    -                                   if(negative && targetUnsigned)
    -                                           return IDS_22_003_02;
    -                           if ((integralPart < 0) || (integralPart > 
integralMax))
    -                                   return IDS_22_003;
    -                           decimalDigits = 0;
    -                           if (decimalPart > 0)
    -                                   decimalDigits = 
getDigitCount(decimalPart);
    -                           if ((decimalPart > decimalMax) || 
((decimalDigits + leadZeros) > targetScale))
    -                           {
    -                                   retCode = IDS_01_S07;
    -                                   // sol 10-080603-3635
    -                                   // trim the decimalPart based one the 
scale
    -                                   // the number of digits in the decimal 
portion needs to be adjusted if it contain
    -                                   // leading zero(s)
    -                                   decimalPart=decimalPart/pow((double)10, 
(int)(getDigitCount(decimalPart) + leadZeros - targetScale));
    -                           }
    -                           useDouble = FALSE;
    -                   }
    -
    -                   break;
    -
    -           case SQL_C_FLOAT:
    -           case SQL_C_DOUBLE:
    -                   if(CDataType == SQL_C_DOUBLE)
    -                           dTmp = *(DOUBLE *)srcDataPtr;
    -                   else
    -                           dTmp = *(SFLOAT *)srcDataPtr;
    -                   negative = (dTmp < 0)? 1: 0;
    -                   if( ((SQLDataType == SQLTYPECODE_NUMERIC) && 
(targetPrecision > 18)) ||
    -                           ((SQLDataType == SQLTYPECODE_NUMERIC_UNSIGNED) 
&& (targetPrecision > 9)))
    -                   { //Bignum
    -
    -                           if(CDataType == SQL_C_DOUBLE)
    -                           {
    -                                   if (!double_to_char (dTmp, DBL_DIG, 
cTmpBuf, sizeof(cTmpBuf)))
    -                                           dataTruncatedWarning = TRUE;
    -                           }
    -                           else
    -                           {
    -                                   if (!double_to_char (dTmp, FLT_DIG, 
cTmpBuf, sizeof(cTmpBuf)))
    -                                           dataTruncatedWarning = TRUE;
    -                           }
     
    +                case SQL_INTEGER:
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;//negValue in unsigned 
col error
    +                        if (dTmp > UINT_MAX )
    +                            return IDS_22_003;
    +                        ulTmp = (ULONG_P)dTmp;
    +                        if  (dTmp != ulTmp)
    +                            retCode = IDS_01_S07;
    +                        DataPtr = &ulTmp;
    +                        DataLen = sizeof(ULONG_P);
    +                    }
    +                    else
    +                    {
    +                        if (!signedInteger)
    +                        {
    +                            if (dTmp < 0 || dTmp > UINT_MAX )
    +                                return IDS_22_003;
    +                            lTmp = (SLONG_P)dTmp;
    +                        }
    +                        else
    +                        {
    +                            if (dTmp < INT_MIN || dTmp > INT_MAX)
    +                                return IDS_22_003;
    +                            lTmp = (SLONG_P)dTmp;
    +                            if  (dTmp != lTmp)
    +                                retCode = IDS_01_S07;
    +                        }
    +                        DataPtr = &lTmp;
    +                        DataLen = sizeof(SLONG_P);                    }
    +                    break;
     
    -                           retCode = Ascii_To_Bignum_Helper(cTmpBuf,
    -                                   strlen(cTmpBuf),
    -                                   (char*)cTmpBuf2,
    -                                   targetLength,
    -                                   targetPrecision,
    -                                   targetScale,
    -                                   SQLDataType,
    -                                   &dataTruncatedWarning);
    +                case SQL_REAL:
    +                    if (dTmp < -FLT_MAX || dTmp > FLT_MAX)
    +                        return IDS_22_003;
    +                    fltTmp = (SFLOAT)dTmp;
    +                    DataPtr = &fltTmp;
    +                    DataLen = sizeof(fltTmp);
    +                    break;
     
    -                           if(retCode != SQL_SUCCESS)
    -                                   return retCode;
    +                case SQL_DOUBLE:
    +                case SQL_FLOAT:
    +                    DataPtr = &dTmp;
    +                    DataLen = sizeof(dTmp);
    +                    break;
     
    -                           useDouble = FALSE;
    -                           if (DataPtr == NULL)
    -                                   DataPtr = cTmpBuf2;
    +                case SQL_DECIMAL:
    +                    if (targetPrecision >= sizeof(cTmpBuf))
    +                        return IDS_22_003;
    +#if defined MXHPUX || defined MXOSS || defined MXAIX || MXSUNSPARC || 
MXSUNSPARC
    +                    dTmp1 = pow((double)10,targetPrecision-targetScale+1);
    +#else
    +                    dTmp1 = pow(10,targetPrecision-targetScale+1);
    +#endif
    +                    if (targetUnsigned)
    +                    {
    +                        if (dTmp < 0)
    +                            return IDS_22_003_02;  //negValue in unsigned 
column
    +                        if (dTmp > dTmp1)
    +                            return IDS_22_003;
     
    -                           DataLen = targetLength;
    -                           memcpy(outDataPtr, DataPtr, DataLen);
    -                           if (byteSwap)
    -                           {
    -                                   if (Datatype_Dependent_Swap((BYTE 
*)outDataPtr, SQLDataType, targetCharSet, DataLen, IEEE_TO_TANDEM) != STATUS_OK)
    -                                           return IDS_HY_000;
    -                           }
    +                        tempPtr = _fcvt(dTmp, targetScale, &dec, &sign);
    +                        tempLen = strlen(tempPtr);
    +                        tempLen1 = (short)(targetPrecision-tempLen);
    --- End diff --
    
    OK.


> ODBC data convert function split
> --------------------------------
>
>                 Key: TRAFODION-2816
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2816
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: client-odbc-linux, client-odbc-windows
>    Affects Versions: 2.3
>            Reporter: Weiqing Xu
>            Assignee: XuWeixin
>            Priority: Major
>
> Now,  the data convert function in ODBC is very long , and very hard to 
> maintenance, we need to refactor it with some short function.
> 1. split one long function to little functions to make it more easy to 
> maintain.
> 2. support convert very long CHAR/VARCHAR to others struct like timestamp.
> 3. Don't modify SQLDataType for SQL_NUMERIC any more. Use FSDataType to 
> decide the real data format. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to