http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_PARAM.CPP ---------------------------------------------------------------------- diff --git a/odbc/Driver/KO_PARAM.CPP b/odbc/Driver/KO_PARAM.CPP index 9bbe14c..e05efce 100644 --- a/odbc/Driver/KO_PARAM.CPP +++ b/odbc/Driver/KO_PARAM.CPP @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + // ---------------------------------------------------------------------------- // @@ -38,38 +38,38 @@ #include "stdafx.h" - // ----------------------------------------------------------------------- // to bind a buffer to a parameter marker in an SQL statement // ----------------------------------------------------------------------- -RETCODE SQL_API SQLBindParameter ( SQLHSTMT pStmt, - SQLUSMALLINT pParamNum, - SQLSMALLINT pIOType, - SQLSMALLINT pValueType, - SQLSMALLINT pParamType, - SQLUINTEGER pColSize, - SQLSMALLINT pDecimalDigits, - SQLPOINTER pParamValuePtr, - SQLINTEGER pParamValueSize, - SQLINTEGER* pParamValueSizePtr ) { +RETCODE SQL_API SQLBindParameter ( SQLHSTMT pStmt, + SQLUSMALLINT pParamNum, + SQLSMALLINT pIOType, + SQLSMALLINT pValueType, + SQLSMALLINT pParamType, + SQLUINTEGER pColSize, + SQLSMALLINT pDecimalDigits, + SQLPOINTER pParamValuePtr, + SQLINTEGER pParamValueSize, + SQLINTEGER* pParamValueSizePtr ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLBindParameter called" ) ); __ODBCPOPMSG ( _ODBCPopMsg ( "SQLBindParameter not implemented" ) ); return SQL_ERROR; } - // ----------------------------------------------------------------------- // to get param descriptions for a specified bound param // ----------------------------------------------------------------------- -RETCODE SQL_API SQLDescribeParam ( SQLHSTMT pStmt, - SQLUSMALLINT pParamNum, - SQLSMALLINT* pDataTypePtr, - SQLUINTEGER* pParamSizePtr, - SQLSMALLINT* pDecimalDigitsPtr, - SQLSMALLINT* pNullablePtr ) { +RETCODE SQL_API SQLDescribeParam ( SQLHSTMT pStmt, + SQLUSMALLINT pParamNum, + SQLSMALLINT* pDataTypePtr, + SQLUINTEGER* pParamSizePtr, + SQLSMALLINT* pDecimalDigitsPtr, + SQLSMALLINT* pNullablePtr ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLDescribeParam called" ) ); __ODBCPOPMSG ( _ODBCPopMsg ( "SQLDescribeParam not implemented" ) ); return SQL_ERROR; @@ -80,15 +80,18 @@ RETCODE SQL_API SQLDescribeParam ( SQLHSTMT pStmt, // to get the number of parameters in a statement // ----------------------------------------------------------------------- -RETCODE SQL_API SQLNumParams ( SQLHSTMT pStmt, SQLSMALLINT* pParamCountPtr ) { +RETCODE SQL_API SQLNumParams ( SQLHSTMT pStmt, SQLSMALLINT* pParamCountPtr ) +{ // since the concept of parameters has not been implemented // this function returns zero in the number of params to // make sure that the calle does not proceed forward on this issue __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNumParams called" ) ); - + if ( pParamCountPtr ) - { *pParamCountPtr = 0; } - + { + *pParamCountPtr = 0; + } + return SQL_SUCCESS; } @@ -96,8 +99,10 @@ RETCODE SQL_API SQLNumParams ( SQLHSTMT pStmt, SQLSMALLINT* pParamCountPtr ) { // to be used wth SQLPutData to provide param data at execution time // ----------------------------------------------------------------------- -RETCODE SQL_API SQLParamData ( SQLHSTMT pStmt, SQLPOINTER* pValuePtrPtr ) { +RETCODE SQL_API SQLParamData ( SQLHSTMT pStmt, SQLPOINTER* pValuePtrPtr ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLParamData called" ) ); __ODBCPOPMSG ( _ODBCPopMsg ( "SQLParamData not implemented" ) ); return SQL_ERROR; } +
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_UTILS.CPP ---------------------------------------------------------------------- diff --git a/odbc/Driver/KO_UTILS.CPP b/odbc/Driver/KO_UTILS.CPP index d46deff..342da13 100644 --- a/odbc/Driver/KO_UTILS.CPP +++ b/odbc/Driver/KO_UTILS.CPP @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + // --------------------------------------------------------------------------------- // @@ -36,70 +36,80 @@ #include "stdafx.h" // ------------------------- local functions ---------------------------- -eGoodBad GetDateFromString ( const char* pDateStr, struct tagDATE_STRUCT* pDateStruct ); -eGoodBad GetTimestampFromString ( const char* pDateStr, struct tagTIMESTAMP_STRUCT* pTimestampStruct ); +eGoodBad GetDateFromString ( const char* pDateStr, struct tagDATE_STRUCT* pDateStruct ); +eGoodBad GetTimestampFromString ( const char* pDateStr, struct tagTIMESTAMP_STRUCT* pTimestampStruct ); // ---------------------------------------------------------------------- // to extract date from string assuming server format to be yyyy-mm-dd or yyyymmdd // ---------------------------------------------------------------------- -eGoodBad GetDateFromString ( const char* pDateStr, struct tagDATE_STRUCT* pDateStruct ) { - char val[5]; - short x; - short day, month; +eGoodBad GetDateFromString ( const char* pDateStr, struct tagDATE_STRUCT* pDateStruct ) +{ + char val[5]; + short x; + short day, month; // length of source x = strlen ( pDateStr ); - + // 10 byte date yyyy-mm-dd, 8 byte date yyyymmdd - if ( x == 8 || x == 10 ) { + if ( x == 8 || x == 10 ) + { // calc pos of day and month in string - if ( x == 8 ) { - day = 6; - month = 4; + if ( x == 8 ) + { + day = 6; + month = 4; } - - else { - day = 8; - month = 5; + + else + { + day = 8; + month = 5; } - + // convert day value - pDateStruct->day = atoi ( pDateStr + day ); + pDateStruct -> day = atoi ( pDateStr + day ); // copy and convert month - strncpy ( val, pDateStr + month, 2 ); val[2] = 0; - pDateStruct->month = atoi ( val ); - strncpy ( val, pDateStr, 4 ); val[4] = 0; - pDateStruct->year = atoi ( val ); + strncpy ( val, pDateStr + month, 2 ); + val[2] = 0; + pDateStruct -> month = atoi ( val ); + strncpy ( val, pDateStr, 4 ); + val[4] = 0; + pDateStruct -> year = atoi ( val ); return GOOD; } - - else { + + else + { __ODBCPOPMSG ( _ODBCPopMsg ( "Invalid date string for conversion: %s", pDateStr ) ); return BAD; } } //Timestamps in text files have to use the format yyyy-mm-dd or yyyy-mm-dd hh:mm:ss[.f...] -eGoodBad GetTimestampFromString ( const char* pStr, struct tagTIMESTAMP_STRUCT* pTimestampStruct ) { - char val[10]; - short x; - short day, month, hour, minute, second, frag; +eGoodBad GetTimestampFromString ( const char* pStr, struct tagTIMESTAMP_STRUCT* pTimestampStruct ) +{ + char val[10]; + short x; + short day, month, hour, minute, second, frag; // length of source x = strlen ( pStr ); const char* p = pStr; - - while ( ( *p != ' ' ) && ( p < pStr + x ) ) { + + while ( ( *p != ' ' ) && ( p < pStr + x ) ) + { p++; } - - if ( ( p - pStr ) != 10 || ( x < 19 && x != 10) ) { + + if ( ( p - pStr ) != 10 || ( x < 19 && x != 10 ) ) + { __ODBCPOPMSG ( _ODBCPopMsg ( "Invalid timestamp string for conversion: %s", pStr ) ); return BAD; } - - month = 5; - day = 8; + + month = 5; + day = 8; hour = 11; minute = 14; second = 17; @@ -107,46 +117,48 @@ eGoodBad GetTimestampFromString ( const char* pStr, struct tagTIMESTAMP_STRUC // convert day value strncpy ( val, pStr + day, 2 ); val[2] = 0; - pTimestampStruct->day = atoi ( val ); + pTimestampStruct -> day = atoi ( val ); // copy and convert month strncpy ( val, pStr + month, 2 ); val[2] = 0; - pTimestampStruct->month = atoi ( val ); + pTimestampStruct -> month = atoi ( val ); //convert year strncpy ( val, pStr, 4 ); val[4] = 0; - pTimestampStruct->year = atoi ( val ); - - if (x > 10) - { - //convert hour - strncpy ( val, pStr + hour, 2 ); - val[2] = 0; - pTimestampStruct->hour = atoi ( val ); - //convert minute - strncpy ( val, pStr + minute, 2 ); - val[2] = 0; - pTimestampStruct->minute = atoi ( val ); - //convert second - strncpy ( val, pStr + second, 2 ); - val[2] = 0; - pTimestampStruct->second = atoi ( val ); - } - else - { - pTimestampStruct->hour = 0; - pTimestampStruct->minute = 0; - pTimestampStruct->second = 0; - } - - if ( x >= 21 ) { - pTimestampStruct->fraction = atoi ( pStr + frag ); + pTimestampStruct -> year = atoi ( val ); + + if ( x > 10 ) + { + //convert hour + strncpy ( val, pStr + hour, 2 ); + val[2] = 0; + pTimestampStruct -> hour = atoi ( val ); + //convert minute + strncpy ( val, pStr + minute, 2 ); + val[2] = 0; + pTimestampStruct -> minute = atoi ( val ); + //convert second + strncpy ( val, pStr + second, 2 ); + val[2] = 0; + pTimestampStruct -> second = atoi ( val ); + } + else + { + pTimestampStruct -> hour = 0; + pTimestampStruct -> minute = 0; + pTimestampStruct -> second = 0; } - - else { - pTimestampStruct->fraction = 0; + + if ( x >= 21 ) + { + pTimestampStruct -> fraction = atoi ( pStr + frag ); } - + + else + { + pTimestampStruct -> fraction = 0; + } + return GOOD; } @@ -155,64 +167,83 @@ eGoodBad GetTimestampFromString ( const char* pStr, struct tagTIMESTAMP_STRUC // ---------------------------------------------------------------------- RETCODE SQL_API _SQLCopyCharData ( pODBCDiag pDiag, void* pTgtDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize ) { + Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, - "_SQLCopyCharData called,pDataBufSize %d, the src is %s, strlen(src) %d, pSrcDataSize %d", pDataBufSize, pSrcData, - strlen ( pSrcData ), pSrcDataSize ) ); - Long n; - + "_SQLCopyCharData called,pDataBufSize %d, the src is %s, strlen(src) %d, pSrcDataSize %d", pDataBufSize, pSrcData, + strlen ( pSrcData ), pSrcDataSize ) ); + Long n; + // caller safe if ( pTgtDataPtr ) - { * ( ( StrPtr ) pTgtDataPtr ) = 0; } - + { + * ( ( StrPtr ) pTgtDataPtr ) = 0; + } + // DATA SIZE - + // check source data to compute size if ( pSrcData && _stricmp ( ( StrPtr ) pSrcData, "NULL" ) != 0 ) - { n = ( pSrcDataSize < 0 ) ? strlen ( ( StrPtr ) pSrcData ) : pSrcDataSize; } // compute length based on whether null terminated - + { + n = ( pSrcDataSize < 0 ) ? strlen ( ( StrPtr ) pSrcData ) : pSrcDataSize; + } // compute length based on whether null terminated + else - { n = 0; } - + { + n = 0; + } + // check if there is a holder for size - if ( pSizePtr ) { + if ( pSizePtr ) + { // set size as per ptr type 16-bt or 32-bit if ( pSizePtrSize == 16 ) - { * ( ( Word* ) pSizePtr ) = ( Word ) n; } - + { + * ( ( Word* ) pSizePtr ) = ( Word ) n; + } + else - { * ( ( Long* ) pSizePtr ) = n; } + { + * ( ( Long* ) pSizePtr ) = n; + } } - + // check if src data but no size holder - else if ( pSrcData ) { + else if ( pSrcData ) + { // check if diag to be set if ( pDiag ) - { _SQLPutDiagRow ( pDiag, "_SQLCopyCharData", "01000", -1, "No holder for data size", NULL ); } - + { + _SQLPutDiagRow ( pDiag, "_SQLCopyCharData", "01000", -1, "No holder for data size", NULL ); + } + __ODBCPOPMSG ( _ODBCPopMsg ( "_SQLCopyCharData - No holder for data size" ) ); return SQL_ERROR; } - + // check if there is a target holder - if ( pTgtDataPtr ) { + if ( pTgtDataPtr ) + { // check if there is a source pointer - if ( pSrcData ) { + if ( pSrcData ) + { // does all of it fit with null char - if ( pDataBufSize >= n + 1 ) { + if ( pDataBufSize >= n + 1 ) + { memcpy ( ( StrPtr ) pTgtDataPtr, pSrcData, n ); - ( ( StrPtr ) pTgtDataPtr ) [n] = 0; + ( ( StrPtr ) pTgtDataPtr )[n] = 0; __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyCharData has been called, the string(not truncated) is %s", - pTgtDataPtr ) ); + pTgtDataPtr ) ); return SQL_SUCCESS; } - + // all of it does not fit - else { + else + { memcpy ( ( StrPtr ) pTgtDataPtr, pSrcData, pDataBufSize - 1 ); - ( ( StrPtr ) pTgtDataPtr ) [pDataBufSize - 1] = 0; + ( ( StrPtr ) pTgtDataPtr )[pDataBufSize - 1] = 0; __ODBCLOG ( _ODBCLogMsg ( LogLevel_WARN, "_SQLCopyCharData has been called, the target string is (truncated) %s", - pTgtDataPtr ) ); + pTgtDataPtr ) ); //return SQL_SUCCESS_WITH_INFO may cause error in tableau //if ( pDiag ) // _SQLPutDiagRow ( pDiag, "_SQLCopyCharData", "01000", -1, "string data truncated", NULL ); @@ -221,94 +252,119 @@ RETCODE SQL_API _SQLCopyCharData ( pODBCDiag pDiag, void* pTgtDataPtr, Long pDat return SQL_SUCCESS; } } - + // tgt data but no src data - else { + else + { // clear tgt * ( ( Char* ) pTgtDataPtr ) = 0; __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyCharData has been called, the string is (empty) %s", pTgtDataPtr ) ); } } - + return SQL_SUCCESS; } RETCODE SQL_API _SQLCopyWCharData ( pODBCDiag pDiag, void* pTgtDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize , bool returnByteSize) { - unique_ptr<wchar_t[]> pWCS ( char2wchar ( pSrcData ) ); - return _SQLCopyWCharDataW ( pDiag, pTgtDataPtr, pDataBufSize, pSizePtr, pSizePtrSize, pWCS.get(), pSrcDataSize, returnByteSize); + Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize, bool returnByteSize ) +{ + unique_ptr <wchar_t[]> pWCS ( char2wchar ( pSrcData ) ); + return _SQLCopyWCharDataW ( pDiag, pTgtDataPtr, pDataBufSize, pSizePtr, pSizePtrSize, pWCS . get (), pSrcDataSize, returnByteSize ); } + //mhb added, for those ard that accept wchar RETCODE SQL_API _SQLCopyWCharDataW ( pODBCDiag pDiag, void* pTgtDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, const wchar_t* pSrcData, Long pSrcDataSize, bool returnByteSize ) { + Word pSizePtrSize, const wchar_t* pSrcData, Long pSrcDataSize, bool returnByteSize ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyWCharDataW called, pTgtDataPtr is null? %d, pSizePtr == null? %d", - pTgtDataPtr == NULL, pSizePtr == NULL ) ); + pTgtDataPtr == NULL, pSizePtr == NULL ) ); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyWCharDataW called, the src string is :" ) ); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, pSrcData ) ); - Long n; - + Long n; + // caller safe if ( pTgtDataPtr ) - { * ( ( wchar_t* ) pTgtDataPtr ) = 0; } - + { + * ( ( wchar_t* ) pTgtDataPtr ) = 0; + } + // DATA SIZE - + // check source data to compute size if ( pSrcData && _wcsicmp ( pSrcData, L"NULL" ) != 0 ) - { n = ( pSrcDataSize < 0 ) ? wcslen ( pSrcData ) : pSrcDataSize; } // compute length based on whether null terminated - + { + n = ( pSrcDataSize < 0 ) ? wcslen ( pSrcData ) : pSrcDataSize; + } // compute length based on whether null terminated + else - { n = 0; } - + { + n = 0; + } + // check if there is a holder for size - if ( pSizePtr ) { + if ( pSizePtr ) + { // set size as per ptr type 16-bt or 32-bit - + //should be number of characters - Long pPtrSizeBuf = n; - if (returnByteSize) { pPtrSizeBuf = 2 * n; } + Long pPtrSizeBuf = n; + if ( returnByteSize ) + { + pPtrSizeBuf = 2 * n; + } if ( pSizePtrSize == 16 ) - { * ( ( Word* ) pSizePtr ) = ( Word ) pPtrSizeBuf; } - + { + * ( ( Word* ) pSizePtr ) = ( Word ) pPtrSizeBuf; + } + else - { * ( ( Long* ) pSizePtr ) = pPtrSizeBuf; } - - __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pSizePtr %d is set to %d", pSizePtr, * ( ( SQLLEN* ) pSizePtr ) ) ); + { + * ( ( Long* ) pSizePtr ) = pPtrSizeBuf; + } + + __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pSizePtr %d is set to %d", pSizePtr, * ( ( SQLLEN* ) pSizePtr ) ) ); } - + // check if src data but no size holder - else if ( pSrcData ) { + else if ( pSrcData ) + { // check if diag to be set if ( pDiag ) - { _SQLPutDiagRow ( pDiag, "_SQLCopyWCharDataW", "01000", -1, "No holder for data size", NULL ); } - + { + _SQLPutDiagRow ( pDiag, "_SQLCopyWCharDataW", "01000", -1, "No holder for data size", NULL ); + } + __ODBCPOPMSG ( _ODBCPopMsg ( "_SQLCopyWCharDataW - No holder for data size" ) ); return SQL_ERROR; } - + // DATA - + // check if there is a target holder - if ( pTgtDataPtr ) { + if ( pTgtDataPtr ) + { // check if there is a source pointer - if ( pSrcData ) { + if ( pSrcData ) + { // does all of it fit with null char - if ( pDataBufSize >= ( n + 1 ) ) { + if ( pDataBufSize >= ( n + 1 ) ) + { memcpy ( ( StrPtr ) pTgtDataPtr, pSrcData, 2 * ( n + 1 ) ); - ( ( wchar_t* ) pTgtDataPtr ) [n] = L'\0'; + ( ( wchar_t* ) pTgtDataPtr )[n] = L'\0'; //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"_SQLCopyWCharDataW has been called, the target string(not truncated) is :")); //unique_ptr<char[]> temp2(wchar2char( (wchar_t*)pTgtDataPtr)); //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,temp2.get())); return SQL_SUCCESS; } - + // all of it does not fit - else { + else + { //if(pDataBufSize % 2 == 1) // pDataBufSize -= 1; memcpy ( ( StrPtr ) pTgtDataPtr, pSrcData, 2 * ( pDataBufSize - 1 ) ); - ( ( wchar_t* ) pTgtDataPtr ) [pDataBufSize - 1] = 0; + ( ( wchar_t* ) pTgtDataPtr )[pDataBufSize - 1] = 0; //__ODBCLOG(_ODBCLogMsg(LogLevel_WARN,"_SQLCopyWCharDataW has been called, the target string is(truncated) :")); //unique_ptr<char[]> temp ( wchar2char ( ( wchar_t* ) pTgtDataPtr ) ); //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG, temp.get())); @@ -320,16 +376,17 @@ RETCODE SQL_API _SQLCopyWCharDataW ( pODBCDiag pDiag, void* pTgtDataPtr, Long pD return SQL_SUCCESS; } } - + // tgt data but no src data - else { + else + { // clear tgt * ( ( wchar_t* ) pTgtDataPtr ) = 0; __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyWCharDataW has been called, the string is (empty) %s", - pTgtDataPtr ) ); + pTgtDataPtr ) ); } } - + return SQL_SUCCESS; } @@ -340,8 +397,9 @@ RETCODE SQL_API _SQLCopyWCharDataW ( pODBCDiag pDiag, void* pTgtDataPtr, Long pD //TODO: it seems that the unsigned values are not treated specially -Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, Word pSrcDataType , - Long* pTgtDataSizePtr ) { +Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, Word pSrcDataType, + Long* pTgtDataSizePtr ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyNumData called" ) ); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The src is %s", pSrcData ) ); // note @@ -349,189 +407,227 @@ Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CS // target data size indicates the type of int - 8bit, 16bit, 32bit, float, double etc // source data type is also recd. but is not being checked right now // this can be used to detrmine if the conversion is possible at all - bool isnull; + bool isnull; // check if source data is NULL isnull = ( !pSrcData || _stricmp ( pSrcData, "NULL" ) == 0 ) ? TRUE : 0; - + // check if target is there - if ( pTgtDataPtr ) { + if ( pTgtDataPtr ) + { // check the data type - switch ( pTgtDataType ) { - case SQL_C_UTINYINT: - if ( !isnull ) { + switch ( pTgtDataType ) + { + case SQL_C_UTINYINT : + if ( !isnull ) + { int i32; i32 = atoi ( pSrcData ); * ( ( unsigned char* ) pTgtDataPtr ) = i32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( char ) ); } - - *pTgtDataSizePtr = sizeof ( char ); + { + memset ( pTgtDataPtr, 0, sizeof ( char) ); + } + + *pTgtDataSizePtr = sizeof ( char); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %d (unsigned char)", - * ( ( unsigned char* ) pTgtDataPtr ) ) ); + * ( ( unsigned char* ) pTgtDataPtr ) ) ); break; - - case SQL_C_STINYINT: - case SQL_C_TINYINT: - if ( !isnull ) { + + case SQL_C_STINYINT : + case SQL_C_TINYINT : + if ( !isnull ) + { int i32; i32 = atoi ( pSrcData ); * ( ( char* ) pTgtDataPtr ) = i32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( char ) ); } - - *pTgtDataSizePtr = sizeof ( char ); + { + memset ( pTgtDataPtr, 0, sizeof ( char) ); + } + + *pTgtDataSizePtr = sizeof ( char); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %d (signed char)", * ( ( char* ) pTgtDataPtr ) ) ); break; - - case SQL_C_USHORT: // unsigned short - if ( !isnull ) { + + case SQL_C_USHORT : // unsigned short + if ( !isnull ) + { int i32; i32 = atoi ( pSrcData ); * ( ( Word* ) pTgtDataPtr ) = i32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( Word ) ); } - - *pTgtDataSizePtr = sizeof ( Word ); + { + memset ( pTgtDataPtr, 0, sizeof ( Word) ); + } + + *pTgtDataSizePtr = sizeof ( Word); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %u (signed short)", - * ( ( unsigned short* ) pTgtDataPtr ) ) ); + * ( ( unsigned short* ) pTgtDataPtr ) ) ); break; - - case SQL_C_SHORT: // case i2 - case SQL_C_SSHORT: // signed short - if ( !isnull ) { + + case SQL_C_SHORT : // case i2 + case SQL_C_SSHORT : // signed short + if ( !isnull ) + { int i32; i32 = atoi ( pSrcData ); * ( ( Word* ) pTgtDataPtr ) = i32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( Word ) ); } - - *pTgtDataSizePtr = sizeof ( Word ); + { + memset ( pTgtDataPtr, 0, sizeof ( Word) ); + } + + *pTgtDataSizePtr = sizeof ( Word); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %d (signed short)", * ( ( Word* ) pTgtDataPtr ) ) ); break; - - case SQL_C_ULONG: // unsigned long - if ( !isnull ) { + + case SQL_C_ULONG : // unsigned long + if ( !isnull ) + { unsigned long ui32; - ui32 = strtoul ( pSrcData , NULL, 10 ); + ui32 = strtoul ( pSrcData, NULL, 10 ); * ( ( unsigned long* ) pTgtDataPtr ) = ui32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( unsigned long ) ); } - - *pTgtDataSizePtr = sizeof ( unsigned long ); + { + memset ( pTgtDataPtr, 0, sizeof ( unsigned long) ); + } + + *pTgtDataSizePtr = sizeof ( unsigned long); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %u (unsigned int)", - * ( ( unsigned long* ) pTgtDataPtr ) ) ); + * ( ( unsigned long* ) pTgtDataPtr ) ) ); break; - - case SQL_C_LONG: // case i4 - case SQL_C_SLONG: // signed long - + + case SQL_C_LONG : // case i4 + case SQL_C_SLONG : // signed long + // ???? check src type - if ( !isnull ) { + if ( !isnull ) + { long i32; i32 = atol ( pSrcData ); * ( ( Long* ) pTgtDataPtr ) = i32; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( Long ) ); } - - *pTgtDataSizePtr = sizeof ( Long ); + { + memset ( pTgtDataPtr, 0, sizeof ( Long) ); + } + + *pTgtDataSizePtr = sizeof ( Long); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %d (signed int)", * ( ( Long* ) pTgtDataPtr ) ) ); break; - - case SQL_C_UBIGINT: - if ( !isnull ) { + + case SQL_C_UBIGINT : + if ( !isnull ) + { unsigned __int64 x64; x64 = _strtoui64 ( pSrcData, NULL, 10 ); * ( ( unsigned __int64* ) pTgtDataPtr ) = x64; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( unsigned __int64 ) ); } - - *pTgtDataSizePtr = sizeof ( unsigned __int64 ); + { + memset ( pTgtDataPtr, 0, sizeof ( unsigned __int64) ); + } + + *pTgtDataSizePtr = sizeof ( unsigned __int64); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %I64u (unsigned big int)", - * ( ( unsigned __int64* ) pTgtDataPtr ) ) ); + * ( ( unsigned __int64* ) pTgtDataPtr ) ) ); break; - - case SQL_BIGINT: - case SQL_C_SBIGINT: - if ( !isnull ) { + + case SQL_BIGINT : + case SQL_C_SBIGINT : + if ( !isnull ) + { __int64 x64; x64 = _strtoi64 ( pSrcData, NULL, 10 ); * ( ( __int64* ) pTgtDataPtr ) = x64; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( __int64 ) ); } - - *pTgtDataSizePtr = sizeof ( __int64 ); + { + memset ( pTgtDataPtr, 0, sizeof ( __int64) ); + } + + *pTgtDataSizePtr = sizeof ( __int64); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %I64d (signed big int)", - * ( ( __int64* ) pTgtDataPtr ) ) ); + * ( ( __int64* ) pTgtDataPtr ) ) ); break; - - //case SQL_DECIMAL: //decimal type has a special struct - case SQL_FLOAT: - case SQL_C_FLOAT: - if ( !isnull ) { + + //case SQL_DECIMAL: //decimal type has a special struct + case SQL_FLOAT : + case SQL_C_FLOAT : + if ( !isnull ) + { // ???? check src type double f; f = atof ( pSrcData ); * ( ( float* ) pTgtDataPtr ) = ( float ) f; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( float ) ); } - - *pTgtDataSizePtr = sizeof ( float ); + { + memset ( pTgtDataPtr, 0, sizeof ( float) ); + } + + *pTgtDataSizePtr = sizeof ( float); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %9.9f (float)", * ( ( float* ) pTgtDataPtr ) ) ); break; - - //case SQL_REAL: - //case SQL_NUMERIC: // case float - - case SQL_C_DOUBLE: - if ( !isnull ) { + + //case SQL_REAL: + //case SQL_NUMERIC: // case float + + case SQL_C_DOUBLE : + if ( !isnull ) + { // ???? check src type - char* e; - double d; - + char* e; + double d; + if ( pSrcDataType == SQL_BIT ) - { d = 1; } - + { + d = 1; + } + else - { d = strtod ( pSrcData, &e ); } - + { + d = strtod ( pSrcData, &e ); + } + * ( ( double* ) pTgtDataPtr ) = d; } - + else - { memset ( pTgtDataPtr, 0, sizeof ( double ) ); } - - *pTgtDataSizePtr = sizeof ( double ); + { + memset ( pTgtDataPtr, 0, sizeof ( double) ); + } + + *pTgtDataSizePtr = sizeof ( double); __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The num is set to %9.9f (double), with the pTgtDataSizePtr %d", - * ( ( double* ) pTgtDataPtr ), *pTgtDataSizePtr ) ); + * ( ( double* ) pTgtDataPtr ), *pTgtDataSizePtr ) ); break; - - default: - return 1; // data type not understood + + default : + return 1; // data type not understood } - - return 0; // successful, at least data type recognized + + return 0; // successful, at least data type recognized } - + else - { return -1; } // should not typically happen + { + return -1; + } // should not typically happen } @@ -540,58 +636,62 @@ Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CS // ---------------------------------------------------------------------- Word _SQLCopyDateTimeData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, - Word pSrcDataType ) { + Word pSrcDataType ) +{ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLCopyDateTimeData called, with the src : %s", pSrcData ) ); // note // source data is received as character string // source data type is also recd. but is not being checked right now // this can be used to detrmine if the conversion is possible at all - bool isnull; + bool isnull; // check if source data is NULL isnull = ( !pSrcData || _stricmp ( pSrcData, "NULL" ) == 0 ) ? TRUE : 0; - + // check if target is there - if ( pTgtDataPtr ) { + if ( pTgtDataPtr ) + { // check the data size - switch ( pTgtDataType ) { - case SQL_C_TYPE_DATE: // 91 - case SQL_C_DATE: - + switch ( pTgtDataType ) + { + case SQL_C_TYPE_DATE : // 91 + case SQL_C_DATE : + // ???? check src type - if ( !isnull ) { - memset ( pTgtDataPtr, 0, sizeof ( struct tagDATE_STRUCT ) ); + if ( !isnull ) + { + memset ( pTgtDataPtr, 0, sizeof ( struct tagDATE_STRUCT) ); GetDateFromString ( pSrcData, ( struct tagDATE_STRUCT* ) pTgtDataPtr ); } - + break; - - case SQL_C_TYPE_TIME: // 92 - case SQL_C_TIME: + + case SQL_C_TYPE_TIME : // 92 + case SQL_C_TIME : //not suppporting Time return 1; - - case SQL_C_TYPE_TIMESTAMP: // 93 - case SQL_C_TIMESTAMP: - + + case SQL_C_TYPE_TIMESTAMP : // 93 + case SQL_C_TIMESTAMP : + // ???? check src type - if ( !isnull ) { - memset ( pTgtDataPtr, 0, sizeof ( struct tagTIMESTAMP_STRUCT ) ); + if ( !isnull ) + { + memset ( pTgtDataPtr, 0, sizeof ( struct tagTIMESTAMP_STRUCT) ); GetTimestampFromString ( pSrcData, ( struct tagTIMESTAMP_STRUCT* ) pTgtDataPtr ); } - + break; - - default: - return 1; // data type not understood + + default : + return 1; // data type not understood } - - return 0; // successful, at least data type recognized + + return 0; // successful, at least data type recognized } - + else - { return -1; } // should not typically happen + { + return -1; + } // should not typically happen } - - - http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KylinODBC.CPP ---------------------------------------------------------------------- diff --git a/odbc/Driver/KylinODBC.CPP b/odbc/Driver/KylinODBC.CPP index 5eda301..e47a468 100644 --- a/odbc/Driver/KylinODBC.CPP +++ b/odbc/Driver/KylinODBC.CPP @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + // --------------------------------------------------------------------------------- // @@ -41,67 +41,71 @@ // ------------------------- global variables ------------------------- -HINSTANCE ghInstDLL = 0; -Long gLogFile = -1; -Word gLogUsage = 0; +HINSTANCE ghInstDLL = 0; +Long gLogFile = -1; +Word gLogUsage = 0; // ----------------------------------------------------------------------- // DLL enrty point // ----------------------------------------------------------------------- -BOOL WINAPI DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { +BOOL WINAPI DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) +{ // note // key functions it needs to perform // 1. initialize the log system if in debug mode - + // Perform actions based on the reason for calling. - switch ( fdwReason ) { - case DLL_PROCESS_ATTACH: + switch ( fdwReason ) + { + case DLL_PROCESS_ATTACH : // Initialize once for each new process. // Return FALSE to fail DLL load. OutputDebugString ( "Process Attached\n" ); // for DBMON // start log _ODBCLogStart (); - #ifdef _DEBUG +#ifdef _DEBUG MessageBox ( GetDesktopWindow(), "Entry into driver DLL - PROCESS_ATTACH", "Kylin ODBC driver", MB_OK ); - #endif +#endif break; - - case DLL_THREAD_ATTACH: - #ifdef _DEBUG + + case DLL_THREAD_ATTACH : +#ifdef _DEBUG // start log _ODBCLogStart (); - #endif +#endif // log msg OutputDebugString ( "Thread Attached\n" ); // for DBMON // Do thread-specific initialization. break; - - case DLL_THREAD_DETACH: - #ifdef _DEBUG + + case DLL_THREAD_DETACH : +#ifdef _DEBUG // stop log _ODBCLogStop ( 0 ); - #endif +#endif // Do thread-specific cleanup. break; - - case DLL_PROCESS_DETACH: - #ifdef _DEBUG + + case DLL_PROCESS_DETACH : +#ifdef _DEBUG // log msg //__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG, "Thread de-tach")); // stop log _ODBCLogStop ( 1 ); - #endif +#endif // Perform any necessary cleanup. break; } - + // check if instance has not been saved if ( ghInstDLL == 0 ) - { ghInstDLL = hinstDLL; } - - return TRUE; // Successful DLL_PROCESS_ATTACH. + { + ghInstDLL = hinstDLL; + } + + return TRUE; // Successful DLL_PROCESS_ATTACH. } @@ -200,7 +204,6 @@ BOOL WINAPI DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) // ----------------------------------------------------------------------- - // ----------------------------------------------------------------------- // ------------------------- deprecated functions ------------------------ // ----------------------------------------------------------------------- @@ -367,4 +370,5 @@ BOOL WINAPI DllMain ( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) } -****************** */ \ No newline at end of file +****************** */ + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KylinODBC.H ---------------------------------------------------------------------- diff --git a/odbc/Driver/KylinODBC.H b/odbc/Driver/KylinODBC.H index 896c9e9..5a0fde4 100644 --- a/odbc/Driver/KylinODBC.H +++ b/odbc/Driver/KylinODBC.H @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + // ---------------------------------------------------------------------------- // // File: KylinODBC.h @@ -80,28 +80,32 @@ #include <memory> // -------------------- types --------------------- -typedef char Char; -typedef short Word; -typedef long Long; +typedef char Char; +typedef short Word; +typedef long Long; -typedef unsigned char UChar; -typedef unsigned short UWord; -typedef unsigned long ULong; +typedef unsigned char UChar; +typedef unsigned short UWord; +typedef unsigned long ULong; -typedef Char* StrPtr; -typedef const Char* CStrPtr; +typedef Char* StrPtr; +typedef const Char* CStrPtr; -enum eGoodBad { GOOD = 0, BAD }; +enum eGoodBad +{ + GOOD = 0, + BAD +}; // ----------------------- predeclarations and typedefs ---------------------------- -struct ODBCEnv; // environment -typedef struct ODBCEnv* pODBCEnv; // ENVIRONMENT as pointer type +struct ODBCEnv; // environment +typedef struct ODBCEnv* pODBCEnv; // ENVIRONMENT as pointer type -struct ODBCConn; // connection -typedef struct ODBCConn* pODBCConn; // CONNECTION as pointer type +struct ODBCConn; // connection +typedef struct ODBCConn* pODBCConn; // CONNECTION as pointer type -struct ODBCStmt; // statement -typedef struct ODBCStmt* pODBCStmt; // STATEMENT as pointer type +struct ODBCStmt; // statement +typedef struct ODBCStmt* pODBCStmt; // STATEMENT as pointer type // --------------------------- descriptor types/signatures -------------------------- @@ -117,38 +121,38 @@ typedef struct ODBCStmt* pODBCStmt; // STATEMENT as po // DIAGNOSTIC ROW - diagnostic message holder and link list // ---------------------------------------------------------------------------------- -struct ODBCDiagRow { - +struct ODBCDiagRow +{ Long NativeErrorCode; // SQL_DIAG_NATIVE, native error code, specific to the data source - Long Row; // error row if applicable - Long Col; // error col if applicable - - Char State[SQL_SQLSTATE_SIZE + 1]; // SQLSTATE --- state as per ODBC spec - StrPtr Msg; // SQL_DIAG_MESSAGE_TEXT, message text - - struct ODBCDiagRow* Next; // next message - struct ODBCDiagRow* Prev; // prev message + Long Row; // error row if applicable + Long Col; // error col if applicable + + Char State[SQL_SQLSTATE_SIZE + 1]; // SQLSTATE --- state as per ODBC spec + StrPtr Msg; // SQL_DIAG_MESSAGE_TEXT, message text + + struct ODBCDiagRow* Next; // next message + struct ODBCDiagRow* Prev; // prev message }; -typedef struct ODBCDiagRow* pODBCDiagRow; // DIAGROW as pointer type +typedef struct ODBCDiagRow* pODBCDiagRow; // DIAGROW as pointer type // ---------------------------------------------------------------------------------- // DIAGNOSTIC - diagnostics header & rows link-list holder holder // ---------------------------------------------------------------------------------- -struct ODBCDiag { - +struct ODBCDiag +{ // header attributes - Char Func[64]; // func/API that generated the messages - + Char Func[64]; // func/API that generated the messages + // diagnostic rows link-list - pODBCDiagRow DiagRows; + pODBCDiagRow DiagRows; }; -typedef struct ODBCDiag* pODBCDiag; // ODBCDIAG as pointer type +typedef struct ODBCDiag* pODBCDiag; // ODBCDIAG as pointer type // ARD @@ -158,64 +162,64 @@ typedef struct ODBCDiag* pODBCDiag; // ODBCDIAG as poi // APPL ROW DESC ITEM - to hold appl specified buffers & other details for one column // ---------------------------------------------------------------------------------- -struct ARDItem { - - Word ColNum; // column number - - Word DataConciseType; // concise data type - Word DataVerboseType; // basic data type - Word DateTimeIntervalCode; // date-time interval code - Long DateTimeIntervalPrec; // date-time precision - Long NumPrecRadix; // 2 if approx num type or 10 exact num type - Word Scale; // scale, right of decimal - - void* DataPtr; // col data - Long DataSize; // size of data buffer - Long* SizePtr; // actual data size - Long* SizeIndPtr; // size indicator ptr - +struct ARDItem +{ + Word ColNum; // column number + + Word DataConciseType; // concise data type + Word DataVerboseType; // basic data type + Word DateTimeIntervalCode; // date-time interval code + Long DateTimeIntervalPrec; // date-time precision + Long NumPrecRadix; // 2 if approx num type or 10 exact num type + Word Scale; // scale, right of decimal + + void* DataPtr; // col data + Long DataSize; // size of data buffer + Long* SizePtr; // actual data size + Long* SizeIndPtr; // size indicator ptr + /////// following r fed & used at time of fetch for optimization - - Word SrcDataType; // src data type ( for optimization only ) - Long SrcDataSize; // size of source data - Word SrcDataPrecision; // precision for source data - Word SrcDataScale; // scale for source data - + + Word SrcDataType; // src data type ( for optimization only ) + Long SrcDataSize; // size of source data + Word SrcDataPrecision; // precision for source data + Word SrcDataScale; // scale for source data + /////// - - struct ARDItem* Next; // next col binding - struct ARDItem* Prev; // prev col binding + + struct ARDItem* Next; // next col binding + struct ARDItem* Prev; // prev col binding }; -typedef struct ARDItem* pARDItem; // ARD-Col as pointer type +typedef struct ARDItem* pARDItem; // ARD-Col as pointer type // ---------------------------------------------------------------------------------- // APPL ROW DESC - to hold appl specified buffers & other details for columns // ---------------------------------------------------------------------------------- -struct ODBCARD { +struct ODBCARD +{ + Word Sign; - Word Sign; - // header fields - Word AllocType; // SQL_DESC_ALLOC_TYPE - ULong RowArraySize; // SQL_DESC_ARRAY_SIZE - UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR - Long* BindOffsetPtr; // SQL_DESC_BIND_OFFSET_PTR - Long BindTypeOrSize; // SQL_DESC_BIND_TYPE - Word DescCount; // SQL_DESC_COUNT - + Word AllocType; // SQL_DESC_ALLOC_TYPE + ULong RowArraySize; // SQL_DESC_ARRAY_SIZE + UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR + Long* BindOffsetPtr; // SQL_DESC_BIND_OFFSET_PTR + Long BindTypeOrSize; // SQL_DESC_BIND_TYPE + Word DescCount; // SQL_DESC_COUNT + // rows for binding each col - pARDItem BindCols; // col bindings - + pARDItem BindCols; // col bindings + // container - pODBCStmt Stmt; // container statememt + pODBCStmt Stmt; // container statememt }; //typedef struct ODBCARD ODBCARD; // ARD data type -typedef struct ODBCARD* pODBCARD; // ARD as pointer type +typedef struct ODBCARD* pODBCARD; // ARD as pointer type // IRD @@ -224,32 +228,31 @@ typedef struct ODBCARD* pODBCARD; // ARD as pointer // IMPL ROW DESC ITEM - to hold info about one IRD item // ---------------------------------------------------------------------------------- -typedef SelectedColumnMeta IRDItem; // IRD data type -typedef SelectedColumnMeta* pIRDItem; // IRD as pointer type +typedef SelectedColumnMeta IRDItem; // IRD data type +typedef SelectedColumnMeta* pIRDItem; // IRD as pointer type // ---------------------------------------------------------------------------------- // IMPL ROW DESC - to hold response col description from server // ---------------------------------------------------------------------------------- -struct ODBCIRD { +struct ODBCIRD +{ + Word Sign; - Word Sign; - // header fields - UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR - Word DescCount; // SQL_DESC_COUNT - ULong* RowsProcessedPtr; // SQL_DESC_ROWS_PROCESSED_PTR, it is changed in _SQL_FETCH - + UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR + Word DescCount; // SQL_DESC_COUNT + ULong* RowsProcessedPtr; // SQL_DESC_ROWS_PROCESSED_PTR, it is changed in _SQL_FETCH + // rows for binding each col - std::unique_ptr<SQLResponse> RowDesc; // Row descriptor - + std::unique_ptr <SQLResponse> RowDesc; // Row descriptor + // container - pODBCStmt Stmt; // container statememt + pODBCStmt Stmt; // container statememt }; -typedef struct ODBCIRD* pODBCIRD; // IRD as pointer type - +typedef struct ODBCIRD* pODBCIRD; // IRD as pointer type // APD @@ -258,57 +261,57 @@ typedef struct ODBCIRD* pODBCIRD; // IRD as pointer type // APPL PARM DESC ITEM - to hold appl specified buffers & other details for one param // ---------------------------------------------------------------------------------- -struct APDItem { - - Word ParamNum; // parameter number - - Word DataConciseType; // data type - Word DataVerboseType; // basic data type - Word DateTimeIntervalCode; // date-time interval code ???? - Long DateTimeIntervalPrec; // date-time precision ???? - Long NumPrecRadix; // 2 if approx num type or 10 exact num type - Word Scale; // scale, right of decimal - - void* DataPtr; // param data - Long DataSize; // size of data - Long* SizePtr; // size of data buffer - Long* SizeIndPtr; // size indicator ptr - - struct APDItem* Next; // next parm binding - struct APDItem* Prev; // prev parm binding +struct APDItem +{ + Word ParamNum; // parameter number + + Word DataConciseType; // data type + Word DataVerboseType; // basic data type + Word DateTimeIntervalCode; // date-time interval code ???? + Long DateTimeIntervalPrec; // date-time precision ???? + Long NumPrecRadix; // 2 if approx num type or 10 exact num type + Word Scale; // scale, right of decimal + + void* DataPtr; // param data + Long DataSize; // size of data + Long* SizePtr; // size of data buffer + Long* SizeIndPtr; // size indicator ptr + + struct APDItem* Next; // next parm binding + struct APDItem* Prev; // prev parm binding }; -typedef struct APDItem* pAPDItem; // APD-Param as pointer type +typedef struct APDItem* pAPDItem; // APD-Param as pointer type // ---------------------------------------------------------------------------------- // APPL PARAM DESC - to hold appl specified buffers & other details for params // ---------------------------------------------------------------------------------- -struct ODBCAPD { +struct ODBCAPD +{ + Word Sign; - Word Sign; - // header fields - Word AllocType; // SQL_DESC_ALLOC_TYPE - ULong RowArraySize; // SQL_DESC_ARRAY_SIZE - UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR - Long* BindOffsetPtr; // SQL_DESC_BIND_OFFSET_PTR - Long BindTypeOrSize; // SQL_DESC_BIND_TYPE - Word DescCount; // SQL_DESC_COUNT - - ULong ParamSetSize; - Long* ParamProcessedPtr; - + Word AllocType; // SQL_DESC_ALLOC_TYPE + ULong RowArraySize; // SQL_DESC_ARRAY_SIZE + UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR + Long* BindOffsetPtr; // SQL_DESC_BIND_OFFSET_PTR + Long BindTypeOrSize; // SQL_DESC_BIND_TYPE + Word DescCount; // SQL_DESC_COUNT + + ULong ParamSetSize; + Long* ParamProcessedPtr; + // rows for binding each col - pAPDItem BindParams; // param bindings - + pAPDItem BindParams; // param bindings + // container - pODBCStmt Stmt; // container statememt + pODBCStmt Stmt; // container statememt }; -typedef struct ODBCAPD* pODBCAPD; // APD as pointer type +typedef struct ODBCAPD* pODBCAPD; // APD as pointer type // IPD @@ -317,55 +320,55 @@ typedef struct ODBCAPD* pODBCAPD; // APD as pointer // IMPL PARM DESC ITEM - to hold impl buffers & other details for one param // ---------------------------------------------------------------------------------- -struct IPDItem { - - Word ParamNum; // parameter number - Word ParamType; // parameter type input/output - Char ParamName[33]; // param name - arbitray/dummy - - Word DataConciseType; // data type - Word DataVerboseType; // basic data type - Word DateTimeIntervalCode; // date-time interval code ???? - Long DateTimeIntervalPrec; // date-time precision ???? - Long NumPrecRadix; // 2 if approx num type or 10 exact num type - Word Scale; // scale, right of decimal - - void* DataPtr; // param data - Long DataSize; // size of data buffer - Word FixedPrecScale; // fixed precision scale - Word Nullable; // is it nullable - - - struct IPDItem* Next; // next parm binding - struct IPDItem* Prev; // prev parm binding +struct IPDItem +{ + Word ParamNum; // parameter number + Word ParamType; // parameter type input/output + Char ParamName[33]; // param name - arbitray/dummy + + Word DataConciseType; // data type + Word DataVerboseType; // basic data type + Word DateTimeIntervalCode; // date-time interval code ???? + Long DateTimeIntervalPrec; // date-time precision ???? + Long NumPrecRadix; // 2 if approx num type or 10 exact num type + Word Scale; // scale, right of decimal + + void* DataPtr; // param data + Long DataSize; // size of data buffer + Word FixedPrecScale; // fixed precision scale + Word Nullable; // is it nullable + + + struct IPDItem* Next; // next parm binding + struct IPDItem* Prev; // prev parm binding }; -typedef struct IPDItem* pIPDItem; // IPD-Param as pointer type +typedef struct IPDItem* pIPDItem; // IPD-Param as pointer type // ---------------------------------------------------------------------------------- // IMPL PARAM DESC - to hold impl buffers & other details for params // ---------------------------------------------------------------------------------- -struct ODBCIPD { +struct ODBCIPD +{ + Word Sign; - Word Sign; - // header fields // Word AllocType; (read-only) // SQL_DESC_ALLOC_TYPE - UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR - Word DescCount; // SQL_DESC_COUNT - ULong* RowsProcessedPtr; // SQL_DESC_ROWS_PROCESSED_PTR - + UWord* ArrayStatusPtr; // SQL_DESC_ARRAY_STATUS_PTR + Word DescCount; // SQL_DESC_COUNT + ULong* RowsProcessedPtr; // SQL_DESC_ROWS_PROCESSED_PTR + // rows for binding each col - pIPDItem BindParams; // param bindings - + pIPDItem BindParams; // param bindings + // container - pODBCStmt Stmt; // container statememt + pODBCStmt Stmt; // container statememt }; -typedef struct ODBCIPD* pODBCIPD; // IPD as pointer type +typedef struct ODBCIPD* pODBCIPD; // IPD as pointer type // STATEMENT @@ -374,53 +377,53 @@ typedef struct ODBCIPD* pODBCIPD; // IPD as pointer // STATEMENT - a single sql stmt scoped within a CONNECTION and part of link list // ---------------------------------------------------------------------------------- -struct ODBCStmt { +struct ODBCStmt +{ + Word Sign; // structure signature - Word Sign; // structure signature - // Attributes - ULong AsyncEnable; - ULong Concurrency; - ULong CursorScroll; - ULong CursorSensitivity; - ULong CursorType; - ULong AutoIPD; - ULong KeysetSize; - ULong MetaDataID; - ULong NoScan; - ULong QryTimeout; - ULong RetrieveData; - - wchar_t* Stmt; // SQL statement - Long StmtLen; // length of statement - bool Prepared; // is it prepared - + ULong AsyncEnable; + ULong Concurrency; + ULong CursorScroll; + ULong CursorSensitivity; + ULong CursorType; + ULong AutoIPD; + ULong KeysetSize; + ULong MetaDataID; + ULong NoScan; + ULong QryTimeout; + ULong RetrieveData; + + wchar_t* Stmt; // SQL statement + Long StmtLen; // length of statement + bool Prepared; // is it prepared + // RESPONSE Word - RespType; // Response type, like fault, result-set, count etc etc - SQLRowContent* CurRowsetStartRow; // start of current rowset - Long CurRowsetStartRowPos; // absolute position - SQLRowContent* CurRowsetEndRow; // end of current rowset - Long CurRowsetEndRowPos; // absolute position - Long RowCount; // total number of rows - + RespType; // Response type, like fault, result-set, count etc etc + SQLRowContent* CurRowsetStartRow; // start of current rowset + Long CurRowsetStartRowPos; // absolute position + SQLRowContent* CurRowsetEndRow; // end of current rowset + Long CurRowsetEndRowPos; // absolute position + Long RowCount; // total number of rows + // DESCRIPTORS - ODBCARD ARD; // application row descriptor - ODBCIRD IRD; // implementation row descriptor - - ODBCAPD APD; // application parm descriptor - ODBCIPD IPD; // implementation parm descriptor - + ODBCARD ARD; // application row descriptor + ODBCIRD IRD; // implementation row descriptor + + ODBCAPD APD; // application parm descriptor + ODBCIPD IPD; // implementation parm descriptor + // DIAG & LINKS - ODBCDiag Diag; // diagnostic details - - pODBCConn Conn; // container connection - + ODBCDiag Diag; // diagnostic details + + pODBCConn Conn; // container connection + // other stmt attributes // state of stmt if required separately - - struct ODBCStmt* Next; // next statement - struct ODBCStmt* Prev; // prev statement + + struct ODBCStmt* Next; // next statement + struct ODBCStmt* Prev; // prev statement }; @@ -430,40 +433,40 @@ struct ODBCStmt { // CONNECTION - a single connection to server scoped within environment & part of link-list // ---------------------------------------------------------------------------------- -struct ODBCConn { +struct ODBCConn +{ + Word Sign; // structure signature - Word Sign; // structure signature - // Attributes - ULong AccessMode; - ULong AutoIPD; - ULong AsyncEnable; - ULong AutoCommit; - ULong TimeOut; - ULong LoginTimeOut; - ULong MetaDataID; - ULong ODBCCursors; - ULong Window; - ULong TxnIsolation; - ULong MaxRows; - ULong QueryTimeout; - - StrPtr ConnectStr; // connection string, the full connection string - StrPtr Server; // server name/address - ULong ServerPort; // server port - StrPtr Project; // name of database - StrPtr UserName; // user name - StrPtr Password; // password - - bool IsConnected; // connection checked - pODBCStmt Stmts; // all stmts within connection - ODBCDiag Diag; // diagnostic details - pODBCEnv Env; // environment - - struct ODBCConn* Next; // next connection - struct ODBCConn* Prev; // prev connection - - std::unique_ptr<MetadataResponse> meta; // ACTUAL metadata returned from REST Server + ULong AccessMode; + ULong AutoIPD; + ULong AsyncEnable; + ULong AutoCommit; + ULong TimeOut; + ULong LoginTimeOut; + ULong MetaDataID; + ULong ODBCCursors; + ULong Window; + ULong TxnIsolation; + ULong MaxRows; + ULong QueryTimeout; + + StrPtr ConnectStr; // connection string, the full connection string + StrPtr Server; // server name/address + ULong ServerPort; // server port + StrPtr Project; // name of database + StrPtr UserName; // user name + StrPtr Password; // password + + bool IsConnected; // connection checked + pODBCStmt Stmts; // all stmts within connection + ODBCDiag Diag; // diagnostic details + pODBCEnv Env; // environment + + struct ODBCConn* Next; // next connection + struct ODBCConn* Prev; // prev connection + + std::unique_ptr <MetadataResponse> meta; // ACTUAL metadata returned from REST Server }; @@ -473,34 +476,35 @@ struct ODBCConn { // ENVIRONMENT - maximum window for an application into the ODBC driver // ---------------------------------------------------------------------------------- -struct ODBCEnv { - - Word Sign; // structure signature - - pODBCConn Conns; // all connections within env - - ODBCDiag Diag; // diagnostic messages - - ULong AttrODBCVersion; // SQL_ATTR_ODBC_VERSION 200 - ULong AttrConnPooling; // SQL_ATTR_CONNECTION_POOLING 201 - ULong AttrCPMatch; // SQL_ATTR_CP_MATCH 202 - ULong AttrOutputNTS; // SQL_ATTR_OUTPUT_NTS +struct ODBCEnv +{ + Word Sign; // structure signature + + pODBCConn Conns; // all connections within env + + ODBCDiag Diag; // diagnostic messages + + ULong AttrODBCVersion; // SQL_ATTR_ODBC_VERSION 200 + ULong AttrConnPooling; // SQL_ATTR_CONNECTION_POOLING 201 + ULong AttrCPMatch; // SQL_ATTR_CP_MATCH 202 + ULong AttrOutputNTS; // SQL_ATTR_OUTPUT_NTS }; // ---------------------------------------------------------------------------------- // Key-value pair - to hold a single key-value pair // ---------------------------------------------------------------------------------- -struct ODBCKV { - StrPtr key; - StrPtr value; +struct ODBCKV +{ + StrPtr key; + StrPtr value; }; // ------------------------- other global variables --------------------------- -extern HINSTANCE ghInstDLL; +extern HINSTANCE ghInstDLL; -extern Long gLogFile; -extern Word gLogUsage; +extern Long gLogFile; +extern Word gLogUsage; // -------------------------------- defines ----------------------------------- #define DEFAULT_PORT 443 @@ -545,118 +549,126 @@ extern Word gLogUsage; } // ---------------------------- diag functions -------------------------------- -pODBCDiagRow _SQLPutDiagRow ( pODBCDiag pDiag, StrPtr pFunc, StrPtr pState, Long pNativeErrorCode, - StrPtr pMsgArgs, va_list pArgs ); -eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState, - Long pNativeErrorCode, StrPtr pMsgArgs, ... ); -eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState, - Long pNativeErrorCode, Long pRow, Long pCol, StrPtr pMsgArgs, ... ); -eGoodBad _SQLFreeDiag ( pODBCDiag pHandle ); -pODBCDiagRow _SQLGetDiagRow ( pODBCDiag pHandle, Word pRowNum ); +pODBCDiagRow _SQLPutDiagRow ( pODBCDiag pDiag, StrPtr pFunc, StrPtr pState, Long pNativeErrorCode, + StrPtr pMsgArgs, va_list pArgs ); +eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState, + Long pNativeErrorCode, StrPtr pMsgArgs, ... ); +eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState, + Long pNativeErrorCode, Long pRow, Long pCol, StrPtr pMsgArgs, ... ); +eGoodBad _SQLFreeDiag ( pODBCDiag pHandle ); +pODBCDiagRow _SQLGetDiagRow ( pODBCDiag pHandle, Word pRowNum ); // -------------------------------- debug functions --------------------------- -enum LogLevel {LogLevel_DEBUG, LogLevel_INFO, LogLevel_WARN, LogLevel_ERROR, LogLevel_FATAL}; +enum LogLevel +{ + LogLevel_DEBUG, + LogLevel_INFO, + LogLevel_WARN, + LogLevel_ERROR, + LogLevel_FATAL +}; -void _ODBCLogStart ( void ); -void _ODBCLogStop ( int pForce ); -void _ODBCLogMsg ( LogLevel level, const char* s, ... ); -void _ODBCLogMsg ( LogLevel level, const wchar_t* textW ); -void _ODBCPopMsg ( const char* s, ... ); -void __ODBCPopMsg ( const char* s, ... ); +void _ODBCLogStart ( void ); +void _ODBCLogStop ( int pForce ); +void _ODBCLogMsg ( LogLevel level, const char* s, ... ); +void _ODBCLogMsg ( LogLevel level, const wchar_t* textW ); +void _ODBCPopMsg ( const char* s, ... ); +void __ODBCPopMsg ( const char* s, ... ); // ------------------------------ data type functions ------------------------- -Word _SQLColDataType ( CStrPtr* pDataType ); -eGoodBad _SQLCheckDataType ( Word pDataType ); -eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode ); -eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* pVerboseDataType, - Word* pConciseDataType, Word* pDateTimeIntervalCode ); +Word _SQLColDataType ( CStrPtr* pDataType ); +eGoodBad _SQLCheckDataType ( Word pDataType ); +eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode ); +eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* pVerboseDataType, + Word* pConciseDataType, Word* pDateTimeIntervalCode ); // ---------------------------- descriptor functions -------------------------- -pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum ); -pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum ); -pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum ); -pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum ); - -eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt ); -eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum ); - -eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt ); -eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem ); - -eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt ); -eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem ); - -eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt ); -eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem ); - -RETCODE SQL_API _SQLSetARDField ( pODBCARD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLSetARDItemField ( pODBCARD pDesc, pARDItem pDescItem, Word pRecNum, Word pFldID, - const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLGetARDField ( const pODBCARD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, - Long* pDataSizePtr ); -RETCODE SQL_API _SQLGetARDItemField ( const pODBCARD pDesc, const pARDItem pDescItem, Word pRecNum, - Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); - -RETCODE SQL_API _SQLSetAPDField ( pODBCAPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLSetAPDItemField ( pODBCAPD pDesc, pAPDItem pDescItem, Word pRecNum, Word pFldID, - const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLGetAPDField ( const pODBCAPD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, - Long* pDataSizePtr ); -RETCODE SQL_API _SQLGetAPDItemField ( const pODBCAPD pDesc, const pAPDItem pDescItem, Word pRecNum, - Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); - -RETCODE SQL_API _SQLSetIRDField ( pODBCIRD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLSetIRDItemField ( pODBCIRD pDesc, pIRDItem pDescItem, Word pRecNum, Word pFldID, - const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLGetIRDField ( const pODBCIRD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, - Long* pDataSizePtr ); -RETCODE SQL_API _SQLGetIRDItemField ( const pODBCIRD pDesc, const pIRDItem pDescItem, Word pRecNum, - Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr , bool isANSI ); - -RETCODE SQL_API _SQLSetIPDField ( pODBCIPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLSetIPDItemField ( pODBCIPD pDesc, pIPDItem pDescItem, Word pRecNum, Word pFldID, - const void* pDataPtr, Long pDataSize ); -RETCODE SQL_API _SQLGetIPDField ( const pODBCIPD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, - Long* pDataSizePtr ); -RETCODE SQL_API _SQLGetIPDItemField ( const pODBCIPD pDesc, const pIPDItem pDescItem, Word pRecNum, - Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); - -RETCODE SQL_API _SQLFreeARDContent ( const pODBCARD pDesc ); -RETCODE SQL_API _SQLFreeAPDContent ( const pODBCAPD pDesc ); -RETCODE SQL_API _SQLFreeIRDContent ( const pODBCIRD pDesc ); -RETCODE SQL_API _SQLFreeIPDContent ( const pODBCIPD pDesc ); - -eGoodBad _SQLAttachARDItem ( pODBCARD pDesc, pARDItem pDescItem ); -eGoodBad _SQLDetachARDItem ( pODBCARD pDesc, pARDItem pDescItem ); - -eGoodBad GetIRDDataTypeDefaults ( CStrPtr pDataType, Word* pSqlDataType, Word* pNativeDataType, - Word* pPrecision, Word* pScale, Long* pLength, Long* pRadix ); -eGoodBad GetIRDColDescInfo ( SelectedColumnMeta* pColDesc, Word* pDataType, Word* pPrecision, Word* pScale, - Long* pLength ); +pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum ); +pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum ); +pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum ); +pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum ); + +eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt ); +eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum ); + +eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt ); +eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem ); + +eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt ); +eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem ); + +eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt ); +eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem ); + +RETCODE SQL_API _SQLSetARDField ( pODBCARD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLSetARDItemField ( pODBCARD pDesc, pARDItem pDescItem, Word pRecNum, Word pFldID, + const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLGetARDField ( const pODBCARD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, + Long* pDataSizePtr ); +RETCODE SQL_API _SQLGetARDItemField ( const pODBCARD pDesc, const pARDItem pDescItem, Word pRecNum, + Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); + +RETCODE SQL_API _SQLSetAPDField ( pODBCAPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLSetAPDItemField ( pODBCAPD pDesc, pAPDItem pDescItem, Word pRecNum, Word pFldID, + const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLGetAPDField ( const pODBCAPD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, + Long* pDataSizePtr ); +RETCODE SQL_API _SQLGetAPDItemField ( const pODBCAPD pDesc, const pAPDItem pDescItem, Word pRecNum, + Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); + +RETCODE SQL_API _SQLSetIRDField ( pODBCIRD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLSetIRDItemField ( pODBCIRD pDesc, pIRDItem pDescItem, Word pRecNum, Word pFldID, + const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLGetIRDField ( const pODBCIRD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, + Long* pDataSizePtr ); +RETCODE SQL_API _SQLGetIRDItemField ( const pODBCIRD pDesc, const pIRDItem pDescItem, Word pRecNum, + Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr, bool isANSI ); + +RETCODE SQL_API _SQLSetIPDField ( pODBCIPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLSetIPDItemField ( pODBCIPD pDesc, pIPDItem pDescItem, Word pRecNum, Word pFldID, + const void* pDataPtr, Long pDataSize ); +RETCODE SQL_API _SQLGetIPDField ( const pODBCIPD pDesc, Word pFldID, void* pDataPtr, Long pDataSize, + Long* pDataSizePtr ); +RETCODE SQL_API _SQLGetIPDItemField ( const pODBCIPD pDesc, const pIPDItem pDescItem, Word pRecNum, + Word pFldID, void* pDataPtr, Long pDataSize, Long* pDataSizePtr ); + +RETCODE SQL_API _SQLFreeARDContent ( const pODBCARD pDesc ); +RETCODE SQL_API _SQLFreeAPDContent ( const pODBCAPD pDesc ); +RETCODE SQL_API _SQLFreeIRDContent ( const pODBCIRD pDesc ); +RETCODE SQL_API _SQLFreeIPDContent ( const pODBCIPD pDesc ); + +eGoodBad _SQLAttachARDItem ( pODBCARD pDesc, pARDItem pDescItem ); +eGoodBad _SQLDetachARDItem ( pODBCARD pDesc, pARDItem pDescItem ); + +eGoodBad GetIRDDataTypeDefaults ( CStrPtr pDataType, Word* pSqlDataType, Word* pNativeDataType, + Word* pPrecision, Word* pScale, Long* pLength, Long* pRadix ); +eGoodBad GetIRDColDescInfo ( SelectedColumnMeta* pColDesc, Word* pDataType, Word* pPrecision, Word* pScale, + Long* pLength ); // ------------------------- execution function ------------------------------- -RETCODE SQL_API _SQLExecStmtFromReq ( pODBCStmt pStmt, bool pPrepared ); -eGoodBad PutRespToStmt ( pODBCStmt pStmt, std::unique_ptr<SQLResponse> resp ); +RETCODE SQL_API _SQLExecStmtFromReq ( pODBCStmt pStmt, bool pPrepared ); +eGoodBad PutRespToStmt ( pODBCStmt pStmt, std::unique_ptr <SQLResponse> resp ); // -------------------------- utility functions ------------------------------- -RETCODE SQL_API _SQLCopyCharData ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize ); -RETCODE SQL_API _SQLCopyWCharData ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize, bool returnByteSize = true ); -RETCODE SQL_API _SQLCopyWCharDataW ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, - Word pSizePtrSize, const wchar_t* pSrcData, Long pSrcDataSize, bool returnByteSize = true ); -Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, - Word pSrcDataType, Long* pTgtDataSizePtr ); -Word _SQLCopyDateTimeData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, - Word pSrcDataType ); +RETCODE SQL_API _SQLCopyCharData ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, + Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize ); +RETCODE SQL_API _SQLCopyWCharData ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, + Word pSizePtrSize, CStrPtr pSrcData, Long pSrcDataSize, bool returnByteSize = true ); +RETCODE SQL_API _SQLCopyWCharDataW ( pODBCDiag pDiag, void* pDataPtr, Long pDataBufSize, void* pSizePtr, + Word pSizePtrSize, const wchar_t* pSrcData, Long pSrcDataSize, bool returnByteSize = true ); +Word _SQLCopyNumData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, + Word pSrcDataType, Long* pTgtDataSizePtr ); +Word _SQLCopyDateTimeData ( pODBCDiag pDiag, void* pTgtDataPtr, Word pTgtDataType, CStrPtr pSrcData, + Word pSrcDataType ); // -------------------------- DSN config functions ------------------------------- -eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ); -eGoodBad LoadODBCINIDataToConn ( pODBCConn pConn ); -eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV ); -RETCODE TryFetchMetadata ( pODBCConn pConn ); -RETCODE TryAuthenticate ( pODBCConn pConn ); -void SetCurrentDSN ( char* connStr, char* logFunc ); -bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition ); -void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ); +eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ); +eGoodBad LoadODBCINIDataToConn ( pODBCConn pConn ); +eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV ); +RETCODE TryFetchMetadata ( pODBCConn pConn ); +RETCODE TryAuthenticate ( pODBCConn pConn ); +void SetCurrentDSN ( char* connStr, char* logFunc ); +bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition ); +void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ); RETCODE SQL_API _SQLDisconnect ( pODBCConn pHandle ); + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/resource.h ---------------------------------------------------------------------- diff --git a/odbc/Driver/resource.h b/odbc/Driver/resource.h index fa30988..08502ae 100644 --- a/odbc/Driver/resource.h +++ b/odbc/Driver/resource.h @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by GODBC.RC @@ -50,3 +50,4 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/stdafx.cpp ---------------------------------------------------------------------- diff --git a/odbc/Driver/stdafx.cpp b/odbc/Driver/stdafx.cpp index 9d73fe5..b6fb3ed 100644 --- a/odbc/Driver/stdafx.cpp +++ b/odbc/Driver/stdafx.cpp @@ -15,5 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -#include "stdafx.h" \ No newline at end of file + +#include "stdafx.h" + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/stdafx.h ---------------------------------------------------------------------- diff --git a/odbc/Driver/stdafx.h b/odbc/Driver/stdafx.h index 79c6597..2d57b5a 100644 --- a/odbc/Driver/stdafx.h +++ b/odbc/Driver/stdafx.h @@ -15,7 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + #pragma message("Compiling precompiled headers. \n") -#include "KylinODBC.h" \ No newline at end of file +#include "KylinODBC.h" + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/ColorPrint.cpp ---------------------------------------------------------------------- diff --git a/odbc/TestDLL/ColorPrint.cpp b/odbc/TestDLL/ColorPrint.cpp index ceb245b..c8df752 100644 --- a/odbc/TestDLL/ColorPrint.cpp +++ b/odbc/TestDLL/ColorPrint.cpp @@ -25,38 +25,47 @@ CONSOLE_SCREEN_BUFFER_INFO consoleInfo; WORD saved_attributes; bool init = false; -void initLocals ( HANDLE hConsole ) { +void initLocals ( HANDLE hConsole ) +{ /* Save current attributes */ GetConsoleScreenBufferInfo ( hConsole, &consoleInfo ); - saved_attributes = consoleInfo.wAttributes; + saved_attributes = consoleInfo . wAttributes; init = true; } -void setPrintColorRED() { +void setPrintColorRED () +{ HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE ); - - if ( !init ) { + + if ( !init ) + { initLocals ( hConsole ); } - + SetConsoleTextAttribute ( hConsole, FOREGROUND_RED ); } -void setPrintColorGreen() { +void setPrintColorGreen () +{ HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE ); - - if ( !init ) { + + if ( !init ) + { initLocals ( hConsole ); } - + SetConsoleTextAttribute ( hConsole, FOREGROUND_GREEN ); } -void resetPrintColor() { +void resetPrintColor () +{ if ( !init ) - { throw - 1; } - + { + throw - 1; + } + HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE ); /* Restore original attributes */ SetConsoleTextAttribute ( hConsole, saved_attributes ); -} \ No newline at end of file +} + http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/ColorPrint.h ---------------------------------------------------------------------- diff --git a/odbc/TestDLL/ColorPrint.h b/odbc/TestDLL/ColorPrint.h index 7ad5710..9724bf5 100644 --- a/odbc/TestDLL/ColorPrint.h +++ b/odbc/TestDLL/ColorPrint.h @@ -18,6 +18,7 @@ #pragma once -void setPrintColorRED(); -void setPrintColorGreen(); -void resetPrintColor(); +void setPrintColorRED (); +void setPrintColorGreen (); +void resetPrintColor (); +