Github user Weixin-Xu commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1310#discussion_r166166997
--- 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 --
The order is incorrect and makes you misunderstand.
The type boolean is only used in server, and only SQL_CHAR will include
SQLTYPECODE_BOOLEAN.
So the correct order is
case SQL_CHAR:
if ( ... )
break;
case others...
---