You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/02/01 10:45:20 UTC
[01/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Repository: kylin
Updated Branches:
refs/heads/2.x-staging 9b19b69f1 -> 3c2329dc1
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/CompareQueryTests.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/CompareQueryTests.cpp b/odbc/TestDLL/CompareQueryTests.cpp
index c7788a2..87d6875 100644
--- a/odbc/TestDLL/CompareQueryTests.cpp
+++ b/odbc/TestDLL/CompareQueryTests.cpp
@@ -41,37 +41,39 @@
}
// ---------------------------------- structure -------------------------------
-typedef struct BindColInfo {
- SQLSMALLINT iColTitleSize; // size of column title
- wchar_t* szColTitle; // column title
- SQLLEN iColDisplaySize; // size to display
- void* szColData; // display buffer
- int iType;
- bool isSigned;
- SQLLEN indPtr; // size or null indicator
- BOOL fChar; // character col flag
- struct BindColInfo* next; // linked list
+typedef struct BindColInfo
+{
+ SQLSMALLINT iColTitleSize; // size of column title
+ wchar_t* szColTitle; // column title
+ SQLLEN iColDisplaySize; // size to display
+ void* szColData; // display buffer
+ int iType;
+ bool isSigned;
+ SQLLEN indPtr; // size or null indicator
+ BOOL fChar; // character col flag
+ struct BindColInfo* next; // linked list
} BIND_COL_INFO;
// -------------------------- function prototypes -----------------------------
-void ShowDiagMessages ( SQLSMALLINT hType, SQLHANDLE hValue, SQLRETURN iStatus, char* szMsg );
+void ShowDiagMessages ( SQLSMALLINT hType, SQLHANDLE hValue, SQLRETURN iStatus, char* szMsg );
-SQLRETURN CheckResults ( HSTMT hStmt , wchar_t* sql );
-void FreeBindings ( BIND_COL_INFO* pBindColInfo );
+SQLRETURN CheckResults ( HSTMT hStmt, wchar_t* sql );
+void FreeBindings ( BIND_COL_INFO* pBindColInfo );
int totalCount;
int successCount;
int failCount;
-std::vector<wstring> failedQueries;
+std::vector <wstring> failedQueries;
-void validateOneQuery ( wchar_t* sql ) {
+void validateOneQuery ( wchar_t* sql )
+{
Sleep ( 1000 );
- SQLRETURN status;
- SQLHANDLE hEnv = 0;
- SQLHANDLE hConn = 0;
- SQLHANDLE hStmt = 0;
+ SQLRETURN status;
+ SQLHANDLE hEnv = 0;
+ SQLHANDLE hConn = 0;
+ SQLHANDLE hStmt = 0;
wchar_t szConnStrOut[1024];
- SQLSMALLINT x;
+ SQLSMALLINT x;
// show query to be executed
wprintf ( L"The query being validated: %ls \n", sql );
// BEFORE U CONNECT
@@ -80,27 +82,27 @@ void validateOneQuery ( wchar_t* sql ) {
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
// set the ODBC version for behaviour expected
- status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
+ status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
// allocate CONNECTION
status = SQLAllocHandle ( SQL_HANDLE_DBC, hEnv, &hConn );
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
- #ifdef _WIN64
+#ifdef _WIN64
// ----------- real connection takes place at this point
// ----------- option 1: user is prompted for DSN & options
status = SQLDriverConnect ( hConn, GetDesktopWindow(),
( unsigned char* ) "",
SQL_NTS, szConnStrOut, 1024, &x,
SQL_DRIVER_COMPLETE );
- #else
- status = SQLDriverConnectW ( hConn , GetDesktopWindow(),
+#else
+ status = SQLDriverConnectW ( hConn, GetDesktopWindow (),
//L"DSN=testDSN;",
L"DRIVER={KylinODBCDriver};PROJECT=default;UID=ADMIN;SERVER=http://localhost;PORT=80;",
SQL_NTS, szConnStrOut, 1024, &x,
SQL_DRIVER_COMPLETE );
- #endif
+#endif
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_DBC, hConn, status, "" );
// CONGRATUALTIONS ---- u r connected to a DBMS via an ODBC driver
@@ -117,199 +119,245 @@ void validateOneQuery ( wchar_t* sql ) {
// show the full results row by row
status = CheckResults ( hStmt, sql );
totalCount++;
-
- if ( status == SQL_ERROR ) {
- setPrintColorRED();
+
+ if ( status == SQL_ERROR )
+ {
+ setPrintColorRED ();
fputs ( "[FAIL]\n", stdout );
- resetPrintColor();
+ resetPrintColor ();
failCount++;
- failedQueries.push_back ( sql );
+ failedQueries . push_back ( sql );
}
-
- else if ( status == SQL_SUCCESS ) {
- setPrintColorGreen();
+
+ else if ( status == SQL_SUCCESS )
+ {
+ setPrintColorGreen ();
fputs ( "[SUCCESS]\n", stdout );
- resetPrintColor();
+ resetPrintColor ();
successCount++;
}
-
+
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_STMT, hStmt, status, "" );
Cleanup:
if ( hStmt )
- { SQLFreeHandle ( SQL_HANDLE_STMT, hStmt ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_STMT, hStmt );
+ }
+
if ( hConn )
- { SQLFreeHandle ( SQL_HANDLE_DBC, hConn ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_DBC, hConn );
+ }
+
if ( hEnv )
- { SQLFreeHandle ( SQL_HANDLE_ENV, hEnv ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_ENV, hEnv );
+ }
+
return;
}
-void validateQueries ( char* file ) {
+void validateQueries ( char* file )
+{
std::string line;
std::ifstream infile ( file );
-
- while ( std::getline ( infile, line ) ) {
- if ( line.size() < 5 )
- { continue; }
-
- unique_ptr<wchar_t[]> p ( char2wchar ( line.c_str() ) );
- validateOneQuery ( p.get() );
+
+ while ( std::getline ( infile, line ) )
+ {
+ if ( line . size () < 5 )
+ {
+ continue;
+ }
+
+ unique_ptr <wchar_t[]> p ( char2wchar ( line . c_str () ) );
+ validateOneQuery ( p . get () );
}
-
- infile.close();
+
+ infile . close ();
}
-bool isValueConsistent ( void* data, wstring& valueJ, int pSrcDataType, bool isSigned ) {
- fwprintf ( stdout, L"The value from the JDBC is : %s \n", valueJ.c_str() );
-
- switch ( pSrcDataType ) {
- case SQL_BIT: {
- wstring tempW;
-
- if ( * ( char* ) data == 0 )
- { tempW = L"false"; }
-
- else if ( * ( char* ) data == 1 )
- { tempW = L"true"; }
-
- else
- { return false; }
-
- return tempW.compare ( valueJ ) == 0;
+bool isValueConsistent ( void* data, wstring& valueJ, int pSrcDataType, bool isSigned )
+{
+ fwprintf ( stdout, L"The value from the JDBC is : %s \n", valueJ . c_str () );
+
+ switch ( pSrcDataType )
+ {
+ case SQL_BIT :
+ {
+ wstring tempW;
+
+ if ( * ( char* ) data == 0 )
+ {
+ tempW = L"false";
}
-
- case SQL_CHAR:
- case SQL_VARCHAR: {
- string temp ( ( char* ) data );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+
+ else if ( * ( char* ) data == 1 )
+ {
+ tempW = L"true";
}
-
- case SQL_WCHAR:
- case SQL_WVARCHAR: {
- wstring tempW ( ( wchar_t* ) data );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+
+ else
+ {
+ return false;
}
-
- case SQL_DECIMAL: {
- string temp ( ( char* ) data );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_CHAR :
+ case SQL_VARCHAR :
+ {
+ string temp ( ( char* ) data );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_WCHAR :
+ case SQL_WVARCHAR :
+ {
+ wstring tempW ( ( wchar_t* ) data );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_DECIMAL :
+ {
+ string temp ( ( char* ) data );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_TINYINT :
+ {
+ int v = 0;
+
+ if ( isSigned )
+ {
+ v = * ( char* ) data;
}
-
- case SQL_TINYINT: {
- int v = 0;
-
- if ( isSigned )
- { v = * ( char* ) data; }
-
- else
- { v = * ( unsigned char* ) data; }
-
- char buffer[100];
- _itoa ( v, buffer, 10 );
- string temp ( buffer );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+
+ else
+ {
+ v = * ( unsigned char* ) data;
}
-
- case SQL_SMALLINT: {
- int v = 0;
-
- if ( isSigned )
- { v = * ( short* ) data; }
-
- else
- { v = * ( unsigned short* ) data; }
-
- char buffer[100];
- _itoa ( v, buffer, 10 );
- string temp ( buffer );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+
+ char buffer[100];
+ _itoa ( v, buffer, 10 );
+ string temp ( buffer );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_SMALLINT :
+ {
+ int v = 0;
+
+ if ( isSigned )
+ {
+ v = * ( short* ) data;
+ }
+
+ else
+ {
+ v = * ( unsigned short* ) data;
}
-
- case SQL_INTEGER: {
+
+ char buffer[100];
+ _itoa ( v, buffer, 10 );
+ string temp ( buffer );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_INTEGER :
+ {
+ __int64 v = 0;
+
+ if ( isSigned )
+ {
+ v = * ( int* ) data;
+ }
+
+ else
+ {
+ v = * ( unsigned int* ) data;
+ }
+
+ char buffer[100];
+ _i64toa ( v, buffer, 10 );
+ string temp ( buffer );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_BIGINT :
+ {
+ if ( isSigned )
+ {
__int64 v = 0;
-
- if ( isSigned )
- { v = * ( int* ) data; }
-
- else
- { v = * ( unsigned int* ) data; }
-
+ v = * ( __int64* ) data;
char buffer[100];
_i64toa ( v, buffer, 10 );
string temp ( buffer );
wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
}
-
- case SQL_BIGINT: {
- if ( isSigned ) {
- __int64 v = 0;
- v = * ( __int64* ) data;
- char buffer[100];
- _i64toa ( v, buffer, 10 );
- string temp ( buffer );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
- }
-
- else {
- unsigned __int64 v = 0;
- v = * ( unsigned __int64* ) data;
- char buffer[100];
- _ui64toa ( v, buffer, 10 );
- string temp ( buffer );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
- }
- }
-
- case SQL_FLOAT: {
- float v = 0;
- v = * ( float* ) data;
- fwprintf ( stdout, L"The value from the ODBC is (float) : %9.9f \n", v );
- double x = ( v - _wtof ( valueJ.c_str() ) );
- return ( x > -0.0000001 ) && ( x < 0.0000001 ); // In Kylin float is treated like double, so it might be more accurate
- }
-
- case SQL_DOUBLE: {
- double v = * ( double* ) data;
- fwprintf ( stdout, L"The value from the ODBC is (double) : %9.9f\n ", v );
- return v == wcstod ( valueJ.c_str(), NULL );
- }
-
- case SQL_TYPE_DATE: {
- string temp ( ( char* ) data );
- wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
- }
-
- case SQL_TYPE_TIMESTAMP: {
- string temp ( ( char* ) data );
+
+ else
+ {
+ unsigned __int64 v = 0;
+ v = * ( unsigned __int64* ) data;
+ char buffer[100];
+ _ui64toa ( v, buffer, 10 );
+ string temp ( buffer );
wstring tempW = string2wstring ( temp );
- fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW.c_str() );
- return tempW.compare ( valueJ ) == 0;
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
}
-
- default:
+ }
+
+ case SQL_FLOAT :
+ {
+ float v = 0;
+ v = * ( float* ) data;
+ fwprintf ( stdout, L"The value from the ODBC is (float) : %9.9f \n", v );
+ double x = ( v - _wtof ( valueJ . c_str () ) );
+ return ( x > -0.0000001 ) && ( x < 0.0000001 ); // In Kylin float is treated like double, so it might be more accurate
+ }
+
+ case SQL_DOUBLE :
+ {
+ double v = * ( double* ) data;
+ fwprintf ( stdout, L"The value from the ODBC is (double) : %9.9f\n ", v );
+ return v == wcstod ( valueJ . c_str (), NULL );
+ }
+
+ case SQL_TYPE_DATE :
+ {
+ string temp ( ( char* ) data );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ case SQL_TYPE_TIMESTAMP :
+ {
+ string temp ( ( char* ) data );
+ wstring tempW = string2wstring ( temp );
+ fwprintf ( stdout, L"The value from the ODBC is : %s \n", tempW . c_str () );
+ return tempW . compare ( valueJ ) == 0;
+ }
+
+ default :
return false;
}
}
@@ -317,153 +365,180 @@ bool isValueConsistent ( void* data, wstring& valueJ, int pSrcDataType, bool isS
// ----------------------------------------------------------------------------
// to validate the full results row by row
// ----------------------------------------------------------------------------
-SQLRETURN CheckResults ( HSTMT hStmt , wchar_t* sql ) {
+SQLRETURN CheckResults ( HSTMT hStmt, wchar_t* sql )
+{
//First directly call REST to get a JDBC version result to compare against
- std::unique_ptr<SQLResponse> response = restQuery ( sql, "http://localhost", 80, "ADMIN", "KADMIN", "default" );
+ std::unique_ptr <SQLResponse> response = restQuery ( sql, "http://localhost", 80, "ADMIN", "KADMIN", "default" );
//Go with hStmt now
- int i, iCol;
- BIND_COL_INFO* head;
- BIND_COL_INFO* last;
- BIND_COL_INFO* curr;
- SQLRETURN status;
- SQLLEN cType;
- SQLSMALLINT iColCount;
+ int i, iCol;
+ BIND_COL_INFO* head;
+ BIND_COL_INFO* last;
+ BIND_COL_INFO* curr;
+ SQLRETURN status;
+ SQLLEN cType;
+ SQLSMALLINT iColCount;
// initializations
head = NULL;
-
+
// ALLOCATE SPACE TO FETCH A COMPLETE ROW
-
+
// get number of cols
if ( ( status = SQLNumResultCols ( hStmt, &iColCount ) ) != SQL_SUCCESS )
- { return status; }
-
+ {
+ return status;
+ }
+
// loop to allocate binding info structure
- for ( iCol = 1; iCol <= iColCount; iCol ++ ) {
+ for ( iCol = 1; iCol <= iColCount; iCol ++ )
+ {
// alloc binding structure
- curr = ( BIND_COL_INFO* ) calloc ( 1, sizeof ( BIND_COL_INFO ) );
-
- if ( curr == NULL ) {
+ curr = ( BIND_COL_INFO* ) calloc ( 1, sizeof ( BIND_COL_INFO) );
+
+ if ( curr == NULL )
+ {
fprintf ( stderr, "Out of memory!\n" );
- return SQL_ERROR; // its not an ODBC error so no diags r required
+ return SQL_ERROR; // its not an ODBC error so no diags r required
}
-
- memset ( curr, 0, sizeof ( BIND_COL_INFO ) );
-
+
+ memset ( curr, 0, sizeof ( BIND_COL_INFO) );
+
// maintain link list
if ( iCol == 1 )
- { head = curr; } // first col, therefore head of list
-
+ {
+ head = curr;
+ } // first col, therefore head of list
+
else
- { last->next = curr; } // attach
-
- last = curr; // tail
-
+ {
+ last -> next = curr;
+ } // attach
+
+ last = curr; // tail
+
// get column title size
- if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_NAME, NULL, 0, & ( curr->iColTitleSize ),
- NULL ) ) != SQL_SUCCESS ) {
+ if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_NAME, NULL, 0, & ( curr -> iColTitleSize ),
+ NULL ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
-
- else {
- ++ curr->iColTitleSize; // allow space for null char
+
+ else
+ {
+ ++ curr -> iColTitleSize; // allow space for null char
}
-
+
// allocate buffer for title
- curr->szColTitle = ( wchar_t* ) calloc ( 1, curr->iColTitleSize * sizeof ( wchar_t ) );
-
- if ( curr->szColTitle == NULL ) {
+ curr -> szColTitle = ( wchar_t* ) calloc ( 1, curr -> iColTitleSize * sizeof ( wchar_t) );
+
+ if ( curr -> szColTitle == NULL )
+ {
FreeBindings ( head );
fprintf ( stderr, "Out of memory!\n" );
- return SQL_ERROR; // its not an ODBC error so no diags r required
+ return SQL_ERROR; // its not an ODBC error so no diags r required
}
-
+
// get column title
- if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_NAME, curr->szColTitle, curr->iColTitleSize,
- & ( curr->iColTitleSize ), NULL ) ) != SQL_SUCCESS ) {
+ if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_NAME, curr -> szColTitle, curr -> iColTitleSize,
+ & ( curr -> iColTitleSize ), NULL ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
-
+
//xxx
// get col length
if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_DISPLAY_SIZE, NULL, 0, NULL,
- & ( curr->iColDisplaySize ) ) ) != SQL_SUCCESS ) {
+ & ( curr -> iColDisplaySize ) ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
-
+
// arbitrary limit on display size
- if ( curr->iColDisplaySize > _DISPLAY_MAX ) { curr->iColDisplaySize = _DISPLAY_MAX; }
-
+ if ( curr -> iColDisplaySize > _DISPLAY_MAX )
+ {
+ curr -> iColDisplaySize = _DISPLAY_MAX;
+ }
+
// allocate buffer for col data + NULL terminator
- curr->szColData = ( void* ) calloc ( 1, 2 * ( curr->iColDisplaySize + 1 ) * sizeof ( char ) );
-
- if ( curr->szColData == NULL ) {
+ curr -> szColData = ( void* ) calloc ( 1, 2 * ( curr -> iColDisplaySize + 1 ) * sizeof ( char) );
+
+ if ( curr -> szColData == NULL )
+ {
FreeBindings ( head );
fprintf ( stderr, "Out of memory!\n" );
- return SQL_ERROR; // its not an ODBC error so no diags r required
+ return SQL_ERROR; // its not an ODBC error so no diags r required
}
-
+
//xxx
// get col type, not used now but can be checked to print value right aligned etcc
- if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_CONCISE_TYPE, NULL, 0, NULL, &cType ) ) != SQL_SUCCESS ) {
+ if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_CONCISE_TYPE, NULL, 0, NULL, &cType ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
-
- curr->iType = cType;
+
+ curr -> iType = cType;
fprintf ( stdout, "The type for column %d is %d\n", iCol, cType );
//xxx
// get col type, not used now but can be checked to print value right aligned etcc
SQLLEN unsignedV = 0;
-
- if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_UNSIGNED , NULL, 0, NULL, &unsignedV ) ) != SQL_SUCCESS ) {
+
+ if ( ( status = SQLColAttributeW ( hStmt, iCol, SQL_DESC_UNSIGNED, NULL, 0, NULL, &unsignedV ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
-
- curr->isSigned = ( unsignedV == 1 ) ? false : true;
- fprintf ( stdout, "The column %d is signed ? %d\n", iCol, curr->isSigned );
+
+ curr -> isSigned = ( unsignedV == 1 ) ? false : true;
+ fprintf ( stdout, "The column %d is signed ? %d\n", iCol, curr -> isSigned );
// set col type indicator in struct
- curr->fChar = ( cType == SQL_CHAR || cType == SQL_VARCHAR || cType == SQL_LONGVARCHAR ||
- cType == SQL_WCHAR || cType == SQL_WVARCHAR || cType == SQL_WLONGVARCHAR );
- fprintf ( stdout, "char flag is set to %d\n", curr->fChar );
+ curr -> fChar = ( cType == SQL_CHAR || cType == SQL_VARCHAR || cType == SQL_LONGVARCHAR ||
+ cType == SQL_WCHAR || cType == SQL_WVARCHAR || cType == SQL_WLONGVARCHAR );
+ fprintf ( stdout, "char flag is set to %d\n", curr -> fChar );
fputs ( "\n", stdout );
-
+
//xxx
// bind the col buffer so that the driver feeds it with col value on every fetch and use generic char binding for very column
- if ( ( status = SQLBindCol ( hStmt, iCol, SQL_C_DEFAULT, ( SQLPOINTER ) curr->szColData,
- 2 * ( curr->iColDisplaySize + 1 ) * sizeof ( char ), & ( curr->indPtr ) ) ) != SQL_SUCCESS ) {
+ if ( ( status = SQLBindCol ( hStmt, iCol, SQL_C_DEFAULT, ( SQLPOINTER ) curr -> szColData,
+ 2 * ( curr -> iColDisplaySize + 1 ) * sizeof ( char), & ( curr -> indPtr ) ) ) != SQL_SUCCESS )
+ {
FreeBindings ( head );
return status;
}
}
-
+
// loop to print all the rows one by one
- for ( i = 1; TRUE; i ++ ) {
+ for ( i = 1; TRUE; i ++ )
+ {
// fetch the next row
if ( ( status = SQLFetch ( hStmt ) ) == SQL_NO_DATA_FOUND )
- { break; } // no more rows so break
-
+ {
+ break;
+ } // no more rows so break
+
// check for error
- else if ( status == SQL_ERROR ) { // fetch failed
+ else if ( status == SQL_ERROR )
+ { // fetch failed
FreeBindings ( head );
return status;
}
-
- for ( curr = head, iCol = 0; iCol < iColCount; iCol ++, curr = curr->next ) {
+
+ for ( curr = head , iCol = 0; iCol < iColCount; iCol ++ , curr = curr -> next )
+ {
fprintf ( stdout, "Row Index: %d, Column Cardinal : %d\n", i - 1, iCol );
-
- if ( !isValueConsistent ( curr->szColData, response->results[i - 1]->contents[iCol], curr->iType, curr->isSigned ) ) {
+
+ if ( !isValueConsistent ( curr -> szColData, response -> results[i - 1] -> contents[iCol], curr -> iType, curr -> isSigned ) )
+ {
FreeBindings ( head );
return SQL_ERROR;
}
-
+
fputs ( "\n", stdout );
}
}
-
+
// free the allocated bindings
FreeBindings ( head );
return SQL_SUCCESS;
@@ -474,27 +549,32 @@ SQLRETURN CheckResults ( HSTMT hStmt , wchar_t* sql ) {
// to free the col info allocated by ShowFullResults
// ----------------------------------------------------------------------------
-void FreeBindings ( BIND_COL_INFO* pBindColInfo ) {
+void FreeBindings ( BIND_COL_INFO* pBindColInfo )
+{
BIND_COL_INFO* next;
-
+
// precaution
- if ( pBindColInfo ) {
- do {
+ if ( pBindColInfo )
+ {
+ do
+ {
// get the next col binding
- next = pBindColInfo->next;
-
+ next = pBindColInfo -> next;
+
// free any buffer for col title
- if ( pBindColInfo->szColTitle ) {
- free ( pBindColInfo->szColTitle );
- pBindColInfo->szColTitle = NULL;
+ if ( pBindColInfo -> szColTitle )
+ {
+ free ( pBindColInfo -> szColTitle );
+ pBindColInfo -> szColTitle = NULL;
}
-
+
// free any col data
- if ( pBindColInfo->szColData ) {
- free ( pBindColInfo->szColData );
- pBindColInfo->szColData = NULL;
+ if ( pBindColInfo -> szColData )
+ {
+ free ( pBindColInfo -> szColData );
+ pBindColInfo -> szColData = NULL;
}
-
+
// free the current binding
free ( pBindColInfo );
// make next the current
@@ -508,30 +588,35 @@ void FreeBindings ( BIND_COL_INFO* pBindColInfo ) {
// to show the ODBC diagnostic messages
// ----------------------------------------------------------------------------
-void ShowDiagMessages ( SQLSMALLINT hType, SQLHANDLE hValue, SQLRETURN iStatus, char* szMsg ) {
+void ShowDiagMessages ( SQLSMALLINT hType, SQLHANDLE hValue, SQLRETURN iStatus, char* szMsg )
+{
SQLSMALLINT iRec = 0;
- SQLINTEGER iError;
- SQLTCHAR szMessage[1024];
- SQLTCHAR szState[1024];
+ SQLINTEGER iError;
+ SQLTCHAR szMessage[1024];
+ SQLTCHAR szState[1024];
// header
- fputs ( "\nDiagnostics:\n" , stdout );
-
+ fputs ( "\nDiagnostics:\n", stdout );
+
// in case of an invalid handle, no message can be extracted
- if ( iStatus == SQL_INVALID_HANDLE ) {
+ if ( iStatus == SQL_INVALID_HANDLE )
+ {
fprintf ( stderr, "ODBC Error: Invalid handle!\n" );
return;
}
-
+
// loop to get all diag messages from driver/driver manager
while ( SQLGetDiagRec ( hType, hValue, ++ iRec, szState, &iError, szMessage,
- ( SQLSMALLINT ) ( sizeof ( szMessage ) / sizeof ( SQLTCHAR ) ), ( SQLSMALLINT* ) NULL ) == SQL_SUCCESS )
- { _ftprintf ( stderr, TEXT ( "[%5.5s] %s (%d)\n" ), szState, szMessage, iError ); }
-
+ ( SQLSMALLINT ) ( sizeof ( szMessage ) / sizeof ( SQLTCHAR) ), ( SQLSMALLINT* ) NULL ) == SQL_SUCCESS )
+ {
+ _ftprintf ( stderr, TEXT ( "[%5.5s] %s (%d)\n" ), szState, szMessage, iError );
+ }
+
// gap
- fputs ( "\n" , stdout );
+ fputs ( "\n", stdout );
}
-void crossValidate() {
+void crossValidate ()
+{
char* queryFile = "testqueries.txt";
//char* queryFile = "c:\\foo.txt";
fprintf ( stdout, "The test queries file location is: %s\n", queryFile );
@@ -539,22 +624,24 @@ void crossValidate() {
validateQueries ( queryFile );
fprintf ( stdout, "The verify process is done.\n", queryFile );
fprintf ( stdout, "Total queries: %d, Successful queries: %d, Failed queries: %d.\n", totalCount, successCount,
- failCount );
-
- for ( vector<wstring>::iterator iter = failedQueries.begin(); iter != failedQueries.end(); ++iter ) {
- fprintf ( stdout, wstring2string ( *iter ).c_str() );
+ failCount );
+
+ for ( vector <wstring>::iterator iter = failedQueries . begin (); iter != failedQueries . end (); ++iter )
+ {
+ fprintf ( stdout, wstring2string ( *iter ) . c_str () );
fprintf ( stdout, "\n\n" );
}
}
-void validateSQLGetTypeInfo () {
+void validateSQLGetTypeInfo ()
+{
Sleep ( 1000 );
- SQLRETURN status;
- SQLHANDLE hEnv = 0;
- SQLHANDLE hConn = 0;
- SQLHANDLE hStmt = 0;
+ SQLRETURN status;
+ SQLHANDLE hEnv = 0;
+ SQLHANDLE hConn = 0;
+ SQLHANDLE hStmt = 0;
wchar_t szConnStrOut[1024];
- SQLSMALLINT x;
+ SQLSMALLINT x;
// BEFORE U CONNECT
// allocate ENVIRONMENT
@@ -562,27 +649,27 @@ void validateSQLGetTypeInfo () {
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
// set the ODBC version for behaviour expected
- status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
+ status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
// allocate CONNECTION
status = SQLAllocHandle ( SQL_HANDLE_DBC, hEnv, &hConn );
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_ENV, hEnv, status, "" );
- #ifdef _WIN64
+#ifdef _WIN64
// ----------- real connection takes place at this point
// ----------- option 1: user is prompted for DSN & options
status = SQLDriverConnect ( hConn, GetDesktopWindow(),
( unsigned char* ) "",
SQL_NTS, szConnStrOut, 1024, &x,
SQL_DRIVER_COMPLETE );
- #else
- status = SQLDriverConnectW ( hConn , GetDesktopWindow(),
+#else
+ status = SQLDriverConnectW ( hConn, GetDesktopWindow (),
//L"DSN=testDSN;",
L"DRIVER={KylinODBCDriver};PROJECT=default;UID=ADMIN;SERVER=http://localhost;PORT=80;",
SQL_NTS, szConnStrOut, 1024, &x,
SQL_DRIVER_COMPLETE );
- #endif
+#endif
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_DBC, hConn, status, "" );
// CONGRATUALTIONS ---- u r connected to a DBMS via an ODBC driver
@@ -592,7 +679,7 @@ void validateSQLGetTypeInfo () {
ODBC_CHK_ERROR ( SQL_HANDLE_DBC, hConn, status, "" );
// execute the statement
//status = SQLExecDirect ( hStmt, ( unsigned char* )argv[1], SQL_NTS );
- status = SQLGetTypeInfoW ( hStmt, SQL_ALL_TYPES);
+ status = SQLGetTypeInfoW ( hStmt, SQL_ALL_TYPES );
// check for error
ODBC_CHK_ERROR ( SQL_HANDLE_STMT, hConn, status, "" );
// check for error
@@ -600,13 +687,20 @@ void validateSQLGetTypeInfo () {
Cleanup:
if ( hStmt )
- { SQLFreeHandle ( SQL_HANDLE_STMT, hStmt ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_STMT, hStmt );
+ }
+
if ( hConn )
- { SQLFreeHandle ( SQL_HANDLE_DBC, hConn ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_DBC, hConn );
+ }
+
if ( hEnv )
- { SQLFreeHandle ( SQL_HANDLE_ENV, hEnv ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_ENV, hEnv );
+ }
+
return;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/QueryFlowTest.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/QueryFlowTest.cpp b/odbc/TestDLL/QueryFlowTest.cpp
index 6de578b..ededef3 100644
--- a/odbc/TestDLL/QueryFlowTest.cpp
+++ b/odbc/TestDLL/QueryFlowTest.cpp
@@ -15,36 +15,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#include "Tests.h"
-void queryFlowTest() {
- SQLRETURN status;
- SQLHANDLE hEnv = 0;
- SQLHANDLE hConn = 0;
- SQLHANDLE hStmt = 0;
+void queryFlowTest ()
+{
+ SQLRETURN status;
+ SQLHANDLE hEnv = 0;
+ SQLHANDLE hConn = 0;
+ SQLHANDLE hStmt = 0;
wchar_t szConnStrOut[1024];
- SQLSMALLINT x;
+ SQLSMALLINT x;
// BEFORE U CONNECT
// allocate ENVIRONMENT
status = SQLAllocHandle ( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv );
// set the ODBC version for behaviour expected
- status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
+ status = SQLSetEnvAttr ( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, 0 );
// allocate CONNECTION
status = SQLAllocHandle ( SQL_HANDLE_DBC, hEnv, &hConn );
- status = SQLDriverConnectW ( hConn, GetDesktopWindow(),
+ status = SQLDriverConnectW ( hConn, GetDesktopWindow (),
L"DRIVER={KylinODBCDriver};PROJECT=default;UID=ADMIN;SERVER=http://localhost;PORT=80;",
//L"DSN=testDSN",
SQL_NTS, szConnStrOut, 1024, &x,
SQL_DRIVER_PROMPT );
// check for error
//ODBC_CHK_ERROR(SQL_HANDLE_DBC,hConn,status,"");
-
+
if ( hConn )
- { SQLFreeHandle ( SQL_HANDLE_DBC, hConn ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_DBC, hConn );
+ }
+
if ( hEnv )
- { SQLFreeHandle ( SQL_HANDLE_ENV, hEnv ); }
-
+ {
+ SQLFreeHandle ( SQL_HANDLE_ENV, hEnv );
+ }
+
printf ( "finish" );
}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/Report.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/Report.cpp b/odbc/TestDLL/Report.cpp
index 9df18f2..14ab409 100644
--- a/odbc/TestDLL/Report.cpp
+++ b/odbc/TestDLL/Report.cpp
@@ -18,10 +18,13 @@
#include "Tests.h"
-void report ( const char* msg ) {
+void report ( const char* msg )
+{
throw exception ( msg );
}
-void report() {
- throw exception();
-}
\ No newline at end of file
+void report ()
+{
+ throw exception ();
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/RestAPITest.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/RestAPITest.cpp b/odbc/TestDLL/RestAPITest.cpp
index c720acf..57308b4 100644
--- a/odbc/TestDLL/RestAPITest.cpp
+++ b/odbc/TestDLL/RestAPITest.cpp
@@ -18,21 +18,27 @@
#include "Tests.h"
-void restAPITest() {
+void restAPITest ()
+{
{
bool ret = restAuthenticate ( KServerAddr, KPort, KUserName, KPassword );
-
+
if ( !ret )
- { report(); }
+ {
+ report ();
+ }
}
{
- std::vector<string> holder;
+ std::vector <string> holder;
restListProjects ( KServerAddr, KPort, KUserName, KPassword, holder );
-
- if ( holder.size() == 0 )
- { report(); }
+
+ if ( holder . size () == 0 )
+ {
+ report ();
+ }
}
{
- std::unique_ptr<MetadataResponse> ret = restGetMeta ( KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
+ std::unique_ptr <MetadataResponse> ret = restGetMeta ( KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
}
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/SimpleQueryTest.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/SimpleQueryTest.cpp b/odbc/TestDLL/SimpleQueryTest.cpp
index 3df7950..8a502b6 100644
--- a/odbc/TestDLL/SimpleQueryTest.cpp
+++ b/odbc/TestDLL/SimpleQueryTest.cpp
@@ -18,31 +18,36 @@
#include "Tests.h"
-void simpleQueryTest() {
+void simpleQueryTest ()
+{
//Intercept query test
{
- std::unique_ptr<SQLResponse> y = restQuery ( L"SELECT 1", KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
-
- if ( ( int ) y->results.size() != 1 ) {
- report();
+ std::unique_ptr <SQLResponse> y = restQuery ( L"SELECT 1", KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
+
+ if ( ( int ) y -> results . size () != 1 )
+ {
+ report ();
}
}
//Ungzipped Query Test
{
- std::unique_ptr<SQLResponse> y = restQuery ( L"select cal_dt from test_kylin_fact limit 1", KServerAddr, KPort,
+ std::unique_ptr <SQLResponse> y = restQuery ( L"select cal_dt from test_kylin_fact limit 1", KServerAddr, KPort,
KUserName, KPassword, KDefaultProject );
-
- if ( ( int ) y->results.size() != 1 ) {
- report();
+
+ if ( ( int ) y -> results . size () != 1 )
+ {
+ report ();
}
}
//zipped Query Test
{
- std::unique_ptr<SQLResponse> y = restQuery ( L"select * from test_kylin_fact limit 12", KServerAddr, KPort, KUserName,
+ std::unique_ptr <SQLResponse> y = restQuery ( L"select * from test_kylin_fact limit 12", KServerAddr, KPort, KUserName,
KPassword, KDefaultProject );
-
- if ( ( int ) y->results.size() != 12 ) {
- report();
+
+ if ( ( int ) y -> results . size () != 12 )
+ {
+ report ();
}
}
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/Source.cpp
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/Source.cpp b/odbc/TestDLL/Source.cpp
index e2ce6c3..d987273 100644
--- a/odbc/TestDLL/Source.cpp
+++ b/odbc/TestDLL/Source.cpp
@@ -21,12 +21,14 @@
using namespace std;
-int main() {
+int main ()
+{
//unit test
//restAPITest();
//regression test:
//simpleQueryTest();
//queryFlowTest();
//crossValidate();
- validateSQLGetTypeInfo();
-}
\ No newline at end of file
+ validateSQLGetTypeInfo ();
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/TestDLL/Tests.h
----------------------------------------------------------------------
diff --git a/odbc/TestDLL/Tests.h b/odbc/TestDLL/Tests.h
index 5b8bbe4..2446def 100644
--- a/odbc/TestDLL/Tests.h
+++ b/odbc/TestDLL/Tests.h
@@ -34,15 +34,17 @@
#include <string>
#include <memory>
#include <windows.h>
-#include <sqlext.h> // required for ODBC calls
+#include <sqlext.h> // required for ODBC calls
+
#include <iostream>
#include <REST.h>
-void report();
+void report ();
void report ( const char* msg );
-void simpleQueryTest();
-void queryFlowTest();
-void restAPITest();
-void crossValidate();
-void validateSQLGetTypeInfo();
+void simpleQueryTest ();
+void queryFlowTest ();
+void restAPITest ();
+void crossValidate ();
+void validateSQLGetTypeInfo ();
+
[09/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_ATTR.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_ATTR.CPP b/odbc/Driver/KO_ATTR.CPP
index 3f21108..d9768d2 100644
--- a/odbc/Driver/KO_ATTR.CPP
+++ b/odbc/Driver/KO_ATTR.CPP
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
// ----------------------------------------------------------------------------
//
// File: KO_ATTR.CPP
@@ -45,32 +45,34 @@
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLSetEnvAttr ( SQLHENV pEnv, SQLINTEGER pAttr, SQLPOINTER pDataPtr, SQLINTEGER pDataSize ) {
+RETCODE SQL_API SQLSetEnvAttr ( SQLHENV pEnv, SQLINTEGER pAttr, SQLPOINTER pDataPtr, SQLINTEGER pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetEnvAttr called" ) );
__CHK_HANDLE ( pEnv, SQL_HANDLE_ENV, SQL_ERROR );
_SQLFreeDiag ( _DIAGENV ( pEnv ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_ODBC_VERSION:
- ( ( pODBCEnv ) pEnv )->AttrODBCVersion = ( ULong ) pDataPtr;
- break;
-
- case SQL_ATTR_CONNECTION_POOLING:
- ( ( pODBCEnv ) pEnv )->AttrConnPooling = ( ULong ) pDataPtr;
- break;
-
- case SQL_ATTR_CP_MATCH:
- ( ( pODBCEnv ) pEnv )->AttrCPMatch = ( ULong ) pDataPtr;
- break;
-
- case SQL_ATTR_OUTPUT_NTS:
- ( ( pODBCEnv ) pEnv )->AttrOutputNTS = ( ULong ) pDataPtr;
- break;
-
- default:
- return SQL_ERROR; // unknown attribute
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_ODBC_VERSION :
+ ( ( pODBCEnv ) pEnv ) -> AttrODBCVersion = ( ULong ) pDataPtr;
+ break;
+
+ case SQL_ATTR_CONNECTION_POOLING :
+ ( ( pODBCEnv ) pEnv ) -> AttrConnPooling = ( ULong ) pDataPtr;
+ break;
+
+ case SQL_ATTR_CP_MATCH :
+ ( ( pODBCEnv ) pEnv ) -> AttrCPMatch = ( ULong ) pDataPtr;
+ break;
+
+ case SQL_ATTR_OUTPUT_NTS :
+ ( ( pODBCEnv ) pEnv ) -> AttrOutputNTS = ( ULong ) pDataPtr;
+ break;
+
+ default :
+ return SQL_ERROR; // unknown attribute
}
-
+
return SQL_SUCCESS;
}
@@ -79,146 +81,151 @@ RETCODE SQL_API SQLSetEnvAttr ( SQLHENV pEnv, SQLINTEGER pAttr, SQLPOINTER pData
// to get current value of specified env attribute
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetEnvAttr ( SQLHENV pEnv,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetEnvAttr ( SQLHENV pEnv,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetEnvAttr called" ) );
__CHK_HANDLE ( pEnv, SQL_HANDLE_ENV, SQL_ERROR );
_SQLFreeDiag ( _DIAGENV ( pEnv ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_ODBC_VERSION:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv )->AttrODBCVersion;
- break;
-
- case SQL_ATTR_CONNECTION_POOLING:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv )->AttrConnPooling;
- break;
-
- case SQL_ATTR_CP_MATCH:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv )->AttrCPMatch;
- break;
-
- case SQL_ATTR_OUTPUT_NTS:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv )->AttrOutputNTS;
- break;
-
- default:
- return SQL_ERROR; // unknown attribute
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_ODBC_VERSION :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrODBCVersion;
+ break;
+
+ case SQL_ATTR_CONNECTION_POOLING :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrConnPooling;
+ break;
+
+ case SQL_ATTR_CP_MATCH :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrCPMatch;
+ break;
+
+ case SQL_ATTR_OUTPUT_NTS :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCEnv ) pEnv ) -> AttrOutputNTS;
+ break;
+
+ default :
+ return SQL_ERROR; // unknown attribute
}
-
+
return SQL_SUCCESS;
}
// --------------------------------------------------------------------
// to set attributes specific to a connection
// --------------------------------------------------------------------
-RETCODE SQL_API SQLSetConnectAttrW ( SQLHDBC hdbc,
- SQLINTEGER fAttribute,
- SQLPOINTER rgbValue,
- SQLINTEGER cbValue ) {
+RETCODE SQL_API SQLSetConnectAttrW ( SQLHDBC hdbc,
+ SQLINTEGER fAttribute,
+ SQLPOINTER rgbValue,
+ SQLINTEGER cbValue )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetConnectAttrW, Attr: %d, DataPtr: %d, DataSize: %d", fAttribute,
- rgbValue, cbValue ) );
+ rgbValue, cbValue ) );
RETCODE code = SQLSetConnectAttr ( hdbc, fAttribute, rgbValue, cbValue );
return code;
}
-RETCODE SQL_API SQLSetConnectAttr ( SQLHDBC pConn, SQLINTEGER pAttr, SQLPOINTER pDataPtr, SQLINTEGER pDataSize ) {
+RETCODE SQL_API SQLSetConnectAttr ( SQLHDBC pConn, SQLINTEGER pAttr, SQLPOINTER pDataPtr, SQLINTEGER pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetConnectAttr, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_ANSI_APP:
- return SQL_ERROR;
-
- case SQL_ATTR_ACCESS_MODE:
- ( ( pODBCConn ) pConn )->AccessMode = ( ULong ) pDataPtr;
- break;
-
- case SQL_ATTR_ASYNC_ENABLE:
- ( ( pODBCConn ) pConn )->AsyncEnable = ( ULong ) pDataPtr;
- break;
-
- //case SQL_ATTR_AUTO_IPD: read-only
-
- case SQL_ATTR_AUTOCOMMIT:
- ( ( pODBCConn ) pConn )->AutoCommit = ( ULong ) pDataPtr;
- break;
-
- case SQL_ATTR_CONNECTION_DEAD:
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_ANSI_APP :
+ return SQL_ERROR;
+
+ case SQL_ATTR_ACCESS_MODE :
+ ( ( pODBCConn ) pConn ) -> AccessMode = ( ULong ) pDataPtr;
+ break;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ ( ( pODBCConn ) pConn ) -> AsyncEnable = ( ULong ) pDataPtr;
+ break;
+
+ //case SQL_ATTR_AUTO_IPD: read-only
+
+ case SQL_ATTR_AUTOCOMMIT :
+ ( ( pODBCConn ) pConn ) -> AutoCommit = ( ULong ) pDataPtr;
+ break;
+
+ case SQL_ATTR_CONNECTION_DEAD :
// (( pODBCConn )pConn)->AutoCommit = ( ULong )pDataPtr;
break;
-
- case SQL_ATTR_CONNECTION_TIMEOUT:
+
+ case SQL_ATTR_CONNECTION_TIMEOUT :
//(( pODBCConn )pConn)->TimeOut = *(( ULong* )pDataPtr );
break;
-
- case SQL_ATTR_CURRENT_CATALOG: // current database
+
+ case SQL_ATTR_CURRENT_CATALOG : // current database
// assumes that current database is what it should be
// return _SQLCopyCharData ( _DIAGCONN(pConn), (( pODBCConn )pConn)->CurrDB, 32, NULL, 16, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_LOGIN_TIMEOUT:
+
+ case SQL_ATTR_LOGIN_TIMEOUT :
// (( pODBCConn )pConn)->LoginTimeOut = *(( ULong* )pDataPtr );
break;
-
- case SQL_ATTR_METADATA_ID:
- ( ( pODBCConn ) pConn )->MetaDataID = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_METADATA_ID :
+ ( ( pODBCConn ) pConn ) -> MetaDataID = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_ODBC_CURSORS:
- ( ( pODBCConn ) pConn )->ODBCCursors = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_ODBC_CURSORS :
+ ( ( pODBCConn ) pConn ) -> ODBCCursors = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_PACKET_SIZE:
+
+ case SQL_ATTR_PACKET_SIZE :
// not a typical option
return SQL_ERROR;
-
- case SQL_ATTR_QUIET_MODE:
- ( ( pODBCConn ) pConn )->Window = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_QUIET_MODE :
+ ( ( pODBCConn ) pConn ) -> Window = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_TRACE:
+
+ case SQL_ATTR_TRACE :
// only for driver manager
break;
-
- case SQL_ATTR_TRACEFILE:
+
+ case SQL_ATTR_TRACEFILE :
// only for driver manager
break;
-
- case SQL_ATTR_TRANSLATE_LIB:
+
+ case SQL_ATTR_TRANSLATE_LIB :
// translation still not implemented
break;
-
- case SQL_ATTR_TRANSLATE_OPTION:
+
+ case SQL_ATTR_TRANSLATE_OPTION :
// translation still not implemented
break;
-
- case SQL_ATTR_TXN_ISOLATION:
- ( ( pODBCConn ) pConn )->TxnIsolation = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_TXN_ISOLATION :
+ ( ( pODBCConn ) pConn ) -> TxnIsolation = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_MAX_ROWS:
- ( ( pODBCConn ) pConn )->MaxRows = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_MAX_ROWS :
+ ( ( pODBCConn ) pConn ) -> MaxRows = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
- ( ( pODBCConn ) pConn )->QueryTimeout = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_QUERY_TIMEOUT :
+ ( ( pODBCConn ) pConn ) -> QueryTimeout = ( ULong ) pDataPtr;
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetConnectAttr is not recognized, Attr: %d, DataPtr: %d, DataSize: %d", pAttr,
- pDataPtr, pDataSize ) );
+ pDataPtr, pDataSize ) );
return SQL_SUCCESS;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetConnectAttr, Attr: %d, DataPtr: %d, DataSize: %d is done!", pAttr,
- pDataPtr, pDataSize ) );
+ pDataPtr, pDataSize ) );
return SQL_SUCCESS;
}
@@ -226,190 +233,194 @@ RETCODE SQL_API SQLSetConnectAttr ( SQLHDBC pConn, SQLINTEGER pAttr, SQLPOINTER
// -----------------------------------------------------------------------
// to get current value of specified conn attribute
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetConnectAttrW ( SQLHDBC pConn,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetConnectAttrW ( SQLHDBC pConn,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetConnectAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_ACCESS_MODE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AccessMode;
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_ACCESS_MODE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AccessMode;
break;
-
- case SQL_ATTR_ASYNC_ENABLE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AsyncEnable;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AsyncEnable;
break;
-
- case SQL_ATTR_AUTO_IPD:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AutoIPD;
+
+ case SQL_ATTR_AUTO_IPD :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AutoIPD;
break;
-
- case SQL_ATTR_AUTOCOMMIT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AutoCommit;
+
+ case SQL_ATTR_AUTOCOMMIT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AutoCommit;
break;
-
- case SQL_ATTR_CONNECTION_DEAD:
- * ( ( ULong* ) pDataPtr ) = SQL_CD_TRUE;
+
+ case SQL_ATTR_CONNECTION_DEAD :
+ * ( ( ULong* ) pDataPtr ) = SQL_CD_TRUE ;
break;
-
- case SQL_ATTR_CONNECTION_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->TimeOut;
+
+ case SQL_ATTR_CONNECTION_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> TimeOut;
break;
-
- case SQL_ATTR_CURRENT_CATALOG: // current database
+
+ case SQL_ATTR_CURRENT_CATALOG : // current database
return _SQLCopyWCharData ( _DIAGCONN ( pConn ), pDataPtr, pDataSize, pDataSizePtr, 32, "default", -1 );
-
- case SQL_ATTR_LOGIN_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->LoginTimeOut;
- break;
-
- case SQL_ATTR_METADATA_ID:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->MetaDataID;
- break;
-
- case SQL_ATTR_ODBC_CURSORS:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->ODBCCursors;
- break;
-
- case SQL_ATTR_PACKET_SIZE:
- return SQL_ERROR; // not a typical option
-
- case SQL_ATTR_QUIET_MODE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->Window;
- break;
-
- case SQL_ATTR_TRACE:
+
+ case SQL_ATTR_LOGIN_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> LoginTimeOut;
+ break;
+
+ case SQL_ATTR_METADATA_ID :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> MetaDataID;
+ break;
+
+ case SQL_ATTR_ODBC_CURSORS :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> ODBCCursors;
+ break;
+
+ case SQL_ATTR_PACKET_SIZE :
+ return SQL_ERROR; // not a typical option
+
+ case SQL_ATTR_QUIET_MODE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> Window;
+ break;
+
+ case SQL_ATTR_TRACE :
// basically for driver manager
break;
-
- case SQL_ATTR_TRACEFILE:
+
+ case SQL_ATTR_TRACEFILE :
// basically for driver manager
break;
-
- case SQL_ATTR_TRANSLATE_LIB:
+
+ case SQL_ATTR_TRANSLATE_LIB :
// not implemented
break;
-
- case SQL_ATTR_TRANSLATE_OPTION:
+
+ case SQL_ATTR_TRANSLATE_OPTION :
// not implemented
break;
-
- case SQL_ATTR_TXN_ISOLATION:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->TxnIsolation;
+
+ case SQL_ATTR_TXN_ISOLATION :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> TxnIsolation;
break;
-
- case SQL_ATTR_MAX_ROWS:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->MaxRows;
+
+ case SQL_ATTR_MAX_ROWS :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> MaxRows;
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->QueryTimeout;
+
+ case SQL_ATTR_QUERY_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> QueryTimeout;
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetConnectAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr, pDataSize ) );
return SQL_SUCCESS;
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLGetConnectAttr ( SQLHDBC pConn,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetConnectAttr ( SQLHDBC pConn,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetConnectAttr, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_ACCESS_MODE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AccessMode;
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_ACCESS_MODE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AccessMode;
break;
-
- case SQL_ATTR_ASYNC_ENABLE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AsyncEnable;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AsyncEnable;
break;
-
- case SQL_ATTR_AUTO_IPD:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AutoIPD;
+
+ case SQL_ATTR_AUTO_IPD :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AutoIPD;
break;
-
- case SQL_ATTR_AUTOCOMMIT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->AutoCommit;
+
+ case SQL_ATTR_AUTOCOMMIT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> AutoCommit;
break;
-
- case SQL_ATTR_CONNECTION_DEAD:
- * ( ( ULong* ) pDataPtr ) = SQL_CD_TRUE;
+
+ case SQL_ATTR_CONNECTION_DEAD :
+ * ( ( ULong* ) pDataPtr ) = SQL_CD_TRUE ;
break;
-
- case SQL_ATTR_CONNECTION_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->TimeOut;
+
+ case SQL_ATTR_CONNECTION_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> TimeOut;
break;
-
- case SQL_ATTR_CURRENT_CATALOG: // current database
+
+ case SQL_ATTR_CURRENT_CATALOG : // current database
return _SQLCopyCharData ( _DIAGCONN ( pConn ), pDataPtr, pDataSize, pDataSizePtr, 32, "default", -1 );
-
- case SQL_ATTR_LOGIN_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->LoginTimeOut;
- break;
-
- case SQL_ATTR_METADATA_ID:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->MetaDataID;
- break;
-
- case SQL_ATTR_ODBC_CURSORS:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->ODBCCursors;
- break;
-
- case SQL_ATTR_PACKET_SIZE:
- return SQL_ERROR; // not a typical option
-
- case SQL_ATTR_QUIET_MODE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->Window;
- break;
-
- case SQL_ATTR_TRACE:
+
+ case SQL_ATTR_LOGIN_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> LoginTimeOut;
+ break;
+
+ case SQL_ATTR_METADATA_ID :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> MetaDataID;
+ break;
+
+ case SQL_ATTR_ODBC_CURSORS :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> ODBCCursors;
+ break;
+
+ case SQL_ATTR_PACKET_SIZE :
+ return SQL_ERROR; // not a typical option
+
+ case SQL_ATTR_QUIET_MODE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> Window;
+ break;
+
+ case SQL_ATTR_TRACE :
// basically for driver manager
break;
-
- case SQL_ATTR_TRACEFILE:
+
+ case SQL_ATTR_TRACEFILE :
// basically for driver manager
break;
-
- case SQL_ATTR_TRANSLATE_LIB:
+
+ case SQL_ATTR_TRANSLATE_LIB :
// not implemented
break;
-
- case SQL_ATTR_TRANSLATE_OPTION:
+
+ case SQL_ATTR_TRANSLATE_OPTION :
// not implemented
break;
-
- case SQL_ATTR_TXN_ISOLATION:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->TxnIsolation;
+
+ case SQL_ATTR_TXN_ISOLATION :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> TxnIsolation;
break;
-
- case SQL_ATTR_MAX_ROWS:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->MaxRows;
+
+ case SQL_ATTR_MAX_ROWS :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> MaxRows;
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn )->QueryTimeout;
+
+ case SQL_ATTR_QUERY_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCConn ) pConn ) -> QueryTimeout;
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetConnectAttr not recognized, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
return SQL_SUCCESS;
}
-
+
return SQL_SUCCESS;
}
@@ -419,316 +430,322 @@ RETCODE SQL_API SQLGetConnectAttr ( SQLHDBC pConn,
// --------------------------------------------------------------------
-RETCODE SQL_API SQLSetStmtAttrW ( SQLHSTMT pStmt,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize )
+RETCODE SQL_API SQLSetStmtAttrW ( SQLHSTMT pStmt,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize )
{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetStmtAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
- switch ( pAttr ) {
- case 1226:/* MS SQL Server Extension */
- case 1227:
- case 1228:
+
+ switch ( pAttr )
+ {
+ case 1226 : /* MS SQL Server Extension */
+ case 1227 :
+ case 1228 :
break;
- case SQL_ATTR_APP_PARAM_DESC:
+ case SQL_ATTR_APP_PARAM_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_PARAM_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_APP_ROW_DESC:
+
+ case SQL_ATTR_APP_ROW_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_ROW_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_ASYNC_ENABLE:
- ( ( pODBCStmt ) pStmt )->AsyncEnable = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ ( ( pODBCStmt ) pStmt ) -> AsyncEnable = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CONCURRENCY:
- ( ( pODBCStmt ) pStmt )->Concurrency = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CONCURRENCY :
+ ( ( pODBCStmt ) pStmt ) -> Concurrency = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_SCROLLABLE:
- ( ( pODBCStmt ) pStmt )->CursorScroll = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_SCROLLABLE :
+ ( ( pODBCStmt ) pStmt ) -> CursorScroll = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_SENSITIVITY:
- ( ( pODBCStmt ) pStmt )->CursorSensitivity = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_SENSITIVITY :
+ ( ( pODBCStmt ) pStmt ) -> CursorSensitivity = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_TYPE:
- ( ( pODBCStmt ) pStmt )->CursorType = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_TYPE :
+ ( ( pODBCStmt ) pStmt ) -> CursorType = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_ENABLE_AUTO_IPD:
- ( ( pODBCStmt ) pStmt )->AutoIPD = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_ENABLE_AUTO_IPD :
+ ( ( pODBCStmt ) pStmt ) -> AutoIPD = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_FETCH_BOOKMARK_PTR:
+
+ case SQL_ATTR_FETCH_BOOKMARK_PTR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_FETCH_BOOKMARK_PTR - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_IMP_PARAM_DESC:
+
+ case SQL_ATTR_IMP_PARAM_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_PARAM_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_IMP_ROW_DESC:
+
+ case SQL_ATTR_IMP_ROW_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_ROW_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_KEYSET_SIZE:
- ( ( pODBCStmt ) pStmt )->KeysetSize = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_KEYSET_SIZE :
+ ( ( pODBCStmt ) pStmt ) -> KeysetSize = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_MAX_LENGTH:
+
+ case SQL_ATTR_MAX_LENGTH :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_LENGTH - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_MAX_ROWS:
+
+ case SQL_ATTR_MAX_ROWS :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_ROWS - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_METADATA_ID:
- ( ( pODBCStmt ) pStmt )->MetaDataID = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_METADATA_ID :
+ ( ( pODBCStmt ) pStmt ) -> MetaDataID = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_NOSCAN:
- ( ( pODBCStmt ) pStmt )->NoScan = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_NOSCAN :
+ ( ( pODBCStmt ) pStmt ) -> NoScan = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_PARAM_BIND_TYPE:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_BIND_TYPE :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_OPERATION_PTR:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_OPERATION_PTR :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_STATUS_PTR:
- _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_STATUS_PTR :
+ _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAMS_PROCESSED_PTR:
+
+ case SQL_ATTR_PARAMS_PROCESSED_PTR :
// ???? note there is an error in MSDN on SQLSetDescField which says ARD/APD instead of IRD/IPD for this option
- _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
+ _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAMSET_SIZE:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAMSET_SIZE :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
+
+ case SQL_ATTR_QUERY_TIMEOUT :
if ( pDataPtr != NULL )
- { ( ( pODBCStmt ) pStmt )->QryTimeout = ( ( ULong ) pDataPtr ); }
-
+ {
+ ( ( pODBCStmt ) pStmt ) -> QryTimeout = ( ( ULong ) pDataPtr );
+ }
+
break;
-
- case SQL_ATTR_RETRIEVE_DATA:
- ( ( pODBCStmt ) pStmt )->RetrieveData = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_RETRIEVE_DATA :
+ ( ( pODBCStmt ) pStmt ) -> RetrieveData = ( ULong ) pDataPtr;
break;
-
- case SQL_ROWSET_SIZE:
- case SQL_ATTR_ROW_ARRAY_SIZE:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
+
+ case SQL_ROWSET_SIZE :
+ case SQL_ATTR_ROW_ARRAY_SIZE :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_BIND_TYPE:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_BIND_TYPE :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_OPERATION_PTR:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_OPERATION_PTR :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_STATUS_PTR:
- _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_STATUS_PTR :
+ _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROWS_FETCHED_PTR:
- _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROWS_FETCHED_PTR :
+ _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_SIMULATE_CURSOR:
+
+ case SQL_ATTR_SIMULATE_CURSOR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_SIMULATE_CURSOR - option not implemented" ) );
return SQL_ERROR;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetStmtAttrW : Stmt attr - unknown %d", pAttr ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLSetStmtAttr ( SQLHSTMT pStmt,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize )
+RETCODE SQL_API SQLSetStmtAttr ( SQLHSTMT pStmt,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize )
{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetStmtAttr, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_APP_PARAM_DESC:
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_APP_PARAM_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_PARAM_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_APP_ROW_DESC:
+
+ case SQL_ATTR_APP_ROW_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_APP_ROW_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_ASYNC_ENABLE:
- ( ( pODBCStmt ) pStmt )->AsyncEnable = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ ( ( pODBCStmt ) pStmt ) -> AsyncEnable = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CONCURRENCY:
- ( ( pODBCStmt ) pStmt )->Concurrency = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CONCURRENCY :
+ ( ( pODBCStmt ) pStmt ) -> Concurrency = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_SCROLLABLE:
- ( ( pODBCStmt ) pStmt )->CursorScroll = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_SCROLLABLE :
+ ( ( pODBCStmt ) pStmt ) -> CursorScroll = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_SENSITIVITY:
- ( ( pODBCStmt ) pStmt )->CursorSensitivity = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_SENSITIVITY :
+ ( ( pODBCStmt ) pStmt ) -> CursorSensitivity = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_CURSOR_TYPE:
- ( ( pODBCStmt ) pStmt )->CursorType = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_CURSOR_TYPE :
+ ( ( pODBCStmt ) pStmt ) -> CursorType = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_ENABLE_AUTO_IPD:
- ( ( pODBCStmt ) pStmt )->AutoIPD = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_ENABLE_AUTO_IPD :
+ ( ( pODBCStmt ) pStmt ) -> AutoIPD = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_FETCH_BOOKMARK_PTR:
+
+ case SQL_ATTR_FETCH_BOOKMARK_PTR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_FETCH_BOOKMARK_PTR - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_IMP_PARAM_DESC:
+
+ case SQL_ATTR_IMP_PARAM_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_PARAM_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_IMP_ROW_DESC:
+
+ case SQL_ATTR_IMP_ROW_DESC :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_IMP_ROW_DESC - Cannot set descriptor" ) );
return SQL_ERROR;
-
- case SQL_ATTR_KEYSET_SIZE:
- ( ( pODBCStmt ) pStmt )->KeysetSize = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_KEYSET_SIZE :
+ ( ( pODBCStmt ) pStmt ) -> KeysetSize = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_MAX_LENGTH:
+
+ case SQL_ATTR_MAX_LENGTH :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_LENGTH - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_MAX_ROWS:
+
+ case SQL_ATTR_MAX_ROWS :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_ROWS - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_METADATA_ID:
- ( ( pODBCStmt ) pStmt )->MetaDataID = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_METADATA_ID :
+ ( ( pODBCStmt ) pStmt ) -> MetaDataID = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_NOSCAN:
- ( ( pODBCStmt ) pStmt )->NoScan = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_NOSCAN :
+ ( ( pODBCStmt ) pStmt ) -> NoScan = ( ULong ) pDataPtr;
break;
-
- case SQL_ATTR_PARAM_BIND_TYPE:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_BIND_TYPE :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_OPERATION_PTR:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_OPERATION_PTR :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAM_STATUS_PTR:
- _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAM_STATUS_PTR :
+ _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAMS_PROCESSED_PTR:
+
+ case SQL_ATTR_PARAMS_PROCESSED_PTR :
// ???? note there is an error in MSDN on SQLSetDescField which says ARD/APD instead of IRD/IPD for this option
- _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
+ _SQLSetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_PARAMSET_SIZE:
- _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_PARAMSET_SIZE :
+ _SQLSetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
+
+ case SQL_ATTR_QUERY_TIMEOUT :
if ( pDataPtr != NULL )
- { ( ( pODBCStmt ) pStmt )->QryTimeout = * ( ( ULong* ) pDataPtr ); }
-
+ {
+ ( ( pODBCStmt ) pStmt ) -> QryTimeout = * ( ( ULong* ) pDataPtr );
+ }
+
break;
-
- case SQL_ATTR_RETRIEVE_DATA:
- ( ( pODBCStmt ) pStmt )->RetrieveData = ( ULong ) pDataPtr;
+
+ case SQL_ATTR_RETRIEVE_DATA :
+ ( ( pODBCStmt ) pStmt ) -> RetrieveData = ( ULong ) pDataPtr;
break;
-
- case SQL_ROWSET_SIZE:
- case SQL_ATTR_ROW_ARRAY_SIZE:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
+
+ case SQL_ROWSET_SIZE :
+ case SQL_ATTR_ROW_ARRAY_SIZE :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_BIND_TYPE:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_BIND_TYPE :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_OPERATION_PTR:
- _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_OPERATION_PTR :
+ _SQLSetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROW_STATUS_PTR:
- _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROW_STATUS_PTR :
+ _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_ROWS_FETCHED_PTR:
- _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
+
+ case SQL_ATTR_ROWS_FETCHED_PTR :
+ _SQLSetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize );
break;
-
- case SQL_ATTR_SIMULATE_CURSOR:
+
+ case SQL_ATTR_SIMULATE_CURSOR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_SIMULATE_CURSOR - option not implemented" ) );
return SQL_ERROR;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetStmtAttr: Stmt attr - unknown %d", pAttr ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
-
-RETCODE SQL_API SQLGetStmtAttrW ( SQLHSTMT pStmt,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetStmtAttrW ( SQLHSTMT pStmt,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetStmtAttrW, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
return SQLGetStmtAttr ( pStmt, pAttr, pDataPtr, pDataSize, pDataSizePtr );
}
@@ -737,157 +754,159 @@ RETCODE SQL_API SQLGetStmtAttrW ( SQLHSTMT pStmt,
// to get attributes specific to a statement
// --------------------------------------------------------------------
-RETCODE SQL_API SQLGetStmtAttr ( SQLHSTMT pStmt,
- SQLINTEGER pAttr,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetStmtAttr ( SQLHSTMT pStmt,
+ SQLINTEGER pAttr,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetStmtAttr, Attr: %d, DataPtr: %d, DataSize: %d", pAttr, pDataPtr,
- pDataSize ) );
+ pDataSize ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
- switch ( pAttr ) {
- case SQL_ATTR_APP_PARAM_DESC:
- * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->APD );
+
+ switch ( pAttr )
+ {
+ case SQL_ATTR_APP_PARAM_DESC :
+ * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt ) -> APD );
break;
-
- case SQL_ATTR_APP_ROW_DESC:
- * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->ARD );
+
+ case SQL_ATTR_APP_ROW_DESC :
+ * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt ) -> ARD );
break;
-
- case SQL_ATTR_ASYNC_ENABLE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->AsyncEnable;
+
+ case SQL_ATTR_ASYNC_ENABLE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> AsyncEnable;
break;
-
- case SQL_ATTR_CONCURRENCY:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->Concurrency;
+
+ case SQL_ATTR_CONCURRENCY :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> Concurrency;
break;
-
- case SQL_ATTR_CURSOR_SCROLLABLE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorScroll;
+
+ case SQL_ATTR_CURSOR_SCROLLABLE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> CursorScroll;
break;
-
- case SQL_ATTR_CURSOR_SENSITIVITY:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorSensitivity;
+
+ case SQL_ATTR_CURSOR_SENSITIVITY :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> CursorSensitivity;
break;
-
- case SQL_ATTR_CURSOR_TYPE:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CursorType;
+
+ case SQL_ATTR_CURSOR_TYPE :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> CursorType;
break;
-
- case SQL_ATTR_ENABLE_AUTO_IPD:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->AutoIPD;
+
+ case SQL_ATTR_ENABLE_AUTO_IPD :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> AutoIPD;
break;
-
- case SQL_ATTR_FETCH_BOOKMARK_PTR:
+
+ case SQL_ATTR_FETCH_BOOKMARK_PTR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_FETCH_BOOKMARK_PTR - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_IMP_PARAM_DESC:
- * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->IPD );
+
+ case SQL_ATTR_IMP_PARAM_DESC :
+ * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt ) -> IPD );
break;
-
- case SQL_ATTR_IMP_ROW_DESC:
- * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt )->IRD );
+
+ case SQL_ATTR_IMP_ROW_DESC :
+ * ( ( Long* ) pDataPtr ) = ( Long ) & ( ( ( pODBCStmt ) pStmt ) -> IRD );
break;
-
- case SQL_ATTR_KEYSET_SIZE:
- * ( ( Long* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->KeysetSize;
+
+ case SQL_ATTR_KEYSET_SIZE :
+ * ( ( Long* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> KeysetSize;
break;
-
- case SQL_ATTR_MAX_LENGTH:
+
+ case SQL_ATTR_MAX_LENGTH :
* ( ( ULong* ) pDataPtr ) = 0;
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_LENGTH - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_MAX_ROWS:
+
+ case SQL_ATTR_MAX_ROWS :
* ( ( ULong* ) pDataPtr ) = 0;
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_MAX_ROWS - option not implemented" ) );
return SQL_ERROR;
-
- case SQL_ATTR_METADATA_ID:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->MetaDataID;
+
+ case SQL_ATTR_METADATA_ID :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> MetaDataID;
break;
-
- case SQL_ATTR_NOSCAN:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->NoScan;
+
+ case SQL_ATTR_NOSCAN :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> NoScan;
break;
-
- case SQL_ATTR_PARAM_BIND_TYPE:
- _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_PARAM_BIND_TYPE :
+ _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR :
+ _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_PARAM_OPERATION_PTR:
- _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_PARAM_OPERATION_PTR :
+ _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_PARAM_STATUS_PTR:
- _SQLGetIPDField ( & ( ( ( pODBCStmt ) pStmt )->IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_PARAM_STATUS_PTR :
+ _SQLGetIPDField ( & ( ( ( pODBCStmt ) pStmt ) -> IPD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_PARAMS_PROCESSED_PTR:
+
+ case SQL_ATTR_PARAMS_PROCESSED_PTR :
// ???? note there is an error in MSDN on SQLSetDescField which says ARD/APD instead of IRD/IPD for this option
- _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
+ _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
pDataSizePtr );
break;
-
- case SQL_ATTR_PARAMSET_SIZE:
- _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt )->APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_PARAMSET_SIZE :
+ _SQLGetAPDField ( & ( ( ( pODBCStmt ) pStmt ) -> APD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_QUERY_TIMEOUT:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->QryTimeout;
+
+ case SQL_ATTR_QUERY_TIMEOUT :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> QryTimeout;
break;
-
- case SQL_ATTR_RETRIEVE_DATA:
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->RetrieveData;
+
+ case SQL_ATTR_RETRIEVE_DATA :
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> RetrieveData;
break;
-
- case SQL_ROWSET_SIZE:
- case SQL_ATTR_ROW_ARRAY_SIZE:
- _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ROWSET_SIZE :
+ case SQL_ATTR_ROW_ARRAY_SIZE :
+ _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_SIZE, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR :
+ _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_OFFSET_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_ROW_BIND_TYPE:
- _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_ROW_BIND_TYPE :
+ _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_BIND_TYPE, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_ROW_NUMBER:
+
+ case SQL_ATTR_ROW_NUMBER :
// ??? in case of rowset being > 1, start row is being returned
- * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt )->CurRowsetStartRowPos;
+ * ( ( ULong* ) pDataPtr ) = ( ( pODBCStmt ) pStmt ) -> CurRowsetStartRowPos;
break;
-
- case SQL_ATTR_ROW_OPERATION_PTR:
- _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt )->ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_ROW_OPERATION_PTR :
+ _SQLGetARDField ( & ( ( ( pODBCStmt ) pStmt ) -> ARD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_ROW_STATUS_PTR:
- _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
+
+ case SQL_ATTR_ROW_STATUS_PTR :
+ _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ARRAY_STATUS_PTR, pDataPtr, pDataSize, pDataSizePtr );
break;
-
- case SQL_ATTR_ROWS_FETCHED_PTR:
- _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
+
+ case SQL_ATTR_ROWS_FETCHED_PTR :
+ _SQLGetIRDField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), SQL_DESC_ROWS_PROCESSED_PTR, pDataPtr, pDataSize,
pDataSizePtr );
break;
-
- case SQL_ATTR_SIMULATE_CURSOR:
+
+ case SQL_ATTR_SIMULATE_CURSOR :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQL_ATTR_SIMULATE_CURSOR - option not implemented" ) );
return SQL_ERROR;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetStmtAttr: Stmt attr - unknown %d", pAttr ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
@@ -895,10 +914,11 @@ RETCODE SQL_API SQLGetStmtAttr ( SQLHSTMT pStmt,
// to get the name of the current cursor
// --------------------------------------------------------------------
-RETCODE SQL_API SQLGetCursorName ( SQLHSTMT pStmt,
- SQLCHAR* pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr ) {
+RETCODE SQL_API SQLGetCursorName ( SQLHSTMT pStmt,
+ SQLCHAR* pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetCursorName called" ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
@@ -910,9 +930,10 @@ RETCODE SQL_API SQLGetCursorName ( SQLHSTMT pStmt,
// to set the name of the current cursor
// --------------------------------------------------------------------
-RETCODE SQL_API SQLSetCursorName ( SQLHSTMT pStmt,
- SQLCHAR* pDataPtr,
- SQLSMALLINT pDataSize ) {
+RETCODE SQL_API SQLSetCursorName ( SQLHSTMT pStmt,
+ SQLCHAR* pDataPtr,
+ SQLSMALLINT pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetCursorName called" ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
[02/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
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 ();
+
[11/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
KYLIN-1389 ODBC - Reformatting C++ Code
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/3c2329dc
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/3c2329dc
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/3c2329dc
Branch: refs/heads/2.x-staging
Commit: 3c2329dc13830b754954e474b1723b280ea6b0d0
Parents: 9b19b69
Author: lidongsjtu <li...@apache.org>
Authored: Mon Feb 1 17:18:24 2016 +0800
Committer: lidongsjtu <li...@apache.org>
Committed: Mon Feb 1 17:18:24 2016 +0800
----------------------------------------------------------------------
odbc/Common/Dump.cpp | 99 +-
odbc/Common/Dump.h | 7 +-
odbc/Common/Gzip.cpp | 84 +-
odbc/Common/Gzip.h | 7 +-
odbc/Common/JDBCODBC.cpp | 169 +-
odbc/Common/JDBCODBC.h | 92 +-
odbc/Common/JsonConverter.cpp | 151 +-
odbc/Common/JsonConverter.h | 15 +-
odbc/Common/MsgTypes.h | 627 ++++---
odbc/Common/QueryCache.cpp | 49 +-
odbc/Common/QueryCache.h | 7 +-
odbc/Common/REST.cpp | 439 +++--
odbc/Common/REST.h | 17 +-
odbc/Common/StringUtils.cpp | 171 +-
odbc/Common/StringUtils.h | 21 +-
odbc/Common/base64.cpp | 120 +-
odbc/Common/base64.h | 5 +-
odbc/Driver/KO_ATTR.CPP | 1143 ++++++------
odbc/Driver/KO_CONN.CPP | 1252 +++++++------
odbc/Driver/KO_CTLG.CPP | 366 ++--
odbc/Driver/KO_Config.cpp | 815 ++++----
odbc/Driver/KO_DESC.CPP | 3089 +++++++++++++++++--------------
odbc/Driver/KO_DIAG.CPP | 1142 +++++++-----
odbc/Driver/KO_DTYPE.CPP | 384 ++--
odbc/Driver/KO_FETCH.CPP | 1414 +++++++-------
odbc/Driver/KO_INFO.CPP | 1331 ++++++-------
odbc/Driver/KO_PARAM.CPP | 53 +-
odbc/Driver/KO_UTILS.CPP | 654 ++++---
odbc/Driver/KylinODBC.CPP | 60 +-
odbc/Driver/KylinODBC.H | 704 +++----
odbc/Driver/resource.h | 3 +-
odbc/Driver/stdafx.cpp | 5 +-
odbc/Driver/stdafx.h | 5 +-
odbc/TestDLL/ColorPrint.cpp | 37 +-
odbc/TestDLL/ColorPrint.h | 7 +-
odbc/TestDLL/CompareQueryTests.cpp | 708 ++++---
odbc/TestDLL/QueryFlowTest.cpp | 34 +-
odbc/TestDLL/Report.cpp | 11 +-
odbc/TestDLL/RestAPITest.cpp | 24 +-
odbc/TestDLL/SimpleQueryTest.cpp | 33 +-
odbc/TestDLL/Source.cpp | 8 +-
odbc/TestDLL/Tests.h | 16 +-
42 files changed, 8419 insertions(+), 6959 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/Dump.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/Dump.cpp b/odbc/Common/Dump.cpp
index c2301f7..dd68373 100644
--- a/odbc/Common/Dump.cpp
+++ b/odbc/Common/Dump.cpp
@@ -15,70 +15,95 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-void displayHexRecord ( char* data, int count, int record_length ) {
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+void displayHexRecord ( char* data, int count, int record_length )
+{
int i;
-
- for ( i = 0; i < count; i++ ) { printf ( "%02x ", data[i] & 0xff ); }
-
- for ( ; i < record_length; i++ ) { printf ( " " ); }
-
+
+ for ( i = 0; i < count; i++ )
+ {
+ printf ( "%02x ", data[i] & 0xff );
+ }
+
+ for ( ; i < record_length; i++ )
+ {
+ printf ( " " );
+ }
+
printf ( ": " );
-
- for ( i = 0; i < count; i++ ) {
- if ( isgraph ( data[i] ) ) { putchar ( data[i] ); }
-
- else { putchar ( '.' ); }
+
+ for ( i = 0; i < count; i++ )
+ {
+ if ( isgraph ( data[i] ) )
+ {
+ putchar ( data[i] );
+ }
+
+ else
+ {
+ putchar ( '.' );
+ }
}
-
+
putchar ( '\n' );
}
-void bufferHexRecord ( char* data, int count, int record_length, char* buffer ) {
+void bufferHexRecord ( char* data, int count, int record_length, char* buffer )
+{
int i;
-
- for ( i = 0; i < count; i++ ) {
+
+ for ( i = 0; i < count; i++ )
+ {
sprintf ( buffer + strlen ( buffer ), "%02x ", data[i] & 0xff );
}
-
+
for ( ; i < record_length; i++ )
- { sprintf ( buffer + strlen ( buffer ), " " ); }
-
+ {
+ sprintf ( buffer + strlen ( buffer ), " " );
+ }
+
sprintf ( buffer + strlen ( buffer ), ": " );
-
- for ( i = 0; i < count; i++ ) {
- if ( isgraph ( data[i] ) ) {
+
+ for ( i = 0; i < count; i++ )
+ {
+ if ( isgraph ( data[i] ) )
+ {
buffer[strlen ( buffer ) + 1] = '\0';
buffer[strlen ( buffer )] = data[i];
}
-
- else {
+
+ else
+ {
buffer[strlen ( buffer ) + 1] = '\0';
buffer[strlen ( buffer )] = '.';
}
}
-
+
buffer[strlen ( buffer ) + 1] = '\0';
buffer[strlen ( buffer )] = '\n';
}
//dump 16 * lines bytes, readable test stored in buffer, reserve 100 bytes in buffer for one line
-void hexDump ( char* data, int lines, char* buffer, bool forward ) {
- if ( !forward ) {
+void hexDump ( char* data, int lines, char* buffer, bool forward )
+{
+ if ( !forward )
+ {
data -= lines * 16;
}
-
+
buffer[0] = '\0';
-
- for ( int i = 0 ; i < lines ; ++i ) {
+
+ for ( int i = 0; i < lines; ++i )
+ {
sprintf ( buffer + strlen ( buffer ), "%10d ", data );
bufferHexRecord ( data, 16, 16, buffer );
data += 16;
}
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/Dump.h
----------------------------------------------------------------------
diff --git a/odbc/Common/Dump.h b/odbc/Common/Dump.h
index 53b980c..cbf7d05 100644
--- a/odbc/Common/Dump.h
+++ b/odbc/Common/Dump.h
@@ -15,8 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#pragma once
-void hexDump ( char* data, int lines, char* buffer, bool forward );
\ No newline at end of file
+void hexDump ( char* data, int lines, char* buffer, bool forward );
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/Gzip.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/Gzip.cpp b/odbc/Common/Gzip.cpp
index 220a1b8..a5ff63a 100644
--- a/odbc/Common/Gzip.cpp
+++ b/odbc/Common/Gzip.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include <cstdio>
#include <string>
#include <cstring>
@@ -26,62 +26,74 @@
using namespace std;
-bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes ) {
- if ( compressedBytes.size() == 0 ) {
+bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes )
+{
+ if ( compressedBytes . size () == 0 )
+ {
uncompressedBytes = compressedBytes ;
return true ;
}
-
- uncompressedBytes.clear() ;
- unsigned full_length = compressedBytes.size() ;
- unsigned half_length = compressedBytes.size() / 2;
- unsigned uncompLength = full_length ;
- char* uncomp = ( char* ) calloc ( sizeof ( char ), uncompLength );
+
+ uncompressedBytes . clear () ;
+ unsigned full_length = compressedBytes . size ();
+ unsigned half_length = compressedBytes . size () / 2;
+ unsigned uncompLength = full_length;
+ char* uncomp = ( char* ) calloc ( sizeof ( char), uncompLength );
z_stream strm;
- strm.next_in = ( Bytef* ) compressedBytes.c_str();
- strm.avail_in = compressedBytes.size() ;
- strm.total_out = 0;
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- bool done = false ;
-
- if ( inflateInit2 ( &strm, ( 16 + MAX_WBITS ) ) != Z_OK ) {
+ strm . next_in = ( Bytef* ) compressedBytes . c_str ();
+ strm . avail_in = compressedBytes . size () ;
+ strm . total_out = 0;
+ strm . zalloc = Z_NULL ;
+ strm . zfree = Z_NULL ;
+ bool done = false;
+
+ if ( inflateInit2 ( &strm, ( 16 + MAX_WBITS ) ) != Z_OK )
+ {
free ( uncomp );
return false;
}
-
- while ( !done ) {
+
+ while ( !done )
+ {
// If our output buffer is too small
- if ( strm.total_out >= uncompLength ) {
+ if ( strm . total_out >= uncompLength )
+ {
// Increase size of output buffer
- char* uncomp2 = ( char* ) calloc ( sizeof ( char ), uncompLength + half_length );
+ char* uncomp2 = ( char* ) calloc ( sizeof ( char), uncompLength + half_length );
memcpy ( uncomp2, uncomp, uncompLength );
uncompLength += half_length ;
free ( uncomp );
uncomp = uncomp2 ;
}
-
- strm.next_out = ( Bytef* ) ( uncomp + strm.total_out );
- strm.avail_out = uncompLength - strm.total_out;
+
+ strm . next_out = ( Bytef* ) ( uncomp + strm . total_out );
+ strm . avail_out = uncompLength - strm . total_out;
// Inflate another chunk.
int err = inflate ( &strm, Z_SYNC_FLUSH );
-
- if ( err == Z_STREAM_END ) { done = true; }
-
- else if ( err != Z_OK ) {
+
+ if ( err == Z_STREAM_END )
+ {
+ done = true;
+ }
+
+ else if ( err != Z_OK )
+ {
break;
}
}
-
- if ( inflateEnd ( &strm ) != Z_OK ) {
+
+ if ( inflateEnd ( &strm ) != Z_OK )
+ {
free ( uncomp );
return false;
}
-
- for ( size_t i = 0; i < strm.total_out; ++i ) {
- uncompressedBytes += uncomp[ i ];
+
+ for ( size_t i = 0; i < strm . total_out; ++i )
+ {
+ uncompressedBytes += uncomp[i];
}
-
+
free ( uncomp );
return true ;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/Gzip.h
----------------------------------------------------------------------
diff --git a/odbc/Common/Gzip.h b/odbc/Common/Gzip.h
index 144ea7c..87264e2 100644
--- a/odbc/Common/Gzip.h
+++ b/odbc/Common/Gzip.h
@@ -15,9 +15,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#pragma once
#include <string>
-bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes );
\ No newline at end of file
+bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes );
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/JDBCODBC.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/JDBCODBC.cpp b/odbc/Common/JDBCODBC.cpp
index a3b056e..b5aa911 100644
--- a/odbc/Common/JDBCODBC.cpp
+++ b/odbc/Common/JDBCODBC.cpp
@@ -15,136 +15,139 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include "JDBCODBC.h"
-ODBCTypes JDBC2ODBC ( int jtype ) {
+ODBCTypes JDBC2ODBC ( int jtype )
+{
JDBCTypes temp = ( JDBCTypes ) jtype;
-
- switch ( temp ) {
- case JDBC_BOOLEAN:
+
+ switch ( temp )
+ {
+ case JDBC_BOOLEAN :
return ODBCTypes::ODBC_Bit ;
break;
-
- case JDBC_BIT:
+
+ case JDBC_BIT :
return ODBCTypes::ODBC_Bit;
break;
-
- case JDBC_TINYINT:
+
+ case JDBC_TINYINT :
return ODBCTypes::ODBC_TinyInt;
break;
-
- case JDBC_SMALLINT:
+
+ case JDBC_SMALLINT :
return ODBCTypes::ODBC_SmallInt;
break;
-
- case JDBC_INTEGER:
+
+ case JDBC_INTEGER :
return ODBCTypes::ODBC_Integer;
break;
-
- case JDBC_BIGINT:
+
+ case JDBC_BIGINT :
return ODBCTypes::ODBC_BigInt;
break;
-
- case JDBC_FLOAT:
+
+ case JDBC_FLOAT :
return ODBCTypes::ODBC_Float;
break;
-
- case JDBC_REAL:
+
+ case JDBC_REAL :
return ODBCTypes::ODBC_Real;
break;
-
- case JDBC_DOUBLE:
+
+ case JDBC_DOUBLE :
return ODBCTypes::ODBC_Double;
break;
-
- case JDBC_NUMERIC:
+
+ case JDBC_NUMERIC :
return ODBCTypes::ODBC_Numeric;
break;
-
- case JDBC_DECIMAL:
+
+ case JDBC_DECIMAL :
return ODBCTypes::ODBC_Decimal;
break;
-
- case JDBC_CHAR:
+
+ case JDBC_CHAR :
return ODBCTypes::ODBC_Char;
//return ODBCTypes::ODBC_WChar;//it's a unicode dirver
break;
-
- case JDBC_VARCHAR:
+
+ case JDBC_VARCHAR :
return ODBCTypes::ODBC_VarChar;
//return ODBCTypes::ODBC_WChar;//it's a unicode dirver
break;
-
- case 2000://"ANY" type in KYLIN
+
+ case 2000 : //"ANY" type in KYLIN
return ODBCTypes::ODBC_WChar;//it's a unicode dirver
break;
-
- case JDBC_LONGVARCHAR:
+
+ case JDBC_LONGVARCHAR :
return ODBCTypes::ODBC_LongVarChar;
break;
-
- case JDBC_DATE:
+
+ case JDBC_DATE :
return ODBCTypes::ODBC_Type_Date;
break;
-
- case JDBC_TIME:
+
+ case JDBC_TIME :
return ODBCTypes::ODBC_Type_Time;
break;
-
- case JDBC_TIMESTAMP:
+
+ case JDBC_TIMESTAMP :
return ODBCTypes::ODBC_Type_Timestamp;
break;
-
- case JDBC_BINARY:
+
+ case JDBC_BINARY :
return ODBCTypes::ODBC_Binary;
break;
-
- case JDBC_VARBINARY:
+
+ case JDBC_VARBINARY :
return ODBCTypes::ODBC_VarBinary;
break;
-
- case JDBC_LONGVARBINARY:
+
+ case JDBC_LONGVARBINARY :
return ODBCTypes::ODBC_LongVarBinary;
break;
-
- /* case NULL:
- break;
- case OTHER:
- break;
- case JAVA_OBJECT:
- break;
- case DISTINCT:
- break;
- case STRUCT:
- break;
- case ARRAY:
- break;
- case BLOB:
- break;
- case CLOB:
- break;
- case REF:
- break;
- case DATALINK:
- break;
- case BOOLEAN:
- break;
- case ROWID:
- break;
- case NCHAR:
- break;
- case NVARCHAR:
- break;
- case LONGNVARCHAR:
- break;
- case NCLOB:
- break;
- case SQLXML:
- break;*/
- default:
+
+ /* case NULL:
+ break;
+ case OTHER:
+ break;
+ case JAVA_OBJECT:
+ break;
+ case DISTINCT:
+ break;
+ case STRUCT:
+ break;
+ case ARRAY:
+ break;
+ case BLOB:
+ break;
+ case CLOB:
+ break;
+ case REF:
+ break;
+ case DATALINK:
+ break;
+ case BOOLEAN:
+ break;
+ case ROWID:
+ break;
+ case NCHAR:
+ break;
+ case NVARCHAR:
+ break;
+ case LONGNVARCHAR:
+ break;
+ case NCLOB:
+ break;
+ case SQLXML:
+ break;*/
+ default :
throw;
break;
}
-};
\ No newline at end of file
+};
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/JDBCODBC.h
----------------------------------------------------------------------
diff --git a/odbc/Common/JDBCODBC.h b/odbc/Common/JDBCODBC.h
index e5c9eef..72e2fd7 100644
--- a/odbc/Common/JDBCODBC.h
+++ b/odbc/Common/JDBCODBC.h
@@ -15,157 +15,156 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
-#pragma once
+#pragma once
-enum JDBCTypes {
+enum JDBCTypes
+{
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>BIT</code>.
*/
JDBC_BIT = -7,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>TINYINT</code>.
*/
JDBC_TINYINT = -6,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>SMALLINT</code>.
*/
JDBC_SMALLINT = 5,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>INTEGER</code>.
*/
JDBC_INTEGER = 4,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>BIGINT</code>.
*/
JDBC_BIGINT = -5,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>FLOAT</code>.
*/
JDBC_FLOAT = 6,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>REAL</code>.
*/
JDBC_REAL = 7,
-
-
+
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>DOUBLE</code>.
*/
JDBC_DOUBLE = 8,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>NUMERIC</code>.
*/
JDBC_NUMERIC = 2,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>DECIMAL</code>.
*/
JDBC_DECIMAL = 3,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>CHAR</code>.
*/
JDBC_CHAR = 1,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>VARCHAR</code>.
*/
JDBC_VARCHAR = 12,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>LONGVARCHAR</code>.
*/
JDBC_LONGVARCHAR = -1,
-
-
+
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>DATE</code>.
*/
JDBC_DATE = 91,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>TIME</code>.
*/
JDBC_TIME = 92,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>TIMESTAMP</code>.
*/
JDBC_TIMESTAMP = 93,
-
-
+
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>BINARY</code>.
*/
JDBC_BINARY = -2,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>VARBINARY</code>.
*/
JDBC_VARBINARY = -3,
-
+
/**
<P>The constant in the Java programming language, sometimes referred
to as a type code, that identifies the generic SQL type
<code>LONGVARBINARY</code>.
*/
JDBC_LONGVARBINARY = -4,
-
+
/**
<P>The constant in the Java programming language
that identifies the generic SQL value
<code>NULL</code>.
*/
//NULL = 0,
-
+
/**
The constant in the Java programming language that indicates
that the SQL type is database-specific and
@@ -173,9 +172,8 @@ enum JDBCTypes {
the methods <code>getObject</code> and <code>setObject</code>.
*/
JDBC_OTHER = 1111,
-
-
-
+
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -183,7 +181,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_JAVA_OBJECT = 2000,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -191,7 +189,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_DISTINCT = 2001,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -199,7 +197,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_STRUCT = 2002,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -207,7 +205,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_ARRAY = 2003,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -215,7 +213,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_BLOB = 2004,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -223,7 +221,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_CLOB = 2005,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type
@@ -231,7 +229,7 @@ enum JDBCTypes {
@since 1.2
*/
JDBC_REF = 2006,
-
+
/**
The constant in the Java programming language, somtimes referred to
as a type code, that identifies the generic SQL type <code>DATALINK</code>.
@@ -239,7 +237,7 @@ enum JDBCTypes {
@since 1.4
*/
JDBC_DATALINK = 70,
-
+
/**
The constant in the Java programming language, somtimes referred to
as a type code, that identifies the generic SQL type <code>BOOLEAN</code>.
@@ -247,9 +245,9 @@ enum JDBCTypes {
@since 1.4
*/
JDBC_BOOLEAN = 16,
-
+
//------------------------- JDBC 4.0 -----------------------------------
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>ROWID</code>
@@ -258,7 +256,7 @@ enum JDBCTypes {
*/
JDBC_ROWID = -8,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>NCHAR</code>
@@ -266,7 +264,7 @@ enum JDBCTypes {
@since 1.6
*/
JDBC_NCHAR = -15,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
@@ -274,7 +272,7 @@ enum JDBCTypes {
@since 1.6
*/
JDBC_NVARCHAR = -9,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
@@ -282,7 +280,7 @@ enum JDBCTypes {
@since 1.6
*/
JDBC_LONGNVARCHAR = -16,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>NCLOB</code>.
@@ -290,7 +288,7 @@ enum JDBCTypes {
@since 1.6
*/
JDBC_NCLOB = 2011,
-
+
/**
The constant in the Java programming language, sometimes referred to
as a type code, that identifies the generic SQL type <code>XML</code>.
@@ -300,7 +298,8 @@ enum JDBCTypes {
JDBC_SQLXML = 2009
};
-enum ODBCTypes {
+enum ODBCTypes
+{
// Summary:
// Maps to SQL_GUID.
ODBC_Guid = -11,
@@ -460,3 +459,4 @@ enum ODBCTypes {
};
ODBCTypes JDBC2ODBC ( int jtype );
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/JsonConverter.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/JsonConverter.cpp b/odbc/Common/JsonConverter.cpp
index 3e081ad..bdca480 100644
--- a/odbc/Common/JsonConverter.cpp
+++ b/odbc/Common/JsonConverter.cpp
@@ -15,16 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include "JsonConverter.h"
#define ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=y.z
#define x_ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=wstring2string(y.z)
-TableMeta* TableMetaFromJSON ( web::json::value & object ) {
- TableMeta* result = new TableMeta();
+TableMeta* TableMetaFromJSON ( web::json::value& object )
+{
+ TableMeta* result = new TableMeta ();
x_ASSIGN_IF_NOT_NULL ( result->TABLE_CAT, object[U ( "table_CAT" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->TABLE_SCHEM , object[U ( "table_SCHEM" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->TABLE_NAME , object[U ( "table_NAME" )], as_string() );
@@ -38,8 +39,9 @@ TableMeta* TableMetaFromJSON ( web::json::value & object ) {
return result;
}
-ColumnMeta* ColumnMetaFromJSON ( web::json::value & object ) {
- ColumnMeta* result = new ColumnMeta();
+ColumnMeta* ColumnMetaFromJSON ( web::json::value& object )
+{
+ ColumnMeta* result = new ColumnMeta ();
x_ASSIGN_IF_NOT_NULL ( result->TABLE_CAT , object[U ( "table_CAT" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->TABLE_SCHEM , object[U ( "table_SCHEM" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->TABLE_NAME , object[U ( "table_NAME" )], as_string() );
@@ -62,42 +64,50 @@ ColumnMeta* ColumnMetaFromJSON ( web::json::value & object ) {
x_ASSIGN_IF_NOT_NULL ( result->SCOPE_SCHEMA , object[U ( "scope_SCHEMA" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->SCOPE_TABLE , object[U ( "scope_TABLE" )], as_string() );
x_ASSIGN_IF_NOT_NULL ( result->IS_AUTOINCREMENT , object[U ( "iS_AUTOINCREMENT" )], as_string() );
-
- if ( !object[U ( "source_DATA_TYPE" )].is_null() ) {
- result->SOURCE_DATA_TYPE = ( short ) object[U ( "source_DATA_TYPE" )].as_integer();
+
+ if ( !object[U ( "source_DATA_TYPE" )] . is_null () )
+ {
+ result -> SOURCE_DATA_TYPE = ( short ) object[U ( "source_DATA_TYPE" )] . as_integer ();
}
-
+
// the orig value passed from REST is java.sql.Types, we convert it to SQL Type
-
- if ( !object[U ( "data_TYPE" )].is_null() ) {
- result->DATA_TYPE = JDBC2ODBC ( object[U ( "data_TYPE" )].as_integer() );
+
+ if ( !object[U ( "data_TYPE" )] . is_null () )
+ {
+ result -> DATA_TYPE = JDBC2ODBC ( object[U ( "data_TYPE" )] . as_integer () );
}
-
- if ( !object[U ( "sql_DATA_TYPE" )].is_null() ) {
- result->SQL_DATA_TYPE = JDBC2ODBC ( object[U ( "sql_DATA_TYPE" )].as_integer() );
+
+ if ( !object[U ( "sql_DATA_TYPE" )] . is_null () )
+ {
+ result -> SQL_DATA_TYPE = JDBC2ODBC ( object[U ( "sql_DATA_TYPE" )] . as_integer () );
}
-
+
return result;
}
-std::unique_ptr<MetadataResponse> MetadataResponseFromJSON ( web::json::value & object ) {
- std::unique_ptr<MetadataResponse> result ( new MetadataResponse() );
- web::json::array& tableMetaArray = object.as_array();
-
- for ( auto iter = tableMetaArray.begin(); iter != tableMetaArray.end(); ++iter ) {
- result->tableMetas.push_back ( TableMetaFromJSON ( *iter ) );
- web::json::value& columns = ( *iter ) [U ( "columns" )];
- web::json::array& columnsMetaArray = columns.as_array();
-
- for ( auto inner_iter = columnsMetaArray.begin(); inner_iter != columnsMetaArray.end(); ++inner_iter ) {
- result->columnMetas.push_back ( ColumnMetaFromJSON ( *inner_iter ) );
+std::unique_ptr <MetadataResponse> MetadataResponseFromJSON ( web::json::value& object )
+{
+ std::unique_ptr <MetadataResponse> result ( new MetadataResponse () );
+ web::json::array& tableMetaArray = object . as_array ();
+
+ for ( auto iter = tableMetaArray . begin (); iter != tableMetaArray . end (); ++iter )
+ {
+ result -> tableMetas . push_back ( TableMetaFromJSON ( *iter ) );
+ web::json::value& columns = ( *iter )[U ( "columns" )];
+ web::json::array& columnsMetaArray = columns . as_array ();
+
+ for ( auto inner_iter = columnsMetaArray . begin (); inner_iter != columnsMetaArray . end (); ++inner_iter )
+ {
+ result -> columnMetas . push_back ( ColumnMetaFromJSON ( *inner_iter ) );
}
}
-
+
return result;
}
-SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value & object ) {
- SelectedColumnMeta* result = new SelectedColumnMeta();
+
+SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value& object )
+{
+ SelectedColumnMeta* result = new SelectedColumnMeta ();
ASSIGN_IF_NOT_NULL ( result->isAutoIncrement , object[U ( "autoIncrement" )], as_bool() );
ASSIGN_IF_NOT_NULL ( result->isCaseSensitive , object[U ( "caseSensitive" )], as_bool() );
ASSIGN_IF_NOT_NULL ( result->isSearchable , object[U ( "searchable" )], as_bool() );
@@ -117,58 +127,71 @@ SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value & object ) {
ASSIGN_IF_NOT_NULL ( result->isReadOnly , object[U ( "readOnly" )], as_bool() );
ASSIGN_IF_NOT_NULL ( result->isWritable , object[U ( "writable" )], as_bool() );
ASSIGN_IF_NOT_NULL ( result->isDefinitelyWritable , object[U ( "definitelyWritable" )], as_bool() );
-
- if ( !object[U ( "columnType" )].is_null() ) {
- result->columnType = JDBC2ODBC ( object[U ( "columnType" )].as_integer() );
+
+ if ( !object[U ( "columnType" )] . is_null () )
+ {
+ result -> columnType = JDBC2ODBC ( object[U ( "columnType" )] . as_integer () );
}
-
+
return result;
}
-void constructUnflattenResults ( SQLResponse* result, web::json::value& o_results ) {
- if ( o_results.is_null() )
- { return; }
-
- for ( auto iter = o_results.as_array().begin(); iter != o_results.as_array().end(); ++iter ) {
- SQLRowContent* row = new SQLRowContent();
-
- for ( auto jter = iter->as_array().begin(); jter != iter->as_array().end(); ++jter ) {
- if ( jter->is_null() ) {
+void constructUnflattenResults ( SQLResponse* result, web::json::value& o_results )
+{
+ if ( o_results . is_null () )
+ {
+ return;
+ }
+
+ for ( auto iter = o_results . as_array () . begin (); iter != o_results . as_array () . end (); ++iter )
+ {
+ SQLRowContent* row = new SQLRowContent ();
+
+ for ( auto jter = iter -> as_array () . begin (); jter != iter -> as_array () . end (); ++jter )
+ {
+ if ( jter -> is_null () )
+ {
wstring emptyCell;
- row->contents.push_back ( emptyCell );
+ row -> contents . push_back ( emptyCell );
}
-
- else {
- row->contents.push_back ( ( jter->as_string() ) );
+
+ else
+ {
+ row -> contents . push_back ( ( jter -> as_string () ) );
}
}
-
- result->results.push_back ( row );
+
+ result -> results . push_back ( row );
}
}
-std::unique_ptr<SQLResponse> SQLResponseFromJSON ( web::json::value & object ) {
- std::unique_ptr<SQLResponse> result ( new SQLResponse() );
+std::unique_ptr <SQLResponse> SQLResponseFromJSON ( web::json::value& object )
+{
+ std::unique_ptr <SQLResponse> result ( new SQLResponse () );
- result->affectedRowCount = object[U ( "affectedRowCount" )].as_integer();
- result->isException = object[U ( "isException" )].as_bool();
+ result -> affectedRowCount = object[U ( "affectedRowCount" )] . as_integer ();
+ result -> isException = object[U ( "isException" )] . as_bool ();
ASSIGN_IF_NOT_NULL ( result->exceptionMessage, object[U ( "exceptionMessage" )], as_string() );
-
- if ( object[U ( "columnMetas" )].is_array()) {
- web::json::array& columnMetasArray = object[U ( "columnMetas" )].as_array();
- for ( auto iter = columnMetasArray.begin(); iter != columnMetasArray.end(); ++iter ) {
- result->columnMetas.push_back ( SelectedColumnMetaFromJSON ( *iter ) );
+
+ if ( object[U ( "columnMetas" )] . is_array () )
+ {
+ web::json::array& columnMetasArray = object[U ( "columnMetas" )] . as_array ();
+ for ( auto iter = columnMetasArray . begin (); iter != columnMetasArray . end (); ++iter )
+ {
+ result -> columnMetas . push_back ( SelectedColumnMetaFromJSON ( *iter ) );
}
}
-
- constructUnflattenResults ( result.get(), object[U ( "results" )] );
+
+ constructUnflattenResults ( result . get (), object[U ( "results" )] );
return result;
}
-std::unique_ptr<ErrorMessage> ErrorMessageFromJSON ( web::json::value & object ) {
- std::unique_ptr<ErrorMessage> result ( new ErrorMessage() );
+std::unique_ptr <ErrorMessage> ErrorMessageFromJSON ( web::json::value& object )
+{
+ std::unique_ptr <ErrorMessage> result ( new ErrorMessage () );
ASSIGN_IF_NOT_NULL ( result->url, object[U ( "url" )], as_string() );
ASSIGN_IF_NOT_NULL ( result->msg, object[U ( "exception" )], as_string() );
return result;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/JsonConverter.h
----------------------------------------------------------------------
diff --git a/odbc/Common/JsonConverter.h b/odbc/Common/JsonConverter.h
index c34c4c6..b3f2a6f 100644
--- a/odbc/Common/JsonConverter.h
+++ b/odbc/Common/JsonConverter.h
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#pragma once
@@ -23,9 +23,10 @@
#include "cpprest/asyncrt_utils.h"
#include "MsgTypes.h"
-TableMeta* TableMetaFromJSON ( web::json::value & object );
-ColumnMeta* ColumnMetaFromJSON ( web::json::value & object );
-SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value & object );
-std::unique_ptr<MetadataResponse> MetadataResponseFromJSON ( web::json::value & object );
-std::unique_ptr<SQLResponse> SQLResponseFromJSON ( web::json::value & object );
-std::unique_ptr<ErrorMessage> ErrorMessageFromJSON ( web::json::value & object );
+TableMeta* TableMetaFromJSON ( web::json::value& object );
+ColumnMeta* ColumnMetaFromJSON ( web::json::value& object );
+SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value& object );
+std::unique_ptr <MetadataResponse> MetadataResponseFromJSON ( web::json::value& object );
+std::unique_ptr <SQLResponse> SQLResponseFromJSON ( web::json::value& object );
+std::unique_ptr <ErrorMessage> ErrorMessageFromJSON ( web::json::value& object );
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/MsgTypes.h
----------------------------------------------------------------------
diff --git a/odbc/Common/MsgTypes.h b/odbc/Common/MsgTypes.h
index d898bf1..718f0b9 100644
--- a/odbc/Common/MsgTypes.h
+++ b/odbc/Common/MsgTypes.h
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
// ----------------------------------------------------------------------------
//
// File: MsgTypes.h
@@ -40,8 +40,9 @@
using namespace std;
-class TableMeta {
- public:
+class TableMeta
+{
+ public:
string TABLE_CAT;
string TABLE_SCHEM;
string TABLE_NAME;
@@ -52,11 +53,11 @@ class TableMeta {
string TYPE_NAME;
string SELF_REFERENCING_COL_NAME;
string REF_GENERATION;
-
};
-class ColumnMeta {
- public:
+class ColumnMeta
+{
+ public:
string TABLE_CAT;
string TABLE_SCHEM;
string TABLE_NAME;
@@ -80,355 +81,371 @@ class ColumnMeta {
string SCOPE_TABLE;
short SOURCE_DATA_TYPE;
string IS_AUTOINCREMENT;
-
};
-class MetadataResponse {
- public:
- std::vector<TableMeta*> tableMetas;
- std::vector<ColumnMeta*> columnMetas;
-
- ~MetadataResponse() {
- for ( std::vector<TableMeta*>::size_type i = 0 ; i < tableMetas.size(); ++i ) {
- TableMeta* p = tableMetas.at ( i );
+class MetadataResponse
+{
+ public:
+ std::vector <TableMeta*> tableMetas;
+ std::vector <ColumnMeta*> columnMetas;
+
+ ~MetadataResponse ()
+ {
+ for ( std::vector <TableMeta*>::size_type i = 0; i < tableMetas . size (); ++i )
+ {
+ TableMeta* p = tableMetas . at ( i );
delete p;
}
-
- for ( std::vector<ColumnMeta*>::size_type i = 0 ; i < columnMetas.size(); ++i ) {
- ColumnMeta* p = columnMetas.at ( i );
+
+ for ( std::vector <ColumnMeta*>::size_type i = 0; i < columnMetas . size (); ++i )
+ {
+ ColumnMeta* p = columnMetas . at ( i );
delete p;
}
}
-
};
-class SelectedColumnMeta {
- public:
+class SelectedColumnMeta
+{
+ public:
bool isAutoIncrement;
bool isCaseSensitive;
bool isSearchable;
bool isCurrency;
- int isNullable ;//0:nonull, 1:nullable, 2: nullableunknown
- bool isSigned ;
+ int isNullable;//0:nonull, 1:nullable, 2: nullableunknown
+ bool isSigned;
int displaySize;
string label;// AS keyword
- string name ;
- string schemaName ;
+ string name;
+ string schemaName;
string catelogName;
string tableName;
int precision;
int scale;
- int columnType ;// the orig value passed from REST is java.sql.Types, we convert it to SQL Type
- string columnTypeName ;
+ int columnType;// the orig value passed from REST is java.sql.Types, we convert it to SQL Type
+ string columnTypeName;
bool isReadOnly;
- bool isWritable ;
- bool isDefinitelyWritable ;
-
+ bool isWritable;
+ bool isDefinitelyWritable;
};
-class SQLRowContent {
- public:
- std::vector<wstring> contents;
-
+class SQLRowContent
+{
+ public:
+ std::vector <wstring> contents;
};
-class SQLResponse {
- public:
+class SQLResponse
+{
+ public:
// the data type for each column
- std::vector<SelectedColumnMeta*> columnMetas;
-
+ std::vector <SelectedColumnMeta*> columnMetas;
+
// the results rows, each row contains several columns
- std::vector<SQLRowContent*> results;
-
+ std::vector <SQLRowContent*> results;
+
// if not select query, only return affected row count
int affectedRowCount;
-
+
// flag indicating whether an exception occurred
bool isException;
-
+
// if isException, the detailed exception message
wstring exceptionMessage;
-
- ~SQLResponse() {
- for ( std::vector<SelectedColumnMeta*>::size_type i = 0 ; i < columnMetas.size(); ++i ) {
- SelectedColumnMeta* p = columnMetas.at ( i );
+
+ ~SQLResponse ()
+ {
+ for ( std::vector <SelectedColumnMeta*>::size_type i = 0; i < columnMetas . size (); ++i )
+ {
+ SelectedColumnMeta* p = columnMetas . at ( i );
delete p;
}
-
- for ( std::vector<SQLRowContent*>::size_type i = 0 ; i < results.size(); ++i ) {
- SQLRowContent* p = results.at ( i );
+
+ for ( std::vector <SQLRowContent*>::size_type i = 0; i < results . size (); ++i )
+ {
+ SQLRowContent* p = results . at ( i );
delete p;
}
}
-
- static std::unique_ptr<SQLResponse> MakeResp4SQLTables ( MetadataResponse* meta ) {
- std::unique_ptr<SQLResponse> ret ( new SQLResponse() );
- FillColumnMetas4SQLTables ( ret.get() );
-
- for ( auto i = meta->tableMetas.begin(); i != meta->tableMetas.end(); i++ ) {
- SQLRowContent* temp = new SQLRowContent();
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_CAT ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_SCHEM ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_NAME ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_TYPE ) );
- temp->contents.push_back ( string2wstring ( ( *i )->REMARKS ) );
- ret->results.push_back ( temp );
+
+ static std::unique_ptr <SQLResponse> MakeResp4SQLTables ( MetadataResponse* meta )
+ {
+ std::unique_ptr <SQLResponse> ret ( new SQLResponse () );
+ FillColumnMetas4SQLTables ( ret . get () );
+
+ for ( auto i = meta -> tableMetas . begin (); i != meta -> tableMetas . end (); i++ )
+ {
+ SQLRowContent* temp = new SQLRowContent ();
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_CAT ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_SCHEM ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_NAME ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_TYPE ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> REMARKS ) );
+ ret -> results . push_back ( temp );
}
-
+
return ret;
}
-
- static std::unique_ptr<SQLResponse> MakeResp4SQLColumns ( MetadataResponse* meta, char* tableName, char* columnName ) {
- std::unique_ptr<SQLResponse> ret ( new SQLResponse() );
- FillColumnMetas4SQLColumns ( ret.get() );
-
- for ( auto i = meta->columnMetas.begin(); i != meta->columnMetas.end(); i++ ) {
+
+ static std::unique_ptr <SQLResponse> MakeResp4SQLColumns ( MetadataResponse* meta, char* tableName, char* columnName )
+ {
+ std::unique_ptr <SQLResponse> ret ( new SQLResponse () );
+ FillColumnMetas4SQLColumns ( ret . get () );
+
+ for ( auto i = meta -> columnMetas . begin (); i != meta -> columnMetas . end (); i++ )
+ {
//filter
- if ( tableName != NULL && _stricmp ( tableName, ( *i )->TABLE_NAME.c_str() ) != 0 )
- { continue; }
-
- if ( columnName != NULL && _stricmp ( columnName, ( *i )->COLUMN_NAME.c_str() ) != 0 )
- { continue; }
-
- SQLRowContent* temp = new SQLRowContent();
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_CAT ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_SCHEM ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TABLE_NAME ) );
- temp->contents.push_back ( string2wstring ( ( *i )->COLUMN_NAME ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->DATA_TYPE ) ) );
- temp->contents.push_back ( string2wstring ( ( *i )->TYPE_NAME ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->COLUMN_SIZE ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->BUFFER_LENGTH ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->DECIMAL_DIGITS ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->NUM_PREC_RADIX ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->NULLABLE ) ) );
- temp->contents.push_back ( string2wstring ( ( *i )->REMARKS ) );
- temp->contents.push_back ( string2wstring ( ( *i )->COLUMN_DEF ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->SQL_DATA_TYPE ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->SQL_DATETIME_SUB ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->CHAR_OCTET_LENGTH ) ) );
- temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->ORDINAL_POSITION ) ) );
- temp->contents.push_back ( string2wstring ( ( *i )->IS_NULLABLE ) );
- temp->contents.push_back ( L"0" ); //user_data_type
- ret->results.push_back ( temp );
+ if ( tableName != NULL && _stricmp ( tableName, ( *i ) -> TABLE_NAME . c_str () ) != 0 )
+ {
+ continue;
+ }
+
+ if ( columnName != NULL && _stricmp ( columnName, ( *i ) -> COLUMN_NAME . c_str () ) != 0 )
+ {
+ continue;
+ }
+
+ SQLRowContent* temp = new SQLRowContent ();
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_CAT ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_SCHEM ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TABLE_NAME ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> COLUMN_NAME ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> DATA_TYPE ) ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> TYPE_NAME ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> COLUMN_SIZE ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> BUFFER_LENGTH ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> DECIMAL_DIGITS ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> NUM_PREC_RADIX ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> NULLABLE ) ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> REMARKS ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> COLUMN_DEF ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> SQL_DATA_TYPE ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> SQL_DATETIME_SUB ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> CHAR_OCTET_LENGTH ) ) );
+ temp -> contents . push_back ( string2wstring ( std::to_string ( ( *i ) -> ORDINAL_POSITION ) ) );
+ temp -> contents . push_back ( string2wstring ( ( *i ) -> IS_NULLABLE ) );
+ temp -> contents . push_back ( L"0" ); //user_data_type
+ ret -> results . push_back ( temp );
}
-
+
return ret;
}
-
- static std::string GetString ( int i ) {
+
+ static std::string GetString ( int i )
+ {
std::ostringstream ss;
ss << i;
- return ss.str();
+ return ss . str ();
}
-
- static void FillColumnMetas4SQLTables ( SQLResponse* sqlResp ) {
- SelectedColumnMeta* m1 = new SelectedColumnMeta();
- m1->label = "TABLE_CAT";
- m1->name = "TABLE_CAT";
- m1->displaySize = 128;
- m1->scale = 0;
- m1->isNullable = 1;
- m1->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m2 = new SelectedColumnMeta();
- m2->label = "TABLE_SCHEM";
- m2->name = "TABLE_SCHEM";
- m2->displaySize = 128;
- m2->scale = 0;
- m2->isNullable = 1;
- m2->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m3 = new SelectedColumnMeta();
- m3->label = "TABLE_NAME";
- m3->name = "TABLE_NAME";
- m3->displaySize = 128;
- m3->scale = 0;
- m3->isNullable = 1;
- m3->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m4 = new SelectedColumnMeta();
- m4->label = "TABLE_TYPE";
- m4->name = "TABLE_TYPE";
- m4->displaySize = 32;
- m4->scale = 0;
- m4->isNullable = 1;
- m4->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m5 = new SelectedColumnMeta();
- m5->label = "REMARKS";
- m5->name = "REMARKS";
- m5->displaySize = 254;
- m5->scale = 0;
- m5->isNullable = 1;
- m5->columnType = ODBCTypes::ODBC_WVarChar;
- sqlResp->columnMetas.push_back ( m1 );
- sqlResp->columnMetas.push_back ( m2 );
- sqlResp->columnMetas.push_back ( m3 );
- sqlResp->columnMetas.push_back ( m4 );
- sqlResp->columnMetas.push_back ( m5 );
+
+ static void FillColumnMetas4SQLTables ( SQLResponse* sqlResp )
+ {
+ SelectedColumnMeta* m1 = new SelectedColumnMeta ();
+ m1 -> label = "TABLE_CAT";
+ m1 -> name = "TABLE_CAT";
+ m1 -> displaySize = 128;
+ m1 -> scale = 0;
+ m1 -> isNullable = 1;
+ m1 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m2 = new SelectedColumnMeta ();
+ m2 -> label = "TABLE_SCHEM";
+ m2 -> name = "TABLE_SCHEM";
+ m2 -> displaySize = 128;
+ m2 -> scale = 0;
+ m2 -> isNullable = 1;
+ m2 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m3 = new SelectedColumnMeta ();
+ m3 -> label = "TABLE_NAME";
+ m3 -> name = "TABLE_NAME";
+ m3 -> displaySize = 128;
+ m3 -> scale = 0;
+ m3 -> isNullable = 1;
+ m3 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m4 = new SelectedColumnMeta ();
+ m4 -> label = "TABLE_TYPE";
+ m4 -> name = "TABLE_TYPE";
+ m4 -> displaySize = 32;
+ m4 -> scale = 0;
+ m4 -> isNullable = 1;
+ m4 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m5 = new SelectedColumnMeta ();
+ m5 -> label = "REMARKS";
+ m5 -> name = "REMARKS";
+ m5 -> displaySize = 254;
+ m5 -> scale = 0;
+ m5 -> isNullable = 1;
+ m5 -> columnType = ODBCTypes::ODBC_WVarChar;
+ sqlResp -> columnMetas . push_back ( m1 );
+ sqlResp -> columnMetas . push_back ( m2 );
+ sqlResp -> columnMetas . push_back ( m3 );
+ sqlResp -> columnMetas . push_back ( m4 );
+ sqlResp -> columnMetas . push_back ( m5 );
}
-
- static void FillColumnMetas4SQLColumns ( SQLResponse* sqlResp ) {
- SelectedColumnMeta* m1 = new SelectedColumnMeta();
- m1->label = "TABLE_CAT";
- m1->name = "TABLE_CAT";
- m1->displaySize = 128;
- m1->scale = 0;
- m1->isNullable = 1;
- m1->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m2 = new SelectedColumnMeta();
- m2->label = "TABLE_SCHEM";
- m2->name = "TABLE_SCHEM";
- m2->displaySize = 128;
- m2->scale = 0;
- m2->isNullable = 1;
- m2->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m3 = new SelectedColumnMeta();
- m3->label = "TABLE_NAME";
- m3->name = "TABLE_NAME";
- m3->displaySize = 128;
- m3->scale = 0;
- m3->isNullable = 1;
- m3->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m4 = new SelectedColumnMeta();
- m4->label = "COLUMN_NAME";
- m4->name = "COLUMN_NAME";
- m4->displaySize = 128;
- m4->scale = 0;
- m4->isNullable = 0;
- m4->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m5 = new SelectedColumnMeta();
- m5->label = "DATA_TYPE";
- m5->name = "DATA_TYPE";
- m5->displaySize = 5;
- m5->scale = 0;
- m5->isNullable = 0;
- m5->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m6 = new SelectedColumnMeta();
- m6->label = "TYPE_NAME";
- m6->name = "TYPE_NAME";
- m6->displaySize = 128;
- m6->scale = 0;
- m6->isNullable = 0;
- m6->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m7 = new SelectedColumnMeta();
- m7->label = "COLUMN_SIZE";
- m7->name = "COLUMN_SIZE";
- m7->displaySize = 10;
- m7->scale = 0;
- m7->isNullable = 1;
- m7->columnType = ODBCTypes::ODBC_Integer;
- SelectedColumnMeta* m8 = new SelectedColumnMeta();
- m8->label = "BUFFER_LENGTH";
- m8->name = "BUFFER_LENGTH";
- m8->displaySize = 10;
- m8->scale = 0;
- m8->isNullable = 1;
- m8->columnType = ODBCTypes::ODBC_Integer;
- SelectedColumnMeta* m9 = new SelectedColumnMeta();
- m9->label = "DECIMAL_DIGITS";
- m9->name = "DECIMAL_DIGITS";
- m9->displaySize = 5;
- m9->scale = 0;
- m9->isNullable = 1;
- m9->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m10 = new SelectedColumnMeta();
- m10->label = "NUM_PREC_RADIX";
- m10->name = "NUM_PREC_RADIX";
- m10->displaySize = 5;
- m10->scale = 0;
- m10->isNullable = 1;
- m10->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m11 = new SelectedColumnMeta();
- m11->label = "NULLABLE";
- m11->name = "NULLABLE";
- m11->displaySize = 5;
- m11->scale = 0;
- m11->isNullable = 0;
- m11->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m12 = new SelectedColumnMeta();
- m12->label = "REMARKS";
- m12->name = "REMARKS";
- m12->displaySize = 128;
- m12->scale = 0;
- m12->isNullable = 1;
- m12->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m13 = new SelectedColumnMeta();
- m13->label = "COLUMN_DEF";
- m13->name = "COLUMN_DEF";
- m13->displaySize = 4000;
- m13->scale = 0;
- m13->isNullable = 1;
- m13->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m14 = new SelectedColumnMeta();
- m14->label = "SQL_DATA_TYPE";
- m14->name = "SQL_DATA_TYPE";
- m14->displaySize = 5;
- m14->scale = 0;
- m14->isNullable = 0;
- m14->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m15 = new SelectedColumnMeta();
- m15->label = "SQL_DATETIME_SUB";
- m15->name = "SQL_DATETIME_SUB";
- m15->displaySize = 5;
- m15->scale = 0;
- m15->isNullable = 1;
- m15->columnType = ODBCTypes::ODBC_SmallInt;
- SelectedColumnMeta* m16 = new SelectedColumnMeta();
- m16->label = "CHAR_OCTET_LENGTH";
- m16->name = "CHAR_OCTET_LENGTH";
- m16->displaySize = 10;
- m16->scale = 0;
- m16->isNullable = 1;
- m16->columnType = ODBCTypes::ODBC_Integer;
- SelectedColumnMeta* m17 = new SelectedColumnMeta();
- m17->label = "ORDINAL_POSITION";
- m17->name = "ORDINAL_POSITION";
- m17->displaySize = 10;
- m17->scale = 0;
- m17->isNullable = 0;
- m17->columnType = ODBCTypes::ODBC_Integer;
- SelectedColumnMeta* m18 = new SelectedColumnMeta();
- m18->label = "IS_NULLABLE";
- m18->name = "IS_NULLABLE";
- m18->displaySize = 254;
- m18->scale = 0;
- m18->isNullable = 1;
- m18->columnType = ODBCTypes::ODBC_WVarChar;
- SelectedColumnMeta* m19 = new SelectedColumnMeta();
- m19->label = "USER_DATA_TYPE";
- m19->name = "USER_DATA_TYPE";
- m19->displaySize = 5;
- m19->scale = 0;
- m19->isNullable = 1;
- m19->columnType = ODBCTypes::ODBC_SmallInt;
- sqlResp->columnMetas.push_back ( m1 );
- sqlResp->columnMetas.push_back ( m2 );
- sqlResp->columnMetas.push_back ( m3 );
- sqlResp->columnMetas.push_back ( m4 );
- sqlResp->columnMetas.push_back ( m5 );
- sqlResp->columnMetas.push_back ( m6 );
- sqlResp->columnMetas.push_back ( m7 );
- sqlResp->columnMetas.push_back ( m8 );
- sqlResp->columnMetas.push_back ( m9 );
- sqlResp->columnMetas.push_back ( m10 );
- sqlResp->columnMetas.push_back ( m11 );
- sqlResp->columnMetas.push_back ( m12 );
- sqlResp->columnMetas.push_back ( m13 );
- sqlResp->columnMetas.push_back ( m14 );
- sqlResp->columnMetas.push_back ( m15 );
- sqlResp->columnMetas.push_back ( m16 );
- sqlResp->columnMetas.push_back ( m17 );
- sqlResp->columnMetas.push_back ( m18 );
- sqlResp->columnMetas.push_back ( m19 );
+
+ static void FillColumnMetas4SQLColumns ( SQLResponse* sqlResp )
+ {
+ SelectedColumnMeta* m1 = new SelectedColumnMeta ();
+ m1 -> label = "TABLE_CAT";
+ m1 -> name = "TABLE_CAT";
+ m1 -> displaySize = 128;
+ m1 -> scale = 0;
+ m1 -> isNullable = 1;
+ m1 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m2 = new SelectedColumnMeta ();
+ m2 -> label = "TABLE_SCHEM";
+ m2 -> name = "TABLE_SCHEM";
+ m2 -> displaySize = 128;
+ m2 -> scale = 0;
+ m2 -> isNullable = 1;
+ m2 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m3 = new SelectedColumnMeta ();
+ m3 -> label = "TABLE_NAME";
+ m3 -> name = "TABLE_NAME";
+ m3 -> displaySize = 128;
+ m3 -> scale = 0;
+ m3 -> isNullable = 1;
+ m3 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m4 = new SelectedColumnMeta ();
+ m4 -> label = "COLUMN_NAME";
+ m4 -> name = "COLUMN_NAME";
+ m4 -> displaySize = 128;
+ m4 -> scale = 0;
+ m4 -> isNullable = 0;
+ m4 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m5 = new SelectedColumnMeta ();
+ m5 -> label = "DATA_TYPE";
+ m5 -> name = "DATA_TYPE";
+ m5 -> displaySize = 5;
+ m5 -> scale = 0;
+ m5 -> isNullable = 0;
+ m5 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m6 = new SelectedColumnMeta ();
+ m6 -> label = "TYPE_NAME";
+ m6 -> name = "TYPE_NAME";
+ m6 -> displaySize = 128;
+ m6 -> scale = 0;
+ m6 -> isNullable = 0;
+ m6 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m7 = new SelectedColumnMeta ();
+ m7 -> label = "COLUMN_SIZE";
+ m7 -> name = "COLUMN_SIZE";
+ m7 -> displaySize = 10;
+ m7 -> scale = 0;
+ m7 -> isNullable = 1;
+ m7 -> columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m8 = new SelectedColumnMeta ();
+ m8 -> label = "BUFFER_LENGTH";
+ m8 -> name = "BUFFER_LENGTH";
+ m8 -> displaySize = 10;
+ m8 -> scale = 0;
+ m8 -> isNullable = 1;
+ m8 -> columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m9 = new SelectedColumnMeta ();
+ m9 -> label = "DECIMAL_DIGITS";
+ m9 -> name = "DECIMAL_DIGITS";
+ m9 -> displaySize = 5;
+ m9 -> scale = 0;
+ m9 -> isNullable = 1;
+ m9 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m10 = new SelectedColumnMeta ();
+ m10 -> label = "NUM_PREC_RADIX";
+ m10 -> name = "NUM_PREC_RADIX";
+ m10 -> displaySize = 5;
+ m10 -> scale = 0;
+ m10 -> isNullable = 1;
+ m10 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m11 = new SelectedColumnMeta ();
+ m11 -> label = "NULLABLE";
+ m11 -> name = "NULLABLE";
+ m11 -> displaySize = 5;
+ m11 -> scale = 0;
+ m11 -> isNullable = 0;
+ m11 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m12 = new SelectedColumnMeta ();
+ m12 -> label = "REMARKS";
+ m12 -> name = "REMARKS";
+ m12 -> displaySize = 128;
+ m12 -> scale = 0;
+ m12 -> isNullable = 1;
+ m12 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m13 = new SelectedColumnMeta ();
+ m13 -> label = "COLUMN_DEF";
+ m13 -> name = "COLUMN_DEF";
+ m13 -> displaySize = 4000;
+ m13 -> scale = 0;
+ m13 -> isNullable = 1;
+ m13 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m14 = new SelectedColumnMeta ();
+ m14 -> label = "SQL_DATA_TYPE";
+ m14 -> name = "SQL_DATA_TYPE";
+ m14 -> displaySize = 5;
+ m14 -> scale = 0;
+ m14 -> isNullable = 0;
+ m14 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m15 = new SelectedColumnMeta ();
+ m15 -> label = "SQL_DATETIME_SUB";
+ m15 -> name = "SQL_DATETIME_SUB";
+ m15 -> displaySize = 5;
+ m15 -> scale = 0;
+ m15 -> isNullable = 1;
+ m15 -> columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m16 = new SelectedColumnMeta ();
+ m16 -> label = "CHAR_OCTET_LENGTH";
+ m16 -> name = "CHAR_OCTET_LENGTH";
+ m16 -> displaySize = 10;
+ m16 -> scale = 0;
+ m16 -> isNullable = 1;
+ m16 -> columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m17 = new SelectedColumnMeta ();
+ m17 -> label = "ORDINAL_POSITION";
+ m17 -> name = "ORDINAL_POSITION";
+ m17 -> displaySize = 10;
+ m17 -> scale = 0;
+ m17 -> isNullable = 0;
+ m17 -> columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m18 = new SelectedColumnMeta ();
+ m18 -> label = "IS_NULLABLE";
+ m18 -> name = "IS_NULLABLE";
+ m18 -> displaySize = 254;
+ m18 -> scale = 0;
+ m18 -> isNullable = 1;
+ m18 -> columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m19 = new SelectedColumnMeta ();
+ m19 -> label = "USER_DATA_TYPE";
+ m19 -> name = "USER_DATA_TYPE";
+ m19 -> displaySize = 5;
+ m19 -> scale = 0;
+ m19 -> isNullable = 1;
+ m19 -> columnType = ODBCTypes::ODBC_SmallInt;
+ sqlResp -> columnMetas . push_back ( m1 );
+ sqlResp -> columnMetas . push_back ( m2 );
+ sqlResp -> columnMetas . push_back ( m3 );
+ sqlResp -> columnMetas . push_back ( m4 );
+ sqlResp -> columnMetas . push_back ( m5 );
+ sqlResp -> columnMetas . push_back ( m6 );
+ sqlResp -> columnMetas . push_back ( m7 );
+ sqlResp -> columnMetas . push_back ( m8 );
+ sqlResp -> columnMetas . push_back ( m9 );
+ sqlResp -> columnMetas . push_back ( m10 );
+ sqlResp -> columnMetas . push_back ( m11 );
+ sqlResp -> columnMetas . push_back ( m12 );
+ sqlResp -> columnMetas . push_back ( m13 );
+ sqlResp -> columnMetas . push_back ( m14 );
+ sqlResp -> columnMetas . push_back ( m15 );
+ sqlResp -> columnMetas . push_back ( m16 );
+ sqlResp -> columnMetas . push_back ( m17 );
+ sqlResp -> columnMetas . push_back ( m18 );
+ sqlResp -> columnMetas . push_back ( m19 );
}
-
};
+class ErrorMessage
+{
+ public:
+ wstring url;
-class ErrorMessage {
- public:
- wstring url;
-
// if isException, the detailed exception message
- wstring msg;
-
-};
\ No newline at end of file
+ wstring msg;
+};
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/QueryCache.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/QueryCache.cpp b/odbc/Common/QueryCache.cpp
index df8f6ac..cedd6aa 100644
--- a/odbc/Common/QueryCache.cpp
+++ b/odbc/Common/QueryCache.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include "QueryCache.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
@@ -49,40 +49,49 @@ const wchar_t* alwaysSuccessResults[3] = {
L"{\"columnMetas\":[{\"isNullable\":2,\"displaySize\":11,\"label\":\"COL\",\"name\":\"COL\",\"schemaName\":\"\",\"catelogName\":\"\",\"tableName\":\"\",\"precision\":10,\"scale\":0,\"columnType\":4,\"columnTypeName\":\"int4\",\"writable\":true,\"caseSensitive\":false,\"autoIncrement\":false,\"searchable\":true,\"currency\":false,\"signed\":true,\"definitelyWritable\":false,\"readOnly\":false}],\"results\":[[\"1\"]],\"isResultsFlatten\":false,\"flattenResult\":null,\"flattenResultOriginalSize\":0,\"cubes\":null,\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,\"duration\":0.002,\"partial\":false}"
};
-int findQuery ( const wchar_t* sql, const wchar_t** regexs, int size ) {
- for ( int i = 0; i < size; ++i ) {
+int findQuery ( const wchar_t* sql, const wchar_t** regexs, int size )
+{
+ for ( int i = 0; i < size; ++i )
+ {
std::tr1::wregex rgx ( regexs[i], regex_constants::icase );
bool match = std::tr1::regex_search ( sql, rgx );
-
- if ( match ) {
+
+ if ( match )
+ {
return i;
}
}
-
+
return -1;
}
-int findInAlwaysSuccessQuery ( const wchar_t* sql ) {
- return findQuery ( sql, alwaysSuccessQueries, sizeof ( alwaysSuccessQueries ) / sizeof ( wchar_t* ) );
+int findInAlwaysSuccessQuery ( const wchar_t* sql )
+{
+ return findQuery ( sql, alwaysSuccessQueries, sizeof ( alwaysSuccessQueries ) / sizeof ( wchar_t*) );
}
-int findInAlwaysFailQuery ( const wchar_t* sql ) {
- return findQuery ( sql, alwaysFailQueries, sizeof ( alwaysFailQueries ) / sizeof ( wchar_t* ) );
+int findInAlwaysFailQuery ( const wchar_t* sql )
+{
+ return findQuery ( sql, alwaysFailQueries, sizeof ( alwaysFailQueries ) / sizeof ( wchar_t*) );
}
-unique_ptr<SQLResponse> loadCache ( const wchar_t* query ) {
+unique_ptr <SQLResponse> loadCache ( const wchar_t* query )
+{
int index = 0;
-
- if ( findInAlwaysFailQuery ( query ) >= 0 ) {
- throw exception ( "Unsupported SQL" );
+
+ if ( findInAlwaysFailQuery ( query ) >= 0 )
+ {
+ throw exception ( "Unsupported SQL" );
}
-
- else if ( ( index = findInAlwaysSuccessQuery ( query ) ) >= 0 ) {
+
+ else if ( ( index = findInAlwaysSuccessQuery ( query ) ) >= 0 )
+ {
web::json::value v = web::json::value::parse ( alwaysSuccessResults[index] );
- std::unique_ptr<SQLResponse> r = SQLResponseFromJSON ( v );
+ std::unique_ptr <SQLResponse> r = SQLResponseFromJSON ( v );
//overwrite(r.get());
return r;
}
-
+
return NULL;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/QueryCache.h
----------------------------------------------------------------------
diff --git a/odbc/Common/QueryCache.h b/odbc/Common/QueryCache.h
index 8b01651..f27375b 100644
--- a/odbc/Common/QueryCache.h
+++ b/odbc/Common/QueryCache.h
@@ -15,10 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#pragma once
#include "MsgTypes.h"
-unique_ptr<SQLResponse> loadCache ( const wchar_t* query );
\ No newline at end of file
+unique_ptr <SQLResponse> loadCache ( const wchar_t* query );
+
[10/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/REST.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/REST.cpp b/odbc/Common/REST.cpp
index 15921aa..bc3a6b8 100644
--- a/odbc/Common/REST.cpp
+++ b/odbc/Common/REST.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/json.h>
@@ -45,9 +45,10 @@ using namespace concurrency::streams;
using namespace web;
using namespace web::json;
-void printLog ( const char* msg ) {
- time_t now = time ( 0 );
- struct tm tstruct;
+void printLog ( const char* msg )
+{
+ time_t now = time ( 0 );
+ struct tm tstruct;
char buffer[100];
tstruct = *localtime ( &now );
strftime ( buffer, 100, "%Y-%m-%d.%X", &tstruct );
@@ -63,17 +64,21 @@ void printLog ( const char* msg ) {
/// <param name="results"></param>
/// <param name="column"></param>
/// <returns></returns>
-int ScanForLength ( std::vector<SQLRowContent*> results, int column ) {
+int ScanForLength ( std::vector <SQLRowContent*> results, int column )
+{
int max = 0;
-
- for ( auto p = results.begin(); p < results.end(); p++ ) {
+
+ for ( auto p = results . begin (); p < results . end (); p++ )
+ {
SQLRowContent* result = *p;
- int length = result->contents[column].size();
-
+ int length = result -> contents[column] . size ();
+
if ( length > max )
- { max = length; }
+ {
+ max = length;
+ }
}
-
+
return max;
}
@@ -84,299 +89,355 @@ int ScanForLength ( std::vector<SQLRowContent*> results, int column ) {
/// <param name="results"></param>
/// <param name="column"></param>
/// <returns></returns>
-int ScanForScale ( std::vector<SQLRowContent*> results, int column ) {
+int ScanForScale ( std::vector <SQLRowContent*> results, int column )
+{
int max = 0;
-
- for ( auto p = results.begin(); p < results.end(); p++ ) {
+
+ for ( auto p = results . begin (); p < results . end (); p++ )
+ {
SQLRowContent* result = *p;
- int length = result->contents[column].size();
- int dotLocation = result->contents[column].find ( L"." );
-
- if ( dotLocation != string::npos ) {
+ int length = result -> contents[column] . size ();
+ int dotLocation = result -> contents[column] . find ( L"." );
+
+ if ( dotLocation != string::npos )
+ {
int scale = length - 1 - dotLocation;
-
+
if ( scale > max )
- { max = scale; }
+ {
+ max = scale;
+ }
}
}
-
+
return max;
}
-void overwrite ( SQLResponse* res ) {
- for ( int i = 0; i < ( int ) res->columnMetas.size(); ++i ) {
- SelectedColumnMeta* meta = res->columnMetas[i];
- ODBCTypes t = ( ODBCTypes ) meta->columnType;
+void overwrite ( SQLResponse* res )
+{
+ for ( int i = 0; i < ( int ) res -> columnMetas . size (); ++i )
+ {
+ SelectedColumnMeta* meta = res -> columnMetas[i];
+ ODBCTypes t = ( ODBCTypes ) meta -> columnType;
int scale = 0;
int length = 0;
-
- switch ( t ) {
- case ODBCTypes::ODBC_Numeric:
- case ODBCTypes::ODBC_Decimal:
- case ODBCTypes::ODBC_Double:
- case ODBCTypes::ODBC_Real:
- case ODBCTypes::ODBC_Float:
- scale = ScanForScale ( res->results, i );
- meta->scale = scale;
- meta->scale = 4;
+
+ switch ( t )
+ {
+ case ODBCTypes::ODBC_Numeric :
+ case ODBCTypes::ODBC_Decimal :
+ case ODBCTypes::ODBC_Double :
+ case ODBCTypes::ODBC_Real :
+ case ODBCTypes::ODBC_Float :
+ scale = ScanForScale ( res -> results, i );
+ meta -> scale = scale;
+ meta -> scale = 4;
break;
-
- case ODBCTypes::ODBC_Char:
- case ODBCTypes::ODBC_VarChar:
- case ODBCTypes::ODBC_LongVarChar:
- case ODBCTypes::ODBC_WChar:
- case ODBCTypes::ODBC_WVarChar:
- case ODBCTypes::ODBC_WLongVarChar:
- case ODBCTypes::ODBC_DateTime:
- case ODBCTypes::ODBC_Type_Date:
- case ODBCTypes::ODBC_Type_Time:
- case ODBCTypes::ODBC_Type_Timestamp:
- length = ScanForLength ( res->results, i );
- meta->displaySize = length;
- meta->precision = length;
+
+ case ODBCTypes::ODBC_Char :
+ case ODBCTypes::ODBC_VarChar :
+ case ODBCTypes::ODBC_LongVarChar :
+ case ODBCTypes::ODBC_WChar :
+ case ODBCTypes::ODBC_WVarChar :
+ case ODBCTypes::ODBC_WLongVarChar :
+ case ODBCTypes::ODBC_DateTime :
+ case ODBCTypes::ODBC_Type_Date :
+ case ODBCTypes::ODBC_Type_Time :
+ case ODBCTypes::ODBC_Type_Timestamp :
+ length = ScanForLength ( res -> results, i );
+ meta -> displaySize = length;
+ meta -> precision = length;
break;
-
- default:
+
+ default :
break;
}
}
}
-std::wstring completeServerStr ( char* serverStr, long port ) {
+std::wstring completeServerStr ( char* serverStr, long port )
+{
//concat the whole server string
char completeServerAddr[256];
char portSuffix[10];
sprintf ( portSuffix, ":%d", port );
-
+
if ( strstr ( serverStr, "https://" ) == serverStr ||
- strstr ( serverStr, "http://" ) == serverStr ) {
+ strstr ( serverStr, "http://" ) == serverStr )
+ {
sprintf ( completeServerAddr, "%s", serverStr );
}
-
- else {
+
+ else
+ {
// by default use https
sprintf ( completeServerAddr, "https://%s", serverStr );
}
-
- if ( strstr ( serverStr, portSuffix ) == NULL ) {
+
+ if ( strstr ( serverStr, portSuffix ) == NULL )
+ {
strcat ( completeServerAddr, portSuffix );
}
-
+
return string2wstring ( std::string ( completeServerAddr ) );
}
-http_request makeRequest ( const char* username, const char* passwd, const wchar_t* uriStr , http::method method ) {
+http_request makeRequest ( const char* username, const char* passwd, const wchar_t* uriStr, http::method method )
+{
http_request request;
char s[128];
sprintf ( s, "%s:%s", username, passwd );
std::string b64 = base64_encode ( ( unsigned char const* ) s, strlen ( s ) );
- request.set_method ( method );
- request.set_request_uri ( uri ( uri::encode_uri ( uriStr ) ) );
- request.headers().add ( header_names::authorization, string2wstring ( "Basic " + b64 ) );
- request.headers().add ( header_names::content_type, "application/json" );
+ request . set_method ( method );
+ request . set_request_uri ( uri ( uri::encode_uri ( uriStr ) ) );
+ request . headers () . add ( header_names::authorization, string2wstring ( "Basic " + b64 ) );
+ request . headers () . add ( header_names::content_type, "application/json" );
return request;
}
-bool restAuthenticate ( char* serverAddr, long port, char* username, char* passwd ) {
- wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+bool restAuthenticate ( char* serverAddr, long port, char* username, char* passwd )
+{
+ wstring serverAddrW = completeServerStr ( serverAddr, port );
http_client_config config;
- config.set_timeout ( utility::seconds ( 300 ) );
+ config . set_timeout ( utility::seconds ( 300 ) );
http_client session ( serverAddrW, config );
//can get project list only when correct username/password is given
http_request request = makeRequest ( username, passwd, L"/kylin/api/projects", methods::GET );
- http_response response = session.request ( request ).get();
-
- if ( response.status_code() == status_codes::OK )
- { return true; }
-
+ http_response response = session . request ( request ) . get ();
+
+ if ( response . status_code () == status_codes::OK )
+ {
+ return true;
+ }
+
else
- { return false; }
+ {
+ return false;
+ }
}
-void restListProjects ( char* serverAddr, long port, char* username, char* passwd , std::vector<string>& holder ) {
- wstring serverAddrW = completeServerStr ( serverAddr, port );
+void restListProjects ( char* serverAddr, long port, char* username, char* passwd, std::vector <string>& holder )
+{
+ wstring serverAddrW = completeServerStr ( serverAddr, port );
http_client_config config;
- config.set_timeout ( utility::seconds ( 300 ) );
+ config . set_timeout ( utility::seconds ( 300 ) );
http_client session ( serverAddrW, config );
http_request request = makeRequest ( username, passwd, L"/kylin/api/projects", methods::GET );
- http_response response = session.request ( request ).get();
-
- if ( response.status_code() == status_codes::OK ) {
- web::json::value projects = response.extract_json().get();
-
- for ( auto iter = projects.as_array().begin(); iter != projects.as_array().end(); ++iter ) {
- holder.push_back ( wstring2string ( ( *iter ) [U ( "name" )].as_string() ) );
+ http_response response = session . request ( request ) . get ();
+
+ if ( response . status_code () == status_codes::OK )
+ {
+ web::json::value projects = response . extract_json () . get ();
+
+ for ( auto iter = projects . as_array () . begin (); iter != projects . as_array () . end (); ++iter )
+ {
+ holder . push_back ( wstring2string ( ( *iter )[U ( "name" )] . as_string () ) );
+ }
+
+ if ( holder . size () == 0 )
+ {
+ throw exception ( "There is no project available in this server" );
}
-
- if ( holder.size() == 0 )
- { throw exception ( "There is no project available in this server" ); }
}
-
- else if ( response.status_code() == status_codes::InternalError ) {
- std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( response.extract_json().get() );
- string errorMsg = wstring2string ( em->msg );
- throw exception ( errorMsg.c_str() );
+
+ else if ( response . status_code () == status_codes::InternalError )
+ {
+ std::unique_ptr <ErrorMessage> em = ErrorMessageFromJSON ( response . extract_json () . get () );
+ string errorMsg = wstring2string ( em -> msg );
+ throw exception ( errorMsg . c_str () );
}
-
- else {
- throw exception ( "REST request(listproject) Invalid Response status code : " + response.status_code() );
+
+ else
+ {
+ throw exception ( "REST request(listproject) Invalid Response status code : " + response . status_code () );
}
}
-std::unique_ptr<MetadataResponse> restGetMeta ( char* serverAddr, long port , char* username, char* passwd,
- char* project ) {
- wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+std::unique_ptr <MetadataResponse> restGetMeta ( char* serverAddr, long port, char* username, char* passwd,
+ char* project )
+{
+ wstring serverAddrW = completeServerStr ( serverAddr, port );
http_client_config config;
- config.set_timeout ( utility::seconds ( 300 ) );
+ config . set_timeout ( utility::seconds ( 300 ) );
http_client session ( serverAddrW, config );
std::wstringstream wss;
wss << L"/kylin/api/tables_and_columns" << L"?project=" << project;
- http_request request = makeRequest ( username, passwd, wss.str().c_str(), methods::GET );
- http_response response = session.request ( request ).get();
-
- if ( response.status_code() == status_codes::OK ) {
- return MetadataResponseFromJSON ( response.extract_json().get() );
+ http_request request = makeRequest ( username, passwd, wss . str () . c_str (), methods::GET );
+ http_response response = session . request ( request ) . get ();
+
+ if ( response . status_code () == status_codes::OK )
+ {
+ return MetadataResponseFromJSON ( response . extract_json () . get () );
}
-
- else if ( response.status_code() == status_codes::Unauthorized ) {
+
+ else if ( response . status_code () == status_codes::Unauthorized )
+ {
throw exception ( "Username/Password Unauthorized." );
}
-
- else if ( response.status_code() == status_codes::InternalError ) {
- std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( response.extract_json().get() );
- string errorMsg = wstring2string ( em->msg );
- throw exception ( errorMsg.c_str() );
+
+ else if ( response . status_code () == status_codes::InternalError )
+ {
+ std::unique_ptr <ErrorMessage> em = ErrorMessageFromJSON ( response . extract_json () . get () );
+ string errorMsg = wstring2string ( em -> msg );
+ throw exception ( errorMsg . c_str () );
}
-
- else {
- throw exception ( "REST request(getmeta) Invalid Response status code : " + response.status_code() );
+
+ else
+ {
+ throw exception ( "REST request(getmeta) Invalid Response status code : " + response . status_code () );
}
}
-wstring cookQuery ( wchar_t* p ) {
+wstring cookQuery ( wchar_t* p )
+{
wchar_t* q = new wchar_t[wcslen ( p ) + 1];
wcscpy ( q, p );
-
- for ( int i = 0 ; i < ( int ) wcslen ( q ); i++ ) {
- if ( q[i] == '\r' || q[i] == '\n' || q[i] == '\t' ) {
+
+ for ( int i = 0; i < ( int ) wcslen ( q ); i++ )
+ {
+ if ( q[i] == '\r' || q[i] == '\n' || q[i] == '\t' )
+ {
q[i] = ' ';
}
}
-
+
wstring ret ( q );
delete[] q;
size_t pos = 0;
-
- for ( size_t pos = 0;; pos += 2 ) {
- pos = ret.find ( L"\"", pos );
-
- if ( pos == wstring::npos ) { break; }
-
- ret.insert ( pos, L"\\" );
+
+ for ( size_t pos = 0;; pos += 2 )
+ {
+ pos = ret . find ( L"\"", pos );
+
+ if ( pos == wstring::npos )
+ {
+ break;
+ }
+
+ ret . insert ( pos, L"\\" );
}
-
+
return ret;
}
-wstring getBodyString ( http_response& response ) {
- bool isGzipped = response.headers().has ( L"Content-Encoding" );
-
- if ( isGzipped ) {
+wstring getBodyString ( http_response& response )
+{
+ bool isGzipped = response . headers () . has ( L"Content-Encoding" );
+
+ if ( isGzipped )
+ {
isGzipped = false;
- http_headers::iterator iterator = response.headers().find ( L"Content-Encoding" );
-
- if ( iterator != response.headers().end() ) {
- wstring contentEncoding = iterator->second;
-
- if ( contentEncoding.find ( L"gzip" ) != std::string::npos )
- { isGzipped = true; }
+ http_headers::iterator iterator = response . headers () . find ( L"Content-Encoding" );
+
+ if ( iterator != response . headers () . end () )
+ {
+ wstring contentEncoding = iterator -> second;
+
+ if ( contentEncoding . find ( L"gzip" ) != std::string::npos )
+ {
+ isGzipped = true;
+ }
}
}
-
- container_buffer<std::string> bodyBuffer;
- response.body().read_to_end ( bodyBuffer ).get();
- const std::string& raw = bodyBuffer.collection();
+
+ container_buffer <std::string> bodyBuffer;
+ response . body () . read_to_end ( bodyBuffer ) . get ();
+ const std::string& raw = bodyBuffer . collection ();
std::string uncompressed;
-
- if ( isGzipped ) {
+
+ if ( isGzipped )
+ {
bool decompressStatus = gzipInflate ( raw, uncompressed );
-
+
if ( !decompressStatus )
- { throw exception ( "gzip decompress failed" ); }
+ {
+ throw exception ( "gzip decompress failed" );
+ }
}
-
- else {
+
+ else
+ {
uncompressed = raw;
}
-
+
//convert the string from utf8 to wchar
- int size_needed = ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed.c_str(), uncompressed.size(), NULL, 0 );
+ int size_needed = ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed . c_str (), uncompressed . size (), NULL, 0 );
std::wstring ret ( size_needed, 0 );
- ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed.c_str(), uncompressed.size(), &ret[0], size_needed );
+ ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed . c_str (), uncompressed . size (), &ret[0], size_needed );
return ret;
}
-std::unique_ptr<SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
- char* passwd,
- char* project ) {
+std::unique_ptr <SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
+ char* passwd,
+ char* project )
+{
//using local cache to intercept probing queries
- std::unique_ptr<SQLResponse> cachedQueryRes = loadCache ( rawSql );
-
+ std::unique_ptr <SQLResponse> cachedQueryRes = loadCache ( rawSql );
+
if ( cachedQueryRes != NULL )
- { return cachedQueryRes; }
-
+ {
+ return cachedQueryRes;
+ }
+
//real requesting
- wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+ wstring serverAddrW = completeServerStr ( serverAddr, port );
http_client_config config;
- config.set_timeout ( utility::seconds ( 36000 ) );
+ config . set_timeout ( utility::seconds ( 36000 ) );
http_client session ( serverAddrW, config );
http_request request = makeRequest ( username, passwd, L"/kylin/api/query", methods::POST );
wstring sql = cookQuery ( rawSql );
std::wstringstream wss;
- wss << L"{ \"acceptPartial\": false, \"project\" : \"" << project << L"\", " << " \"sql\" : \"" << sql << L"\" }" ;
- request.set_body ( wss.str(), L"application/json" );
- request.headers().add ( header_names::accept_encoding, "gzip,deflate" );
+ wss << L"{ \"acceptPartial\": false, \"project\" : \"" << project << L"\", " << " \"sql\" : \"" << sql << L"\" }" ;
+ request . set_body ( wss . str (), L"application/json" );
+ request . headers () . add ( header_names::accept_encoding, "gzip,deflate" );
http::status_code status;
http_response response;
-
- try {
- response = session.request ( request ).get();
- status = response.status_code();
+
+ try
+ {
+ response = session . request ( request ) . get ();
+ status = response . status_code ();
}
-
- catch ( std::exception& e ) {
+
+ catch ( std::exception& e )
+ {
std::stringstream ss;
- ss << "An exception is throw Error message: " << e.what();
- throw exception ( ss.str().c_str() );
+ ss << "An exception is throw Error message: " << e . what ();
+ throw exception ( ss . str () . c_str () );
}
-
+
wstring ret = getBodyString ( response );
-
- if ( status == status_codes::OK ) {
+
+ if ( status == status_codes::OK )
+ {
//convert to json
web::json::value actualRes = web::json::value::parse ( ret );
- std::unique_ptr<SQLResponse> r = SQLResponseFromJSON ( actualRes );
-
- if ( r->isException == true ) {
- string expMsg = wstring2string ( r->exceptionMessage );
- throw exception ( expMsg.c_str() );
+ std::unique_ptr <SQLResponse> r = SQLResponseFromJSON ( actualRes );
+
+ if ( r -> isException == true )
+ {
+ string expMsg = wstring2string ( r -> exceptionMessage );
+ throw exception ( expMsg . c_str () );
}
-
- overwrite ( r.get() );
+
+ overwrite ( r . get () );
return r;
}
-
- else if ( status == status_codes::InternalError ) {
- std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( web::json::value::parse ( ret ) );
- string expMsg = wstring2string ( em->msg );
- throw exception ( expMsg.c_str() );
+
+ else if ( status == status_codes::InternalError )
+ {
+ std::unique_ptr <ErrorMessage> em = ErrorMessageFromJSON ( web::json::value::parse ( ret ) );
+ string expMsg = wstring2string ( em -> msg );
+ throw exception ( expMsg . c_str () );
}
-
- else {
+
+ else
+ {
throw exception ( "Unknown exception in rest query with return code " + status );
}
-
+
return NULL;
}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/REST.h
----------------------------------------------------------------------
diff --git a/odbc/Common/REST.h b/odbc/Common/REST.h
index e20d745..bb405ef 100644
--- a/odbc/Common/REST.h
+++ b/odbc/Common/REST.h
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#pragma once
#include "vld.h"
@@ -25,11 +25,12 @@
//REST
bool restAuthenticate ( char* serverAddr, long port, char* username, char* passwd );
-void restListProjects ( char* serverAddr, long port, char* username, char* passwd, std::vector<string>& holder );
+void restListProjects ( char* serverAddr, long port, char* username, char* passwd, std::vector <string>& holder );
+
+std::unique_ptr <SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
+ char* passwd,
+ char* project );
-std::unique_ptr<SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
- char* passwd,
- char* project );
+std::unique_ptr <MetadataResponse> restGetMeta ( char* serverAddr, long port, char* username, char* passwd,
+ char* project );
-std::unique_ptr<MetadataResponse> restGetMeta ( char* serverAddr, long port, char* username, char* passwd,
- char* project );
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/StringUtils.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/StringUtils.cpp b/odbc/Common/StringUtils.cpp
index dd33773..151b6d4 100644
--- a/odbc/Common/StringUtils.cpp
+++ b/odbc/Common/StringUtils.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include <iostream>
#include <stdlib.h>
#include <string>
@@ -31,131 +31,167 @@
using namespace std;
-std::unique_ptr<char[]> str_base64_encode ( char* raw ) {
+std::unique_ptr <char[]> str_base64_encode ( char* raw )
+{
trimwhitespace ( raw );
string encStr = base64_encode ( ( const unsigned char* ) raw, strlen ( raw ) );
- std::unique_ptr<char[]> temp ( new char[encStr.length() + 1] );
- strcpy ( temp.get(), encStr.c_str() );
+ std::unique_ptr <char[]> temp ( new char[encStr . length () + 1] );
+ strcpy ( temp . get (), encStr . c_str () );
return temp;
}
-std::unique_ptr<char[]> str_base64_decode ( char* enc ) {
+std::unique_ptr <char[]> str_base64_decode ( char* enc )
+{
string s ( enc );
string decStr = base64_decode ( s );
- std::unique_ptr<char[]> temp ( new char[decStr.length() + 1] );
- strcpy ( temp.get(), decStr.c_str() );
+ std::unique_ptr <char[]> temp ( new char[decStr . length () + 1] );
+ strcpy ( temp . get (), decStr . c_str () );
return temp;
}
-void trimwhitespace ( char* str ) {
+void trimwhitespace ( char* str )
+{
if ( str == NULL || strlen ( str ) == 0 )
- { return; }
-
+ {
+ return;
+ }
+
char* start = str;
char* end;
-
+
// Trim leading space
- while ( isspace ( *start ) ) { start++; }
-
- if ( *start == 0 ) { // All spaces?
+ while ( isspace ( *start ) )
+ {
+ start++;
+ }
+
+ if ( *start == 0 )
+ { // All spaces?
str[0] = '\0';
return;
}
-
+
// Trim trailing space
end = start + strlen ( start ) - 1;
-
- while ( end > start && isspace ( *end ) ) { end--; }
-
+
+ while ( end > start && isspace ( *end ) )
+ {
+ end--;
+ }
+
// Write new null terminator
* ( end + 1 ) = 0;
memmove ( str, start, end - start + 2 );
}
-void copyTrimmed ( char** dest, char* src ) {
+void copyTrimmed ( char** dest, char* src )
+{
// check if previous value exists
- if ( *dest ) {
+ if ( *dest )
+ {
delete[] ( *dest );
*dest = NULL;
}
-
+
*dest = new char[strlen ( src ) + 1];
strcpy ( *dest, src );
trimwhitespace ( *dest );
}
-std::unique_ptr<wchar_t[]> char2wchar ( char* orig ) {
+std::unique_ptr <wchar_t[]> char2wchar ( char* orig )
+{
if ( orig == NULL )
- { return NULL; }
-
+ {
+ return NULL;
+ }
+
size_t newsize = strlen ( orig ) + 1;
- std::unique_ptr<wchar_t[]> wcstring ( new wchar_t[newsize] );
+ std::unique_ptr <wchar_t[]> wcstring ( new wchar_t[newsize] );
size_t convertedChars = 0;
- mbstowcs_s ( &convertedChars, wcstring.get(), newsize, orig, _TRUNCATE );
+ mbstowcs_s ( &convertedChars, wcstring . get (), newsize, orig, _TRUNCATE );
return wcstring;
}
-std::unique_ptr<wchar_t[]> char2wchar ( const char* orig ) {
+std::unique_ptr <wchar_t[]> char2wchar ( const char* orig )
+{
if ( orig == NULL )
- { return NULL; }
-
+ {
+ return NULL;
+ }
+
size_t newsize = strlen ( orig ) + 1;
- std::unique_ptr<wchar_t[]> wcstring ( new wchar_t[newsize] );
+ std::unique_ptr <wchar_t[]> wcstring ( new wchar_t[newsize] );
size_t convertedChars = 0;
- mbstowcs_s ( &convertedChars, wcstring.get(), newsize, orig, _TRUNCATE );
+ mbstowcs_s ( &convertedChars, wcstring . get (), newsize, orig, _TRUNCATE );
return wcstring;
}
//specifying the destination
-void char2wchar ( char* orig, wchar_t* dest, int destBufferLength ) {
+void char2wchar ( char* orig, wchar_t* dest, int destBufferLength )
+{
if ( orig == NULL )
- { return; }
-
- if ( destBufferLength > 0 ) {
- if ( destBufferLength <= ( int ) strlen ( orig ) ) {
+ {
+ return;
+ }
+
+ if ( destBufferLength > 0 )
+ {
+ if ( destBufferLength <= ( int ) strlen ( orig ) )
+ {
throw - 1;
}
}
-
+
size_t newsize = strlen ( orig ) + 1;
size_t convertedChars = 0;
mbstowcs_s ( &convertedChars, dest, newsize, orig, _TRUNCATE );
}
-std::unique_ptr<char[]> wchar2char ( wchar_t* orig ) {
+std::unique_ptr <char[]> wchar2char ( wchar_t* orig )
+{
if ( orig == NULL )
- { return NULL; }
-
+ {
+ return NULL;
+ }
+
size_t origsize = wcslen ( orig ) + 1;
size_t convertedChars = 0;
const size_t newsize = origsize;
- std::unique_ptr<char[]> nstring ( new char[newsize] );
- wcstombs_s ( &convertedChars, nstring.get(), newsize, orig, _TRUNCATE );
+ std::unique_ptr <char[]> nstring ( new char[newsize] );
+ wcstombs_s ( &convertedChars, nstring . get (), newsize, orig, _TRUNCATE );
return nstring;
}
-std::unique_ptr<char[]> wchar2char ( const wchar_t* orig ) {
+std::unique_ptr <char[]> wchar2char ( const wchar_t* orig )
+{
if ( orig == NULL )
- { return NULL; }
-
+ {
+ return NULL;
+ }
+
size_t origsize = wcslen ( orig ) + 1;
size_t convertedChars = 0;
const size_t newsize = origsize;
- std::unique_ptr<char[]> nstring ( new char[newsize] );
- wcstombs_s ( &convertedChars, nstring.get(), newsize, orig, _TRUNCATE );
+ std::unique_ptr <char[]> nstring ( new char[newsize] );
+ wcstombs_s ( &convertedChars, nstring . get (), newsize, orig, _TRUNCATE );
return nstring;
}
-void wchar2char ( wchar_t* orig, char* dest, int destBufferLength ) {
+void wchar2char ( wchar_t* orig, char* dest, int destBufferLength )
+{
if ( orig == NULL )
- { return; }
-
- if ( destBufferLength > 0 ) {
- if ( destBufferLength <= ( int ) wcslen ( orig ) ) {
+ {
+ return;
+ }
+
+ if ( destBufferLength > 0 )
+ {
+ if ( destBufferLength <= ( int ) wcslen ( orig ) )
+ {
throw - 1;
}
}
-
+
size_t origsize = wcslen ( orig ) + 1;
size_t convertedChars = 0;
const size_t newsize = origsize;
@@ -163,27 +199,32 @@ void wchar2char ( wchar_t* orig, char* dest, int destBufferLength ) {
}
-std::wstring string2wstring ( std::string& orig ) {
+std::wstring string2wstring ( std::string& orig )
+{
std::wstring ws;
- ws.assign ( orig.begin(), orig.end() );
+ ws . assign ( orig . begin (), orig . end () );
return ws;
}
-std::string wstring2string ( std::wstring& orig ) {
+std::string wstring2string ( std::wstring& orig )
+{
std::string s;
- s.assign ( orig.begin(), orig.end() );
+ s . assign ( orig . begin (), orig . end () );
return s;
}
-std::unique_ptr<char[]> make_unique_str ( int size ) {
- return std::unique_ptr<char[]> ( new char[size + 1] );
+std::unique_ptr <char[]> make_unique_str ( int size )
+{
+ return std::unique_ptr <char[]> ( new char[size + 1] );
}
-void remove_char(char *src, const char tgt)
+void remove_char ( char* src, const char tgt )
{
- char * fp = src;
- while (*src) {
- if (*src != tgt) {
+ char* fp = src;
+ while ( *src )
+ {
+ if ( *src != tgt )
+ {
*fp = *src;
fp++;
}
@@ -192,5 +233,3 @@ void remove_char(char *src, const char tgt)
*fp = '\0' ;
}
-
-
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/StringUtils.h
----------------------------------------------------------------------
diff --git a/odbc/Common/StringUtils.h b/odbc/Common/StringUtils.h
index 5aec343..d7f1634 100644
--- a/odbc/Common/StringUtils.h
+++ b/odbc/Common/StringUtils.h
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#pragma once
#include <memory>
@@ -24,12 +24,12 @@
//UTIL
-std::unique_ptr<wchar_t[]> char2wchar ( char* orig );
-std::unique_ptr<wchar_t[]> char2wchar ( const char* orig );
+std::unique_ptr <wchar_t[]> char2wchar ( char* orig );
+std::unique_ptr <wchar_t[]> char2wchar ( const char* orig );
void char2wchar ( char* orig, wchar_t* dest, int destLength );
-std::unique_ptr<char[]> wchar2char ( wchar_t* orig );
-std::unique_ptr<char[]> wchar2char ( const wchar_t* orig );
+std::unique_ptr <char[]> wchar2char ( wchar_t* orig );
+std::unique_ptr <char[]> wchar2char ( const wchar_t* orig );
void wchar2char ( wchar_t* orig, char* dest, int destLength );
std::wstring string2wstring ( std::string& orig );
@@ -38,9 +38,10 @@ std::string wstring2string ( std::wstring& orig );
void trimwhitespace ( char* str );
void copyTrimmed ( char** dest, char* src );
-std::unique_ptr<char[]> str_base64_encode ( char* raw );
-std::unique_ptr<char[]> str_base64_decode ( char* enc );
+std::unique_ptr <char[]> str_base64_encode ( char* raw );
+std::unique_ptr <char[]> str_base64_decode ( char* enc );
+
+std::unique_ptr <char[]> make_unique_str ( int size );
-std::unique_ptr<char[]> make_unique_str ( int size );
+void remove_char ( char* src, const char tgt );
-void remove_char(char *src, const char tgt);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/base64.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/base64.cpp b/odbc/Common/base64.cpp
index 7b09664..9e26b46 100644
--- a/odbc/Common/base64.cpp
+++ b/odbc/Common/base64.cpp
@@ -15,101 +15,131 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#include "Base64.h"
#include <iostream>
static const std::string base64_chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"abcdefghijklmnopqrstuvwxyz"
+"0123456789+/";
-static inline bool is_base64 ( unsigned char c ) {
+static inline bool is_base64 ( unsigned char c )
+{
return ( isalnum ( c ) || ( c == '+' ) || ( c == '/' ) );
}
-std::string base64_encode ( unsigned char const* bytes_to_encode, unsigned int in_len ) {
+std::string base64_encode ( unsigned char const* bytes_to_encode, unsigned int in_len )
+{
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
-
- while ( in_len-- ) {
+
+ while ( in_len-- )
+ {
char_array_3[i++] = * ( bytes_to_encode++ );
-
- if ( i == 3 ) {
+
+ if ( i == 3 )
+ {
char_array_4[0] = ( char_array_3[0] & 0xfc ) >> 2;
char_array_4[1] = ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 );
char_array_4[2] = ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 );
char_array_4[3] = char_array_3[2] & 0x3f;
-
- for ( i = 0; ( i < 4 ) ; i++ )
- { ret += base64_chars[char_array_4[i]]; }
-
+
+ for ( i = 0; ( i < 4 ); i++ )
+ {
+ ret += base64_chars[char_array_4[i]];
+ }
+
i = 0;
}
}
-
- if ( i ) {
+
+ if ( i )
+ {
for ( j = i; j < 3; j++ )
- { char_array_3[j] = '\0'; }
-
+ {
+ char_array_3[j] = '\0';
+ }
+
char_array_4[0] = ( char_array_3[0] & 0xfc ) >> 2;
char_array_4[1] = ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 );
char_array_4[2] = ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 );
char_array_4[3] = char_array_3[2] & 0x3f;
-
+
for ( j = 0; ( j < i + 1 ); j++ )
- { ret += base64_chars[char_array_4[j]]; }
-
+ {
+ ret += base64_chars[char_array_4[j]];
+ }
+
while ( ( i++ < 3 ) )
- { ret += '='; }
+ {
+ ret += '=';
+ }
}
-
+
return ret;
}
-std::string base64_decode ( std::string const& encoded_string ) {
- int in_len = encoded_string.size();
+std::string base64_decode ( std::string const& encoded_string )
+{
+ int in_len = encoded_string . size ();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
-
- while ( in_len-- && ( encoded_string[in_] != '=' ) && is_base64 ( encoded_string[in_] ) ) {
- char_array_4[i++] = encoded_string[in_]; in_++;
-
- if ( i == 4 ) {
+
+ while ( in_len-- && ( encoded_string[in_] != '=' ) && is_base64 ( encoded_string[in_] ) )
+ {
+ char_array_4[i++] = encoded_string[in_];
+ in_++;
+
+ if ( i == 4 )
+ {
for ( i = 0; i < 4; i++ )
- { char_array_4[i] = base64_chars.find ( char_array_4[i] ); }
-
+ {
+ char_array_4[i] = base64_chars . find ( char_array_4[i] );
+ }
+
char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 );
char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 );
char_array_3[2] = ( ( char_array_4[2] & 0x3 ) << 6 ) + char_array_4[3];
-
+
for ( i = 0; ( i < 3 ); i++ )
- { ret += char_array_3[i]; }
-
+ {
+ ret += char_array_3[i];
+ }
+
i = 0;
}
}
-
- if ( i ) {
+
+ if ( i )
+ {
for ( j = i; j < 4; j++ )
- { char_array_4[j] = 0; }
-
+ {
+ char_array_4[j] = 0;
+ }
+
for ( j = 0; j < 4; j++ )
- { char_array_4[j] = base64_chars.find ( char_array_4[j] ); }
-
+ {
+ char_array_4[j] = base64_chars . find ( char_array_4[j] );
+ }
+
char_array_3[0] = ( char_array_4[0] << 2 ) + ( ( char_array_4[1] & 0x30 ) >> 4 );
char_array_3[1] = ( ( char_array_4[1] & 0xf ) << 4 ) + ( ( char_array_4[2] & 0x3c ) >> 2 );
char_array_3[2] = ( ( char_array_4[2] & 0x3 ) << 6 ) + char_array_4[3];
-
- for ( j = 0; ( j < i - 1 ); j++ ) { ret += char_array_3[j]; }
+
+ for ( j = 0; ( j < i - 1 ); j++ )
+ {
+ ret += char_array_3[j];
+ }
}
-
+
return ret;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Common/base64.h
----------------------------------------------------------------------
diff --git a/odbc/Common/base64.h b/odbc/Common/base64.h
index f0af44d..5710e3c 100644
--- a/odbc/Common/base64.h
+++ b/odbc/Common/base64.h
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#pragma once
#include <string>
@@ -23,6 +23,3 @@
std::string base64_encode ( unsigned char const*, unsigned int len );
std::string base64_decode ( std::string const& s );
-
-
-
[03/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_INFO.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_INFO.CPP b/odbc/Driver/KO_INFO.CPP
index a90c1de..21c39e6 100644
--- a/odbc/Driver/KO_INFO.CPP
+++ b/odbc/Driver/KO_INFO.CPP
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
// ----------------------------------------------------------------------------
//
@@ -56,543 +56,551 @@
// to get driver related information
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetInfoW ( SQLHDBC pConn,
- SQLUSMALLINT pInfoType,
- SQLPOINTER pInfoValuePtr,
- SQLSMALLINT pBufferLength,
- SQLSMALLINT* pStringLengthPtr ) {
+RETCODE SQL_API SQLGetInfoW ( SQLHDBC pConn,
+ SQLUSMALLINT pInfoType,
+ SQLPOINTER pInfoValuePtr,
+ SQLSMALLINT pBufferLength,
+ SQLSMALLINT* pStringLengthPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetInfoW called: Field: %d, Length: %d", pInfoType, pBufferLength ) );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
+
// check the info required
// check this page for detailed http://msdn.microsoft.com/en-us/library/ms711681(v=vs.85).aspx
- switch ( pInfoType ) {
- case SQL_COLUMN_ALIAS://87 called
+ switch ( pInfoType )
+ {
+ case SQL_COLUMN_ALIAS : //87 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
break;
-
- case SQL_CONVERT_FUNCTIONS ://48 called
- case SQL_CONVERT_BIGINT:
- case SQL_CONVERT_BINARY:
- case SQL_CONVERT_BIT:
- case SQL_CONVERT_CHAR:
- case SQL_CONVERT_GUID:
- case SQL_CONVERT_DATE:
- case SQL_CONVERT_DECIMAL:
- case SQL_CONVERT_DOUBLE:
- case SQL_CONVERT_FLOAT:
- case SQL_CONVERT_INTEGER:
- case SQL_CONVERT_INTERVAL_YEAR_MONTH:
- case SQL_CONVERT_INTERVAL_DAY_TIME:
- case SQL_CONVERT_LONGVARBINARY:
- case SQL_CONVERT_LONGVARCHAR:
- case SQL_CONVERT_NUMERIC:
- case SQL_CONVERT_REAL:
- case SQL_CONVERT_SMALLINT:
- case SQL_CONVERT_TIME:
- case SQL_CONVERT_TIMESTAMP:
- case SQL_CONVERT_TINYINT:
- case SQL_CONVERT_VARBINARY:
- case SQL_CONVERT_VARCHAR:
- case SQL_CONVERT_WCHAR:
- case SQL_CONVERT_WLONGVARCHAR:
- case SQL_CONVERT_WVARCHAR:
- break;
-
+
+ case SQL_CONVERT_FUNCTIONS : //48 called
+ case SQL_CONVERT_BIGINT :
+ case SQL_CONVERT_BINARY :
+ case SQL_CONVERT_BIT :
+ case SQL_CONVERT_CHAR :
+ case SQL_CONVERT_GUID :
+ case SQL_CONVERT_DATE :
+ case SQL_CONVERT_DECIMAL :
+ case SQL_CONVERT_DOUBLE :
+ case SQL_CONVERT_FLOAT :
+ case SQL_CONVERT_INTEGER :
+ case SQL_CONVERT_INTERVAL_YEAR_MONTH :
+ case SQL_CONVERT_INTERVAL_DAY_TIME :
+ case SQL_CONVERT_LONGVARBINARY :
+ case SQL_CONVERT_LONGVARCHAR :
+ case SQL_CONVERT_NUMERIC :
+ case SQL_CONVERT_REAL :
+ case SQL_CONVERT_SMALLINT :
+ case SQL_CONVERT_TIME :
+ case SQL_CONVERT_TIMESTAMP :
+ case SQL_CONVERT_TINYINT :
+ case SQL_CONVERT_VARBINARY :
+ case SQL_CONVERT_VARCHAR :
+ case SQL_CONVERT_WCHAR :
+ case SQL_CONVERT_WLONGVARCHAR :
+ case SQL_CONVERT_WVARCHAR :
+ break;
+
case SQL_MAX_IDENTIFIER_LEN : //10005 called
break;
-
- case SQL_ODBC_INTERFACE_CONFORMANCE://152 called
- break;
-
- case SQL_SQL_CONFORMANCE: //118 called
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the SQL-92 datetime literals supported by the data source. Note that these are the datetime literals listed in the SQL-92 specification and are separate from the datetime literal escape clauses defined by ODBC. For more information about the ODBC datetime literal escape clauses, see Date, Time, and Timestamp Literals.
- A FIPS Transitional level�Cconformant driver will always return the "1" value in the bitmask for the bits in the following list. A value of "0" means that SQL-92 datetime literals are not supported.
- The following bitmasks are used to determine which literals are supported:
- SQL_DL_SQL92_DATESQL_DL_SQL92_TIMESQL_DL_SQL92_TIMESTAMPSQL_DL_SQL92_INTERVAL_YEARSQL_DL_SQL92_INTERVAL_MONTHSQL_DL_SQL92_INTERVAL_DAYSQL_DL_SQL92_INTERVAL_HOURSQL_DL_SQL92_INTERVAL_MINUTESQL_DL_SQL92_INTERVAL_SECONDSQL_DL_SQL92_INTERVAL_YEAR_TO_MONTHSQL_DL_SQL92_INTERVAL_DAY_TO_HOUR
- SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTESQL_DL_SQL92_INTERVAL_DAY_TO_SECONDSQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTESQL_DL_SQL92_INTERVAL_HOUR_TO_SECONDSQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND
- */
- case SQL_DATETIME_LITERALS: //119 called
+
+ case SQL_ODBC_INTERFACE_CONFORMANCE : //152 called
+ break;
+
+ case SQL_SQL_CONFORMANCE : //118 called
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the SQL-92 datetime literals supported by the data source. Note that these are the datetime literals listed in the SQL-92 specification and are separate from the datetime literal escape clauses defined by ODBC. For more information about the ODBC datetime literal escape clauses, see Date, Time, and Timestamp Literals.
+ A FIPS Transitional level�Cconformant driver will always return the "1" value in the bitmask for the bits in the following list. A value of "0" means that SQL-92 datetime literals are not supported.
+ The following bitmasks are used to determine which literals are supported:
+ SQL_DL_SQL92_DATESQL_DL_SQL92_TIMESQL_DL_SQL92_TIMESTAMPSQL_DL_SQL92_INTERVAL_YEARSQL_DL_SQL92_INTERVAL_MONTHSQL_DL_SQL92_INTERVAL_DAYSQL_DL_SQL92_INTERVAL_HOURSQL_DL_SQL92_INTERVAL_MINUTESQL_DL_SQL92_INTERVAL_SECONDSQL_DL_SQL92_INTERVAL_YEAR_TO_MONTHSQL_DL_SQL92_INTERVAL_DAY_TO_HOUR
+ SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTESQL_DL_SQL92_INTERVAL_DAY_TO_SECONDSQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTESQL_DL_SQL92_INTERVAL_HOUR_TO_SECONDSQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND
+ */
+ case SQL_DATETIME_LITERALS : //119 called
//assuming all datetime literals are supported
* ( ( Long* ) pInfoValuePtr ) =
- SQL_DL_SQL92_DATE |
- SQL_DL_SQL92_TIME |
- SQL_DL_SQL92_TIMESTAMP |
- SQL_DL_SQL92_INTERVAL_YEAR |
- SQL_DL_SQL92_INTERVAL_MONTH |
- SQL_DL_SQL92_INTERVAL_DAY |
- SQL_DL_SQL92_INTERVAL_HOUR |
- SQL_DL_SQL92_INTERVAL_MINUTE |
- SQL_DL_SQL92_INTERVAL_SECOND |
- SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
- SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR |
- SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
- SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |
- SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
- SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND |
- SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPADD scalar function.
- The following bitmasks are used to determine which intervals are supported:
- SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
- An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.SQL_DATETIME_LITERALS(ODBC 3.0)
- */
+ SQL_DL_SQL92_DATE |
+ SQL_DL_SQL92_TIME |
+ SQL_DL_SQL92_TIMESTAMP |
+ SQL_DL_SQL92_INTERVAL_YEAR |
+ SQL_DL_SQL92_INTERVAL_MONTH |
+ SQL_DL_SQL92_INTERVAL_DAY |
+ SQL_DL_SQL92_INTERVAL_HOUR |
+ SQL_DL_SQL92_INTERVAL_MINUTE |
+ SQL_DL_SQL92_INTERVAL_SECOND |
+ SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |
+ SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
+ SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND |
+ SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPADD scalar function.
+ The following bitmasks are used to determine which intervals are supported:
+ SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
+ An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.SQL_DATETIME_LITERALS(ODBC 3.0)
+ */
case SQL_TIMEDATE_ADD_INTERVALS : // 109 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_FN_TSI_FRAC_SECOND |
- SQL_FN_TSI_SECOND |
- SQL_FN_TSI_MINUTE |
- SQL_FN_TSI_HOUR |
- SQL_FN_TSI_DAY |
- SQL_FN_TSI_WEEK |
- SQL_FN_TSI_MONTH |
- SQL_FN_TSI_QUARTER |
- SQL_FN_TSI_YEAR ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPDIFF scalar function.
- The following bitmasks are used to determine which intervals are supported:
- SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
- An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.
- */
+ SQL_FN_TSI_FRAC_SECOND |
+ SQL_FN_TSI_SECOND |
+ SQL_FN_TSI_MINUTE |
+ SQL_FN_TSI_HOUR |
+ SQL_FN_TSI_DAY |
+ SQL_FN_TSI_WEEK |
+ SQL_FN_TSI_MONTH |
+ SQL_FN_TSI_QUARTER |
+ SQL_FN_TSI_YEAR ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPDIFF scalar function.
+ The following bitmasks are used to determine which intervals are supported:
+ SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
+ An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.
+ */
case SQL_TIMEDATE_DIFF_INTERVALS : //110 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_FN_TSI_FRAC_SECOND |
- SQL_FN_TSI_SECOND |
- SQL_FN_TSI_MINUTE |
- SQL_FN_TSI_HOUR |
- SQL_FN_TSI_DAY |
- SQL_FN_TSI_WEEK |
- SQL_FN_TSI_MONTH |
- SQL_FN_TSI_QUARTER |
- SQL_FN_TSI_YEAR ;
- break;
-
- case SQL_AGGREGATE_FUNCTIONS: //169 called
+ SQL_FN_TSI_FRAC_SECOND |
+ SQL_FN_TSI_SECOND |
+ SQL_FN_TSI_MINUTE |
+ SQL_FN_TSI_HOUR |
+ SQL_FN_TSI_DAY |
+ SQL_FN_TSI_WEEK |
+ SQL_FN_TSI_MONTH |
+ SQL_FN_TSI_QUARTER |
+ SQL_FN_TSI_YEAR ;
+ break;
+
+ case SQL_AGGREGATE_FUNCTIONS : //169 called
* ( ( Long* ) pInfoValuePtr ) = SQL_AF_ALL | SQL_AF_AVG | SQL_AF_COUNT | SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN |
- SQL_AF_SUM ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the datetime scalar functions that are supported by the driver and the associated data source, as defined in SQL-92.
- The following bitmasks are used to determine which datetime functions are supported:
- SQL_SDF_CURRENT_DATESQL_SDF_CURRENT_TIMESQL_SDF_CURRENT_TIMESTAMP
- */
- case SQL_SQL92_DATETIME_FUNCTIONS: //155 called
+ SQL_AF_SUM ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the datetime scalar functions that are supported by the driver and the associated data source, as defined in SQL-92.
+ The following bitmasks are used to determine which datetime functions are supported:
+ SQL_SDF_CURRENT_DATESQL_SDF_CURRENT_TIMESQL_SDF_CURRENT_TIMESTAMP
+ */
+ case SQL_SQL92_DATETIME_FUNCTIONS : //155 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_SDF_CURRENT_DATE |
- SQL_SDF_CURRENT_TIME |
- SQL_SDF_CURRENT_TIMESTAMP ;
+ SQL_SDF_CURRENT_DATE |
+ SQL_SDF_CURRENT_TIME |
+ SQL_SDF_CURRENT_TIMESTAMP ;
break;
-
- case SQL_SQL92_VALUE_EXPRESSIONS: //165 called
+
+ case SQL_SQL92_VALUE_EXPRESSIONS : //165 called
break;
-
- case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS: //159 called
+
+ case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS : //159 called
break;
-
- case SQL_SQL92_STRING_FUNCTIONS: //164 called
+
+ case SQL_SQL92_STRING_FUNCTIONS : //164 called
break;
-
- case SQL_SQL92_PREDICATES : //160 called
+
+ case SQL_SQL92_PREDICATES : //160 called
break;
-
- case SQL_SQL92_RELATIONAL_JOIN_OPERATORS : //161 called
+
+ case SQL_SQL92_RELATIONAL_JOIN_OPERATORS : //161 called
break;
-
- case SQL_DRIVER_ODBC_VER: // 77 called
+
+ case SQL_DRIVER_ODBC_VER : // 77 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "03.00", -1 );
//*pStringLengthPtr = *pStringLengthPtr *2;
break;
-
- case SQL_CURSOR_COMMIT_BEHAVIOR: //23 called
+
+ case SQL_CURSOR_COMMIT_BEHAVIOR : //23 called
//MessageBox ( GetDesktopWindow(), "SQL_CURSOR_COMMIT_BEHAVIOR", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CB_CLOSE;
break;
-
- case SQL_CORRELATION_NAME: //74
+
+ case SQL_CORRELATION_NAME : //74
//MessageBox ( GetDesktopWindow(), "SQL_CORRELATION_NAME", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CN_ANY;
break;
-
- case SQL_MAX_CONCURRENT_ACTIVITIES: // 1
-
+
+ case SQL_MAX_CONCURRENT_ACTIVITIES : // 1
+
//MessageBox ( GetDesktopWindow(), "SQL_MAX_CONCURRENT_ACTIVITIES", "SQLGetInfo", MB_OK );
- if ( pInfoValuePtr ) { * ( ( Word* ) pInfoValuePtr ) = 2; }
-
+ if ( pInfoValuePtr )
+ {
+ * ( ( Word* ) pInfoValuePtr ) = 2;
+ }
+
break;
-
- case SQL_ODBC_API_CONFORMANCE: // 9
-
+
+ case SQL_ODBC_API_CONFORMANCE : // 9
+
//MessageBox ( GetDesktopWindow(), "SQL_ODBC_API_CONFORMANCE", "SQLGetInfo", MB_OK );
- if ( pInfoValuePtr ) { * ( ( Word* ) pInfoValuePtr ) = SQL_OAC_NONE; } // for MS Access
-
+ if ( pInfoValuePtr )
+ {
+ * ( ( Word* ) pInfoValuePtr ) = SQL_OAC_NONE;
+ } // for MS Access
+
break;
-
- case SQL_DTC_TRANSITION_COST: // 1750
- break;
- case SQL_DATA_SOURCE_READ_ONLY: // 25
+ case SQL_DTC_TRANSITION_COST : // 1750
+ break;
+
+ case SQL_DATA_SOURCE_READ_ONLY : // 25
//MessageBox ( GetDesktopWindow(), "SQL_DATA_SOURCE_READ_ONLY", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_DRIVER_NAME: // 6
+
+ case SQL_DRIVER_NAME : // 6
//MessageBox ( GetDesktopWindow(), "SQL_DRIVER_NAME", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "driver.DLL", -1 );
break;
-
- case SQL_SEARCH_PATTERN_ESCAPE: // 14
+
+ case SQL_SEARCH_PATTERN_ESCAPE : // 14
//MessageBox ( GetDesktopWindow(), "SQL_SEARCH_PATTERN_ESCAPE", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "\\", -1 );
break;
-
- case SQL_NON_NULLABLE_COLUMNS: // 75
+
+ case SQL_NON_NULLABLE_COLUMNS : // 75
//MessageBox ( GetDesktopWindow(), "SQL_NON_NULLABLE_COLUMNS", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_NNC_NULL;
break;
-
- case SQL_QUALIFIER_NAME_SEPARATOR: // 41 called
+
+ case SQL_QUALIFIER_NAME_SEPARATOR : // 41 called
//MessageBox ( GetDesktopWindow(), "SQL_QUALIFIER_NAME_SEPARATOR", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, ".", -1 );
break;
-
- case SQL_FILE_USAGE: // 84
+
+ case SQL_FILE_USAGE : // 84
//MessageBox ( GetDesktopWindow(), "SQL_FILE_USAGE", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_FILE_NOT_SUPPORTED;
break;
-
- case SQL_QUALIFIER_TERM: // 42 // SQL_CATALOG_TERM: called
+
+ case SQL_QUALIFIER_TERM : // 42 // SQL_CATALOG_TERM: called
//MessageBox ( GetDesktopWindow(), "SQL_QUALIFIER_TERM", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "database", -1 );
break;
-
- case SQL_OWNER_TERM: // 39 //called
+
+ case SQL_OWNER_TERM : // 39 //called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "owner", -1 );
break;
-
- case SQL_TABLE_TERM: // 45 called
+
+ case SQL_TABLE_TERM : // 45 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "table", -1 );
break;
-
- case SQL_CURSOR_ROLLBACK_BEHAVIOR: // 24 called
+
+ case SQL_CURSOR_ROLLBACK_BEHAVIOR : // 24 called
//MessageBox ( GetDesktopWindow(), "SQL_CURSOR_ROLLBACK_BEHAVIOR", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CB_CLOSE;
break;
-
- case SQL_DATA_SOURCE_NAME: // 2
+
+ case SQL_DATA_SOURCE_NAME : // 2
//MessageBox ( GetDesktopWindow(), "SQL_DATA_SOURCE_NAME", "SQLGetInfo", MB_OK );
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "GODBC", -1 );
break;
-
- case 16:
+
+ case 16 :
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "default", -1 );
break;
-
- case SQL_PROCEDURES: // 21
+
+ case SQL_PROCEDURES : // 21
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_IDENTIFIER_QUOTE_CHAR: // 29 //called by tb
+
+ case SQL_IDENTIFIER_QUOTE_CHAR : // 29 //called by tb
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "\"", -1 );
break;
-
- case SQL_MAX_SCHEMA_NAME_LEN: // 32
+
+ case SQL_MAX_SCHEMA_NAME_LEN : // 32
* ( ( short* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_USER_NAME: // 47
+
+ case SQL_USER_NAME : // 47
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "default", -1 );
break;
-
- case SQL_POS_OPERATIONS: // 79
+
+ case SQL_POS_OPERATIONS : // 79
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_POS_POSITION;
break;
-
- case SQL_STATIC_SENSITIVITY: // 83
+
+ case SQL_STATIC_SENSITIVITY : // 83
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_SS_ADDITIONS;
break;
-
- case SQL_LOCK_TYPES: // 78
+
+ case SQL_LOCK_TYPES : // 78
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_LCK_NO_CHANGE;
break;
-
- case SQL_GETDATA_EXTENSIONS: // 81 called
+
+ case SQL_GETDATA_EXTENSIONS : // 81 called
* ( ( Long* ) pInfoValuePtr ) = SQL_GD_ANY_COLUMN;
break;
-
- case SQL_TXN_ISOLATION_OPTION: // 72
+
+ case SQL_TXN_ISOLATION_OPTION : // 72
* ( ( Long* ) pInfoValuePtr ) = SQL_TXN_SERIALIZABLE;
break;
-
- case SQL_BOOKMARK_PERSISTENCE: // 82
+
+ case SQL_BOOKMARK_PERSISTENCE : // 82
* ( ( Long* ) pInfoValuePtr ) = 0;
break;
-
- case SQL_SCROLL_OPTIONS: // 44
+
+ case SQL_SCROLL_OPTIONS : // 44
* ( ( Long* ) pInfoValuePtr ) = SQL_SO_FORWARD_ONLY;
break;
-
- case SQL_SCROLL_CONCURRENCY: // 43
+
+ case SQL_SCROLL_CONCURRENCY : // 43
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_SCCO_READ_ONLY;
break;
-
- case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: // 144
+
+ case SQL_DYNAMIC_CURSOR_ATTRIBUTES1 : // 144
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_KEYSET_CURSOR_ATTRIBUTES1: // 150
+
+ case SQL_KEYSET_CURSOR_ATTRIBUTES1 : // 150
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_STATIC_CURSOR_ATTRIBUTES1: // 167
+
+ case SQL_STATIC_CURSOR_ATTRIBUTES1 : // 167
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: // 146
+
+ case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 : // 146
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_KEYSET_CURSOR_ATTRIBUTES2: // 151
+
+ case SQL_KEYSET_CURSOR_ATTRIBUTES2 : // 151
* ( ( Long* ) pInfoValuePtr ) = SQL_CA2_READ_ONLY_CONCURRENCY;
break;
-
- case SQL_STATIC_CURSOR_ATTRIBUTES2: // 168
+
+ case SQL_STATIC_CURSOR_ATTRIBUTES2 : // 168
* ( ( Long* ) pInfoValuePtr ) = SQL_CA2_READ_ONLY_CONCURRENCY;
break;
-
- case SQL_NEED_LONG_DATA_LEN: // 111
+
+ case SQL_NEED_LONG_DATA_LEN : // 111
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
break;
-
- case SQL_TXN_CAPABLE: // 46 called
+
+ case SQL_TXN_CAPABLE : // 46 called
* ( ( Word* ) pInfoValuePtr ) = SQL_TC_NONE;
break;
-
- case SQL_DEFAULT_TXN_ISOLATION: // 26
+
+ case SQL_DEFAULT_TXN_ISOLATION : // 26
* ( ( Long* ) pInfoValuePtr ) = SQL_TXN_READ_COMMITTED;
break;
-
- case SQL_DBMS_NAME: // 17 called
+
+ case SQL_DBMS_NAME : // 17 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Gen ODBC Server", -1 );
break;
-
- case SQL_ODBC_SQL_CONFORMANCE: // 15
+
+ case SQL_ODBC_SQL_CONFORMANCE : // 15
// deprecated
* ( ( Word* ) pInfoValuePtr ) = SQL_OSC_MINIMUM;
break;
-
- case SQL_INTEGRITY: // 73
+
+ case SQL_INTEGRITY : // 73
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_QUALIFIER_USAGE: // 92 called
+
+ case SQL_QUALIFIER_USAGE : // 92 called
* ( ( Long* ) pInfoValuePtr ) = SQL_CU_DML_STATEMENTS | SQL_CU_PROCEDURE_INVOCATION | SQL_CU_TABLE_DEFINITION;
break;
-
- case SQL_DBMS_VER: // 18 called
+
+ case SQL_DBMS_VER : // 18 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "01.00.00000", -1 );
break;
-
- case SQL_QUOTED_IDENTIFIER_CASE: // 93 called
+
+ case SQL_QUOTED_IDENTIFIER_CASE : // 93 called
//*(( Word* )pInfoValuePtr) = SQL_IC_SENSITIVE;
* ( ( Word* ) pInfoValuePtr ) = SQL_IC_UPPER;
break;
-
- case SQL_MAX_CATALOG_NAME_LEN: // 34
+
+ case SQL_MAX_CATALOG_NAME_LEN : // 34
* ( ( Word* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_MAX_TABLE_NAME_LEN: // 35
+
+ case SQL_MAX_TABLE_NAME_LEN : // 35
* ( ( Word* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_ACTIVE_CONNECTIONS: // 0
+
+ case SQL_ACTIVE_CONNECTIONS : // 0
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACTIVE_CONNECTIONS" ));
break;
-
- case SQL_CATALOG_LOCATION: // 114
+
+ case SQL_CATALOG_LOCATION : // 114
* ( ( Word* ) pInfoValuePtr ) = SQL_CL_START;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_CATALOG_LOCATION" ));
break;
-
- case SQL_CATALOG_NAME: // 10003
+
+ case SQL_CATALOG_NAME : // 10003
break;
- case SQL_CONCAT_NULL_BEHAVIOR: // 22
+ case SQL_CONCAT_NULL_BEHAVIOR : // 22
* ( ( Word* ) pInfoValuePtr ) = SQL_CB_NULL;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_CONCAT_NULL_BEHAVIOR" ));
break;
-
- case SQL_GROUP_BY: // 88
+
+ case SQL_GROUP_BY : // 88
* ( ( Word* ) pInfoValuePtr ) = SQL_GB_GROUP_BY_EQUALS_SELECT;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_GROUP_BY" ));
break;
-
- case SQL_IDENTIFIER_CASE: // 28
+
+ case SQL_IDENTIFIER_CASE : // 28
* ( ( Word* ) pInfoValuePtr ) = SQL_IC_MIXED;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_IDENTIFIER_CASE" ));
break;
-
- case SQL_MAX_INDEX_SIZE: // 102
+
+ case SQL_MAX_INDEX_SIZE : // 102
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_INDEX_SIZE" ));
break;
-
- case SQL_MAX_ROW_SIZE: // 104
+
+ case SQL_MAX_ROW_SIZE : // 104
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_ROW_SIZE" ));
break;
-
- case SQL_MAX_ROW_SIZE_INCLUDES_LONG: // 103
+
+ case SQL_MAX_ROW_SIZE_INCLUDES_LONG : // 103
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_ROW_SIZE_INCLUDES_LONG" ));
break;
-
- case SQL_MAX_TABLES_IN_SELECT: // 106
+
+ case SQL_MAX_TABLES_IN_SELECT : // 106
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_TABLES_IN_SELECT" ));
break;
-
- case SQL_NULL_COLLATION: // 85
+
+ case SQL_NULL_COLLATION : // 85
* ( ( Word* ) pInfoValuePtr ) = SQL_NC_START;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_NULL_COLLATION" ));
break;
-
- case SQL_ORDER_BY_COLUMNS_IN_SELECT: // 90
+
+ case SQL_ORDER_BY_COLUMNS_IN_SELECT : // 90
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ORDER_BY_COLUMNS_IN_SELECT" ));
break;
-
- case SQL_PROCEDURE_TERM: // 40
+
+ case SQL_PROCEDURE_TERM : // 40
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "procedure", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_PROCEDURE_TERM" ));
break;
-
- case SQL_OWNER_USAGE: // 91 called
+
+ case SQL_OWNER_USAGE : // 91 called
* ( ( Word* ) pInfoValuePtr ) = SQL_SU_DML_STATEMENTS | SQL_SU_TABLE_DEFINITION | SQL_SU_PRIVILEGE_DEFINITION;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OWNER_USAGE" ));
break;
-
- case SQL_SUBQUERIES: // 95
+
+ case SQL_SUBQUERIES : // 95
* ( ( Long* ) pInfoValuePtr ) = SQL_SQ_CORRELATED_SUBQUERIES |
- SQL_SQ_COMPARISON |
- SQL_SQ_EXISTS |
- SQL_SQ_IN |
- SQL_SQ_QUANTIFIED;
+ SQL_SQ_COMPARISON |
+ SQL_SQ_EXISTS |
+ SQL_SQ_IN |
+ SQL_SQ_QUANTIFIED;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SUBQUERIES" ));
break;
-
- case SQL_MULT_RESULT_SETS: // 36:
+
+ case SQL_MULT_RESULT_SETS : // 36:
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MULT_RESULT_SETS" ));
break;
-
- case SQL_SERVER_NAME: // 13
+
+ case SQL_SERVER_NAME : // 13
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16,
- ( ( pODBCConn ) pConn )->Server ? ( ( pODBCConn ) pConn )->Server : "", -1 );
+ ( ( pODBCConn ) pConn ) -> Server ? ( ( pODBCConn ) pConn ) -> Server : "", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SERVER_NAME" ));
break;
-
- case SQL_ACCESSIBLE_PROCEDURES: // 20
+
+ case SQL_ACCESSIBLE_PROCEDURES : // 20
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACCESSIBLE_PROCEDURES" ));
break;
-
- case SQL_ACCESSIBLE_TABLES: // 19
+
+ case SQL_ACCESSIBLE_TABLES : // 19
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACCESSIBLE_TABLES" ));
break;
-
- case SQL_OJ_CAPABILITIES: // 115 called
+
+ case SQL_OJ_CAPABILITIES : // 115 called
* ( ( Long* ) pInfoValuePtr ) = SQL_OJ_LEFT |
- SQL_OJ_RIGHT |
- SQL_OJ_FULL |
- SQL_OJ_NESTED |
- SQL_OJ_NOT_ORDERED |
- SQL_OJ_INNER |
- SQL_OJ_ALL_COMPARISON_OPS;
+ SQL_OJ_RIGHT |
+ SQL_OJ_FULL |
+ SQL_OJ_NESTED |
+ SQL_OJ_NOT_ORDERED |
+ SQL_OJ_INNER |
+ SQL_OJ_ALL_COMPARISON_OPS;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OJ_CAPABILITIES" ));
break;
-
- case SQL_DRIVER_VER: // 7 called
+
+ case SQL_DRIVER_VER : // 7 called
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "01.00.00000", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_DRIVER_VER" ));
break;
-
- case SQL_LIKE_ESCAPE_CLAUSE: // 113
+
+ case SQL_LIKE_ESCAPE_CLAUSE : // 113
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_LIKE_ESCAPE_CLAUSE" ));
break;
-
- case SQL_SPECIAL_CHARACTERS: // 94 //called by tb
+
+ case SQL_SPECIAL_CHARACTERS : // 94 //called by tb
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "$_", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SPECIAL_CHARACTERS" ));
break;
-
- case SQL_MAX_COLUMNS_IN_GROUP_BY: // 97
+
+ case SQL_MAX_COLUMNS_IN_GROUP_BY : // 97
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_GROUP_BY" ));
break;
-
- case SQL_MAX_COLUMNS_IN_INDEX: // 98
+
+ case SQL_MAX_COLUMNS_IN_INDEX : // 98
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_INDEX" ));
break;
-
- case SQL_MAX_COLUMNS_IN_ORDER_BY: // 99
+
+ case SQL_MAX_COLUMNS_IN_ORDER_BY : // 99
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_ORDER_BY" ));
break;
-
- case SQL_MAX_COLUMNS_IN_SELECT: // 100
+
+ case SQL_MAX_COLUMNS_IN_SELECT : // 100
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_SELECT" ));
break;
-
- case SQL_MAX_COLUMNS_IN_TABLE: // 101
+
+ case SQL_MAX_COLUMNS_IN_TABLE : // 101
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_TABLE" ));
break;
-
- case SQL_NUMERIC_FUNCTIONS: // 49 called
- * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard numeric functions
+
+ case SQL_NUMERIC_FUNCTIONS : // 49 called
+ * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard numeric functions
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_NUMERIC_FUNCTIONS" ));
break;
-
- case SQL_OUTER_JOINS: // 38
+
+ case SQL_OUTER_JOINS : // 38
_SQLCopyWCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
// __ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OUTER_JOINS" ));
break;
-
- case SQL_STRING_FUNCTIONS: // 50 called
- * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard string functions
+
+ case SQL_STRING_FUNCTIONS : // 50 called
+ * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard string functions
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_STRING_FUNCTIONS" ));
break;
-
- case SQL_SYSTEM_FUNCTIONS: // 51 called
+
+ case SQL_SYSTEM_FUNCTIONS : // 51 called
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SYSTEM_FUNCTIONS" ));
break;
-
- /*
- Note: The information type was introduced in ODBC 1.0; each bitmask is labeled with the version in which it was introduced.
- An SQLUINTEGER bitmask enumerating the scalar date and time functions supported by the driver and associated data source.
- The following bitmasks are used to determine which date and time functions are supported:
- SQL_FN_TD_CURRENT_DATE ODBC 3.0)SQL_FN_TD_CURRENT_TIME (ODBC 3.0)SQL_FN_TD_CURRENT_TIMESTAMP (ODBC 3.0)SQL_FN_TD_CURDATE (ODBC 1.0)SQL_FN_TD_CURTIME (ODBC 1.0) SQL_FN_TD_DAYNAME (ODBC 2.0)SQL_FN_TD_DAYOFMONTH (ODBC 1.0)SQL_FN_TD_DAYOFWEEK (ODBC 1.0)SQL_FN_TD_DAYOFYEAR (ODBC 1.0) SQL_FN_TD_EXTRACT (ODBC 3.0)SQL_FN_TD_HOUR (ODBC 1.0)SQL_FN_TD_MINUTE (ODBC 1.0)SQL_FN_TD_MONTH (ODBC 1.0)SQL_FN_TD_MONTHNAME (ODBC 2.0)SQL_FN_TD_NOW (ODBC 1.0)SQL_FN_TD_QUARTER (ODBC 1.0)SQL_FN_TD_SECOND (ODBC 1.0)SQL_FN_TD_TIMESTAMPADD (ODBC 2.0)SQL_FN_TD_TIMESTAMPDIFF (ODBC 2.0)SQL_FN_TD_WEEK (ODBC 1.0)SQL_FN_TD_YEAR (ODBC 1.0)
- */
- case SQL_TIMEDATE_FUNCTIONS: // 52 called
+
+ /*
+ Note: The information type was introduced in ODBC 1.0; each bitmask is labeled with the version in which it was introduced.
+ An SQLUINTEGER bitmask enumerating the scalar date and time functions supported by the driver and associated data source.
+ The following bitmasks are used to determine which date and time functions are supported:
+ SQL_FN_TD_CURRENT_DATE ODBC 3.0)SQL_FN_TD_CURRENT_TIME (ODBC 3.0)SQL_FN_TD_CURRENT_TIMESTAMP (ODBC 3.0)SQL_FN_TD_CURDATE (ODBC 1.0)SQL_FN_TD_CURTIME (ODBC 1.0) SQL_FN_TD_DAYNAME (ODBC 2.0)SQL_FN_TD_DAYOFMONTH (ODBC 1.0)SQL_FN_TD_DAYOFWEEK (ODBC 1.0)SQL_FN_TD_DAYOFYEAR (ODBC 1.0) SQL_FN_TD_EXTRACT (ODBC 3.0)SQL_FN_TD_HOUR (ODBC 1.0)SQL_FN_TD_MINUTE (ODBC 1.0)SQL_FN_TD_MONTH (ODBC 1.0)SQL_FN_TD_MONTHNAME (ODBC 2.0)SQL_FN_TD_NOW (ODBC 1.0)SQL_FN_TD_QUARTER (ODBC 1.0)SQL_FN_TD_SECOND (ODBC 1.0)SQL_FN_TD_TIMESTAMPADD (ODBC 2.0)SQL_FN_TD_TIMESTAMPDIFF (ODBC 2.0)SQL_FN_TD_WEEK (ODBC 1.0)SQL_FN_TD_YEAR (ODBC 1.0)
+ */
+ case SQL_TIMEDATE_FUNCTIONS : // 52 called
* ( ( Long* ) pInfoValuePtr ) =
//SQL_FN_TD_CURRENT_DATE |
//SQL_FN_TD_CURRENT_TIME |
@@ -617,552 +625,560 @@ RETCODE SQL_API SQLGetInfoW ( SQLHDBC pConn,
//SQL_FN_TD_YEAR
;
break;
-
- default:
+
+ default :
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR,
- "Function Missing!!! SQLGetInfoW, Field: %d, DataPtr: %d, BufLen: %d, SizePtr: %d\n", pInfoType, pInfoValuePtr,
- pBufferLength, pStringLengthPtr ) );
+ "Function Missing!!! SQLGetInfoW, Field: %d, DataPtr: %d, BufLen: %d, SizePtr: %d\n", pInfoType, pInfoValuePtr,
+ pBufferLength, pStringLengthPtr ) );
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLGetInfo ( SQLHDBC pConn,
- SQLUSMALLINT pInfoType,
- SQLPOINTER pInfoValuePtr,
- SQLSMALLINT pBufferLength,
- SQLSMALLINT* pStringLengthPtr ) {
+RETCODE SQL_API SQLGetInfo ( SQLHDBC pConn,
+ SQLUSMALLINT pInfoType,
+ SQLPOINTER pInfoValuePtr,
+ SQLSMALLINT pBufferLength,
+ SQLSMALLINT* pStringLengthPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetInfo called: Field: %d, Length: %d", pInfoType, pBufferLength ) );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
+
// check the info required
- switch ( pInfoType ) {
- case SQL_COLUMN_ALIAS://87 called
+ switch ( pInfoType )
+ {
+ case SQL_COLUMN_ALIAS : //87 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
break;
-
- case SQL_CONVERT_FUNCTIONS ://48 called
- case SQL_CONVERT_BIGINT:
- case SQL_CONVERT_BINARY:
- case SQL_CONVERT_BIT:
- case SQL_CONVERT_CHAR:
- case SQL_CONVERT_GUID:
- case SQL_CONVERT_DATE:
- case SQL_CONVERT_DECIMAL:
- case SQL_CONVERT_DOUBLE:
- case SQL_CONVERT_FLOAT:
- case SQL_CONVERT_INTEGER:
- case SQL_CONVERT_INTERVAL_YEAR_MONTH:
- case SQL_CONVERT_INTERVAL_DAY_TIME:
- case SQL_CONVERT_LONGVARBINARY:
- case SQL_CONVERT_LONGVARCHAR:
- case SQL_CONVERT_NUMERIC:
- case SQL_CONVERT_REAL:
- case SQL_CONVERT_SMALLINT:
- case SQL_CONVERT_TIME:
- case SQL_CONVERT_TIMESTAMP:
- case SQL_CONVERT_TINYINT:
- case SQL_CONVERT_VARBINARY:
- case SQL_CONVERT_VARCHAR:
- case SQL_CONVERT_WCHAR:
- case SQL_CONVERT_WLONGVARCHAR:
- case SQL_CONVERT_WVARCHAR:
- break;
-
+
+ case SQL_CONVERT_FUNCTIONS : //48 called
+ case SQL_CONVERT_BIGINT :
+ case SQL_CONVERT_BINARY :
+ case SQL_CONVERT_BIT :
+ case SQL_CONVERT_CHAR :
+ case SQL_CONVERT_GUID :
+ case SQL_CONVERT_DATE :
+ case SQL_CONVERT_DECIMAL :
+ case SQL_CONVERT_DOUBLE :
+ case SQL_CONVERT_FLOAT :
+ case SQL_CONVERT_INTEGER :
+ case SQL_CONVERT_INTERVAL_YEAR_MONTH :
+ case SQL_CONVERT_INTERVAL_DAY_TIME :
+ case SQL_CONVERT_LONGVARBINARY :
+ case SQL_CONVERT_LONGVARCHAR :
+ case SQL_CONVERT_NUMERIC :
+ case SQL_CONVERT_REAL :
+ case SQL_CONVERT_SMALLINT :
+ case SQL_CONVERT_TIME :
+ case SQL_CONVERT_TIMESTAMP :
+ case SQL_CONVERT_TINYINT :
+ case SQL_CONVERT_VARBINARY :
+ case SQL_CONVERT_VARCHAR :
+ case SQL_CONVERT_WCHAR :
+ case SQL_CONVERT_WLONGVARCHAR :
+ case SQL_CONVERT_WVARCHAR :
+ break;
+
case SQL_MAX_IDENTIFIER_LEN : //10005 called
break;
-
- case SQL_ODBC_INTERFACE_CONFORMANCE://152 called
- break;
-
- case SQL_SQL_CONFORMANCE: //118 called
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the SQL-92 datetime literals supported by the data source. Note that these are the datetime literals listed in the SQL-92 specification and are separate from the datetime literal escape clauses defined by ODBC. For more information about the ODBC datetime literal escape clauses, see Date, Time, and Timestamp Literals.
- A FIPS Transitional level�Cconformant driver will always return the "1" value in the bitmask for the bits in the following list. A value of "0" means that SQL-92 datetime literals are not supported.
- The following bitmasks are used to determine which literals are supported:
- SQL_DL_SQL92_DATESQL_DL_SQL92_TIMESQL_DL_SQL92_TIMESTAMPSQL_DL_SQL92_INTERVAL_YEARSQL_DL_SQL92_INTERVAL_MONTHSQL_DL_SQL92_INTERVAL_DAYSQL_DL_SQL92_INTERVAL_HOURSQL_DL_SQL92_INTERVAL_MINUTESQL_DL_SQL92_INTERVAL_SECONDSQL_DL_SQL92_INTERVAL_YEAR_TO_MONTHSQL_DL_SQL92_INTERVAL_DAY_TO_HOUR
- SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTESQL_DL_SQL92_INTERVAL_DAY_TO_SECONDSQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTESQL_DL_SQL92_INTERVAL_HOUR_TO_SECONDSQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND
- */
- case SQL_DATETIME_LITERALS: //119 called
+
+ case SQL_ODBC_INTERFACE_CONFORMANCE : //152 called
+ break;
+
+ case SQL_SQL_CONFORMANCE : //118 called
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the SQL-92 datetime literals supported by the data source. Note that these are the datetime literals listed in the SQL-92 specification and are separate from the datetime literal escape clauses defined by ODBC. For more information about the ODBC datetime literal escape clauses, see Date, Time, and Timestamp Literals.
+ A FIPS Transitional level�Cconformant driver will always return the "1" value in the bitmask for the bits in the following list. A value of "0" means that SQL-92 datetime literals are not supported.
+ The following bitmasks are used to determine which literals are supported:
+ SQL_DL_SQL92_DATESQL_DL_SQL92_TIMESQL_DL_SQL92_TIMESTAMPSQL_DL_SQL92_INTERVAL_YEARSQL_DL_SQL92_INTERVAL_MONTHSQL_DL_SQL92_INTERVAL_DAYSQL_DL_SQL92_INTERVAL_HOURSQL_DL_SQL92_INTERVAL_MINUTESQL_DL_SQL92_INTERVAL_SECONDSQL_DL_SQL92_INTERVAL_YEAR_TO_MONTHSQL_DL_SQL92_INTERVAL_DAY_TO_HOUR
+ SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTESQL_DL_SQL92_INTERVAL_DAY_TO_SECONDSQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTESQL_DL_SQL92_INTERVAL_HOUR_TO_SECONDSQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND
+ */
+ case SQL_DATETIME_LITERALS : //119 called
//assuming all datetime literals are supported
* ( ( Long* ) pInfoValuePtr ) =
- SQL_DL_SQL92_DATE |
- SQL_DL_SQL92_TIME |
- SQL_DL_SQL92_TIMESTAMP |
- SQL_DL_SQL92_INTERVAL_YEAR |
- SQL_DL_SQL92_INTERVAL_MONTH |
- SQL_DL_SQL92_INTERVAL_DAY |
- SQL_DL_SQL92_INTERVAL_HOUR |
- SQL_DL_SQL92_INTERVAL_MINUTE |
- SQL_DL_SQL92_INTERVAL_SECOND |
- SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
- SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR |
- SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
- SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |
- SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
- SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND |
- SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPADD scalar function.
- The following bitmasks are used to determine which intervals are supported:
- SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
- An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.SQL_DATETIME_LITERALS(ODBC 3.0)
- */
+ SQL_DL_SQL92_DATE |
+ SQL_DL_SQL92_TIME |
+ SQL_DL_SQL92_TIMESTAMP |
+ SQL_DL_SQL92_INTERVAL_YEAR |
+ SQL_DL_SQL92_INTERVAL_MONTH |
+ SQL_DL_SQL92_INTERVAL_DAY |
+ SQL_DL_SQL92_INTERVAL_HOUR |
+ SQL_DL_SQL92_INTERVAL_MINUTE |
+ SQL_DL_SQL92_INTERVAL_SECOND |
+ SQL_DL_SQL92_INTERVAL_YEAR_TO_MONTH |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_HOUR |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_MINUTE |
+ SQL_DL_SQL92_INTERVAL_DAY_TO_SECOND |
+ SQL_DL_SQL92_INTERVAL_HOUR_TO_MINUTE |
+ SQL_DL_SQL92_INTERVAL_HOUR_TO_SECOND |
+ SQL_DL_SQL92_INTERVAL_MINUTE_TO_SECOND ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPADD scalar function.
+ The following bitmasks are used to determine which intervals are supported:
+ SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
+ An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.SQL_DATETIME_LITERALS(ODBC 3.0)
+ */
case SQL_TIMEDATE_ADD_INTERVALS : // 109 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_FN_TSI_FRAC_SECOND |
- SQL_FN_TSI_SECOND |
- SQL_FN_TSI_MINUTE |
- SQL_FN_TSI_HOUR |
- SQL_FN_TSI_DAY |
- SQL_FN_TSI_WEEK |
- SQL_FN_TSI_MONTH |
- SQL_FN_TSI_QUARTER |
- SQL_FN_TSI_YEAR ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPDIFF scalar function.
- The following bitmasks are used to determine which intervals are supported:
- SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
- An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.
- */
+ SQL_FN_TSI_FRAC_SECOND |
+ SQL_FN_TSI_SECOND |
+ SQL_FN_TSI_MINUTE |
+ SQL_FN_TSI_HOUR |
+ SQL_FN_TSI_DAY |
+ SQL_FN_TSI_WEEK |
+ SQL_FN_TSI_MONTH |
+ SQL_FN_TSI_QUARTER |
+ SQL_FN_TSI_YEAR ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the timestamp intervals supported by the driver and associated data source for the TIMESTAMPDIFF scalar function.
+ The following bitmasks are used to determine which intervals are supported:
+ SQL_FN_TSI_FRAC_SECONDSQL_FN_TSI_SECONDSQL_FN_TSI_MINUTESQL_FN_TSI_HOURSQL_FN_TSI_DAYSQL_FN_TSI_WEEKSQL_FN_TSI_MONTHSQL_FN_TSI_QUARTERSQL_FN_TSI_YEAR
+ An FIPS Transitional level�Cconformant driver will always return a bitmask in which all of these bits are set.
+ */
case SQL_TIMEDATE_DIFF_INTERVALS : //110 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_FN_TSI_FRAC_SECOND |
- SQL_FN_TSI_SECOND |
- SQL_FN_TSI_MINUTE |
- SQL_FN_TSI_HOUR |
- SQL_FN_TSI_DAY |
- SQL_FN_TSI_WEEK |
- SQL_FN_TSI_MONTH |
- SQL_FN_TSI_QUARTER |
- SQL_FN_TSI_YEAR ;
- break;
-
- case SQL_AGGREGATE_FUNCTIONS: //169 called
+ SQL_FN_TSI_FRAC_SECOND |
+ SQL_FN_TSI_SECOND |
+ SQL_FN_TSI_MINUTE |
+ SQL_FN_TSI_HOUR |
+ SQL_FN_TSI_DAY |
+ SQL_FN_TSI_WEEK |
+ SQL_FN_TSI_MONTH |
+ SQL_FN_TSI_QUARTER |
+ SQL_FN_TSI_YEAR ;
+ break;
+
+ case SQL_AGGREGATE_FUNCTIONS : //169 called
* ( ( Long* ) pInfoValuePtr ) = SQL_AF_ALL | SQL_AF_AVG | SQL_AF_COUNT | SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN |
- SQL_AF_SUM ;
- break;
-
- /*
- An SQLUINTEGER bitmask enumerating the datetime scalar functions that are supported by the driver and the associated data source, as defined in SQL-92.
- The following bitmasks are used to determine which datetime functions are supported:
- SQL_SDF_CURRENT_DATESQL_SDF_CURRENT_TIMESQL_SDF_CURRENT_TIMESTAMP
- */
- case SQL_SQL92_DATETIME_FUNCTIONS: //155 called
+ SQL_AF_SUM ;
+ break;
+
+ /*
+ An SQLUINTEGER bitmask enumerating the datetime scalar functions that are supported by the driver and the associated data source, as defined in SQL-92.
+ The following bitmasks are used to determine which datetime functions are supported:
+ SQL_SDF_CURRENT_DATESQL_SDF_CURRENT_TIMESQL_SDF_CURRENT_TIMESTAMP
+ */
+ case SQL_SQL92_DATETIME_FUNCTIONS : //155 called
* ( ( Long* ) pInfoValuePtr ) =
- SQL_SDF_CURRENT_DATE |
- SQL_SDF_CURRENT_TIME |
- SQL_SDF_CURRENT_TIMESTAMP ;
+ SQL_SDF_CURRENT_DATE |
+ SQL_SDF_CURRENT_TIME |
+ SQL_SDF_CURRENT_TIMESTAMP ;
break;
-
- case SQL_SQL92_VALUE_EXPRESSIONS: //165 called
+
+ case SQL_SQL92_VALUE_EXPRESSIONS : //165 called
break;
-
- case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS: //159 called
+
+ case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS : //159 called
break;
-
- case SQL_SQL92_STRING_FUNCTIONS: //164 called
+
+ case SQL_SQL92_STRING_FUNCTIONS : //164 called
break;
-
- case SQL_SQL92_PREDICATES : //160 called
+
+ case SQL_SQL92_PREDICATES : //160 called
break;
-
- case SQL_SQL92_RELATIONAL_JOIN_OPERATORS : //161 called
+
+ case SQL_SQL92_RELATIONAL_JOIN_OPERATORS : //161 called
break;
-
- case SQL_DRIVER_ODBC_VER: // 77 called
+
+ case SQL_DRIVER_ODBC_VER : // 77 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "03.00", -1 );
break;
-
- case SQL_CURSOR_COMMIT_BEHAVIOR: //23 called
+
+ case SQL_CURSOR_COMMIT_BEHAVIOR : //23 called
//MessageBox ( GetDesktopWindow(), "SQL_CURSOR_COMMIT_BEHAVIOR", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CB_CLOSE;
break;
-
- case SQL_CORRELATION_NAME: //74
+
+ case SQL_CORRELATION_NAME : //74
//MessageBox ( GetDesktopWindow(), "SQL_CORRELATION_NAME", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CN_ANY;
break;
-
- case SQL_MAX_CONCURRENT_ACTIVITIES: // 1
-
+
+ case SQL_MAX_CONCURRENT_ACTIVITIES : // 1
+
//MessageBox ( GetDesktopWindow(), "SQL_MAX_CONCURRENT_ACTIVITIES", "SQLGetInfo", MB_OK );
- if ( pInfoValuePtr ) { * ( ( Word* ) pInfoValuePtr ) = 2; }
-
+ if ( pInfoValuePtr )
+ {
+ * ( ( Word* ) pInfoValuePtr ) = 2;
+ }
+
break;
-
- case SQL_ODBC_API_CONFORMANCE: // 9
-
+
+ case SQL_ODBC_API_CONFORMANCE : // 9
+
//MessageBox ( GetDesktopWindow(), "SQL_ODBC_API_CONFORMANCE", "SQLGetInfo", MB_OK );
- if ( pInfoValuePtr ) { * ( ( Word* ) pInfoValuePtr ) = SQL_OAC_NONE; } // for MS Access
-
+ if ( pInfoValuePtr )
+ {
+ * ( ( Word* ) pInfoValuePtr ) = SQL_OAC_NONE;
+ } // for MS Access
+
break;
- case SQL_DTC_TRANSITION_COST: // 1750
- break;
-
- case SQL_DATA_SOURCE_READ_ONLY: // 25
+ case SQL_DTC_TRANSITION_COST : // 1750
+ break;
+
+ case SQL_DATA_SOURCE_READ_ONLY : // 25
//MessageBox ( GetDesktopWindow(), "SQL_DATA_SOURCE_READ_ONLY", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_DRIVER_NAME: // 6 //called by tb
+
+ case SQL_DRIVER_NAME : // 6 //called by tb
//MessageBox ( GetDesktopWindow(), "SQL_DRIVER_NAME", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "driver.DLL", -1 );
break;
-
- case SQL_SEARCH_PATTERN_ESCAPE: // 14
+
+ case SQL_SEARCH_PATTERN_ESCAPE : // 14
//MessageBox ( GetDesktopWindow(), "SQL_SEARCH_PATTERN_ESCAPE", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "\\", -1 );
break;
-
- case SQL_NON_NULLABLE_COLUMNS: // 75
+
+ case SQL_NON_NULLABLE_COLUMNS : // 75
//MessageBox ( GetDesktopWindow(), "SQL_NON_NULLABLE_COLUMNS", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_NNC_NULL;
break;
-
- case SQL_QUALIFIER_NAME_SEPARATOR: // 41 called
+
+ case SQL_QUALIFIER_NAME_SEPARATOR : // 41 called
//MessageBox ( GetDesktopWindow(), "SQL_QUALIFIER_NAME_SEPARATOR", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, ".", -1 );
break;
-
- case SQL_FILE_USAGE: // 84
+
+ case SQL_FILE_USAGE : // 84
//MessageBox ( GetDesktopWindow(), "SQL_FILE_USAGE", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_FILE_NOT_SUPPORTED;
break;
-
- case SQL_QUALIFIER_TERM: // 42 // SQL_CATALOG_TERM: called
+
+ case SQL_QUALIFIER_TERM : // 42 // SQL_CATALOG_TERM: called
//MessageBox ( GetDesktopWindow(), "SQL_QUALIFIER_TERM", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "database", -1 );
break;
-
- case SQL_OWNER_TERM: // 39 //called
+
+ case SQL_OWNER_TERM : // 39 //called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "owner", -1 );
break;
-
- case SQL_TABLE_TERM: // 45 called
+
+ case SQL_TABLE_TERM : // 45 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "table", -1 );
break;
-
- case SQL_CURSOR_ROLLBACK_BEHAVIOR: // 24 called
+
+ case SQL_CURSOR_ROLLBACK_BEHAVIOR : // 24 called
//MessageBox ( GetDesktopWindow(), "SQL_CURSOR_ROLLBACK_BEHAVIOR", "SQLGetInfo", MB_OK );
* ( ( short* ) pInfoValuePtr ) = SQL_CB_CLOSE;
break;
-
- case SQL_DATA_SOURCE_NAME: // 2
+
+ case SQL_DATA_SOURCE_NAME : // 2
//MessageBox ( GetDesktopWindow(), "SQL_DATA_SOURCE_NAME", "SQLGetInfo", MB_OK );
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "GODBC", -1 );
break;
-
- case 16:
+
+ case 16 :
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "default", -1 );
break;
-
- case SQL_PROCEDURES: // 21
+
+ case SQL_PROCEDURES : // 21
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_IDENTIFIER_QUOTE_CHAR: // 29 //called by tb
+
+ case SQL_IDENTIFIER_QUOTE_CHAR : // 29 //called by tb
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "\"", -1 );
break;
-
- case SQL_MAX_SCHEMA_NAME_LEN:
+
+ case SQL_MAX_SCHEMA_NAME_LEN :
* ( ( short* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_USER_NAME:
+
+ case SQL_USER_NAME :
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "default", -1 );
break;
-
- case SQL_POS_OPERATIONS: // 79
+
+ case SQL_POS_OPERATIONS : // 79
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_POS_POSITION;
break;
-
- case SQL_STATIC_SENSITIVITY: // 83
+
+ case SQL_STATIC_SENSITIVITY : // 83
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_SS_ADDITIONS;
break;
-
- case SQL_LOCK_TYPES: // 78
+
+ case SQL_LOCK_TYPES : // 78
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_LCK_NO_CHANGE;
break;
-
- case SQL_GETDATA_EXTENSIONS: // 81 called
+
+ case SQL_GETDATA_EXTENSIONS : // 81 called
* ( ( Long* ) pInfoValuePtr ) = SQL_GD_ANY_COLUMN;
break;
-
- case SQL_TXN_ISOLATION_OPTION: // 72
+
+ case SQL_TXN_ISOLATION_OPTION : // 72
* ( ( Long* ) pInfoValuePtr ) = SQL_TXN_SERIALIZABLE;
break;
-
- case SQL_BOOKMARK_PERSISTENCE: // 82
+
+ case SQL_BOOKMARK_PERSISTENCE : // 82
* ( ( Long* ) pInfoValuePtr ) = 0;
break;
-
- case SQL_SCROLL_OPTIONS: // 44
+
+ case SQL_SCROLL_OPTIONS : // 44
* ( ( Long* ) pInfoValuePtr ) = SQL_SO_FORWARD_ONLY;
break;
-
- case SQL_SCROLL_CONCURRENCY: // 43
+
+ case SQL_SCROLL_CONCURRENCY : // 43
// deprecated
* ( ( Long* ) pInfoValuePtr ) = SQL_SCCO_READ_ONLY;
break;
-
- case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: // 144
+
+ case SQL_DYNAMIC_CURSOR_ATTRIBUTES1 : // 144
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_KEYSET_CURSOR_ATTRIBUTES1: // 150
+
+ case SQL_KEYSET_CURSOR_ATTRIBUTES1 : // 150
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_STATIC_CURSOR_ATTRIBUTES1: // 167
+
+ case SQL_STATIC_CURSOR_ATTRIBUTES1 : // 167
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: // 146
+
+ case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 : // 146
* ( ( Long* ) pInfoValuePtr ) = SQL_CA1_NEXT;
break;
-
- case SQL_KEYSET_CURSOR_ATTRIBUTES2: // 151
+
+ case SQL_KEYSET_CURSOR_ATTRIBUTES2 : // 151
* ( ( Long* ) pInfoValuePtr ) = SQL_CA2_READ_ONLY_CONCURRENCY;
break;
-
- case SQL_STATIC_CURSOR_ATTRIBUTES2: // 168
+
+ case SQL_STATIC_CURSOR_ATTRIBUTES2 : // 168
* ( ( Long* ) pInfoValuePtr ) = SQL_CA2_READ_ONLY_CONCURRENCY;
break;
-
- case SQL_NEED_LONG_DATA_LEN: // 111
+
+ case SQL_NEED_LONG_DATA_LEN : // 111
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
break;
-
- case SQL_TXN_CAPABLE: // 46 called
+
+ case SQL_TXN_CAPABLE : // 46 called
* ( ( Word* ) pInfoValuePtr ) = SQL_TC_NONE;
break;
-
- case SQL_DEFAULT_TXN_ISOLATION: // 26
+
+ case SQL_DEFAULT_TXN_ISOLATION : // 26
* ( ( Long* ) pInfoValuePtr ) = SQL_TXN_READ_COMMITTED;
break;
-
- case SQL_DBMS_NAME: // 17 called
+
+ case SQL_DBMS_NAME : // 17 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Gen ODBC Server", -1 );
break;
-
- case SQL_ODBC_SQL_CONFORMANCE: // 15
+
+ case SQL_ODBC_SQL_CONFORMANCE : // 15
// deprecated
* ( ( Word* ) pInfoValuePtr ) = SQL_OSC_MINIMUM;
break;
-
- case SQL_INTEGRITY: // 73
+
+ case SQL_INTEGRITY : // 73
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
break;
-
- case SQL_QUALIFIER_USAGE: // 92 called
+
+ case SQL_QUALIFIER_USAGE : // 92 called
* ( ( Long* ) pInfoValuePtr ) = SQL_CU_DML_STATEMENTS | SQL_CU_PROCEDURE_INVOCATION | SQL_CU_TABLE_DEFINITION;
break;
-
- case SQL_DBMS_VER: // 18 called
+
+ case SQL_DBMS_VER : // 18 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "01.00.00000", -1 );
break;
-
- case SQL_QUOTED_IDENTIFIER_CASE: // 93 called
+
+ case SQL_QUOTED_IDENTIFIER_CASE : // 93 called
//*(( Word* )pInfoValuePtr) = SQL_IC_SENSITIVE;
* ( ( Word* ) pInfoValuePtr ) = SQL_IC_UPPER;
break;
-
- case SQL_MAX_CATALOG_NAME_LEN: // 34
+
+ case SQL_MAX_CATALOG_NAME_LEN : // 34
* ( ( Word* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_MAX_TABLE_NAME_LEN: // 35
+
+ case SQL_MAX_TABLE_NAME_LEN : // 35
* ( ( Word* ) pInfoValuePtr ) = 128;
break;
-
- case SQL_ACTIVE_CONNECTIONS: // 0
+
+ case SQL_ACTIVE_CONNECTIONS : // 0
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACTIVE_CONNECTIONS" ));
break;
-
- case SQL_CATALOG_LOCATION: // 114
+
+ case SQL_CATALOG_LOCATION : // 114
* ( ( Word* ) pInfoValuePtr ) = SQL_CL_START;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_CATALOG_LOCATION" ));
break;
-
- case SQL_CATALOG_NAME: // 10003
+
+ case SQL_CATALOG_NAME : // 10003
break;
- case SQL_CONCAT_NULL_BEHAVIOR: // 22
+ case SQL_CONCAT_NULL_BEHAVIOR : // 22
* ( ( Word* ) pInfoValuePtr ) = SQL_CB_NULL;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_CONCAT_NULL_BEHAVIOR" ));
break;
-
- case SQL_GROUP_BY: // 88
+
+ case SQL_GROUP_BY : // 88
* ( ( Word* ) pInfoValuePtr ) = SQL_GB_GROUP_BY_EQUALS_SELECT;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_GROUP_BY" ));
break;
-
- case SQL_IDENTIFIER_CASE: // 28
+
+ case SQL_IDENTIFIER_CASE : // 28
* ( ( Word* ) pInfoValuePtr ) = SQL_IC_MIXED;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_IDENTIFIER_CASE" ));
break;
-
- case SQL_MAX_INDEX_SIZE: // 102
+
+ case SQL_MAX_INDEX_SIZE : // 102
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_INDEX_SIZE" ));
break;
-
- case SQL_MAX_ROW_SIZE: // 104
+
+ case SQL_MAX_ROW_SIZE : // 104
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_ROW_SIZE" ));
break;
-
- case SQL_MAX_ROW_SIZE_INCLUDES_LONG: // 103
+
+ case SQL_MAX_ROW_SIZE_INCLUDES_LONG : // 103
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_ROW_SIZE_INCLUDES_LONG" ));
break;
-
- case SQL_MAX_TABLES_IN_SELECT: // 106
+
+ case SQL_MAX_TABLES_IN_SELECT : // 106
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_TABLES_IN_SELECT" ));
break;
-
- case SQL_NULL_COLLATION: // 85
+
+ case SQL_NULL_COLLATION : // 85
* ( ( Word* ) pInfoValuePtr ) = SQL_NC_START;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_NULL_COLLATION" ));
break;
-
- case SQL_ORDER_BY_COLUMNS_IN_SELECT: // 90
+
+ case SQL_ORDER_BY_COLUMNS_IN_SELECT : // 90
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "N", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ORDER_BY_COLUMNS_IN_SELECT" ));
break;
-
- case SQL_PROCEDURE_TERM: // 40
+
+ case SQL_PROCEDURE_TERM : // 40
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "procedure", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_PROCEDURE_TERM" ));
break;
-
- case SQL_OWNER_USAGE: // 91 called
+
+ case SQL_OWNER_USAGE : // 91 called
* ( ( Word* ) pInfoValuePtr ) = SQL_SU_DML_STATEMENTS | SQL_SU_TABLE_DEFINITION | SQL_SU_PRIVILEGE_DEFINITION;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OWNER_USAGE" ));
break;
-
- case SQL_SUBQUERIES: // 95
+
+ case SQL_SUBQUERIES : // 95
* ( ( Long* ) pInfoValuePtr ) = SQL_SQ_CORRELATED_SUBQUERIES |
- SQL_SQ_COMPARISON |
- SQL_SQ_EXISTS |
- SQL_SQ_IN |
- SQL_SQ_QUANTIFIED;
+ SQL_SQ_COMPARISON |
+ SQL_SQ_EXISTS |
+ SQL_SQ_IN |
+ SQL_SQ_QUANTIFIED;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SUBQUERIES" ));
break;
-
- case SQL_MULT_RESULT_SETS: // 36:
+
+ case SQL_MULT_RESULT_SETS : // 36:
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MULT_RESULT_SETS" ));
break;
-
- case SQL_SERVER_NAME: // 13
+
+ case SQL_SERVER_NAME : // 13
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16,
- ( ( pODBCConn ) pConn )->Server ? ( ( pODBCConn ) pConn )->Server : "", -1 );
+ ( ( pODBCConn ) pConn ) -> Server ? ( ( pODBCConn ) pConn ) -> Server : "", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SERVER_NAME" ));
break;
-
- case SQL_ACCESSIBLE_PROCEDURES: // 20
+
+ case SQL_ACCESSIBLE_PROCEDURES : // 20
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACCESSIBLE_PROCEDURES" ));
break;
-
- case SQL_ACCESSIBLE_TABLES: // 19
+
+ case SQL_ACCESSIBLE_TABLES : // 19
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_ACCESSIBLE_TABLES" ));
break;
-
- case SQL_OJ_CAPABILITIES: // 115 called
+
+ case SQL_OJ_CAPABILITIES : // 115 called
* ( ( Long* ) pInfoValuePtr ) = SQL_OJ_LEFT |
- SQL_OJ_RIGHT |
- SQL_OJ_FULL |
- SQL_OJ_NESTED |
- SQL_OJ_NOT_ORDERED |
- SQL_OJ_INNER |
- SQL_OJ_ALL_COMPARISON_OPS;
+ SQL_OJ_RIGHT |
+ SQL_OJ_FULL |
+ SQL_OJ_NESTED |
+ SQL_OJ_NOT_ORDERED |
+ SQL_OJ_INNER |
+ SQL_OJ_ALL_COMPARISON_OPS;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OJ_CAPABILITIES" ));
break;
-
- case SQL_DRIVER_VER: // 7 called
+
+ case SQL_DRIVER_VER : // 7 called
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "01.00.00000", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_DRIVER_VER" ));
break;
-
- case SQL_LIKE_ESCAPE_CLAUSE: // 113
+
+ case SQL_LIKE_ESCAPE_CLAUSE : // 113
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_LIKE_ESCAPE_CLAUSE" ));
break;
-
- case SQL_SPECIAL_CHARACTERS: // 94 //called by tb
+
+ case SQL_SPECIAL_CHARACTERS : // 94 //called by tb
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "$_", -1 );
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SPECIAL_CHARACTERS" ));
break;
-
- case SQL_MAX_COLUMNS_IN_GROUP_BY: // 97
+
+ case SQL_MAX_COLUMNS_IN_GROUP_BY : // 97
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_GROUP_BY" ));
break;
-
- case SQL_MAX_COLUMNS_IN_INDEX: // 98
+
+ case SQL_MAX_COLUMNS_IN_INDEX : // 98
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_INDEX" ));
break;
-
- case SQL_MAX_COLUMNS_IN_ORDER_BY: // 99
+
+ case SQL_MAX_COLUMNS_IN_ORDER_BY : // 99
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_ORDER_BY" ));
break;
-
- case SQL_MAX_COLUMNS_IN_SELECT: // 100
+
+ case SQL_MAX_COLUMNS_IN_SELECT : // 100
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_SELECT" ));
break;
-
- case SQL_MAX_COLUMNS_IN_TABLE: // 101
+
+ case SQL_MAX_COLUMNS_IN_TABLE : // 101
* ( ( Word* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_MAX_COLUMNS_IN_TABLE" ));
break;
-
- case SQL_NUMERIC_FUNCTIONS: // 49 called
- * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard numeric functions
+
+ case SQL_NUMERIC_FUNCTIONS : // 49 called
+ * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard numeric functions
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_NUMERIC_FUNCTIONS" ));
break;
-
- case SQL_OUTER_JOINS: // 38
+
+ case SQL_OUTER_JOINS : // 38
_SQLCopyCharData ( _DIAGCONN ( pConn ), pInfoValuePtr, pBufferLength, pStringLengthPtr, 16, "Y", -1 );
// __ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_OUTER_JOINS" ));
break;
-
- case SQL_STRING_FUNCTIONS: // 50 called
- * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard string functions
+
+ case SQL_STRING_FUNCTIONS : // 50 called
+ * ( ( Long* ) pInfoValuePtr ) = 0; // ???? set of standard string functions
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_STRING_FUNCTIONS" ));
break;
-
- case SQL_SYSTEM_FUNCTIONS: // 51 called
+
+ case SQL_SYSTEM_FUNCTIONS : // 51 called
* ( ( Long* ) pInfoValuePtr ) = 0;
//__ODBCPOPMSG(_ODBCPopMsg("SQLGetInfo, SQL_SYSTEM_FUNCTIONS" ));
break;
-
- /*
- Note: The information type was introduced in ODBC 1.0; each bitmask is labeled with the version in which it was introduced.
- An SQLUINTEGER bitmask enumerating the scalar date and time functions supported by the driver and associated data source.
- The following bitmasks are used to determine which date and time functions are supported:
- SQL_FN_TD_CURRENT_DATE ODBC 3.0)SQL_FN_TD_CURRENT_TIME (ODBC 3.0)SQL_FN_TD_CURRENT_TIMESTAMP (ODBC 3.0)SQL_FN_TD_CURDATE (ODBC 1.0)SQL_FN_TD_CURTIME (ODBC 1.0) SQL_FN_TD_DAYNAME (ODBC 2.0)SQL_FN_TD_DAYOFMONTH (ODBC 1.0)SQL_FN_TD_DAYOFWEEK (ODBC 1.0)SQL_FN_TD_DAYOFYEAR (ODBC 1.0) SQL_FN_TD_EXTRACT (ODBC 3.0)SQL_FN_TD_HOUR (ODBC 1.0)SQL_FN_TD_MINUTE (ODBC 1.0)SQL_FN_TD_MONTH (ODBC 1.0)SQL_FN_TD_MONTHNAME (ODBC 2.0)SQL_FN_TD_NOW (ODBC 1.0)SQL_FN_TD_QUARTER (ODBC 1.0)SQL_FN_TD_SECOND (ODBC 1.0)SQL_FN_TD_TIMESTAMPADD (ODBC 2.0)SQL_FN_TD_TIMESTAMPDIFF (ODBC 2.0)SQL_FN_TD_WEEK (ODBC 1.0)SQL_FN_TD_YEAR (ODBC 1.0)
- */
- case SQL_TIMEDATE_FUNCTIONS: // 52 called
+
+ /*
+ Note: The information type was introduced in ODBC 1.0; each bitmask is labeled with the version in which it was introduced.
+ An SQLUINTEGER bitmask enumerating the scalar date and time functions supported by the driver and associated data source.
+ The following bitmasks are used to determine which date and time functions are supported:
+ SQL_FN_TD_CURRENT_DATE ODBC 3.0)SQL_FN_TD_CURRENT_TIME (ODBC 3.0)SQL_FN_TD_CURRENT_TIMESTAMP (ODBC 3.0)SQL_FN_TD_CURDATE (ODBC 1.0)SQL_FN_TD_CURTIME (ODBC 1.0) SQL_FN_TD_DAYNAME (ODBC 2.0)SQL_FN_TD_DAYOFMONTH (ODBC 1.0)SQL_FN_TD_DAYOFWEEK (ODBC 1.0)SQL_FN_TD_DAYOFYEAR (ODBC 1.0) SQL_FN_TD_EXTRACT (ODBC 3.0)SQL_FN_TD_HOUR (ODBC 1.0)SQL_FN_TD_MINUTE (ODBC 1.0)SQL_FN_TD_MONTH (ODBC 1.0)SQL_FN_TD_MONTHNAME (ODBC 2.0)SQL_FN_TD_NOW (ODBC 1.0)SQL_FN_TD_QUARTER (ODBC 1.0)SQL_FN_TD_SECOND (ODBC 1.0)SQL_FN_TD_TIMESTAMPADD (ODBC 2.0)SQL_FN_TD_TIMESTAMPDIFF (ODBC 2.0)SQL_FN_TD_WEEK (ODBC 1.0)SQL_FN_TD_YEAR (ODBC 1.0)
+ */
+ case SQL_TIMEDATE_FUNCTIONS : // 52 called
* ( ( Long* ) pInfoValuePtr ) =
SQL_FN_TD_CURRENT_DATE |
SQL_FN_TD_CURRENT_TIME |
@@ -1186,60 +1202,67 @@ RETCODE SQL_API SQLGetInfo ( SQLHDBC pConn,
SQL_FN_TD_WEEK |
SQL_FN_TD_YEAR ;
break;
-
- default:
+
+ default :
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR,
- "Function Missing!!! SQLGetInfo, Field: %d, DataPtr: %d, BufLen: %d, SizePtr: %d\n", pInfoType, pInfoValuePtr,
- pBufferLength, pStringLengthPtr ) );
+ "Function Missing!!! SQLGetInfo, Field: %d, DataPtr: %d, BufLen: %d, SizePtr: %d\n", pInfoType, pInfoValuePtr,
+ pBufferLength, pStringLengthPtr ) );
}
-
+
return SQL_SUCCESS;
}
// -----------------------------------------------------------------------
// to get type related information, this communicates with the server
// -----------------------------------------------------------------------
-RETCODE SQL_API _SQLGetTypeInfoBasic ( HSTMT pStmt, SWORD pDataType ) {
+RETCODE SQL_API _SQLGetTypeInfoBasic ( HSTMT pStmt, SWORD pDataType )
+{
__CHK_HANDLE(pStmt,SQL_HANDLE_STMT,SQL_ERROR);
-
- std::unique_ptr<SQLResponse> p;
- try {
- wstring info = U("{\"columnMetas\":[{\"isNullable\":0,\"displaySize\":10,\"label\":\"TYPE_NAME\",\"name\":\"TYPE_NAME\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":128,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR(128)\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":0,\"displaySize\":5,\"label\":\"DATA_TYPE\",\"name\":\"DATA_TYPE\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":1,\"displaySize\":10,\"label\":\"COLUMN_SIZE\",\"name\":\"COLUMN_SIZE\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":10,\"scal
e\":0,\"columnType\":4,\"columnTypeName\":\"INTEGER\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":1,\"displaySize\":10,\"label\":\"LITERAL_PREFIX?\",\"name\":\"LITERAL_PREFIX?\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":128,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR(128)\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":1,\"displaySize\":10,\"label\":\"LITERAL_SUFFIX?\",\"name\":\"LITERAL_SUFFIX?\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":128,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR(128)\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoI
ncrement\":false,\"definitelyWritable\":false},{\"isNullable\":1,\"displaySize\":10,\"label\":\"CREATE_PARAMS?\",\"name\":\"CREATE_PARAMS?\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":128,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR(128)\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":0,\"displaySize\":5,\"label\":\"NULLABLE\",\"name\":\"NULLABLE\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":0,\"displaySize\":5,\"label\":\"CASE_SENSITIVE?\",\"name\":\"CASE_SENSITIVE?\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null
,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":0,\"displaySize\":5,\"label\":\"SEARCHABLE?\",\"name\":\"SEARCHABLE?\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":1,\"displaySize\":5,\"label\":\"UNSIGNED_ATTRIBUTE??\",\"name\":\"UNSIGNED_ATTRIBUTE??\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,\"writable\":false,\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":tr
ue,\"autoIncrement\":false,\"definitelyWritable\":false},{\"isNullable\":0,\"displaySize\":5,\"label\":\"FIXED_PREC_SCALE???\",\"name\":\"FIXED_PREC_SCALE???\",\"schemaName\":null,\"catelogName\":null,\"tableName\":null,\"precision\":5,\"scale\":0,\"columnType\":5,\"columnTypeName\":\"SMALLINT\",\"readOnly\":true,
<TRUNCATED>
[04/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_FETCH.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_FETCH.CPP b/odbc/Driver/KO_FETCH.CPP
index 39f0915..880ed10 100644
--- a/odbc/Driver/KO_FETCH.CPP
+++ b/odbc/Driver/KO_FETCH.CPP
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
// ----------------------------------------------------------------------------
//
@@ -87,14 +87,14 @@
#include "Dump.h"
// ------------------------- local functions -----------------------------
-RETCODE SQL_API _SQLFetch ( pODBCStmt pStmt, Word pFetchOrientation, Long pFetchOffset, ULong* pRowCountPtr,
- UWord* pRowStatusArray );
-RETCODE SQL_API _SQLColConvert ( pODBCStmt pStmt, void* pTgtDataPtr, Long* pTgtDataSizePtr, CStrPtr pSrcColData,
- pARDItem pARDCol , bool isSigned );
-RETCODE SQL_API _SQLFetchMoveNext ( pODBCStmt pStmt );
-RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt );
+RETCODE SQL_API _SQLFetch ( pODBCStmt pStmt, Word pFetchOrientation, Long pFetchOffset, ULong* pRowCountPtr,
+ UWord* pRowStatusArray );
+RETCODE SQL_API _SQLColConvert ( pODBCStmt pStmt, void* pTgtDataPtr, Long* pTgtDataSizePtr, CStrPtr pSrcColData,
+ pARDItem pARDCol, bool isSigned );
+RETCODE SQL_API _SQLFetchMoveNext ( pODBCStmt pStmt );
+RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt );
-SQLRowContent* GetIfExist ( std::vector<SQLRowContent*>& container, int index );
+SQLRowContent* GetIfExist ( std::vector <SQLRowContent*>& container, int index );
// -----------------------------------------------------------------------
// to get specific detail//attribute about a col returned from server --- FROM IRD
@@ -102,128 +102,141 @@ SQLRowContent* GetIfExist ( std::vector<SQLRowContent*>& container, int index );
// -----------------------------------------------------------------------
-RETCODE _SQLColAttribute_basic ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLUSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr, // in bytes
- SQLPOINTER pNumValuePtr ,// integer
- bool isANSI
- ) { //if returned data is numeric, feed this
- Long n;
- SQLResponse* ird;
- pIRDItem col;
+RETCODE _SQLColAttribute_basic ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLUSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr, // in bytes
+ SQLPOINTER pNumValuePtr,// integer
+ bool isANSI
+)
+{ //if returned data is numeric, feed this
+ Long n;
+ SQLResponse* ird;
+ pIRDItem col;
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
+
// precaution
- if ( pColNum == 0 ) {
+ if ( pColNum == 0 )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLColAttribute", "01000", -1, "bad params" );
return SQL_ERROR;
}
-
+
// get the row descriptor obtained with response
- ird = ( ( ( pODBCStmt ) pStmt )->IRD ).RowDesc.get();
-
+ ird = ( ( ( pODBCStmt ) pStmt ) -> IRD ) . RowDesc . get ();
+
// check
- if ( ird == NULL ) {
+ if ( ird == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLColAttribute", "01000", -1, "No resultset or no col descriptors" );
return SQL_ERROR;
}
-
+
// find the xth element/col
- col = _SQLGetIRDItem ( & ( ( ( pODBCStmt ) pStmt )->IRD ), pColNum );
-
+ col = _SQLGetIRDItem ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), pColNum );
+
// check
- if ( col == NULL ) {
+ if ( col == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLColAttribute", "01000", -1, "Invalid col num" );
return SQL_ERROR;
}
-
+
// get value from descriptor as per field type
- switch ( pFldID ) {
- // numeric types clubbed together
- case SQL_DESC_AUTO_UNIQUE_VALUE: // is col auto-incrementing
- case SQL_DESC_CASE_SENSITIVE: // is col case-insensitive
- case SQL_DESC_TYPE: // verbose type
- case SQL_DESC_CONCISE_TYPE: // concise type
- case SQL_DESC_COUNT: // no.of highest bound column
- case SQL_DESC_LENGTH:
- case SQL_DESC_DISPLAY_SIZE:
- case SQL_DESC_OCTET_LENGTH:
- case SQL_DESC_FIXED_PREC_SCALE:
- case SQL_DESC_NULLABLE:
- case SQL_DESC_NUM_PREC_RADIX:
- case SQL_DESC_PRECISION:
- case SQL_DESC_SCALE:
- case SQL_DESC_SEARCHABLE:
- case SQL_DESC_UNNAMED:
- case SQL_DESC_UNSIGNED:
- case SQL_DESC_UPDATABLE:
- // added for Excel
- case SQL_COLUMN_LENGTH:
- case SQL_COLUMN_PRECISION:
- case SQL_COLUMN_SCALE:
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, pFldID, pNumValuePtr, -1, NULL , isANSI );
+ switch ( pFldID )
+ {
+ // numeric types clubbed together
+ case SQL_DESC_AUTO_UNIQUE_VALUE : // is col auto-incrementing
+ case SQL_DESC_CASE_SENSITIVE : // is col case-insensitive
+ case SQL_DESC_TYPE : // verbose type
+ case SQL_DESC_CONCISE_TYPE : // concise type
+ case SQL_DESC_COUNT : // no.of highest bound column
+ case SQL_DESC_LENGTH :
+ case SQL_DESC_DISPLAY_SIZE :
+ case SQL_DESC_OCTET_LENGTH :
+ case SQL_DESC_FIXED_PREC_SCALE :
+ case SQL_DESC_NULLABLE :
+ case SQL_DESC_NUM_PREC_RADIX :
+ case SQL_DESC_PRECISION :
+ case SQL_DESC_SCALE :
+ case SQL_DESC_SEARCHABLE :
+ case SQL_DESC_UNNAMED :
+ case SQL_DESC_UNSIGNED :
+ case SQL_DESC_UPDATABLE :
+ // added for Excel
+ case SQL_COLUMN_LENGTH :
+ case SQL_COLUMN_PRECISION :
+ case SQL_COLUMN_SCALE :
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, pFldID, pNumValuePtr, -1, NULL, isANSI );
break;
-
- // char types clubbed together
-
- case SQL_DESC_BASE_TABLE_NAME: // table name for column
- case SQL_DESC_CATALOG_NAME: // database name
- case SQL_DESC_LITERAL_PREFIX:
- case SQL_DESC_LITERAL_SUFFIX:
- case SQL_DESC_LOCAL_TYPE_NAME:
- case SQL_DESC_TYPE_NAME:
- case SQL_DESC_SCHEMA_NAME:
- case SQL_DESC_TABLE_NAME:
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, pFldID, pDataPtr, pDataSize,
+
+ // char types clubbed together
+
+ case SQL_DESC_BASE_TABLE_NAME : // table name for column
+ case SQL_DESC_CATALOG_NAME : // database name
+ case SQL_DESC_LITERAL_PREFIX :
+ case SQL_DESC_LITERAL_SUFFIX :
+ case SQL_DESC_LOCAL_TYPE_NAME :
+ case SQL_DESC_TYPE_NAME :
+ case SQL_DESC_SCHEMA_NAME :
+ case SQL_DESC_TABLE_NAME :
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, pFldID, pDataPtr, pDataSize,
pDataSizePtr ? &n : NULL, isANSI );
-
+
if ( pDataSizePtr )
- { *pDataSizePtr = ( Word ) n; }
-
+ {
+ *pDataSizePtr = ( Word ) n;
+ }
+
break;
-
- case SQL_DESC_BASE_COLUMN_NAME:
- case SQL_DESC_LABEL:
- case SQL_DESC_NAME:
+
+ case SQL_DESC_BASE_COLUMN_NAME :
+ case SQL_DESC_LABEL :
+ case SQL_DESC_NAME :
// ////
// as a special case the name length may be required without the actual name
//////
StrPtr cname;
- Word cnamesize;
-
- if ( pDataPtr ) {
- cname = ( StrPtr ) pDataPtr;
- cnamesize = pDataSize;
+ Word cnamesize;
+
+ if ( pDataPtr )
+ {
+ cname = ( StrPtr ) pDataPtr;
+ cnamesize = pDataSize;
}
-
- else {
- cname = new Char[256]; // arbitary
- cnamesize = 255;
+
+ else
+ {
+ cname = new Char[256]; // arbitary
+ cnamesize = 255;
}
-
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, pFldID, cname, cnamesize,
+
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, pFldID, cname, cnamesize,
pDataSizePtr ? &n : NULL, isANSI );
-
+
if ( pDataPtr == NULL )
- { delete[] cname; }
-
+ {
+ delete[] cname;
+ }
+
if ( pDataSizePtr )
- { *pDataSizePtr = ( Word ) n; }
-
+ {
+ *pDataSizePtr = ( Word ) n;
+ }
+
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLColAttribute unknown attr, ColNum: %d, FldID: %d\n", pColNum, pFldID ) );
return SQL_ERROR;
}
- //unique_ptr<char[]> temp ( wchar2char ( ( wchar_t* ) pDataPtr ) );
- //__ODBCLOG(_ODBCLogMsg(LogLevel_INFO, "_SQLColAttribute_basic was called - Stmt:%d, ColNum:%d, FldId:%d, pDataStr:%s, pDataSize:%d, pDataSizePtr:%d(n:%d), pNumValPtr:%d",
- // pStmt, pColNum, pFldID, temp.get(), pDataSize, pDataSizePtr, n, pNumValuePtr ? *(( Long* )pNumValuePtr):-1));
+ //unique_ptr<char[]> temp ( wchar2char ( ( wchar_t* ) pDataPtr ) );
+ //__ODBCLOG(_ODBCLogMsg(LogLevel_INFO, "_SQLColAttribute_basic was called - Stmt:%d, ColNum:%d, FldId:%d, pDataStr:%s, pDataSize:%d, pDataSizePtr:%d(n:%d), pNumValPtr:%d",
+ // pStmt, pColNum, pFldID, temp.get(), pDataSize, pDataSizePtr, n, pNumValuePtr ? *(( Long* )pNumValuePtr):-1));
return SQL_SUCCESS;
}
@@ -258,27 +271,29 @@ RETCODE SQL_API SQLColAttribute ( SQLHSTMT pStmt,
}
#else
-RETCODE SQL_API SQLColAttributeW ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLUSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr,
- SQLPOINTER pNumValuePtr ) {
+RETCODE SQL_API SQLColAttributeW ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLUSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr,
+ SQLPOINTER pNumValuePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColAttributeW called, ColNum: %d, FldID: %d", pColNum, pFldID ) );
- RETCODE code = _SQLColAttribute_basic ( pStmt, pColNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, pNumValuePtr,
- false );
+ RETCODE code = _SQLColAttribute_basic ( pStmt, pColNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, pNumValuePtr,
+ false );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "the return code is %d", code ) );
return code;
}
-RETCODE SQL_API SQLColAttribute ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLUSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr,
- SQLPOINTER pNumValuePtr ) {
+RETCODE SQL_API SQLColAttribute ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLUSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr,
+ SQLPOINTER pNumValuePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColAttributeW called, ColNum: %d, FldID: %d", pColNum, pFldID ) );
return _SQLColAttribute_basic ( pStmt, pColNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, pNumValuePtr, true );
}
@@ -290,132 +305,146 @@ RETCODE SQL_API SQLColAttribute ( SQLHSTMT pStmt,
// kylin specific
// ----------------------------------------------------------------------
-SQLRETURN SQL_API _SQLDescribeCol_basic ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- void* pColNamePtr,
- SQLSMALLINT pColNameSize,
- SQLSMALLINT* pColNameSizePtr,
- SQLSMALLINT* pDataTypePtr,
- SQLULEN* pColSizePtr,
- SQLSMALLINT* pDecimalDigitsPtr,
- SQLSMALLINT* pNullablePtr ,
+SQLRETURN SQL_API _SQLDescribeCol_basic ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ void* pColNamePtr,
+ SQLSMALLINT pColNameSize,
+ SQLSMALLINT* pColNameSizePtr,
+ SQLSMALLINT* pDataTypePtr,
+ SQLULEN* pColSizePtr,
+ SQLSMALLINT* pDecimalDigitsPtr,
+ SQLSMALLINT* pNullablePtr,
bool isANSI
- ) {
- Long n;
- SQLResponse* ird;
- pIRDItem col;
+)
+{
+ Long n;
+ SQLResponse* ird;
+ pIRDItem col;
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
+
// precaution
- if ( pColNum == 0 ) {
+ if ( pColNum == 0 )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLDescribeCol", "01000", -1, "bad params" );
return SQL_ERROR;
}
-
+
// get the row descriptor obtained with response
- ird = ( ( ( pODBCStmt ) pStmt )->IRD ).RowDesc.get();
-
+ ird = ( ( ( pODBCStmt ) pStmt ) -> IRD ) . RowDesc . get ();
+
// check
- if ( ird == NULL ) {
+ if ( ird == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLDescribeCol", "01000", -1, "No resultset or no col descriptors" );
return SQL_ERROR;
}
-
+
// find the xth element/col
- col = _SQLGetIRDItem ( & ( ( ( pODBCStmt ) pStmt )->IRD ), pColNum );
-
+ col = _SQLGetIRDItem ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), pColNum );
+
// check
- if ( col == NULL ) {
+ if ( col == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLDescribeCol", "01000", -1, "Invalid col num" );
return SQL_ERROR;
}
-
+
// COL-NAME ie title
- if ( pColNamePtr ) {
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, SQL_DESC_BASE_COLUMN_NAME, pColNamePtr,
+ if ( pColNamePtr )
+ {
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, SQL_DESC_BASE_COLUMN_NAME, pColNamePtr,
pColNameSize, pColNameSizePtr ? &n : NULL, isANSI );
-
- // here should return length of characters
- if ( pColNameSizePtr ) {
- if (isANSI) {
- *pColNameSizePtr = ( Word ) n;
- }
- else {
- *pColNameSizePtr = ( Word ) ( n / 2 );
- }
- }
-
+
+ // here should return length of characters
+ if ( pColNameSizePtr )
+ {
+ if ( isANSI )
+ {
+ *pColNameSizePtr = ( Word ) n;
+ }
+ else
+ {
+ *pColNameSizePtr = ( Word ) ( n / 2 );
+ }
+ }
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, (wchar_t*)pColNamePtr ) );
}
-
+
// COL-DATA TYPE
-
- if ( pDataTypePtr ) {
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, SQL_DESC_CONCISE_TYPE, pDataTypePtr, -1,
+
+ if ( pDataTypePtr )
+ {
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, SQL_DESC_CONCISE_TYPE, pDataTypePtr, -1,
NULL, isANSI );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "data type: %d", *pDataTypePtr ) );
}
-
+
// COL-SIZE
-
- if ( pColSizePtr ) {
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, SQL_DESC_LENGTH, pColSizePtr, -1, NULL,
+
+ if ( pColSizePtr )
+ {
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, SQL_DESC_LENGTH, pColSizePtr, -1, NULL,
isANSI );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "column size: %d", *pColSizePtr ) );
}
-
+
// COL-DECIMAL
-
- if ( pDecimalDigitsPtr ) {
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, SQL_DESC_SCALE, pDecimalDigitsPtr, -1, NULL,
+
+ if ( pDecimalDigitsPtr )
+ {
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, SQL_DESC_SCALE, pDecimalDigitsPtr, -1, NULL,
isANSI );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "decimal scale: %d", *pDecimalDigitsPtr ) );
}
-
+
// COL-NULLABLE
-
- if ( pNullablePtr ) {
- _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt )->IRD ), col, pColNum, SQL_DESC_NULLABLE, pNullablePtr, -1, NULL,
+
+ if ( pNullablePtr )
+ {
+ _SQLGetIRDItemField ( & ( ( ( pODBCStmt ) pStmt ) -> IRD ), col, pColNum, SQL_DESC_NULLABLE, pNullablePtr, -1, NULL,
isANSI );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "nullable: %d", *pNullablePtr ) );
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLDescribeCol returned" ) );
return SQL_SUCCESS;
}
-SQLRETURN SQL_API SQLDescribeColW ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLWCHAR* pColNamePtr,
- SQLSMALLINT pColNameSize,
- SQLSMALLINT* pColNameSizePtr,
- SQLSMALLINT* pDataTypePtr,
- SQLULEN* pColSizePtr,
- SQLSMALLINT* pDecimalDigitsPtr,
- SQLSMALLINT* pNullablePtr ) {
+SQLRETURN SQL_API SQLDescribeColW ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLWCHAR* pColNamePtr,
+ SQLSMALLINT pColNameSize,
+ SQLSMALLINT* pColNameSizePtr,
+ SQLSMALLINT* pDataTypePtr,
+ SQLULEN* pColSizePtr,
+ SQLSMALLINT* pDecimalDigitsPtr,
+ SQLSMALLINT* pNullablePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLDescribeColW. Col: %d, ColNamePtr: %d, ColNameSize: %d, ColNameSizePtr: %d, DataTypePtr: %d, ColSizePtr: %d, DecDigitsPtr: %d, NullPtr: %d",
- pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr, pDecimalDigitsPtr, pNullablePtr ) );
+ "SQLDescribeColW. Col: %d, ColNamePtr: %d, ColNameSize: %d, ColNameSizePtr: %d, DataTypePtr: %d, ColSizePtr: %d, DecDigitsPtr: %d, NullPtr: %d",
+ pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr, pDecimalDigitsPtr, pNullablePtr ) );
return _SQLDescribeCol_basic ( pStmt, pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr,
- pDecimalDigitsPtr, pNullablePtr , false );
+ pDecimalDigitsPtr, pNullablePtr, false );
}
-SQLRETURN SQL_API SQLDescribeCol ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLCHAR* pColNamePtr,
- SQLSMALLINT pColNameSize,
- SQLSMALLINT* pColNameSizePtr,
- SQLSMALLINT* pDataTypePtr,
- SQLULEN* pColSizePtr,
- SQLSMALLINT* pDecimalDigitsPtr,
- SQLSMALLINT* pNullablePtr ) {
+SQLRETURN SQL_API SQLDescribeCol ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLCHAR* pColNamePtr,
+ SQLSMALLINT pColNameSize,
+ SQLSMALLINT* pColNameSizePtr,
+ SQLSMALLINT* pDataTypePtr,
+ SQLULEN* pColSizePtr,
+ SQLSMALLINT* pDecimalDigitsPtr,
+ SQLSMALLINT* pNullablePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLDescribeCol. Col: %d, ColNamePtr: %d, ColNameSize: %d, ColNameSizePtr: %d, DataTypePtr: %d, ColSizePtr: %d, DecDigitsPtr: %d, NullPtr: %d",
- pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr, pDecimalDigitsPtr, pNullablePtr ) );
+ "SQLDescribeCol. Col: %d, ColNamePtr: %d, ColNameSize: %d, ColNameSizePtr: %d, DataTypePtr: %d, ColSizePtr: %d, DecDigitsPtr: %d, NullPtr: %d",
+ pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr, pDecimalDigitsPtr, pNullablePtr ) );
return _SQLDescribeCol_basic ( pStmt, pColNum, pColNamePtr, pColNameSize, pColNameSizePtr, pDataTypePtr, pColSizePtr,
- pDecimalDigitsPtr, pNullablePtr , true );
+ pDecimalDigitsPtr, pNullablePtr, true );
}
// -----------------------------------------------------------------------
@@ -436,62 +465,68 @@ SQLRETURN SQL_API SQLDescribeCol ( SQLHSTMT pStmt,
SQLLEN * StrLen_or_Ind);
*/
-RETCODE SQL_API SQLBindCol ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLSMALLINT pDataType,
- SQLPOINTER pDataPtr,
- SQLLEN pDataSize,
- SQLLEN* pDataSizePtr ) {
+RETCODE SQL_API SQLBindCol ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLSMALLINT pDataType,
+ SQLPOINTER pDataPtr,
+ SQLLEN pDataSize,
+ SQLLEN* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLBindCol called, ColNum: %d, TgtType: %d, ValuePtr: %d, Capacity: %d",
- pColNum, pDataType, pDataPtr, pDataSize ) );
- pODBCARD ard; // application row descriptor
- pARDItem ardcol; // application row descriptor item
+ pColNum, pDataType, pDataPtr, pDataSize ) );
+ pODBCARD ard; // application row descriptor
+ pARDItem ardcol; // application row descriptor item
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
// extract the appl. row descriptor from stmt
- ard = & ( ( ( pODBCStmt ) pStmt )->ARD );
+ ard = & ( ( ( pODBCStmt ) pStmt ) -> ARD );
// get the specified column if already bound
ardcol = _SQLGetARDItem ( ard, pColNum );
-
+
// EXISTS
-
- if ( ardcol != NULL ) {
+
+ if ( ardcol != NULL )
+ {
// check if total unbind is required
- if ( pDataPtr == NULL && pDataSizePtr == NULL ) {
+ if ( pDataPtr == NULL && pDataSizePtr == NULL )
+ {
// detach it from ARD link list
_SQLDetachARDItem ( ard, ardcol );
// free
delete ardcol;
}
-
- else {
+
+ else
+ {
// unbind/rebind col details
_SQLSetARDItemField ( ard, ardcol, pColNum, SQL_DESC_DATA_PTR, pDataPtr, -1 );
_SQLSetARDItemField ( ard, ardcol, pColNum, SQL_DESC_CONCISE_TYPE, ( void* ) pDataType, -1 );
_SQLSetARDItemField ( ard, ardcol, pColNum, SQL_DESC_LENGTH, ( void* ) pDataSize, -1 );
_SQLSetARDItemField ( ard, ardcol, pColNum, SQL_DESC_OCTET_LENGTH_PTR, pDataSizePtr, -1 );
// reset the source data type
- ardcol->SrcDataType = 0;
+ ardcol -> SrcDataType = 0;
}
-
+
return SQL_SUCCESS;
}
-
+
// DOES NOT EXIST
-
+
// check for bad params
- if ( pDataPtr == NULL && pDataSizePtr == NULL ) {
+ if ( pDataPtr == NULL && pDataSizePtr == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLBindCol", "01000", -1, "Bad params" );
return SQL_ERROR;
}
-
+
// check for bad params
- else if ( pDataSize < 0 ) {
+ else if ( pDataSize < 0 )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLBindCol", "01000", -1, "Invalid buffer length" );
return SQL_ERROR;
}
-
+
// CREATE
// allocate a new col-item
ardcol = new ARDItem;
@@ -514,7 +549,8 @@ RETCODE SQL_API SQLBindCol ( SQLHSTMT pStmt,
// Kylin specific
// ---------------------------------------------------------------------
-RETCODE SQL_API SQLNumResultCols ( SQLHSTMT pStmt, SQLSMALLINT* pColCountPtr ) {
+RETCODE SQL_API SQLNumResultCols ( SQLHSTMT pStmt, SQLSMALLINT* pColCountPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNumResultCols called" ) );
SQLResponse* rowdesc;
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
@@ -523,17 +559,18 @@ RETCODE SQL_API SQLNumResultCols ( SQLHSTMT pStmt, SQLSMALLINT* pColCountPtr )
// caller safe
* ( ( SQLSMALLINT* ) pColCountPtr ) = 0;
// get the row desciptor
- rowdesc = ( ( pODBCStmt ) pStmt )->IRD.RowDesc.get();
-
- if ( rowdesc == NULL ) {
+ rowdesc = ( ( pODBCStmt ) pStmt ) -> IRD . RowDesc . get ();
+
+ if ( rowdesc == NULL )
+ {
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "SQLNumResultCols", "01000", -1, "no resultset or IRD" );
return SQL_ERROR;
}
-
+
// count the number of columns
- * ( ( SQLSMALLINT* ) pColCountPtr ) = ( SQLSMALLINT ) ( rowdesc->columnMetas.size() );
+ * ( ( SQLSMALLINT* ) pColCountPtr ) = ( SQLSMALLINT ) ( rowdesc -> columnMetas . size () );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNumResultCols called returned: %d",
- * ( ( SQLSMALLINT* ) pColCountPtr ) ) );
+ * ( ( SQLSMALLINT* ) pColCountPtr ) ) );
return SQL_SUCCESS;
}
@@ -542,12 +579,13 @@ RETCODE SQL_API SQLNumResultCols ( SQLHSTMT pStmt, SQLSMALLINT* pColCountPtr )
// to count the number of rows in the current result --- COUNTING ELEMENTS IN IRD
// ----------------------------------------------------------------------
-RETCODE SQL_API SQLRowCount ( HSTMT pStmt, SQLLEN* pDataPtr ) {
+RETCODE SQL_API SQLRowCount ( HSTMT pStmt, SQLLEN* pDataPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLRowCount called" ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
- *pDataPtr = ( ( pODBCStmt ) pStmt )->RowCount;
+ *pDataPtr = ( ( pODBCStmt ) pStmt ) -> RowCount;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLRowCount returned: %d", *pDataPtr ) );
return SQL_SUCCESS;
}
@@ -556,7 +594,8 @@ RETCODE SQL_API SQLRowCount ( HSTMT pStmt, SQLLEN* pDataPtr ) {
// to return the next row from the resultset
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLFetch ( HSTMT pStmt ) {
+RETCODE SQL_API SQLFetch ( HSTMT pStmt )
+{
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
@@ -568,14 +607,15 @@ RETCODE SQL_API SQLFetch ( HSTMT pStmt ) {
ULong* pRowCountPtr,
UWord* pRowStatusArray )
*/
- RETCODE ret = _SQLFetch ( ( pODBCStmt ) pStmt, SQL_FETCH_NEXT,
- ( ( pODBCStmt ) pStmt )->ARD.RowArraySize > 0 ? ( ( pODBCStmt ) pStmt )->ARD.RowArraySize : 1,
- ( ( pODBCStmt ) pStmt )->IRD.RowsProcessedPtr, ( ( pODBCStmt ) pStmt )->IRD.ArrayStatusPtr );
-
- if ( ret == SQL_NO_DATA ) {
+ RETCODE ret = _SQLFetch ( ( pODBCStmt ) pStmt, SQL_FETCH_NEXT,
+ ( ( pODBCStmt ) pStmt ) -> ARD . RowArraySize > 0 ? ( ( pODBCStmt ) pStmt ) -> ARD . RowArraySize : 1,
+ ( ( pODBCStmt ) pStmt ) -> IRD . RowsProcessedPtr, ( ( pODBCStmt ) pStmt ) -> IRD . ArrayStatusPtr );
+
+ if ( ret == SQL_NO_DATA )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Last row of current query has been fetched" ) );
}
-
+
return ret;
}
@@ -584,35 +624,41 @@ RETCODE SQL_API SQLFetch ( HSTMT pStmt ) {
// Version Introduced: ODBC 1.0 Standards Compliance: Deprecated (from msdn)
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLExtendedFetch ( SQLHSTMT pStmt,
- SQLUSMALLINT pFetchOrientation,
- SQLINTEGER pFetchOffset,
- SQLUINTEGER* pRowCountPtr,
- SQLUSMALLINT* pRowStatusArray ) {
+RETCODE SQL_API SQLExtendedFetch ( SQLHSTMT pStmt,
+ SQLUSMALLINT pFetchOrientation,
+ SQLINTEGER pFetchOffset,
+ SQLUINTEGER* pRowCountPtr,
+ SQLUSMALLINT* pRowStatusArray )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLExtendedFetch called, Stmt: %d, FO: %d, Offset: %d, Rcount: %d, RowStatus: %d", pStmt, pFetchOrientation,
- pFetchOffset, pRowCountPtr, pRowStatusArray ) );
+ "SQLExtendedFetch called, Stmt: %d, FO: %d, Offset: %d, Rcount: %d, RowStatus: %d", pStmt, pFetchOrientation,
+ pFetchOffset, pRowCountPtr, pRowStatusArray ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLExtendedFetch is not implemented " ) );
return SQL_ERROR;
Long n;
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
// free diags
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
-
+
// only fetch next supported
- if ( pFetchOrientation != SQL_FETCH_NEXT ) {
+ if ( pFetchOrientation != SQL_FETCH_NEXT )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLExtendedFetch option not supported, FetchOrientation: %d", pFetchOrientation ) );
return SQL_ERROR;
}
-
+
// check if number of rows explicitly specified
if ( pFetchOffset <= 0 )
- { n = ( ( pODBCStmt ) pStmt )->ARD.RowArraySize; }
-
+ {
+ n = ( ( pODBCStmt ) pStmt ) -> ARD . RowArraySize;
+ }
+
// use default rowset size as a fallback
if ( n <= 0 )
- { n = 1; }
-
+ {
+ n = 1;
+ }
+
return _SQLFetch ( ( pODBCStmt ) pStmt, pFetchOrientation, n, pRowCountPtr, pRowStatusArray );
}
@@ -621,9 +667,10 @@ RETCODE SQL_API SQLExtendedFetch ( SQLHSTMT pStmt,
// to fetch the specified rowset of data from the result set
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLFetchScroll ( SQLHSTMT pStatementHandle,
- SQLSMALLINT pFetchOrientation,
- SQLINTEGER pFetchOffset ) {
+RETCODE SQL_API SQLFetchScroll ( SQLHSTMT pStatementHandle,
+ SQLSMALLINT pFetchOrientation,
+ SQLINTEGER pFetchOffset )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLFetchScroll called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLFetchScroll not implemented" ) );
return SQL_ERROR;
@@ -634,9 +681,10 @@ RETCODE SQL_API SQLFetchScroll ( SQLHSTMT pStatementHandle,
// to send data for a parameter or column to the driver at statement execution time
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLPutData ( SQLHSTMT pStmt,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize ) {
+RETCODE SQL_API SQLPutData ( SQLHSTMT pStmt,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPutData called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLPutData not implemented" ) );
return SQL_ERROR;
@@ -646,265 +694,303 @@ RETCODE SQL_API SQLPutData ( SQLHSTMT pStmt,
// to iterate through multiple resultsets
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLMoreResults ( HSTMT pStmt ) {
+RETCODE SQL_API SQLMoreResults ( HSTMT pStmt )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLMoreResults called" ) );
- pODBCStmt odbcStmt = (pODBCStmt)pStmt;
- if (odbcStmt->IRD.RowDesc != NULL ) {
+ pODBCStmt odbcStmt = ( pODBCStmt )pStmt;
+ if ( odbcStmt -> IRD . RowDesc != NULL )
+ {
// ------- THIS CASE SHOULD NOT OCCUR ----------
// check if position is currently unknown
- if ( odbcStmt->CurRowsetStartRow == NULL && odbcStmt->CurRowsetStartRowPos == 0 ) {
+ if ( odbcStmt -> CurRowsetStartRow == NULL && odbcStmt -> CurRowsetStartRowPos == 0 )
+ {
// position to first row ( both the pointers )
- if (GetIfExist ( odbcStmt->IRD.RowDesc->results, 1 ) )
- {
- return SQL_SUCCESS;
- }
+ if ( GetIfExist ( odbcStmt -> IRD . RowDesc -> results, 1 ) )
+ {
+ return SQL_SUCCESS;
+ }
}
// -----------------------------------------------
// position to next row if already position is known
- else if ( odbcStmt->CurRowsetEndRow != NULL ) {
+ else if ( odbcStmt -> CurRowsetEndRow != NULL )
+ {
// position to next row
- if (GetIfExist ( odbcStmt->IRD.RowDesc->results, odbcStmt->CurRowsetEndRowPos ) )
- {
- return SQL_SUCCESS;
- }
+ if ( GetIfExist ( odbcStmt -> IRD . RowDesc -> results, odbcStmt -> CurRowsetEndRowPos ) )
+ {
+ return SQL_SUCCESS;
+ }
}
- return SQL_NO_DATA;
+ return SQL_NO_DATA;
}
- return SQL_ERROR;
+ return SQL_ERROR;
}
// -----------------------------------------------------------------------
// to get a driver specific version of specified sql statement
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLNativeSql ( SQLHDBC pConn,
- SQLCHAR* pInStmtText,
- SQLINTEGER pInStmtTextLen,
- SQLCHAR* pOutStmtText,
- SQLINTEGER pOutStmtTextLen,
- SQLINTEGER* pOutStmtTextLenPtr ) {
+RETCODE SQL_API SQLNativeSql ( SQLHDBC pConn,
+ SQLCHAR* pInStmtText,
+ SQLINTEGER pInStmtTextLen,
+ SQLCHAR* pOutStmtText,
+ SQLINTEGER pOutStmtTextLen,
+ SQLINTEGER* pOutStmtTextLenPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLNativeSql called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLNativeSql not implemented" ) );
return SQL_ERROR;
}
-
-
// -----------------------------------------------------------------------
// to convert and transfer col data for application
// -----------------------------------------------------------------------
//mhb TODO, check if the sqltype defined here match from c#
-RETCODE SQL_API _SQLColConvert ( pODBCStmt pStmt,
- void* pTgtDataPtr,
- Long* pTgtDataSizePtr,
- const wchar_t* pSrcColData,
- pARDItem pARDCol,
- bool isSigned ) {
+RETCODE SQL_API _SQLColConvert ( pODBCStmt pStmt,
+ void* pTgtDataPtr,
+ Long* pTgtDataSizePtr,
+ const wchar_t* pSrcColData,
+ pARDItem pARDCol,
+ bool isSigned )
+{
//check out this for SQL data type to C data type mapping
//http://msdn.microsoft.com/en-us/library/ms714556(v=vs.85).aspx
// note
// this function actually determines the conversion
// required to transfer the data
- Word pSrcDataType = pARDCol->SrcDataType;
- Word pTgtDataType = pARDCol->DataConciseType;
- Long pTgtDataSize = pARDCol->DataSize;
+ Word pSrcDataType = pARDCol -> SrcDataType;
+ Word pTgtDataType = pARDCol -> DataConciseType;
+ Long pTgtDataSize = pARDCol -> DataSize;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLColConvert called" ) );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The SrcDataType is %d, the TgtDataType is %d, the TgtDataSize is %d",
- pSrcDataType, pTgtDataType, pTgtDataSize ) );
-
+ pSrcDataType, pTgtDataType, pTgtDataSize ) );
+
// TARGET TYPE IS LEFT TO OUR DRIVER
// check if target type is open
- if ( pTgtDataType == SQL_DEFAULT ) {
+ if ( pTgtDataType == SQL_DEFAULT )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pTgtDataType is SQL_DEFAULT, use default type mapping." ) );
-
+
// determine targettype based on data-source type
// check out this http://msdn.microsoft.com/en-us/library/ms716298(v=vs.85).aspx for default type mapping
- switch ( pSrcDataType ) {
- case SQL_CHAR:
- pTgtDataType = SQL_C_CHAR;
+ switch ( pSrcDataType )
+ {
+ case SQL_CHAR :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- case SQL_VARCHAR:
- pTgtDataType = SQL_C_CHAR;
+
+ case SQL_VARCHAR :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- case SQL_WCHAR:
+
+ case SQL_WCHAR :
pTgtDataType = SQL_C_WCHAR;
break;
-
- case SQL_WVARCHAR:
+
+ case SQL_WVARCHAR :
pTgtDataType = SQL_C_WCHAR;
break;
-
- case SQL_DECIMAL:
- pTgtDataType = SQL_C_CHAR;
+
+ case SQL_DECIMAL :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- case SQL_BIT:
+
+ case SQL_BIT :
pTgtDataType = SQL_C_BIT;
break;
-
- case SQL_TINYINT:
+
+ case SQL_TINYINT :
if ( isSigned )
- { pTgtDataType = SQL_C_STINYINT; }
-
+ {
+ pTgtDataType = SQL_C_STINYINT ;
+ }
+
else
- { pTgtDataType = SQL_C_UTINYINT; }
-
+ {
+ pTgtDataType = SQL_C_UTINYINT ;
+ }
+
break;
-
- case SQL_SMALLINT:
+
+ case SQL_SMALLINT :
if ( isSigned )
- { pTgtDataType = SQL_C_SSHORT; }
-
+ {
+ pTgtDataType = SQL_C_SSHORT ;
+ }
+
else
- { pTgtDataType = SQL_C_USHORT; }
-
+ {
+ pTgtDataType = SQL_C_USHORT ;
+ }
+
break;
-
- case SQL_INTEGER:
+
+ case SQL_INTEGER :
if ( isSigned )
- { pTgtDataType = SQL_C_SLONG; }
-
+ {
+ pTgtDataType = SQL_C_SLONG ;
+ }
+
else
- { pTgtDataType = SQL_C_ULONG; }
-
+ {
+ pTgtDataType = SQL_C_ULONG ;
+ }
+
break;
-
- case SQL_BIGINT:
+
+ case SQL_BIGINT :
if ( isSigned )
- { pTgtDataType = SQL_C_SBIGINT; }
-
+ {
+ pTgtDataType = SQL_C_SBIGINT ;
+ }
+
else
- { pTgtDataType = SQL_C_UBIGINT; }
-
+ {
+ pTgtDataType = SQL_C_UBIGINT ;
+ }
+
break;
-
- case SQL_FLOAT:
- pTgtDataType = SQL_C_FLOAT;
+
+ case SQL_FLOAT :
+ pTgtDataType = SQL_C_FLOAT ;
break;
-
- case SQL_DOUBLE:
- pTgtDataType = SQL_C_DOUBLE;
+
+ case SQL_DOUBLE :
+ pTgtDataType = SQL_C_DOUBLE ;
break;
-
- case SQL_TYPE_DATE:
- pTgtDataType = SQL_C_CHAR;
+
+ case SQL_TYPE_DATE :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- case SQL_TYPE_TIME:
- pTgtDataType = SQL_C_CHAR;
+
+ case SQL_TYPE_TIME :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- case SQL_TYPE_TIMESTAMP:
- pTgtDataType = SQL_C_CHAR;
+
+ case SQL_TYPE_TIMESTAMP :
+ pTgtDataType = SQL_C_CHAR ;
break;
-
- //case SQL_C_SLONG:
- //case SQL_C_ULONG: // unsigned long
- //case SQL_C_USHORT:
- //case SQL_C_SSHORT:
- //case SQL_NUMERIC:
- //case SQL_REAL:
- // pTgtDataType = pSrcDataType;
- // break;
-
- default:
+
+ //case SQL_C_SLONG:
+ //case SQL_C_ULONG: // unsigned long
+ //case SQL_C_USHORT:
+ //case SQL_C_SSHORT:
+ //case SQL_NUMERIC:
+ //case SQL_REAL:
+ // pTgtDataType = pSrcDataType;
+ // break;
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "The data type %d not implemented", pSrcDataType ) );
return SQL_ERROR;
break;
}
}
-
- else {
- __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pTgtDataType is NOT SQL_DEFAULT, it is %d", pTgtDataType ) );
+
+ else
+ {
+ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pTgtDataType is NOT SQL_DEFAULT, it is %d", pTgtDataType ) );
}
-
+
// TARGET TYPE IS CHAR
// as an optimization, check if the application
// or target data type is char. since the data from
// server is already in char format. the data can
// easily be transferred without incurring any
// conversion overhead
- unique_ptr<char[]> pTextInAnsi ( wchar2char ( pSrcColData ) );
-
+ unique_ptr <char[]> pTextInAnsi ( wchar2char ( pSrcColData ) );
+
// check if char type
- if ( pTgtDataType == SQL_CHAR || pTgtDataType == SQL_VARCHAR ) {
+ if ( pTgtDataType == SQL_CHAR || pTgtDataType == SQL_VARCHAR )
+ {
// only in case of src data being bool a conversion is required
- if ( pSrcDataType == SQL_BIT ) {
+ if ( pSrcDataType == SQL_BIT )
+ {
// prepare a converted single char bool string
- Char src[2];
-
- if ( pTextInAnsi.get() == NULL )
- { src[0] = '0'; }
-
+ Char src[2];
+
+ if ( pTextInAnsi . get () == NULL )
+ {
+ src[0] = '0';
+ }
+
else
- { src[0] = ( pTextInAnsi.get() [0] == 'T' || pTextInAnsi.get() [0] == '1' || pTextInAnsi.get() [0] == 't' ) ? '1' : '0'; }
-
+ {
+ src[0] = ( pTextInAnsi . get ()[0] == 'T' || pTextInAnsi . get ()[0] == '1' || pTextInAnsi . get ()[0] == 't' ) ? '1' : '0';
+ }
+
src[1] = 0;
// transfer the bool string
- return _SQLCopyCharData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol->DataSize, pTgtDataSizePtr, 32, src, -1 );
+ return _SQLCopyCharData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol -> DataSize, pTgtDataSizePtr, 32, src, -1 );
}
-
- else {
+
+ else
+ {
// transfer the string as it is
- return _SQLCopyCharData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol->DataSize, pTgtDataSizePtr, 32, pTextInAnsi.get(),
- -1 );
+ return _SQLCopyCharData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol -> DataSize, pTgtDataSizePtr, 32, pTextInAnsi . get (),
+ -1 );
}
}
- else if ( pTgtDataType == SQL_WCHAR || pTgtDataType == SQL_WVARCHAR ) {
- return _SQLCopyWCharDataW ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol->DataSize, pTgtDataSizePtr, 32, pSrcColData, -1 );
+ else if ( pTgtDataType == SQL_WCHAR || pTgtDataType == SQL_WVARCHAR )
+ {
+ return _SQLCopyWCharDataW ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pARDCol -> DataSize, pTgtDataSizePtr, 32, pSrcColData, -1 );
}
-
+
// TARGET TYPE IS NOT CHAR
-
+
// try using a numeric conversion
- switch ( _SQLCopyNumData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pTgtDataType, pTextInAnsi.get(), pSrcDataType ,
- pTgtDataSizePtr ) ) {
- case -1:
+ switch ( _SQLCopyNumData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pTgtDataType, pTextInAnsi . get (), pSrcDataType,
+ pTgtDataSizePtr ) )
+ {
+ case -1 :
return SQL_ERROR;
-
- case 0:
+
+ case 0 :
return SQL_SUCCESS;
-
- default:
+
+ default :
break;
}
-
+
// try using a date/time conversion
- switch ( _SQLCopyDateTimeData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pTgtDataType, pTextInAnsi.get(), pSrcDataType ) ) {
- case -1:
+ switch ( _SQLCopyDateTimeData ( _DIAGSTMT ( pStmt ), pTgtDataPtr, pTgtDataType, pTextInAnsi . get (), pSrcDataType ) )
+ {
+ case -1 :
return SQL_ERROR;
-
- case 0:
+
+ case 0 :
return SQL_SUCCESS;
-
- default:
+
+ default :
break;
}
-
+
// try using SQL_BIT data type ie bool
- if ( pTgtDataType == SQL_BIT ) {
+ if ( pTgtDataType == SQL_BIT )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "the target data type is SQL_C_BIT" ) );
-
+
// prepare a converted single char bool string
- if ( pTextInAnsi.get() == NULL )
- { * ( ( char* ) pTgtDataPtr ) = 0; }
-
+ if ( pTextInAnsi . get () == NULL )
+ {
+ * ( ( char* ) pTgtDataPtr ) = 0;
+ }
+
else
- { * ( ( char* ) pTgtDataPtr ) = ( pTextInAnsi.get() [0] == 'T' || pTextInAnsi.get() [0] == '1' || pTextInAnsi.get() [0] == 't' ) ? 1 : 0; }
-
+ {
+ * ( ( char* ) pTgtDataPtr ) = ( pTextInAnsi . get ()[0] == 'T' || pTextInAnsi . get ()[0] == '1' || pTextInAnsi . get ()[0] == 't' ) ? 1 : 0;
+ }
+
return SQL_SUCCESS;
}
-
+
// error condition
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLColConvert - Unknown data type, Target: %d, Source: %d", pTgtDataType,
- pSrcDataType ) );
+ pSrcDataType ) );
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLColConvert", "01000", -1, "Unknown data type, Target: %d, Source: %d",
- pTgtDataType, pSrcDataType );
+ pTgtDataType, pSrcDataType );
return SQL_ERROR;
}
@@ -916,87 +1002,99 @@ RETCODE SQL_API _SQLColConvert ( pODBCStmt pStmt,
RETCODE SQL_API _SQLFetchCol ( pODBCStmt pStmt,
pARDItem pARDCol, //ard
SQLResponse* pRowDesc,// ird
- SQLRowContent* pRowData ) { //content
+ SQLRowContent* pRowData )
+{ //content
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLFetchCol called" ) );
// note
// this function checks the binding type and positions the pointer
// for copying the data accordingly. It takes into account the
// current row position in rowset, the initial min increment specified
// by client and the size of the row or col buffer
- Long i;
- Long j;
- Long* tgtsizeptr; // target size ptr
- void* tgtdataptr; // target data ptr
- const wchar_t* srcdata; // source data
- SelectedColumnMeta* coldesc;
+ Long i;
+ Long j;
+ Long* tgtsizeptr; // target size ptr
+ void* tgtdataptr; // target data ptr
+ const wchar_t* srcdata; // source data
+ SelectedColumnMeta* coldesc;
// COMPUTE DATA AND SIZE PTR
// get the row pos in current rowset
- i = ( pStmt->CurRowsetEndRowPos - pStmt->CurRowsetStartRowPos );
+ i = ( pStmt -> CurRowsetEndRowPos - pStmt -> CurRowsetStartRowPos );
// compute min increment
- j = ( pStmt->ARD.BindOffsetPtr ) ? * ( pStmt->ARD.BindOffsetPtr ) : 0;
-
+ j = ( pStmt -> ARD . BindOffsetPtr ) ? * ( pStmt -> ARD . BindOffsetPtr ) : 0;
+
// check the binding type
- if ( pStmt->ARD.BindTypeOrSize != SQL_BIND_BY_COLUMN ) {
+ if ( pStmt -> ARD . BindTypeOrSize != SQL_BIND_BY_COLUMN )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "ARD bindtypeorsize not euqal to SQL_BIND_BY_COLUMN" ) );
// note
Long k;
// compute row-size increment
- k = ( pStmt->ARD.BindTypeOrSize );
+ k = ( pStmt -> ARD . BindTypeOrSize );
// compute target col and size ptr
- tgtdataptr = ( void* ) ( ( ( Char* ) ( pARDCol->DataPtr ) ) + j + ( i * k ) );
- tgtsizeptr = ( Long* ) ( ( ( Char* ) ( pARDCol->SizePtr ) ) + j + ( i * k ) );
+ tgtdataptr = ( void* ) ( ( ( Char* ) ( pARDCol -> DataPtr ) ) + j + ( i * k ) );
+ tgtsizeptr = ( Long* ) ( ( ( Char* ) ( pARDCol -> SizePtr ) ) + j + ( i * k ) );
}
-
+
// column-wise binding
- else {
+ else
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "ARD bindtypeorsize euqal to SQL_BIND_BY_COLUMN" ) );
// move both data and size ptr in the array
//TODO find out where the pARDCol->DataSize if set
- tgtdataptr = ( void* ) ( ( ( Char* ) ( pARDCol->DataPtr ) ) + j + ( i * pARDCol->DataSize ) ); // use based on data type
- tgtsizeptr = ( Long* ) ( ( ( Char* ) ( pARDCol->SizePtr ) ) + j + ( i * sizeof ( SQLLEN ) ) );
+ tgtdataptr = ( void* ) ( ( ( Char* ) ( pARDCol -> DataPtr ) ) + j + ( i * pARDCol -> DataSize ) ); // use based on data type
+ tgtsizeptr = ( Long* ) ( ( ( Char* ) ( pARDCol -> SizePtr ) ) + j + ( i * sizeof ( SQLLEN) ) );
}
-
+
// PRECAUTION
-
- if ( tgtdataptr ) { * ( ( Char* ) tgtdataptr ) = 0; }
-
- if ( tgtsizeptr ) { * ( ( Long* ) tgtsizeptr ) = 0; }
-
+
+ if ( tgtdataptr )
+ {
+ * ( ( Char* ) tgtdataptr ) = 0;
+ }
+
+ if ( tgtsizeptr )
+ {
+ * ( ( Long* ) tgtsizeptr ) = 0;
+ }
+
// COLLECT AND CHECK
// get col desc for specified col ( response )
- coldesc = pRowDesc->columnMetas.at ( pARDCol->ColNum - 1 );
+ coldesc = pRowDesc -> columnMetas . at ( pARDCol -> ColNum - 1 );
//if ( coldesc == NULL ) {
// _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLFetchCol", "01000", -1, pStmt->CurRowsetEndRowPos, pARDCol->ColNum, "column not found in resultset for specified index" );
// return SQL_SUCCESS_WITH_INFO; // no col for specified index
//}
// get the col data for specfied col ( response )
- srcdata = pRowData->contents.at ( pARDCol->ColNum - 1 ).c_str();
-
+ srcdata = pRowData -> contents . at ( pARDCol -> ColNum - 1 ) . c_str ();
+
//coldata = SOAPGetChildElemX ( pRowData, pARDCol->ColNum );
//if ( coldata == NULL ) {
-
+
// _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLFetchCol", "01000", -1, pStmt->CurRowsetEndRowPos, pARDCol->ColNum, "column not found in resultset for specified index" );
// return SQL_SUCCESS_WITH_INFO; // no col for specified index
//}
-
+
// get col value as string
//srcdata = SOAPGetElemText ( coldata );
-
+
// NULL DATA // note: a text of NULL indicates NULL data from server
-
+
// check if data is NULL
- if ( srcdata == NULL || _wcsicmp ( srcdata, L"NULL" ) == 0 ) {
+ if ( srcdata == NULL || _wcsicmp ( srcdata, L"NULL" ) == 0 )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "srcdata is null" ) );
-
+
// check if a size indicator is available
- if ( tgtsizeptr == NULL ) {
- _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLFetchCol", "22002", -1, pStmt->CurRowsetEndRowPos, pARDCol->ColNum,
- "Indicator variable required but not supplied" );
+ if ( tgtsizeptr == NULL )
+ {
+ _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLFetchCol", "22002", -1, pStmt -> CurRowsetEndRowPos, pARDCol -> ColNum,
+ "Indicator variable required but not supplied" );
return SQL_SUCCESS_WITH_INFO;
}
-
+
// set to SQL_NULL_DATA
- else {
+ else
+ {
// indicate null data
* ( ( Long* ) tgtsizeptr ) = SQL_NULL_DATA;
// added precaution for bad appl design
@@ -1005,16 +1103,18 @@ RETCODE SQL_API _SQLFetchCol ( pODBCStmt pStmt,
return SQL_SUCCESS;
}
}
-
+
// check if info about src is also available in ARD col
- if ( pARDCol->SrcDataType == 0 )
- { GetIRDColDescInfo ( coldesc, & ( pARDCol->SrcDataType ), & ( pARDCol->SrcDataPrecision ), & ( pARDCol->SrcDataScale ), & ( pARDCol->SrcDataSize ) ); } // collect source data information in form comparable to appl
-
+ if ( pARDCol -> SrcDataType == 0 )
+ {
+ GetIRDColDescInfo ( coldesc, & ( pARDCol -> SrcDataType ), & ( pARDCol -> SrcDataPrecision ), & ( pARDCol -> SrcDataScale ), & ( pARDCol -> SrcDataSize ) );
+ } // collect source data information in form comparable to appl
+
// CONVERT AND TRANSFER
//Important!!!
//Notice the specification of different types
//http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.odbc.doc/odbc72.htm
- RETCODE ret = _SQLColConvert ( pStmt, tgtdataptr, tgtsizeptr, srcdata, pARDCol, coldesc->isSigned );
+ RETCODE ret = _SQLColConvert ( pStmt, tgtdataptr, tgtsizeptr, srcdata, pARDCol, coldesc -> isSigned );
//char buffer[1024];
//hexDump((char*)tgtdataptr,4,buffer,false);
//__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,buffer));
@@ -1028,64 +1128,78 @@ RETCODE SQL_API _SQLFetchCol ( pODBCStmt pStmt,
// to move to the next row with relevant checks
// -----------------------------------------------------------------------
-RETCODE SQL_API _SQLFetchMoveNext ( pODBCStmt pStmt ) {
+RETCODE SQL_API _SQLFetchMoveNext ( pODBCStmt pStmt )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLFetch MoveNext is called" ) );
-
+
// check if there is some response of type resultset
- if (pStmt->IRD.RowDesc != NULL ) {
+ if ( pStmt -> IRD . RowDesc != NULL )
+ {
// ------- THIS CASE SHOULD NOT OCCUR ----------
-
+
// check if position is currently unknown
- if ( pStmt->CurRowsetStartRow == NULL && pStmt->CurRowsetStartRowPos == 0 ) {
+ if ( pStmt -> CurRowsetStartRow == NULL && pStmt -> CurRowsetStartRowPos == 0 )
+ {
// position to first row ( both the pointers )
- pStmt->CurRowsetStartRowPos = 1;
- pStmt->CurRowsetStartRow = GetIfExist ( pStmt->IRD.RowDesc->results, 1 );
- pStmt->CurRowsetEndRowPos = 1;
- pStmt->CurRowsetEndRow = GetIfExist ( pStmt->IRD.RowDesc->results, 1 );
+ pStmt -> CurRowsetStartRowPos = 1;
+ pStmt -> CurRowsetStartRow = GetIfExist ( pStmt -> IRD . RowDesc -> results, 1 );
+ pStmt -> CurRowsetEndRowPos = 1;
+ pStmt -> CurRowsetEndRow = GetIfExist ( pStmt -> IRD . RowDesc -> results, 1 );
}
-
+
// -----------------------------------------------
-
+
// position to next row if already position is known
- else if ( pStmt->CurRowsetEndRow != NULL ) {
+ else if ( pStmt -> CurRowsetEndRow != NULL )
+ {
// position to next row
- pStmt->CurRowsetEndRowPos += 1;
- pStmt->CurRowsetEndRow = GetIfExist ( pStmt->IRD.RowDesc->results, pStmt->CurRowsetEndRowPos );
+ pStmt -> CurRowsetEndRowPos += 1;
+ pStmt -> CurRowsetEndRow = GetIfExist ( pStmt -> IRD . RowDesc -> results, pStmt -> CurRowsetEndRowPos );
}
-
+
// finally check if there is some data found
- if ( pStmt->CurRowsetEndRow == NULL ) {
+ if ( pStmt -> CurRowsetEndRow == NULL )
+ {
// put in diag
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "01000", -1, "SQLFetch - no data" );
return SQL_NO_DATA;
}
-
+
else
- { return SQL_SUCCESS; }
+ {
+ return SQL_SUCCESS;
+ }
}
-
- else {
+
+ else
+ {
// error situation
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLFetchMoveNext", "01000", -1, "no resultset" );
return SQL_ERROR;
}
}
-SQLRowContent* GetIfExist ( std::vector<SQLRowContent*>& container, int index ) {
+SQLRowContent* GetIfExist ( std::vector <SQLRowContent*>& container, int index )
+{
index = index - 1; //sql cardinals start at 1
-
- if ( index >= ( int ) container.size() )
- { return NULL; }
-
+
+ if ( index >= ( int ) container . size () )
+ {
+ return NULL;
+ }
+
else
- { return container.at ( index ); }
+ {
+ return container . at ( index );
+ }
}
// -----------------------------------------------------------------------
// to set the initial row positions for a fetch
// -----------------------------------------------------------------------
-RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt ) {
+RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt )
+{
// note
// there r 2 row pointers one is the start row for the current fetch and
// the other is the end row after the current fetch
@@ -1093,40 +1207,47 @@ RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt ) {
// after the cur end row
// a block of rows which is fetched in one go is ROWSET while the full
// result is called RESULTSET
-
+
// check if there is some response of type resultset
if (
- pStmt->IRD.RowDesc != NULL ) {
+ pStmt -> IRD . RowDesc != NULL )
+ {
// check if position is currently unknown
- if ( pStmt->CurRowsetEndRow == NULL && pStmt->CurRowsetEndRowPos == 0 ) {
+ if ( pStmt -> CurRowsetEndRow == NULL && pStmt -> CurRowsetEndRowPos == 0 )
+ {
// position to first row ( both the pointers )
- pStmt->CurRowsetEndRowPos = 1;
- pStmt->CurRowsetEndRow = GetIfExist ( pStmt->IRD.RowDesc->results, pStmt->CurRowsetEndRowPos );
+ pStmt -> CurRowsetEndRowPos = 1;
+ pStmt -> CurRowsetEndRow = GetIfExist ( pStmt -> IRD . RowDesc -> results, pStmt -> CurRowsetEndRowPos );
}
-
+
// already positioned somewhere
- else if ( pStmt->CurRowsetEndRow != NULL ) {
+ else if ( pStmt -> CurRowsetEndRow != NULL )
+ {
// position to next row
- pStmt->CurRowsetEndRowPos += 1;
- pStmt->CurRowsetEndRow = GetIfExist ( pStmt->IRD.RowDesc->results, pStmt->CurRowsetEndRowPos );
+ pStmt -> CurRowsetEndRowPos += 1;
+ pStmt -> CurRowsetEndRow = GetIfExist ( pStmt -> IRD . RowDesc -> results, pStmt -> CurRowsetEndRowPos );
}
-
+
// calibrate the first row with end row
- pStmt->CurRowsetStartRow = pStmt->CurRowsetEndRow;
- pStmt->CurRowsetStartRowPos = pStmt->CurRowsetEndRowPos;
-
+ pStmt -> CurRowsetStartRow = pStmt -> CurRowsetEndRow;
+ pStmt -> CurRowsetStartRowPos = pStmt -> CurRowsetEndRowPos;
+
// finally check if there is some data found
- if ( pStmt->CurRowsetStartRow == NULL ) {
+ if ( pStmt -> CurRowsetStartRow == NULL )
+ {
// put in diag
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "01000", -1, "SQLFetch - no data" );
return SQL_NO_DATA;
}
-
+
else
- { return SQL_SUCCESS; }
+ {
+ return SQL_SUCCESS;
+ }
}
-
- else {
+
+ else
+ {
// error situation
_SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "_SQLResetRowPos", "01000", -1, "no resultset" );
return SQL_ERROR;
@@ -1138,114 +1259,146 @@ RETCODE SQL_API _SQLResetRowPos ( pODBCStmt pStmt ) {
// to return the next row from the resultset
// -----------------------------------------------------------------------
-RETCODE SQL_API _SQLFetch ( pODBCStmt pStmt,
- Word pFetchOrientation,
- Long pFetchOffset, //ARD.RowArraySize
- ULong* pRowCountPtr, //IRD.RowsProcessedPtr
- UWord* pRowStatusArray ) { //ArrayStatusPtr
+RETCODE SQL_API _SQLFetch ( pODBCStmt pStmt,
+ Word pFetchOrientation,
+ Long pFetchOffset, //ARD.RowArraySize
+ ULong* pRowCountPtr, //IRD.RowsProcessedPtr
+ UWord* pRowStatusArray )
+{ //ArrayStatusPtr
// note
// fetchoffset is treated as the number of rows to fetch
- bool flgNoData;
- Long i, n1, n2;
- RETCODE s;
- SQLRowContent* rowdata;
- SQLResponse* rowdesc;
- pODBCARD ard;
- pARDItem ardcol;
-
+ bool flgNoData;
+ Long i, n1, n2;
+ RETCODE s;
+ SQLRowContent* rowdata;
+ SQLResponse* rowdesc;
+ pODBCARD ard;
+ pARDItem ardcol;
+
// CALLER SAFE
-
+
// caller safe for row fetched
if ( pRowCountPtr )
- { *pRowCountPtr = 0; }
-
+ {
+ *pRowCountPtr = 0;
+ }
+
// caller safe for each row status
if ( pRowStatusArray )
- for ( i = 0; i < pFetchOffset; i ++ ) { pRowStatusArray[i] = SQL_ROW_NOROW; }
-
+ for ( i = 0; i < pFetchOffset; i ++ )
+ {
+ pRowStatusArray[i] = SQL_ROW_NOROW;
+ }
+
// RESET POSITION OR SET INITIAL POSITIONS
-
+
// postions the row counter for fetch start
if ( ( s = _SQLResetRowPos ( ( pODBCStmt ) pStmt ) ) != SQL_SUCCESS )
- { return s; }
-
+ {
+ return s;
+ }
+
// COLLECT INFO to START
// get the row desc - ird
- rowdesc = ( ( pODBCStmt ) pStmt )->IRD.RowDesc.get();
+ rowdesc = ( ( pODBCStmt ) pStmt ) -> IRD . RowDesc . get ();
// get the row desc - ard
- ard = & ( ( ( pODBCStmt ) pStmt )->ARD );
-
+ ard = & ( ( ( pODBCStmt ) pStmt ) -> ARD );
+
// MAIN LOOP to fetch rowset number of rows
// loop to fetch the rows
- for ( i = 0, n1 = 0, n2 = 0, flgNoData = FALSE; i < pFetchOffset && flgNoData == FALSE; i ++ ) {
+ for ( i = 0 , n1 = 0 , n2 = 0 , flgNoData = FALSE; i < pFetchOffset && flgNoData == FALSE; i ++ )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Get One Row:" ) );
-
+
// check if first row or not
- if ( i != 0 ) {
+ if ( i != 0 )
+ {
// move to next row if not first time
- switch ( _SQLFetchMoveNext ( pStmt ) ) {
- case SQL_NO_DATA:
- flgNoData = TRUE; // can continue
+ switch ( _SQLFetchMoveNext ( pStmt ) )
+ {
+ case SQL_NO_DATA :
+ flgNoData = TRUE; // can continue
continue;
-
- case SQL_ERROR:
- return SQL_ERROR; // not continuing
-
- default: // case SQL_SUCCESS:
+
+ case SQL_ERROR :
+ return SQL_ERROR; // not continuing
+
+ default : // case SQL_SUCCESS:
break;
}
}
-
+
// get the current row data
- rowdata = pStmt->CurRowsetEndRow;
-
+ rowdata = pStmt -> CurRowsetEndRow;
+
// LOOP to fetch cols of one row
-
+
// loop to put data in all bound cols
- for ( ardcol = ard->BindCols; ardcol != NULL; ardcol = ardcol->Next ) {
+ for ( ardcol = ard -> BindCols; ardcol != NULL; ardcol = ardcol -> Next )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Get one column:" ) );
// get data using _SQLFetchCol
s = _SQLFetchCol ( pStmt, ardcol, rowdesc, rowdata );
-
+
// update row status
- switch ( s ) {
- case SQL_SUCCESS:
- if ( pRowStatusArray && pRowStatusArray[i] == SQL_ROW_NOROW ) { pRowStatusArray[i] = SQL_ROW_SUCCESS_WITH_INFO; }
-
+ switch ( s )
+ {
+ case SQL_SUCCESS :
+ if ( pRowStatusArray && pRowStatusArray[i] == SQL_ROW_NOROW )
+ {
+ pRowStatusArray[i] = SQL_ROW_SUCCESS_WITH_INFO;
+ }
+
break;
-
- case SQL_SUCCESS_WITH_INFO:
- ++ n1; // rows with info
-
- if ( pRowStatusArray ) { pRowStatusArray[i - 1] = SQL_ROW_SUCCESS_WITH_INFO; }
-
+
+ case SQL_SUCCESS_WITH_INFO :
+ ++ n1; // rows with info
+
+ if ( pRowStatusArray )
+ {
+ pRowStatusArray[i - 1] = SQL_ROW_SUCCESS_WITH_INFO;
+ }
+
break;
-
- default:
- ++ n2; // no. of rows with error
-
- if ( pRowStatusArray ) { pRowStatusArray[i - 1] = SQL_ROW_ERROR; }
+
+ default :
+ ++ n2; // no. of rows with error
+
+ if ( pRowStatusArray )
+ {
+ pRowStatusArray[i - 1] = SQL_ROW_ERROR;
+ }
}
}
-
+
// update the number of rows fetched
- if ( pRowCountPtr ) { *pRowCountPtr = i + 1; }
+ if ( pRowCountPtr )
+ {
+ *pRowCountPtr = i + 1;
+ }
}
-
+
// check if no data
if ( flgNoData == TRUE && i <= 0 )
- { return SQL_NO_DATA; }
-
+ {
+ return SQL_NO_DATA;
+ }
+
// check if all error
else if ( i > 0 && n2 == i )
- { return SQL_ERROR; }
-
+ {
+ return SQL_ERROR;
+ }
+
// check if any success with info
else if ( i > 0 && n1 > 0 )
- { return SQL_SUCCESS_WITH_INFO; }
-
+ {
+ return SQL_SUCCESS_WITH_INFO;
+ }
+
// all success
- else {
+ else
+ {
return SQL_SUCCESS;
}
}
@@ -1255,80 +1408,87 @@ RETCODE SQL_API _SQLFetch ( pODBCStmt pStmt,
// to retrieve long data for a single column in the result set using multiple calls
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetData ( SQLHSTMT pStmt,
- SQLUSMALLINT pColNum,
- SQLSMALLINT pDataType,
- SQLPOINTER pDataPtr,
- SQLLEN pDataSize,
- SQLLEN* pDataSizePtr ) {
- __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
-
- __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetData called, ColNum: %d, TgtType: %d, ValuePtr: %d, Capacity: %d",
- pColNum, pDataType, pDataPtr, pDataSize ) );
-
- if ( pColNum < 1 || pColNum > (( pODBCStmt )pStmt)->IRD.DescCount ) {
- _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "07009", -1, "Dynamic SQL error-invalid descriptor index" );
+RETCODE SQL_API SQLGetData ( SQLHSTMT pStmt,
+ SQLUSMALLINT pColNum,
+ SQLSMALLINT pDataType,
+ SQLPOINTER pDataPtr,
+ SQLLEN pDataSize,
+ SQLLEN* pDataSizePtr )
+{
+ __CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
+
+ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetData called, ColNum: %d, TgtType: %d, ValuePtr: %d, Capacity: %d",
+ pColNum, pDataType, pDataPtr, pDataSize ) );
+
+ if ( pColNum < 1 || pColNum > ( ( pODBCStmt )pStmt ) -> IRD . DescCount )
+ {
+ _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "07009", -1, "Dynamic SQL error-invalid descriptor index" );
return SQL_ERROR;
- }
-
- pODBCARD ard;
- pARDItem ardcol;
- SQLRowContent* rowdata;
- SQLResponse* rowdesc;
- SQLSMALLINT tgtPDataType;
-
- ard = & ( ( ( pODBCStmt ) pStmt )->ARD );
- rowdata = ((pODBCStmt)pStmt)->CurRowsetEndRow;
- rowdesc = ( ( pODBCStmt ) pStmt )->IRD.RowDesc.get();
-
- if ( rowdata == NULL ) {
- _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "HY010", -1, "CLI-specific condition-function sequence error" );
+ }
+
+ pODBCARD ard;
+ pARDItem ardcol;
+ SQLRowContent* rowdata;
+ SQLResponse* rowdesc;
+ SQLSMALLINT tgtPDataType;
+
+ ard = & ( ( ( pODBCStmt ) pStmt ) -> ARD );
+ rowdata = ( ( pODBCStmt )pStmt ) -> CurRowsetEndRow;
+ rowdesc = ( ( pODBCStmt ) pStmt ) -> IRD . RowDesc . get ();
+
+ if ( rowdata == NULL )
+ {
+ _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "HY010", -1, "CLI-specific condition-function sequence error" );
return SQL_ERROR;
- }
-
- ardcol = _SQLGetARDItem ( ard, pColNum );
- if (ardcol != NULL) {
- /* It's illegal to call SQLGetdata for a "bound" Column */
- _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "07009", -1, "dynamic SQL error-invalid descriptor index" );
+ }
+
+ ardcol = _SQLGetARDItem ( ard, pColNum );
+ if ( ardcol != NULL )
+ {
+ /* It's illegal to call SQLGetdata for a "bound" Column */
+ _SQLPutDiagRow ( SQL_HANDLE_STMT, pStmt, "", "07009", -1, "dynamic SQL error-invalid descriptor index" );
return SQL_ERROR;
- }
-
- // convert C data type to SQL data type
- switch (pDataType)
- {
- case SQL_C_SBIGINT:
- case SQL_C_SLONG:
- case SQL_C_SSHORT:
- case SQL_C_STINYINT:
- tgtPDataType = pDataType - SQL_SIGNED_OFFSET;
- break;
- case SQL_C_ULONG:
- case SQL_C_USHORT:
- case SQL_C_UTINYINT:
- case SQL_C_UBIGINT:
- tgtPDataType = pDataType - SQL_UNSIGNED_OFFSET;
- break;
- default:
- tgtPDataType = pDataType;
- break;
- }
-
- // manually bind column information to output
- RETCODE ret = SQLBindCol(pStmt, pColNum, tgtPDataType, pDataPtr, pDataSize, pDataSizePtr);
- if (ret != SQL_SUCCESS) {
- return ret;
- }
-
- ardcol = _SQLGetARDItem ( ard, pColNum );
- ret = _SQLFetchCol ( (pODBCStmt)pStmt, ardcol, rowdesc, rowdata );
- if (ret != SQL_SUCCESS) {
- return ret;
- }
- _SQLDetachARDItem(ard, ardcol);
-
- /*unique_ptr<char[]> temp2 ( wchar2char ( ( wchar_t* ) pDataPtr ) );
- __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Data1: %s", temp2.get()));
- __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Size1: %d", *pDataSizePtr));*/
-
- return SQL_SUCCESS;
+ }
+
+ // convert C data type to SQL data type
+ switch ( pDataType )
+ {
+ case SQL_C_SBIGINT :
+ case SQL_C_SLONG :
+ case SQL_C_SSHORT :
+ case SQL_C_STINYINT :
+ tgtPDataType = pDataType - SQL_SIGNED_OFFSET;
+ break;
+ case SQL_C_ULONG :
+ case SQL_C_USHORT :
+ case SQL_C_UTINYINT :
+ case SQL_C_UBIGINT :
+ tgtPDataType = pDataType - SQL_UNSIGNED_OFFSET;
+ break;
+ default :
+ tgtPDataType = pDataType;
+ break;
+ }
+
+ // manually bind column information to output
+ RETCODE ret = SQLBindCol ( pStmt, pColNum, tgtPDataType, pDataPtr, pDataSize, pDataSizePtr );
+ if ( ret != SQL_SUCCESS )
+ {
+ return ret;
+ }
+
+ ardcol = _SQLGetARDItem ( ard, pColNum );
+ ret = _SQLFetchCol ( ( pODBCStmt )pStmt, ardcol, rowdesc, rowdata );
+ if ( ret != SQL_SUCCESS )
+ {
+ return ret;
+ }
+ _SQLDetachARDItem ( ard, ardcol );
+
+ /*unique_ptr<char[]> temp2 ( wchar2char ( ( wchar_t* ) pDataPtr ) );
+ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Data1: %s", temp2.get()));
+ __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Size1: %d", *pDataSizePtr));*/
+
+ return SQL_SUCCESS;
}
+
[08/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_CONN.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_CONN.CPP b/odbc/Driver/KO_CONN.CPP
index 28642b1..cee9b39 100644
--- a/odbc/Driver/KO_CONN.CPP
+++ b/odbc/Driver/KO_CONN.CPP
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
// ----------------------------------------------------------------------------
//
// File: KO_CONN.CPP
@@ -58,110 +58,126 @@
INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
// ----------------------------- local functions ------------------------------
-static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue );
+static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue );
-static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg );
+static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg );
-static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn );
+static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn );
-static Word PromptForConnInfo ( SQLHDBC pConn );
+static Word PromptForConnInfo ( SQLHDBC pConn );
-static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
- struct ODBCKV** pKV );
+static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
+ struct ODBCKV** pKV );
-static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen );
-static bool BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
- Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs );
+static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen );
+static bool BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
+ Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs );
-static const char *supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
-static const char *defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
+static const char* supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
+static const char* defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
// -----------------------------------------------------------------------
// to set a specified property in the connection structure
// -----------------------------------------------------------------------
-eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
+eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue )
+{
// note
// this function does not create a copy of char data
// it just transfers the pointer
// numeric data is assumed to be a pointer
-
+
// check property
- switch ( pPropID ) {
- case CONN_PROP_SERVER:
-
+ switch ( pPropID )
+ {
+ case CONN_PROP_SERVER :
+
// check if a new value has to be put
- if ( pPropValue ) {
- copyTrimmed ( & ( ( char* ) pConn->Server ), ( char* ) pPropValue );
+ if ( pPropValue )
+ {
+ copyTrimmed ( & ( ( char* ) pConn -> Server ), ( char* ) pPropValue );
}
-
- if ( pConn->Server == NULL || strlen ( pConn->Server ) == 0 ) {
+
+ if ( pConn -> Server == NULL || strlen ( pConn -> Server ) == 0 )
+ {
__ODBCPopMsg ( "Server cannot be empty" );
return BAD;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The server is set to %s", pConn->Server ) );
break;
-
- case CONN_PROP_PORT:
-
+
+ case CONN_PROP_PORT :
+
// numeric values are passed as pointer to value
if ( pPropValue )
- { pConn->ServerPort = * ( ( ULong* ) pPropValue ); }
-
- if ( pConn->ServerPort == 0 ) {
+ {
+ pConn -> ServerPort = * ( ( ULong* ) pPropValue );
+ }
+
+ if ( pConn -> ServerPort == 0 )
+ {
__ODBCPopMsg ( "ServerPort cannot be 0" );
return BAD;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The port is set to %d", pConn->ServerPort ) );
break;
-
- case CONN_PROP_UID:
-
+
+ case CONN_PROP_UID :
+
// check if a new value has to be put
if ( pPropValue )
- { copyTrimmed ( & ( ( char* ) pConn->UserName ), ( char* ) pPropValue ); }
-
- if ( pConn->UserName == NULL || strlen ( pConn->UserName ) == 0 ) {
+ {
+ copyTrimmed ( & ( ( char* ) pConn -> UserName ), ( char* ) pPropValue );
+ }
+
+ if ( pConn -> UserName == NULL || strlen ( pConn -> UserName ) == 0 )
+ {
__ODBCPopMsg ( "UserName cannot be empty" );
return BAD;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The uid is set to %s", pConn->UserName ) );
break;
-
- case CONN_PROP_PWD:
-
+
+ case CONN_PROP_PWD :
+
// check if a new value has to be put
if ( pPropValue )
- { copyTrimmed ( & ( ( char* ) pConn->Password ), ( char* ) pPropValue ); }
-
- if ( pConn->Password == NULL || strlen ( pConn->Password ) == 0 ) {
+ {
+ copyTrimmed ( & ( ( char* ) pConn -> Password ), ( char* ) pPropValue );
+ }
+
+ if ( pConn -> Password == NULL || strlen ( pConn -> Password ) == 0 )
+ {
__ODBCPopMsg ( "Password cannot be empty" );
return BAD;
}
-
+
break;
-
- case CONN_PROP_PROJECT:
-
+
+ case CONN_PROP_PROJECT :
+
// check if a new value has to be put
if ( pPropValue )
- { copyTrimmed ( & ( ( char* ) pConn->Project ), ( char* ) pPropValue ); }
-
- if ( pConn->Project == NULL || strlen ( pConn->Project ) == 0 ) {
+ {
+ copyTrimmed ( & ( ( char* ) pConn -> Project ), ( char* ) pPropValue );
+ }
+
+ if ( pConn -> Project == NULL || strlen ( pConn -> Project ) == 0 )
+ {
__ODBCPopMsg ( "Project cannot be empty" );
return BAD;
}
-
+
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "Bad connection property" ) );
return BAD;
}
-
+
return GOOD;
}
@@ -170,45 +186,52 @@ eGoodBad SetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
// to create copy of a value and then set it in the struct
// -----------------------------------------------------------------------
-static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue ) {
- bool IsPropStr;
-
+static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPropValue )
+{
+ bool IsPropStr;
+
// precaution
if ( !pConn )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// determine the prop type
- switch ( pPropID ) {
- case CONN_PROP_PORT: // port is stored as a number
+ switch ( pPropID )
+ {
+ case CONN_PROP_PORT : // port is stored as a number
IsPropStr = FALSE;
break;
-
- default:
+
+ default :
IsPropStr = TRUE;
break;
}
-
+
// check property type
- if ( IsPropStr ) {
- Word x;
- unique_ptr<char[]> s = NULL;
+ if ( IsPropStr )
+ {
+ Word x;
+ unique_ptr <char[]> s = NULL;
// find length of property
x = pPropValue ? strlen ( ( StrPtr ) pPropValue ) : 0;
-
+
// check if something
- if ( x > 0 ) {
+ if ( x > 0 )
+ {
// create copy of property
s = make_unique_str ( x );
// store
- strcpy ( s.get(), ( StrPtr ) pPropValue );
+ strcpy ( s . get (), ( StrPtr ) pPropValue );
}
-
+
// now set the property
- return SetConnProp ( pConn, pPropID, s.get() );
+ return SetConnProp ( pConn, pPropID, s . get () );
}
-
- else {
- Long v;
+
+ else
+ {
+ Long v;
// convert value to integer
v = ( pPropValue ) ? atoi ( ( StrPtr ) pPropValue ) : 0;
// now set the property
@@ -220,146 +243,198 @@ static eGoodBad CreateAndSetConnProp ( pODBCConn pConn, Word pPropID, void* pPro
// to provide the default data to DSN config dialog 1
// -----------------------------------------------------------------------
-static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg ) {
- BOOL x;
-
+static eGoodBad PutDataToDlgDSNCfg1 ( pODBCConn pConn, HWND hDlg )
+{
+ BOOL x;
+
// precaution
- if ( !pConn || !hDlg ) {
+ if ( !pConn || !hDlg )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "PutDataToDlgDSNCfg1 - Bad params" ) );
return BAD;
}
-
+
// server name/IP
- if ( pConn->Server )
- { x = SetDlgItemText ( hDlg, IDC_SERVER, pConn->Server ); }
-
+ if ( pConn -> Server )
+ {
+ x = SetDlgItemText ( hDlg, IDC_SERVER, pConn -> Server );
+ }
+
else
- { x = SetDlgItemText ( hDlg, IDC_SERVER, "" ); }
-
- if ( !x ) { return BAD; }
-
+ {
+ x = SetDlgItemText ( hDlg, IDC_SERVER, "" );
+ }
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// server port
- if ( pConn->ServerPort )
- { x = SetDlgItemInt ( hDlg, IDC_PORT, pConn->ServerPort, FALSE ); }
-
+ if ( pConn -> ServerPort )
+ {
+ x = SetDlgItemInt ( hDlg, IDC_PORT, pConn -> ServerPort, FALSE );
+ }
+
else
- { x = SetDlgItemInt ( hDlg, IDC_PORT, DEFAULT_PORT, FALSE ); }
-
- if ( !x ) { return BAD; }
-
+ {
+ x = SetDlgItemInt ( hDlg, IDC_PORT, DEFAULT_PORT, FALSE );
+ }
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// user name
- if ( pConn->UserName )
- { x = SetDlgItemText ( hDlg, IDC_UID, pConn->UserName ); }
-
+ if ( pConn -> UserName )
+ {
+ x = SetDlgItemText ( hDlg, IDC_UID, pConn -> UserName );
+ }
+
else
- { x = SetDlgItemText ( hDlg, IDC_UID, "" ); }
-
- if ( !x ) { return BAD; }
-
+ {
+ x = SetDlgItemText ( hDlg, IDC_UID, "" );
+ }
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// password
- if ( pConn->Password )
- { x = SetDlgItemText ( hDlg, IDC_PWD, pConn->Password ); }
-
+ if ( pConn -> Password )
+ {
+ x = SetDlgItemText ( hDlg, IDC_PWD, pConn -> Password );
+ }
+
else
- { x = SetDlgItemText ( hDlg, IDC_PWD, "" ); }
-
- if ( !x ) { return BAD; }
-
+ {
+ x = SetDlgItemText ( hDlg, IDC_PWD, "" );
+ }
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
return GOOD;
}
-
// -----------------------------------------------------------------------
// to fetch the data from the dialog 1 into the conn-struct
// -----------------------------------------------------------------------
-static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn ) {
- Long x;
- std::unique_ptr<char[]> n = NULL;
+static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn )
+{
+ Long x;
+ std::unique_ptr <char[]> n = NULL;
eGoodBad status;
-
+
// note
// no error handling is currently being done for
// GetDlgItemText/GetDlgItemInt/SetConnProp
// generally should not be a problem
-
+
// precaution
- if ( !pConn || !hDlg ) {
+ if ( !pConn || !hDlg )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "GetDataFromDlgDSNCfg1 - Bad params" ) );
return BAD;
}
-
+
////// server name/IP
// get length of input text
x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
- n = make_unique_str ( x + 8 ); // allocate space for holding the text
-
- char serverStrBuf[256];
- GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, x + 1 ); // get text from dialog
-
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
-
- strcpy ( n.get(), supportedProtocols[ItemIndex] );
- strcat ( n.get(), PROTOCOL_SEP );
- strcat ( n.get(), serverStrBuf );
+
+ if ( x > 0 )
+ {
+ n = make_unique_str ( x + 8 ); // allocate space for holding the text
+
+ char serverStrBuf[256];
+ GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, x + 1 ); // get text from dialog
+
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+
+ strcpy ( n . get (), supportedProtocols[ItemIndex] );
+ strcat ( n . get (), PROTOCOL_SEP );
+ strcat ( n . get (), serverStrBuf );
}
-
+
else
- { n = NULL; } // no input
-
+ {
+ n = NULL;
+ } // no input
+
// set value in struct
- status = SetConnProp ( pConn, CONN_PROP_SERVER, n.get() );
-
- if ( status == BAD ) { return BAD; }
-
+ status = SetConnProp ( pConn, CONN_PROP_SERVER, n . get () );
+
+ if ( status == BAD )
+ {
+ return BAD;
+ }
+
///// Port
// get value
x = GetDlgItemInt ( hDlg, IDC_PORT, NULL, FALSE );
// set value in struct
status = SetConnProp ( pConn, CONN_PROP_PORT, &x );
-
- if ( status == BAD ) { return BAD; }
-
+
+ if ( status == BAD )
+ {
+ return BAD;
+ }
+
////// User name
// get length
x = SendDlgItemMessage ( hDlg, IDC_UID, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
// allocate space
- n = make_unique_str ( x ); // allocate space for holding the text
- GetDlgItemText ( hDlg, IDC_UID, n.get(), x + 1 );
+ n = make_unique_str ( x ); // allocate space for holding the text
+ GetDlgItemText ( hDlg, IDC_UID, n . get (), x + 1 );
}
-
+
else
- { n = NULL; }
-
+ {
+ n = NULL;
+ }
+
// set value in struct
- status = SetConnProp ( pConn, CONN_PROP_UID, n.get() );
-
- if ( status == BAD ) { return BAD; }
-
+ status = SetConnProp ( pConn, CONN_PROP_UID, n . get () );
+
+ if ( status == BAD )
+ {
+ return BAD;
+ }
+
////// Password
// get length
x = SendDlgItemMessage ( hDlg, IDC_PWD, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
// allocate space
- n = make_unique_str ( x ); // allocate space for holding the text
- GetDlgItemText ( hDlg, IDC_PWD, n.get(), x + 1 );
+ n = make_unique_str ( x ); // allocate space for holding the text
+ GetDlgItemText ( hDlg, IDC_PWD, n . get (), x + 1 );
}
-
+
else
- { n = NULL; }
-
+ {
+ n = NULL;
+ }
+
// set value in struct
- status = SetConnProp ( pConn, CONN_PROP_PWD, n.get() );
-
- if ( status == BAD ) { return BAD; }
-
+ status = SetConnProp ( pConn, CONN_PROP_PWD, n . get () );
+
+ if ( status == BAD )
+ {
+ return BAD;
+ }
+
return GOOD;
}
@@ -368,18 +443,21 @@ static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, pODBCConn pConn ) {
// call back for DSN config dialog 1
// --------------------------------------------------------------------------
-INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
pODBCConn pgConn = NULL;
eGoodBad status = GOOD;
RETCODE ret = SQL_SUCCESS;
-
- switch ( uMsg ) {
- case WM_INITDIALOG: {
- // init protocol list
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[0]));
- SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[1]));
- SendMessage(hwndCombo, CB_SETCURSEL, 0, 0 );
+
+ switch ( uMsg )
+ {
+ case WM_INITDIALOG :
+ {
+ // init protocol list
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[0] ) );
+ SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[1] ) );
+ SendMessage ( hwndCombo, CB_SETCURSEL, 0, 0 );
// store the structure for future use
SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
@@ -387,120 +465,136 @@ INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
PutDataToDlgDSNCfg1 ( ( pODBCConn ) lParam, hDlg );
// set focus automatically
return TRUE;
- }
- case WM_COMMAND:
- switch ( LOWORD ( wParam ) ) {
- case IDC_PROTOCOL: {
- switch ( HIWORD ( wParam ) ) {
- case CBN_SELCHANGE: {
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
- if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) ) { return TRUE; }
-
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
-
- case IDC_CONNECT: {
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
- HWND hwndOK = GetDlgItem ( hDlg, IDOK );
- // fetch all information from controls & feed to struct
- pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
- status = GetDataFromDlgDSNCfg1 ( hDlg, pgConn );
-
- if ( status == BAD ) {
- //Blank input, already popped message
- return FALSE;
- }
-
- ret = TryAuthenticate ( pgConn );
-
- if ( ret == SQL_ERROR ) {
- //validation of data & other prompts goes here
- __ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
- return FALSE;
- }
-
- //passed verification
- EnableWindow ( hwndCombo, TRUE );
-
- try {
- std::vector<string> projects;
- restListProjects ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password, projects );
-
- // reload project list
- SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
- for ( unsigned int i = 0 ; i < projects.size(); ++i ) {
- SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects.at ( i ).c_str() );
+ }
+ case WM_COMMAND :
+ switch ( LOWORD ( wParam ) )
+ {
+ case IDC_PROTOCOL :
+ {
+ switch ( HIWORD ( wParam ) )
+ {
+ case CBN_SELCHANGE :
+ {
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+ if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) )
+ {
+ return TRUE;
}
-
- SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
- }
-
- catch ( exception& e ) {
- __ODBCPopMsg ( e.what() );
+
return FALSE;
}
-
- EnableWindow ( hwndOK, TRUE );
- return TRUE;
+ default :
+ break;
}
-
- case IDOK: {
- pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
- int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
- ( WPARAM ) 0, ( LPARAM ) 0 );
- TCHAR projectName[256];
- ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
- ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
- SetConnProp ( pgConn, CONN_PROP_PROJECT, projectName );
- //last trial with project given
- ret = TryFetchMetadata ( pgConn );
-
- if ( ret == SQL_ERROR ) {
- //validation of data & other prompts goes here
- __ODBCPopMsg ( "Something went wrong with your selected project" );
- return FALSE;
+ break;
+ }
+
+ case IDC_CONNECT :
+ {
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+ HWND hwndOK = GetDlgItem ( hDlg, IDOK );
+ // fetch all information from controls & feed to struct
+ pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
+ status = GetDataFromDlgDSNCfg1 ( hDlg, pgConn );
+
+ if ( status == BAD )
+ {
+ //Blank input, already popped message
+ return FALSE;
+ }
+
+ ret = TryAuthenticate ( pgConn );
+
+ if ( ret == SQL_ERROR )
+ {
+ //validation of data & other prompts goes here
+ __ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
+ return FALSE;
+ }
+
+ //passed verification
+ EnableWindow ( hwndCombo, TRUE );
+
+ try
+ {
+ std::vector <string> projects;
+ restListProjects ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password, projects );
+
+ // reload project list
+ SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
+ for ( unsigned int i = 0; i < projects . size (); ++i )
+ {
+ SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects . at ( i ) . c_str () );
}
-
- EndDialog ( hDlg, wParam );
- return TRUE;
+
+ SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
}
-
- // Fall through, do not break or return
- case IDCANCEL:
+
+ catch ( exception& e )
+ {
+ __ODBCPopMsg ( e . what () );
+ return FALSE;
+ }
+
+ EnableWindow ( hwndOK, TRUE );
+ return TRUE;
+ }
+
+ case IDOK :
+ {
+ pgConn = ( pODBCConn ) GetWindowLongPtr ( hDlg, DWLP_USER );
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+ int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
+ ( WPARAM ) 0, ( LPARAM ) 0 );
+ TCHAR projectName[256];
+ ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
+ ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
+ SetConnProp ( pgConn, CONN_PROP_PROJECT, projectName );
+ //last trial with project given
+ ret = TryFetchMetadata ( pgConn );
+
+ if ( ret == SQL_ERROR )
+ {
+ //validation of data & other prompts goes here
+ __ODBCPopMsg ( "Something went wrong with your selected project" );
+ return FALSE;
+ }
+
+ EndDialog ( hDlg, wParam );
+ return TRUE;
+ }
+
+ // Fall through, do not break or return
+ case IDCANCEL :
// indicate end with control id as return value
EndDialog ( hDlg, wParam );
return TRUE;
}
}
-
+
return FALSE;
}
-
// -----------------------------------------------------------------------
// to get connection info from user
// -----------------------------------------------------------------------
-static Word PromptForConnInfo ( SQLHDBC pConn ) {
- int i;
+static Word PromptForConnInfo ( SQLHDBC pConn )
+{
+ int i;
// invoke dialog to fetch info
i = DialogBoxParam ( ghInstDLL, MAKEINTRESOURCE ( IDD_DSN_CFG1 ), NULL, DlgDSNCfg1Proc, ( LPARAM ) pConn );
-
+
// check status
- switch ( i ) {
- case IDOK:
- return 1; // complete
-
- default:
- return 0; // user-cancelled
+ switch ( i )
+ {
+ case IDOK :
+ return 1; // complete
+
+ default :
+ return 0; // user-cancelled
}
}
@@ -509,109 +603,129 @@ static Word PromptForConnInfo ( SQLHDBC pConn ) {
// to split a given string into key value pairs separated with semi-colon
// -----------------------------------------------------------------------
-eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV ) {
- bool flgError;
- Word x;
- Word pairs;
- Word i, len;
- struct ODBCKV* kvtemp;
- struct ODBCKV* kv;
+eGoodBad CvtStrToKeyValues ( CStrPtr pStr, Word pMaxLen, Word* pNumPair, struct ODBCKV** pKV )
+{
+ bool flgError;
+ Word x;
+ Word pairs;
+ Word i, len;
+ struct ODBCKV* kvtemp;
+ struct ODBCKV* kv;
// caller safe
- *pNumPair = 0;
- *pKV = NULL;
+ *pNumPair = 0;
+ *pKV = NULL;
// local initializations
- kvtemp = NULL;
- kv = NULL;
-
+ kvtemp = NULL;
+ kv = NULL;
+
// main loop to split the strings into key values
- for ( pairs = 0, i = 0, len = ( pMaxLen > 0 ) ? pMaxLen : strlen ( pStr ), flgError = FALSE; i < len &&
- !flgError; pairs ++ ) {
+ for ( pairs = 0 , i = 0 , len = ( pMaxLen > 0 ) ? pMaxLen : strlen ( pStr ) , flgError = FALSE; i < len &&
+ !flgError; pairs ++ )
+ {
// find the length of key
- for ( x = 0; pStr[i] != '=' && i < len; x ++, i ++ );
-
+ for ( x = 0; pStr[i] != '=' && i < len; x ++ , i ++ );
+
// check if a valid key found
- if ( x <= 0 ) {
- flgError = TRUE; // error condition
+ if ( x <= 0 )
+ {
+ flgError = TRUE; // error condition
continue;
}
-
+
// allocate a new record ie key-value if required
- if ( kv == NULL || pairs % KV_BLOCK_SIZE == 0 ) {
+ if ( kv == NULL || pairs % KV_BLOCK_SIZE == 0 )
+ {
// allocate more records
- kvtemp = new struct ODBCKV[pairs + KV_BLOCK_SIZE];
- memset ( kvtemp, 0, sizeof ( struct ODBCKV ) * ( pairs + KV_BLOCK_SIZE ) );
-
+ kvtemp = new struct ODBCKV[pairs + KV_BLOCK_SIZE ];
+ memset ( kvtemp, 0, sizeof ( struct ODBCKV) * ( pairs + KV_BLOCK_SIZE ) );
+
// transfer the old ones into this new one
- if ( kv ) {
- memcpy ( kvtemp, kv, sizeof ( struct ODBCKV ) *pairs );
+ if ( kv )
+ {
+ memcpy ( kvtemp, kv, sizeof ( struct ODBCKV) * pairs );
delete[] kv;
kv = NULL;
}
-
+
// now start using the new one
- kv = kvtemp;
- kvtemp = NULL;
+ kv = kvtemp;
+ kvtemp = NULL;
}
-
+
// create key in current row
- kv[pairs].key = new Char[x + 1];
+ kv[pairs] . key = new Char[x + 1];
// put key
- strncpy ( kv[pairs].key, pStr + ( i - x ), x );
- kv[pairs].key[x] = 0;
+ strncpy ( kv[pairs] . key, pStr + ( i - x ), x );
+ kv[pairs] . key[x] = 0;
// move ahead to ignore equals sign
++ i;
-
+
// find the length of value
- if ( strcmp ( kv[pairs].key, "PWD" ) != 0 ) {
- for ( x = 0; pStr[i] != ';' && i < len; x ++, i ++ ) ;
+ if ( strcmp ( kv[pairs] . key, "PWD" ) != 0 )
+ {
+ for ( x = 0; pStr[i] != ';' && i < len; x ++ , i ++ );
}
-
- else {
+
+ else
+ {
//There may exist ; in PWD
- for ( x = 0; i < len; x ++, i ++ ) {
+ for ( x = 0; i < len; x ++ , i ++ )
+ {
if ( strnicmp ( &pStr[i], ";SERVER=", 8 ) == 0 )
- { break; }
+ {
+ break;
+ }
}
}
-
+
// check if a non-empty value found
- if ( x > 0 ) {
+ if ( x > 0 )
+ {
// create value in current row
- kv[pairs].value = new Char[x + 1];
+ kv[pairs] . value = new Char[x + 1];
// put value
- strncpy ( kv[pairs].value, pStr + ( i - x ), x );
- kv[pairs].value[x] = 0;
+ strncpy ( kv[pairs] . value, pStr + ( i - x ), x );
+ kv[pairs] . value[x] = 0;
}
-
+
// move ahead to ignore the semi-colon at end of key-value
++ i;
}
-
+
// check for error condition
- if ( flgError ) {
+ if ( flgError )
+ {
// clean up
- if ( kv ) {
+ if ( kv )
+ {
delete[] kv;
kv = NULL;
}
-
- return BAD; // error condition
+
+ return BAD; // error condition
}
-
- else {
- *pNumPair = pairs;
- *pKV = kv;
+
+ else
+ {
+ *pNumPair = pairs;
+ *pKV = kv;
return GOOD;
}
}
-void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ) {
- for ( int i = 0 ; i < pairs; ++i ) {
- if ( keyvalues[i].key )
- { delete[] keyvalues[i].key ; }
-
- if ( keyvalues[i].value )
- { delete[] keyvalues[i].value; }
+void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs )
+{
+ for ( int i = 0; i < pairs; ++i )
+ {
+ if ( keyvalues[i] . key )
+ {
+ delete[] keyvalues[i] . key ;
+ }
+
+ if ( keyvalues[i] . value )
+ {
+ delete[] keyvalues[i] . value;
+ }
}
}
@@ -620,30 +734,41 @@ void FreeGenODBCKeyValues ( ODBCKV* keyvalues, int pairs ) {
// to find a particular key and/or value in key-value pair list
// -----------------------------------------------------------------------
-bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition ) {
- Word i;
- bool flgMatch;
-
+bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pItems, Word* pPosition )
+{
+ Word i;
+ bool flgMatch;
+
// loop to traverse the list
- for ( i = 0, flgMatch = FALSE; i < pItems; i ++ ) {
+ for ( i = 0 , flgMatch = FALSE; i < pItems; i ++ )
+ {
// match key
- flgMatch = ( pKey && _stricmp ( pKey, pKV[i].key ) == 0 );
-
+ flgMatch = ( pKey && _stricmp ( pKey, pKV[i] . key ) == 0 );
+
// match value
- if ( pValue && pKV[i].value )
- { flgMatch = ( _stricmp ( pValue, pKV[i].value ) == 0 ); }
-
+ if ( pValue && pKV[i] . value )
+ {
+ flgMatch = ( _stricmp ( pValue, pKV[i] . value ) == 0 );
+ }
+
// break if match
- if ( flgMatch ) { break; }
+ if ( flgMatch )
+ {
+ break;
+ }
}
-
+
// check if found
- if ( flgMatch ) {
- if ( pPosition ) { *pPosition = i; }
-
+ if ( flgMatch )
+ {
+ if ( pPosition )
+ {
+ *pPosition = i;
+ }
+
return TRUE;
}
-
+
return FALSE;
}
@@ -653,7 +778,8 @@ bool FindInKeyValues ( CStrPtr pKey, CStrPtr pValue, struct ODBCKV* pKV, Word pI
// -----------------------------------------------------------------------
static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Word* pNumPair,
- struct ODBCKV** pKV ) {
+ struct ODBCKV** pKV )
+{
//Never called
throw - 1;
}
@@ -663,30 +789,36 @@ static eGoodBad LoadKeyValuesfromFileDSN ( pODBCConn pConn, CStrPtr pDSNName, Wo
// to add a key-value pair to specified conn string
// -----------------------------------------------------------------------
-static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen ) {
- Word i, j;
-
+static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStrConn, Word pMaxLen )
+{
+ Word i, j;
+
// precaution
if ( !pKey )
- { return FALSE; }
-
+ {
+ return FALSE;
+ }
+
// get length of key and value
i = strlen ( pKey );
j = ( pValue ) ? strlen ( pValue ) : 0;
-
+
// check if both can be added along with equal sign & semi-colon
- if ( *iPos + i + j + 2 <= pMaxLen ) {
+ if ( *iPos + i + j + 2 <= pMaxLen )
+ {
strcat ( pStrConn, pKey );
strcat ( pStrConn, "=" );
-
+
if ( pValue )
- { strcat ( pStrConn, pValue ); }
-
+ {
+ strcat ( pStrConn, pValue );
+ }
+
strcat ( pStrConn, ";" );
- ( *iPos ) = ( *iPos ) + i + j + 2; // re-position
+ ( *iPos ) = ( *iPos ) + i + j + 2; // re-position
return TRUE;
}
-
+
return FALSE;
}
@@ -696,321 +828,384 @@ static bool AddKVToConnStr ( StrPtr pKey, StrPtr pValue, Word* iPos, StrPtr pStr
// -----------------------------------------------------------------------
static bool BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn pConn, struct ODBCKV* KVInput,
- Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs ) {
- Word iPos = 0;
- Char p[32]; // arbitary for string port number as string
+ Word iKVInputPairs, struct ODBCKV* KVFileDSN, Word iKVFileDSNPairs )
+{
+ Word iPos = 0;
+ Char p[32]; // arbitary for string port number as string
// initializations
memset ( pStrConn, 0, pMaxLen );
// convert port number to string
- _itoa ( pConn->ServerPort, p, 10 );
-
+ _itoa ( pConn -> ServerPort, p, 10 );
+
// transfer all strings from struct
- if ( !AddKVToConnStr ( "DRIVER", "{KylinODBCDriver}", &iPos, pStrConn, pMaxLen ) ) {
+ if ( !AddKVToConnStr ( "DRIVER", "{KylinODBCDriver}", &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Driver" ) );
return FALSE;
}
-
- if ( !AddKVToConnStr ( "SERVER", pConn->Server, &iPos, pStrConn, pMaxLen ) ) {
+
+ if ( !AddKVToConnStr ( "SERVER", pConn -> Server, &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Server" ) );
return FALSE;
}
-
- if ( !AddKVToConnStr ( "PROJECT", pConn->Project, &iPos, pStrConn, pMaxLen ) ) {
+
+ if ( !AddKVToConnStr ( "PROJECT", pConn -> Project, &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Project" ) );
return FALSE;
}
-
- if ( !AddKVToConnStr ( "PORT", p, &iPos, pStrConn, pMaxLen ) ) {
+
+ if ( !AddKVToConnStr ( "PORT", p, &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Port" ) );
return FALSE;
}
-
- if ( !AddKVToConnStr ( "UID", pConn->UserName, &iPos, pStrConn, pMaxLen ) ) {
+
+ if ( !AddKVToConnStr ( "UID", pConn -> UserName, &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Uid" ) );
return FALSE;
}
-
- if ( !AddKVToConnStr ( "PWD", pConn->Password, &iPos, pStrConn, pMaxLen ) ) {
+
+ if ( !AddKVToConnStr ( "PWD", pConn -> Password, &iPos, pStrConn, pMaxLen ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "AddKVToConnStr failed in %s", "Pwd" ) );
return FALSE;
}
-
+
return TRUE;
}
// -----------------------------------------------------------------------
// to connect to the driver
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLDriverConnectW ( SQLHDBC hdbc,
- SQLHWND hwnd,
- SQLWCHAR* szConnStrIn,
- SQLSMALLINT cchConnStrIn,
- SQLWCHAR* szConnStrOut,
- SQLSMALLINT cchConnStrOutMax,
- SQLSMALLINT* pcchConnStrOut,
- SQLUSMALLINT fDriverCompletion ) {
+RETCODE SQL_API SQLDriverConnectW ( SQLHDBC hdbc,
+ SQLHWND hwnd,
+ SQLWCHAR* szConnStrIn,
+ SQLSMALLINT cchConnStrIn,
+ SQLWCHAR* szConnStrOut,
+ SQLSMALLINT cchConnStrOutMax,
+ SQLSMALLINT* pcchConnStrOut,
+ SQLUSMALLINT fDriverCompletion )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLDriverConnectW called, cchConnStrIn %d, cchConnStrOutMax %d, wcslen %d",
- cchConnStrIn, cchConnStrOutMax, wcslen ( szConnStrIn ) ) );
+ cchConnStrIn, cchConnStrOutMax, wcslen ( szConnStrIn ) ) );
int inStrLength = wcslen ( szConnStrIn ) + 1;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The inStr Length is : %d", inStrLength ) );
- unique_ptr<char[]> pInStr ( new char[inStrLength] );
- unique_ptr<char[]> pOutStr ( new char[cchConnStrOutMax + 1] );
- wchar2char ( szConnStrIn, pInStr.get(), inStrLength );
+ unique_ptr <char[]> pInStr ( new char[inStrLength] );
+ unique_ptr <char[]> pOutStr ( new char[cchConnStrOutMax + 1] );
+ wchar2char ( szConnStrIn, pInStr . get (), inStrLength );
//__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"The inStr is : %s",pInStr.get()));
- SQLSMALLINT outStrLength = 0 ;
- RETCODE code = SQLDriverConnect ( hdbc, hwnd, ( SQLCHAR* ) pInStr.get(), cchConnStrIn, ( SQLCHAR* ) pOutStr.get(),
+ SQLSMALLINT outStrLength = 0;
+ RETCODE code = SQLDriverConnect ( hdbc, hwnd, ( SQLCHAR* ) pInStr . get (), cchConnStrIn, ( SQLCHAR* ) pOutStr . get (),
cchConnStrOutMax, &outStrLength, fDriverCompletion );
-
- if ( code == SQL_ERROR ) {
+
+ if ( code == SQL_ERROR )
+ {
return code;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "pcchConnStrOut null? %d, cchConnStrOutMax > 0 ? %d, szConnStrOut null? %d",
- pcchConnStrOut == NULL, cchConnStrOutMax > 0 , szConnStrOut == NULL ) );
-
- if ( cchConnStrOutMax > 0 && pcchConnStrOut && szConnStrOut ) {
- char2wchar ( pOutStr.get(), szConnStrOut, ( int ) cchConnStrOutMax );
+ pcchConnStrOut == NULL, cchConnStrOutMax > 0 , szConnStrOut == NULL ) );
+
+ if ( cchConnStrOutMax > 0 && pcchConnStrOut && szConnStrOut )
+ {
+ char2wchar ( pOutStr . get (), szConnStrOut, ( int ) cchConnStrOutMax );
*pcchConnStrOut = wcslen ( szConnStrOut );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "(W)The Length of Out Conn Str is %d", *pcchConnStrOut ) );
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "the ret code is %d", code ) );
return code;
}
-RETCODE SQL_API SQLDriverConnect ( SQLHDBC pConn,
- SQLHWND pWndHandle,
- SQLCHAR* pInConnStr,
- SQLSMALLINT pInConnStrLen,
- SQLCHAR* pOutConnStr,
- SQLSMALLINT pOutConnStrLen,
- SQLSMALLINT* pOutConnStrLenPtr,
- SQLUSMALLINT pDriverCompletion ) {
+RETCODE SQL_API SQLDriverConnect ( SQLHDBC pConn,
+ SQLHWND pWndHandle,
+ SQLCHAR* pInConnStr,
+ SQLSMALLINT pInConnStrLen,
+ SQLCHAR* pOutConnStr,
+ SQLSMALLINT pOutConnStrLen,
+ SQLSMALLINT* pOutConnStrLenPtr,
+ SQLUSMALLINT pDriverCompletion )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The window handle is %d, the driver completion flag is %d", pWndHandle,
- pDriverCompletion ) );
+ pDriverCompletion ) );
pODBCConn pgConn = ( pODBCConn ) pConn;
- bool f;
- bool flgDriver, flgDSN; // flags for knowing if these key present in string
- bool flgServer, flgPort, flgUID, flgPWD, flgProj; // flags for knowing if these key present in string
- Word i, n;
- Word iKVInputPairs; // no of key value pairs as input
- Word iDriverPos, iDSNPos; // ??? can be eliminated by optimization of code
- Word iServerPos, iPortPos, iUIDPos, iPWDPos, iProjPos; // ??? can be eliminated by optimization of code
- struct ODBCKV* KVInput; // key value as input via function param
- struct ODBCKV* KV; // generic, temp
-
- if ( !pInConnStr ) {
+ bool f;
+ bool flgDriver, flgDSN; // flags for knowing if these key present in string
+ bool flgServer, flgPort, flgUID, flgPWD, flgProj; // flags for knowing if these key present in string
+ Word i, n;
+ Word iKVInputPairs; // no of key value pairs as input
+ Word iDriverPos, iDSNPos; // ??? can be eliminated by optimization of code
+ Word iServerPos, iPortPos, iUIDPos, iPWDPos, iProjPos; // ??? can be eliminated by optimization of code
+ struct ODBCKV* KVInput; // key value as input via function param
+ struct ODBCKV* KV; // generic, temp
+
+ if ( !pInConnStr )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLDriverConnect: pInConnStr is required" ) );
return SQL_ERROR;
}
-
- else {
+
+ else
+ {
//__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"The passed-in Connection Str is %s",(char*)pInConnStr));
}
-
+
__CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
_SQLFreeDiag ( _DIAGCONN ( pConn ) );
-
+
// caller safe
- if ( pOutConnStr ) { *pOutConnStr = 0; }
-
- if ( pOutConnStrLenPtr ) { *pOutConnStrLenPtr = 0; }
-
+ if ( pOutConnStr )
+ {
+ *pOutConnStr = 0;
+ }
+
+ if ( pOutConnStrLenPtr )
+ {
+ *pOutConnStrLenPtr = 0;
+ }
+
// initializations
- KVInput = NULL;
- flgServer = FALSE;
- flgPort = FALSE;
- flgUID = FALSE;
- flgPWD = FALSE;
- flgProj = FALSE;
-
+ KVInput = NULL;
+ flgServer = FALSE;
+ flgPort = FALSE;
+ flgUID = FALSE;
+ flgPWD = FALSE;
+ flgProj = FALSE;
+
// check if an in-string has been specified
- if ( pInConnStr ) {
+ if ( pInConnStr )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Parsing the in str" ) );
-
+
// split into key-value pairs
- if ( CvtStrToKeyValues ( ( StrPtr ) pInConnStr, pInConnStrLen, &iKVInputPairs, &KVInput ) != GOOD ) {
+ if ( CvtStrToKeyValues ( ( StrPtr ) pInConnStr, pInConnStrLen, &iKVInputPairs, &KVInput ) != GOOD )
+ {
return SQL_ERROR;
}
-
+
// first check if dsn keyword is present
flgDSN = FindInKeyValues ( "DSN", NULL, KVInput, iKVInputPairs, &iDSNPos );
// look for driver only if DSN is absent else Driver is always ignored
flgDriver = ( flgDSN ) ? FALSE : FindInKeyValues ( "DRIVER", NULL, KVInput, iKVInputPairs, &iDriverPos );
-
+
// if DSN is to be used, fetch its set of key values
- if ( flgDSN ) {
+ if ( flgDSN )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The in str is a dsn string" ) );
//connect by dsn
SetCurrentDSN ( ( char* ) pInConnStr, "SQLDriverConnect" );
-
- if ( LoadODBCINIDataToConn ( pgConn ) != GOOD ) {
+
+ if ( LoadODBCINIDataToConn ( pgConn ) != GOOD )
+ {
return SQL_ERROR;
}
}
-
- else if ( flgDriver ) {
+
+ else if ( flgDriver )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The in str is a driver string" ) );
/************* debug
for ( i = 0, n = iKVInputPairs, KV = KVInput; i < n; i++ )
fprintf ( stderr, "Index: %d, Key: %s, Value: %s\n", i, KV[i].key ? KV[i].key : "(nokey)", KV[i].value ? KV[i].value : "(no value)" );
*********/
-
+
// loop to parse both input key-values and DSN key-values & feed into struct
- for ( i = 0, n = iKVInputPairs, KV = KVInput; i < n; i++ ) {
- if ( !flgServer ) {
+ for ( i = 0 , n = iKVInputPairs , KV = KVInput; i < n; i++ )
+ {
+ if ( !flgServer )
+ {
flgServer = FindInKeyValues ( "SERVER", NULL, KV, n, &iServerPos );
-
- if ( flgServer ) { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_SERVER, KV[iServerPos].value ); }
+
+ if ( flgServer )
+ {
+ CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_SERVER, KV[iServerPos] . value );
+ }
}
-
- if ( !flgPort ) {
+
+ if ( !flgPort )
+ {
flgPort = FindInKeyValues ( "PORT", NULL, KV, n, &iPortPos );
-
- if ( flgPort ) { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PORT, KV[iPortPos].value ); }
+
+ if ( flgPort )
+ {
+ CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PORT, KV[iPortPos] . value );
+ }
}
-
- if ( !flgUID ) {
+
+ if ( !flgUID )
+ {
flgUID = FindInKeyValues ( "UID", NULL, KV, n, &iUIDPos );
-
- if ( flgUID ) {
- CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_UID, KV[iUIDPos].value );
+
+ if ( flgUID )
+ {
+ CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_UID, KV[iUIDPos] . value );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Log in as User : %s ", KV[iUIDPos].value ) );
}
}
-
- if ( !flgPWD ) {
+
+ if ( !flgPWD )
+ {
flgPWD = FindInKeyValues ( "PWD", NULL, KV, n, &iPWDPos );
-
- if ( flgPWD ) { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PWD, KV[iPWDPos].value ); }
+
+ if ( flgPWD )
+ {
+ CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PWD, KV[iPWDPos] . value );
+ }
}
-
- if ( !flgProj ) {
+
+ if ( !flgProj )
+ {
flgProj = FindInKeyValues ( "PROJECT", NULL, KV, n, &iProjPos );
-
- if ( flgProj ) { CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PROJECT, KV[iProjPos].value ); }
+
+ if ( flgProj )
+ {
+ CreateAndSetConnProp ( ( pODBCConn ) pConn, CONN_PROP_PROJECT, KV[iProjPos] . value );
+ }
}
}
}
-
- else {
+
+ else
+ {
_SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045, "Only DSN or driver connect is allowed" );
__ODBCPOPMSG ( _ODBCPopMsg ( "Only DSN or driver connect is allowed, instead of %s", pInConnStr ) );
return SQL_ERROR;
}
-
+
FreeGenODBCKeyValues ( KVInput, iKVInputPairs );
delete[] KVInput;
}
-
- else if ( pDriverCompletion == SQL_DRIVER_NOPROMPT ) { // check if no-prompt forced
+
+ else if ( pDriverCompletion == SQL_DRIVER_NOPROMPT )
+ { // check if no-prompt forced
__ODBCPOPMSG ( _ODBCPopMsg ( "No connection string && no prompt specified" ) );
_SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045,
- "Access denied. (using UID: NO , using password: NO)" );
+ "Access denied. (using UID: NO , using password: NO)" );
return SQL_ERROR;
}
-
+
RETCODE ret;
-
+
// check if prompt required ie any info is missing
- if ( flgDriver && ( !flgServer || !flgPort || !flgUID || !flgPWD || !flgProj ) ) {
+ if ( flgDriver && ( !flgServer || !flgPort || !flgUID || !flgPWD || !flgProj ) )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "Connection info imcomplete, prompt for input..." ) );
-
- if ( flgUID && !flgPWD && pDriverCompletion == SQL_DRIVER_NOPROMPT ) {
+
+ if ( flgUID && !flgPWD && pDriverCompletion == SQL_DRIVER_NOPROMPT )
+ {
_SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045,
- "Access denied for user 'root'@'kylin-tableau-clean.com' (using password: NO)" );
+ "Access denied for user 'root'@'kylin-tableau-clean.com' (using password: NO)" );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR,
- "UID present but PWD absent, guessing it's on Tableau Server, return SQL ERROR" ) );
+ "UID present but PWD absent, guessing it's on Tableau Server, return SQL ERROR" ) );
return SQL_ERROR;
}
-
+
//connect by driver
// fetch entire connection information thru dialogs
- switch ( PromptForConnInfo ( pConn ) ) {
- case 0: // user-cancelled
+ switch ( PromptForConnInfo ( pConn ) )
+ {
+ case 0 : // user-cancelled
return SQL_NO_DATA_FOUND;
-
- default:
+
+ default :
break;
}
-
+
ret = SQL_SUCCESS;
}
-
- else {
+
+ else
+ {
ret = TryFetchMetadata ( pgConn ) ;
-
- if ( ret == SQL_ERROR ) {
+
+ if ( ret == SQL_ERROR )
+ {
return ret;
}
}
-
+
// OUT CONN STRING
// build the out-connection string if required
- if ( pOutConnStr && pOutConnStrLen > 0 && pOutConnStrLenPtr ) {
- if ( flgDriver ) {
+ if ( pOutConnStr && pOutConnStrLen > 0 && pOutConnStrLenPtr )
+ {
+ if ( flgDriver )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Building out str..." ) );
// build the out conn string using key value pairs
f = BuildConnStr ( ( StrPtr ) pOutConnStr, pOutConnStrLen, ( pODBCConn ) pConn, NULL, 0, NULL, 0 );
-
- if ( !f ) {
+
+ if ( !f )
+ {
_SQLPutDiagRow ( SQL_HANDLE_DBC, pConn, "SQLDriverConnectW", "HY000", 1045, "Out connection string not complete" );
}
}
-
- else {
+
+ else
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Copy in str to out str" ) );
strcpy ( ( char* ) pOutConnStr, ( char* ) pInConnStr );
}
-
+
*pOutConnStrLenPtr = strlen ( ( StrPtr ) pOutConnStr );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The Length of Out Conn Str is %d", *pOutConnStrLenPtr ) );
}
-
- else {
+
+ else
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "skip writing to the out put string" ) );
}
-
+
return ret;
}
-RETCODE TryFetchMetadata ( pODBCConn pgConn ) {
+RETCODE TryFetchMetadata ( pODBCConn pgConn )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "start loading metadata..." ) );
-
- try {
- pgConn->meta = std::move ( restGetMeta ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password,
- pgConn->Project ) );
+
+ try
+ {
+ pgConn -> meta = std::move ( restGetMeta ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password,
+ pgConn -> Project ) );
}
-
- catch ( const exception& e ) {
+
+ catch ( const exception& e )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to get metadata" ) );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
_SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
return SQL_ERROR;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End loading metadata" ) );
return SQL_SUCCESS;
}
-RETCODE TryAuthenticate ( pODBCConn pgConn ) {
+RETCODE TryAuthenticate ( pODBCConn pgConn )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start authenticating.." ) );
-
- try {
- bool authenticated = restAuthenticate ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password );
-
+
+ try
+ {
+ bool authenticated = restAuthenticate ( pgConn -> Server, pgConn -> ServerPort, pgConn -> UserName, pgConn -> Password );
+
if ( !authenticated )
- { throw exception ( "Username/Password incorrect." ); }
+ {
+ throw exception ( "Username/Password incorrect." );
+ }
}
-
- catch ( const exception& e ) {
+
+ catch ( const exception& e )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to authenticate." ) );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
_SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
return SQL_ERROR;
}
-
+
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End authenticating" ) );
return SQL_SUCCESS;
}
@@ -1019,13 +1214,14 @@ RETCODE TryAuthenticate ( pODBCConn pgConn ) {
// to connect to the server using standard parameters
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLConnect ( SQLHDBC pConn,
- SQLCHAR* pServerName,
+RETCODE SQL_API SQLConnect ( SQLHDBC pConn,
+ SQLCHAR* pServerName,
SQLSMALLINT pServerNameLen,
- SQLCHAR* pUserName,
+ SQLCHAR* pUserName,
SQLSMALLINT pUserNameLen,
- SQLCHAR* pPassword,
- SQLSMALLINT pPasswordLen ) {
+ SQLCHAR* pPassword,
+ SQLSMALLINT pPasswordLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLConnect called" ) );
__CHK_HANDLE ( pConn, SQL_HANDLE_DBC, SQL_ERROR );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLConnect - not implemented, use SQLDriverConnect" ) );
@@ -1034,14 +1230,15 @@ RETCODE SQL_API SQLConnect ( SQLHDBC pConn,
return ( SQL_SUCCESS );
}
-SQLRETURN SQL_API SQLConnectW ( SQLHDBC hdbc,
+SQLRETURN SQL_API SQLConnectW ( SQLHDBC hdbc,
SQLWCHAR* szDSN,
- SQLSMALLINT cchDSN,
+ SQLSMALLINT cchDSN,
SQLWCHAR* szUID,
- SQLSMALLINT cchUID,
+ SQLSMALLINT cchUID,
SQLWCHAR* szAuthStr,
- SQLSMALLINT cchAuthStr
- ) {
+ SQLSMALLINT cchAuthStr
+)
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLConnectW called" ) );
__CHK_HANDLE ( hdbc, SQL_HANDLE_DBC, SQL_ERROR );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLConnectW - not implemented, use SQLDriverConnectW" ) );
@@ -1051,18 +1248,19 @@ SQLRETURN SQL_API SQLConnectW ( SQLHDBC hdbc,
}
-
// -----------------------------------------------------------------------
// to connect in multiple iterations
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLBrowseConnect ( SQLHDBC pConn,
- SQLCHAR* InConnectionString,
- SQLSMALLINT StringLength1,
- SQLCHAR* OutConnectionString,
- SQLSMALLINT BufferLength,
- SQLSMALLINT* StringLength2Ptr ) {
+RETCODE SQL_API SQLBrowseConnect ( SQLHDBC pConn,
+ SQLCHAR* InConnectionString,
+ SQLSMALLINT StringLength1,
+ SQLCHAR* OutConnectionString,
+ SQLSMALLINT BufferLength,
+ SQLSMALLINT* StringLength2Ptr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLBrowseConnect called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLBrowseConnect - not implemented, use SQLDriverConnect" ) );
return SQL_ERROR;
-}
\ No newline at end of file
+}
+
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_CTLG.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_CTLG.CPP b/odbc/Driver/KO_CTLG.CPP
index dc23551..7206ec1 100644
--- a/odbc/Driver/KO_CTLG.CPP
+++ b/odbc/Driver/KO_CTLG.CPP
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
// ----------------------------------------------------------------------------
//
// File: KO_CTLG.CPP
@@ -46,49 +46,51 @@
#include "stdafx.h"
-
// -----------------------------------------------------------------------
// to get list of catalog(database), schema(users), tables(tables)
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLTablesW ( SQLHSTMT pStmt,
- SQLWCHAR* pCatalogName,
- SQLSMALLINT pCatalogNameSize,
- SQLWCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameSize,
- SQLWCHAR* pTableName,
- SQLSMALLINT pTableNameSize,
- SQLWCHAR* pTableType,
- SQLSMALLINT pTableTypeSize ) {
+RETCODE SQL_API SQLTablesW ( SQLHSTMT pStmt,
+ SQLWCHAR* pCatalogName,
+ SQLSMALLINT pCatalogNameSize,
+ SQLWCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameSize,
+ SQLWCHAR* pTableName,
+ SQLSMALLINT pTableNameSize,
+ SQLWCHAR* pTableType,
+ SQLSMALLINT pTableTypeSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTablesW is called " ) );
- unique_ptr<char[]> p1 ( wchar2char ( pCatalogName ) );
- unique_ptr<char[]> p2 ( wchar2char ( pSchemaName ) );
- unique_ptr<char[]> p3 ( wchar2char ( pTableName ) );
- unique_ptr<char[]> p4 ( wchar2char ( pTableType ) );
- return SQLTables ( pStmt, ( SQLCHAR* ) p1.get(), pCatalogNameSize, ( SQLCHAR* ) p2.get(), pSchemaNameSize,
- ( SQLCHAR* ) p3.get(), pTableNameSize, ( SQLCHAR* ) p4.get(), pTableTypeSize );
+ unique_ptr <char[]> p1 ( wchar2char ( pCatalogName ) );
+ unique_ptr <char[]> p2 ( wchar2char ( pSchemaName ) );
+ unique_ptr <char[]> p3 ( wchar2char ( pTableName ) );
+ unique_ptr <char[]> p4 ( wchar2char ( pTableType ) );
+ return SQLTables ( pStmt, ( SQLCHAR* ) p1 . get (), pCatalogNameSize, ( SQLCHAR* ) p2 . get (), pSchemaNameSize,
+ ( SQLCHAR* ) p3 . get (), pTableNameSize, ( SQLCHAR* ) p4 . get (), pTableTypeSize );
}
-RETCODE SQL_API SQLTables ( SQLHSTMT pStmt,
- SQLCHAR* pCatalogName,
- SQLSMALLINT pCatalogNameSize,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameSize,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameSize,
- SQLCHAR* pTableType,
- SQLSMALLINT pTableTypeSize ) {
+RETCODE SQL_API SQLTables ( SQLHSTMT pStmt,
+ SQLCHAR* pCatalogName,
+ SQLSMALLINT pCatalogNameSize,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameSize,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameSize,
+ SQLCHAR* pTableType,
+ SQLSMALLINT pTableTypeSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTables: Ctlg: %s, %d, Schema: %s, %d, Table: %s,%d, Type: %s, %d",
- pCatalogName, pCatalogNameSize, pSchemaName, pSchemaNameSize, pTableName, pTableNameSize, pTableType,
- pTableTypeSize ) );
+ pCatalogName, pCatalogNameSize, pSchemaName, pSchemaNameSize, pTableName, pTableNameSize, pTableType,
+ pTableTypeSize ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
- std::unique_ptr<SQLResponse> p = SQLResponse::MakeResp4SQLTables ( ( ( pODBCStmt ) pStmt )->Conn->meta.get() );
-
- if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+ std::unique_ptr <SQLResponse> p = SQLResponse::MakeResp4SQLTables ( ( ( pODBCStmt ) pStmt ) -> Conn -> meta . get () );
+
+ if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+ {
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
@@ -96,49 +98,52 @@ RETCODE SQL_API SQLTables ( SQLHSTMT pStmt,
// to get the list of column names in specified tables
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLColumnsW ( SQLHSTMT pStmt,
- SQLWCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLWCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLWCHAR* pTableName,
- SQLSMALLINT pTableNameLen,
- SQLWCHAR* pColumnName,
- SQLSMALLINT pColumnNameLen ) {
+RETCODE SQL_API SQLColumnsW ( SQLHSTMT pStmt,
+ SQLWCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLWCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLWCHAR* pTableName,
+ SQLSMALLINT pTableNameLen,
+ SQLWCHAR* pColumnName,
+ SQLSMALLINT pColumnNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumnsW is called" ) );
- unique_ptr<char[]> p1 ( wchar2char ( pCtlgName ) );
- unique_ptr<char[]> p2 ( wchar2char ( pSchemaName ) );
- unique_ptr<char[]> p3 ( wchar2char ( pTableName ) );
- unique_ptr<char[]> p4 ( wchar2char ( pColumnName ) );
- return SQLColumns ( pStmt, ( SQLCHAR* ) p1.get(), pCtlgNameLen, ( SQLCHAR* ) p2.get(), pSchemaNameLen,
- ( SQLCHAR* ) p3.get(), pTableNameLen, ( SQLCHAR* ) p4.get(), pColumnNameLen );
+ unique_ptr <char[]> p1 ( wchar2char ( pCtlgName ) );
+ unique_ptr <char[]> p2 ( wchar2char ( pSchemaName ) );
+ unique_ptr <char[]> p3 ( wchar2char ( pTableName ) );
+ unique_ptr <char[]> p4 ( wchar2char ( pColumnName ) );
+ return SQLColumns ( pStmt, ( SQLCHAR* ) p1 . get (), pCtlgNameLen, ( SQLCHAR* ) p2 . get (), pSchemaNameLen,
+ ( SQLCHAR* ) p3 . get (), pTableNameLen, ( SQLCHAR* ) p4 . get (), pColumnNameLen );
}
-RETCODE SQL_API SQLColumns ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen,
- SQLCHAR* pColumnName,
- SQLSMALLINT pColumnNameLen ) {
+RETCODE SQL_API SQLColumns ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen,
+ SQLCHAR* pColumnName,
+ SQLSMALLINT pColumnNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumns called, Ctlg: %s, %d. Schema: %s, %d, Table: %s, %d, Col: %s, %d",
- pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen, pColumnName, pColumnNameLen ) );
+ pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen, pColumnName, pColumnNameLen ) );
__CHK_HANDLE ( pStmt, SQL_HANDLE_STMT, SQL_ERROR );
_SQLFreeDiag ( _DIAGSTMT ( pStmt ) );
- // Some application will bring '\\' into table name
- remove_char(( char* )pTableName, '\\');
+ // Some application will bring '\\' into table name
+ remove_char ( ( char* )pTableName, '\\' );
// feed stmt structure with response
- std::unique_ptr<SQLResponse> p = SQLResponse::MakeResp4SQLColumns ( ( ( pODBCStmt ) pStmt )->Conn->meta.get(),
- ( char* ) pTableName, ( char* ) pColumnName );
-
- if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+ std::unique_ptr <SQLResponse> p = SQLResponse::MakeResp4SQLColumns ( ( ( pODBCStmt ) pStmt ) -> Conn -> meta . get (),
+ ( char* ) pTableName, ( char* ) pColumnName );
+
+ if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+ {
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
@@ -146,16 +151,16 @@ RETCODE SQL_API SQLColumns ( SQLHSTMT pStmt,
// to get the list of column names which make a row unqiue or r updateable
// ------------------------------------------------------------------------
-SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT pStmt,
- SQLUSMALLINT pIdentifierType,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen,
- SQLUSMALLINT pScope,
- SQLUSMALLINT pNullable )
+SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT pStmt,
+ SQLUSMALLINT pIdentifierType,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen,
+ SQLUSMALLINT pScope,
+ SQLUSMALLINT pNullable )
{
// note
@@ -168,7 +173,7 @@ SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT pStmt,
// SQL_SCOPE_TRANSACTION
// SQL_SCOPE_SESSION
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSpecialColumns called, Ctlg: %s, %d. Schema: %s, %d, Table: %s, %d",
- pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen ) );
+ pCtlgName, pCtlgNameLen, pSchemaName, pSchemaNameLen, pTableName, pTableNameLen ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSpecialColumns not implemented" ) );
return SQL_ERROR;
}
@@ -177,15 +182,16 @@ SQLRETURN SQL_API SQLSpecialColumns ( SQLHSTMT pStmt,
// to get table and/or index statistics
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLStatistics ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen,
- SQLUSMALLINT pUnique,
- SQLUSMALLINT pReserved ) {
+RETCODE SQL_API SQLStatistics ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen,
+ SQLUSMALLINT pUnique,
+ SQLUSMALLINT pReserved )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLStatistics called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLStatistics not implemented" ) );
return SQL_ERROR;
@@ -194,95 +200,101 @@ RETCODE SQL_API SQLStatistics ( SQLHSTMT pStmt,
// -----------------------------------------------------------------------
// to get columns which make up the p-keys
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLPrimaryKeysW ( SQLHSTMT pStmt,
- SQLWCHAR* pCtlgName,
+RETCODE SQL_API SQLPrimaryKeysW ( SQLHSTMT pStmt,
+ SQLWCHAR* pCtlgName,
SQLSMALLINT pCtlgNameLen,
- SQLWCHAR* pSchemaName,
+ SQLWCHAR* pSchemaName,
SQLSMALLINT pSchemaNameLen,
- SQLWCHAR* pTableName,
- SQLSMALLINT pTableNameLen ) {
+ SQLWCHAR* pTableName,
+ SQLSMALLINT pTableNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrimaryKeysW called" ) );
return SQLPrimaryKeys ( pStmt, NULL, NULL, NULL, NULL, NULL, NULL );
}
-RETCODE SQL_API SQLPrimaryKeys ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
+RETCODE SQL_API SQLPrimaryKeys ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
+ SQLCHAR* pSchemaName,
SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen ) {
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLPrimaryKeys called" ) );
- std::unique_ptr<SQLResponse> p ( new SQLResponse() );
-
- if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+ std::unique_ptr <SQLResponse> p ( new SQLResponse () );
+
+ if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+ {
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
// -----------------------------------------------------------------------
// to get foreign key information
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLForeignKeysW ( SQLHSTMT pStmt,
- SQLWCHAR* pPKCtlgName,
- SQLSMALLINT pPKCtlgNameLen,
- SQLWCHAR* pPKSchemaName,
- SQLSMALLINT pPKSchemaNameLen,
- SQLWCHAR* pPKTableName,
- SQLSMALLINT pPKTableNameLen,
- SQLWCHAR* pFKCtlgName,
- SQLSMALLINT pFKCtlgNameLen,
- SQLWCHAR* pFKSchemaName,
- SQLSMALLINT pFKSchemaNameLen,
- SQLWCHAR* pFKTableName,
- SQLSMALLINT pFKTableNameLen ) {
+RETCODE SQL_API SQLForeignKeysW ( SQLHSTMT pStmt,
+ SQLWCHAR* pPKCtlgName,
+ SQLSMALLINT pPKCtlgNameLen,
+ SQLWCHAR* pPKSchemaName,
+ SQLSMALLINT pPKSchemaNameLen,
+ SQLWCHAR* pPKTableName,
+ SQLSMALLINT pPKTableNameLen,
+ SQLWCHAR* pFKCtlgName,
+ SQLSMALLINT pFKCtlgNameLen,
+ SQLWCHAR* pFKSchemaName,
+ SQLSMALLINT pFKSchemaNameLen,
+ SQLWCHAR* pFKTableName,
+ SQLSMALLINT pFKTableNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLForeignKeysW called" ) );
- unique_ptr<char[]> p1 ( wchar2char ( pPKCtlgName ) );
- unique_ptr<char[]> p2 ( wchar2char ( pPKSchemaName ) );
- unique_ptr<char[]> p3 ( wchar2char ( pPKTableName ) );
- unique_ptr<char[]> p4 ( wchar2char ( pFKCtlgName ) );
- unique_ptr<char[]> p5 ( wchar2char ( pFKSchemaName ) );
- unique_ptr<char[]> p6 ( wchar2char ( pFKTableName ) );
+ unique_ptr <char[]> p1 ( wchar2char ( pPKCtlgName ) );
+ unique_ptr <char[]> p2 ( wchar2char ( pPKSchemaName ) );
+ unique_ptr <char[]> p3 ( wchar2char ( pPKTableName ) );
+ unique_ptr <char[]> p4 ( wchar2char ( pFKCtlgName ) );
+ unique_ptr <char[]> p5 ( wchar2char ( pFKSchemaName ) );
+ unique_ptr <char[]> p6 ( wchar2char ( pFKTableName ) );
return SQLForeignKeys ( pStmt,
- ( SQLCHAR* ) p1.get(),
+ ( SQLCHAR* ) p1 . get (),
pPKCtlgNameLen,
- ( SQLCHAR* ) p2.get(),
+ ( SQLCHAR* ) p2 . get (),
pPKSchemaNameLen,
- ( SQLCHAR* ) p3.get(),
+ ( SQLCHAR* ) p3 . get (),
pPKTableNameLen,
- ( SQLCHAR* ) p4.get(),
+ ( SQLCHAR* ) p4 . get (),
pFKCtlgNameLen,
- ( SQLCHAR* ) p5.get(),
+ ( SQLCHAR* ) p5 . get (),
pFKSchemaNameLen,
- ( SQLCHAR* ) p6.get(),
+ ( SQLCHAR* ) p6 . get (),
pFKTableNameLen );
}
-RETCODE SQL_API SQLForeignKeys ( SQLHSTMT pStmt,
- SQLCHAR* pPKCtlgName,
- SQLSMALLINT pPKCtlgNameLen,
- SQLCHAR* pPKSchemaName,
- SQLSMALLINT pPKSchemaNameLen,
- SQLCHAR* pPKTableName,
- SQLSMALLINT pPKTableNameLen,
- SQLCHAR* pFKCtlgName,
- SQLSMALLINT pFKCtlgNameLen,
- SQLCHAR* pFKSchemaName,
- SQLSMALLINT pFKSchemaNameLen,
- SQLCHAR* pFKTableName,
- SQLSMALLINT pFKTableNameLen ) {
+RETCODE SQL_API SQLForeignKeys ( SQLHSTMT pStmt,
+ SQLCHAR* pPKCtlgName,
+ SQLSMALLINT pPKCtlgNameLen,
+ SQLCHAR* pPKSchemaName,
+ SQLSMALLINT pPKSchemaNameLen,
+ SQLCHAR* pPKTableName,
+ SQLSMALLINT pPKTableNameLen,
+ SQLCHAR* pFKCtlgName,
+ SQLSMALLINT pFKCtlgNameLen,
+ SQLCHAR* pFKSchemaName,
+ SQLSMALLINT pFKSchemaNameLen,
+ SQLCHAR* pFKTableName,
+ SQLSMALLINT pFKTableNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLForeignKeys called pPKCtlgName: %s, pPKSchemaName : %s, pPKTableName: %s, pFKCtlgName: %s, pFKSchemaName: %s, pFKTableName: %s",
- pPKCtlgName, pPKSchemaName, pPKTableName, pFKCtlgName, pFKSchemaName, pFKTableName ) );
- std::unique_ptr<SQLResponse> p ( new SQLResponse() );
-
- if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD ) {
+ "SQLForeignKeys called pPKCtlgName: %s, pPKSchemaName : %s, pPKTableName: %s, pFKCtlgName: %s, pFKSchemaName: %s, pFKTableName: %s",
+ pPKCtlgName, pPKSchemaName, pPKTableName, pFKCtlgName, pFKSchemaName, pFKTableName ) );
+ std::unique_ptr <SQLResponse> p ( new SQLResponse () );
+
+ if ( PutRespToStmt ( ( pODBCStmt ) pStmt, std::move ( p ) ) != GOOD )
+ {
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
@@ -291,13 +303,13 @@ RETCODE SQL_API SQLForeignKeys ( SQLHSTMT pStmt,
// to get a list of tables and the privileges associated with each table
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen )
+RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen )
{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLTablePrivileges called" ) );
@@ -309,15 +321,16 @@ RETCODE SQL_API SQLTablePrivileges ( SQLHSTMT pStmt,
// to get a list of columns and associated privileges for the specified table
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pTableName,
- SQLSMALLINT pTableNameLen,
- SQLCHAR* pColumnName,
- SQLSMALLINT pColumnNameLen ) {
+RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pTableName,
+ SQLSMALLINT pTableNameLen,
+ SQLCHAR* pColumnName,
+ SQLSMALLINT pColumnNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLColumnPrivileges called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLColumnPrivileges not implemented" ) );
return SQL_ERROR;
@@ -329,13 +342,14 @@ RETCODE SQL_API SQLColumnPrivileges ( SQLHSTMT pStmt,
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLProcedures ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pProcName,
- SQLSMALLINT pProcNameLen ) {
+RETCODE SQL_API SQLProcedures ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pProcName,
+ SQLSMALLINT pProcNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLProcedures called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLProcedures not implemented" ) );
return SQL_ERROR;
@@ -346,18 +360,18 @@ RETCODE SQL_API SQLProcedures ( SQLHSTMT pStmt,
// to get a list of procedure names stored in a specific data source
// ------------------------------------------------------------------------
-RETCODE SQL_API SQLProcedureColumns ( SQLHSTMT pStmt,
- SQLCHAR* pCtlgName,
- SQLSMALLINT pCtlgNameLen,
- SQLCHAR* pSchemaName,
- SQLSMALLINT pSchemaNameLen,
- SQLCHAR* pProcName,
- SQLSMALLINT pProcNameLen,
- SQLCHAR* pColumnName,
- SQLSMALLINT pColumnNameLen ) {
+RETCODE SQL_API SQLProcedureColumns ( SQLHSTMT pStmt,
+ SQLCHAR* pCtlgName,
+ SQLSMALLINT pCtlgNameLen,
+ SQLCHAR* pSchemaName,
+ SQLSMALLINT pSchemaNameLen,
+ SQLCHAR* pProcName,
+ SQLSMALLINT pProcNameLen,
+ SQLCHAR* pColumnName,
+ SQLSMALLINT pColumnNameLen )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLProceduresColumns called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLProceduresColumns not implemented" ) );
return SQL_ERROR;
}
-
[07/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_Config.cpp
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_Config.cpp b/odbc/Driver/KO_Config.cpp
index d4ebae3..0f95714 100644
--- a/odbc/Driver/KO_Config.cpp
+++ b/odbc/Driver/KO_Config.cpp
@@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
+
#include "stdafx.h"
#include "StringUtils.h"
@@ -47,157 +47,192 @@
static char currentDSN[BUFFERSIZE];
-static const char *supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
-static const char *defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
+static const char* supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
+static const char* defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
static int GetValueFromODBCINI ( char* section, char* key, char* defaultValue, char* buffer, int bufferSize,
- char* initFileName ) {
+ char* initFileName )
+{
return SQLGetPrivateProfileString ( section, key, defaultValue, buffer, bufferSize, initFileName );
}
-static BOOL SetValueInODBCINI ( char* section, char* key, char* newValue, char* initFileName ) {
+static BOOL SetValueInODBCINI ( char* section, char* key, char* newValue, char* initFileName )
+{
return SQLWritePrivateProfileString ( section, key, newValue, initFileName );
}
-static BOOL AddDSN ( char* dsnName ) {
+static BOOL AddDSN ( char* dsnName )
+{
return SQLWritePrivateProfileString ( "ODBC Data Sources", dsnName, "KylinODBCDriver", INITFILE );
}
-static BOOL RemoveDSN ( char* dsnName ) {
+static BOOL RemoveDSN ( char* dsnName )
+{
BOOL temp = true;
temp = SQLWritePrivateProfileString ( dsnName, NULL, NULL, INITFILE );
return SQLWritePrivateProfileString ( "ODBC Data Sources", dsnName, NULL, INITFILE ) && temp;
}
-void SetCurrentDSN ( char* connStr, char* logFunc ) {
+void SetCurrentDSN ( char* connStr, char* logFunc )
+{
currentDSN[0] = '\0';
Word pairCount = 0;
- Word index = 0 ;
+ Word index = 0;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "%s : lparam: %s", logFunc, connStr ) );
ODBCKV* pKV = NULL;
-
- if ( connStr == NULL || CvtStrToKeyValues ( connStr, -1, &pairCount, &pKV ) != GOOD ) {
+
+ if ( connStr == NULL || CvtStrToKeyValues ( connStr, -1, &pairCount, &pKV ) != GOOD )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "%s: failed to parse the attribute string %s", logFunc, connStr ) );
}
-
- else {
- if ( FindInKeyValues ( "DSN", NULL, pKV, pairCount, &index ) != true ) {
+
+ else
+ {
+ if ( FindInKeyValues ( "DSN", NULL, pKV, pairCount, &index ) != true )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "%s: failed to find the DSN attribute in %s", logFunc, connStr ) );
}
-
- else {
- strcpy ( currentDSN, pKV[index].value );
+
+ else
+ {
+ strcpy ( currentDSN, pKV[index] . value );
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "%s: success to set the currentDSN: %s", logFunc, currentDSN ) );
}
-
+
FreeGenODBCKeyValues ( pKV, pairCount );
delete[] pKV;
}
}
-static eGoodBad LoadODBCINIDataToDlgDSNCfg2 ( HWND hDlg ) {
- BOOL x;
+static eGoodBad LoadODBCINIDataToDlgDSNCfg2 ( HWND hDlg )
+{
+ BOOL x;
char buffer[BUFFERSIZE];
-
+
// precaution
- if ( !hDlg ) {
+ if ( !hDlg )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "LoadODBCINIDataToDlgDSNCfg2 - Bad params: hDlg is NULL" ) );
return BAD;
}
-
+
// DSN name
x = SetDlgItemText ( hDlg, IDC_DSNNAME, currentDSN );
-
- if ( !x ) { return BAD; }
-
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// server name/IP and protocol
GetValueFromODBCINI ( currentDSN, SERVERKEY, "", buffer, BUFFERSIZE, INITFILE );
- int protocol = 0;
- int hostOffset = 0;
- if (buffer[0] == 'h' && buffer[1] == 't' && buffer[2] == 't' && buffer[3] == 'p')
- {
- if (buffer[4] == ':' && buffer[5] == '/' && buffer[6] == '/')
- {
- protocol = 1;
- hostOffset = 7;
- }
- else if (buffer[4] == 's' && buffer[5] == ':' && buffer[6] == '/' && buffer[7] == '/')
- {
- hostOffset = 8;
- }
- }
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- SendMessage ( hwndCombo, CB_SETCURSEL, protocol, 0 );
-
- strcpy(buffer, buffer + hostOffset);
+ int protocol = 0;
+ int hostOffset = 0;
+ if ( buffer[0] == 'h' && buffer[1] == 't' && buffer[2] == 't' && buffer[3] == 'p' )
+ {
+ if ( buffer[4] == ':' && buffer[5] == '/' && buffer[6] == '/' )
+ {
+ protocol = 1;
+ hostOffset = 7;
+ }
+ else if ( buffer[4] == 's' && buffer[5] == ':' && buffer[6] == '/' && buffer[7] == '/' )
+ {
+ hostOffset = 8;
+ }
+ }
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ SendMessage ( hwndCombo, CB_SETCURSEL, protocol, 0 );
+
+ strcpy ( buffer, buffer + hostOffset );
x = SetDlgItemText ( hDlg, IDC_SERVER, buffer );
- if ( !x ) { return BAD; }
-
+ if ( !x )
+ {
+ return BAD;
+ }
+
// server port
- char* defaultPort = PORT_HTTPS_DEFAULT;
- if (protocol == 1)
- {
- defaultPort = PORT_HTTP_DEFAULT;
- }
+ char* defaultPort = PORT_HTTPS_DEFAULT;
+ if ( protocol == 1 )
+ {
+ defaultPort = PORT_HTTP_DEFAULT;
+ }
GetValueFromODBCINI ( currentDSN, PORTKEY, defaultPort, buffer, BUFFERSIZE, INITFILE );
int portTemp = atoi ( buffer );
- if ( portTemp == 0 ) { portTemp = atoi(defaultPort); }
-
+ if ( portTemp == 0 )
+ {
+ portTemp = atoi ( defaultPort );
+ }
+
x = SetDlgItemInt ( hDlg, IDC_PORT, portTemp, FALSE );
-
- if ( !x ) { return BAD; }
-
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// user name
GetValueFromODBCINI ( currentDSN, UIDKEY, "", buffer, BUFFERSIZE, INITFILE );
x = SetDlgItemText ( hDlg, IDC_UID, buffer );
-
- if ( !x ) { return BAD; }
-
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
// password
GetValueFromODBCINI ( currentDSN, PWDKEY, "", buffer, BUFFERSIZE, INITFILE );
x = SetDlgItemText ( hDlg, IDC_PWD, buffer );
-
- if ( !x ) { return BAD; }
-
+
+ if ( !x )
+ {
+ return BAD;
+ }
+
return GOOD;
}
-static eGoodBad RetriveDlgData ( HWND hDlg, char* newDSN, char* serverStr, char* uidStr, char* pwdStr, long* port ) {
+static eGoodBad RetriveDlgData ( HWND hDlg, char* newDSN, char* serverStr, char* uidStr, char* pwdStr, long* port )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start retrieving the configs..." ) );
Long x;
-
- if ( !hDlg ) {
+
+ if ( !hDlg )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "RetriveDlgData - Bad params: hDlg is NULL" ) );
return BAD;
}
-
- x = SendDlgItemMessage ( hDlg, IDC_DSNNAME, EM_LINELENGTH, 0, 0 ); // get text from dialog
-
- if ( x > 0 ) {
- GetDlgItemText ( hDlg, IDC_DSNNAME, newDSN, BUFFERSIZE ); // get text from dialog
+
+ x = SendDlgItemMessage ( hDlg, IDC_DSNNAME, EM_LINELENGTH, 0, 0 ); // get text from dialog
+
+ if ( x > 0 )
+ {
+ GetDlgItemText ( hDlg, IDC_DSNNAME, newDSN, BUFFERSIZE ); // get text from dialog
}
-
- else {
+
+ else
+ {
newDSN[0] = '\0';
}
-
+
////// server name/IP
// get length of input text
x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
- if ( x > 0 ) {
- char serverStrBuf[BUFFERSIZE - 8];
- GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, BUFFERSIZE ); // get text from dialog
-
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
- strcpy ( serverStr, supportedProtocols[ItemIndex] );
- strcat ( serverStr, PROTOCOL_SEP );
- strcat ( serverStr, serverStrBuf );
- }
- else {
+ if ( x > 0 )
+ {
+ char serverStrBuf[BUFFERSIZE - 8];
+ GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, BUFFERSIZE ); // get text from dialog
+
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+ strcpy ( serverStr, supportedProtocols[ItemIndex] );
+ strcat ( serverStr, PROTOCOL_SEP );
+ strcat ( serverStr, serverStrBuf );
+ }
+ else
+ {
serverStr[0] = '\0';
}
///// Port
@@ -207,153 +242,170 @@ static eGoodBad RetriveDlgData ( HWND hDlg, char* newDSN, char* serverStr, char*
////// User name
// get length
x = SendDlgItemMessage ( hDlg, IDC_UID, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
// allocate space
GetDlgItemText ( hDlg, IDC_UID, uidStr, BUFFERSIZE );
}
-
- else {
+
+ else
+ {
uidStr[0] = '\0';
}
-
+
////// Password
// get length
x = SendDlgItemMessage ( hDlg, IDC_PWD, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
GetDlgItemText ( hDlg, IDC_PWD, pwdStr, BUFFERSIZE );
}
-
- else {
+
+ else
+ {
pwdStr[0] = '\0';
}
-
+
trimwhitespace ( newDSN );
trimwhitespace ( serverStr );
trimwhitespace ( uidStr );
trimwhitespace ( pwdStr );
-
- if ( strlen ( newDSN ) == 0 ) {
+
+ if ( strlen ( newDSN ) == 0 )
+ {
__ODBCPopMsg ( "DSN name cannot be empty" );
return BAD;
}
-
- if ( strlen ( serverStr ) == 0 ) {
+
+ if ( strlen ( serverStr ) == 0 )
+ {
__ODBCPopMsg ( "Server cannot be empty" );
return BAD;
}
-
- if ( strlen ( uidStr ) == 0 ) {
+
+ if ( strlen ( uidStr ) == 0 )
+ {
__ODBCPopMsg ( "Username cannot be empty" );
return BAD;
}
-
- if ( strlen ( pwdStr ) == 0 ) {
+
+ if ( strlen ( pwdStr ) == 0 )
+ {
__ODBCPopMsg ( "Password cannot be empty" );
return BAD;
}
-
- if ( port == 0 ) {
+
+ if ( port == 0 )
+ {
__ODBCPopMsg ( "Port cannot be 0" );
return BAD;
}
-
+
return GOOD;
}
-static pODBCConn createConn() {
- pODBCConn conn;
+static pODBCConn createConn ()
+{
+ pODBCConn conn;
// allocate a conn
conn = new ODBCConn;
// clear the conn attributes
- memset ( conn, 0, sizeof ( ODBCConn ) );
+ memset ( conn, 0, sizeof ( ODBCConn) );
// set the handle signature
- ( ( pODBCConn ) conn )->Sign = SQL_HANDLE_DBC;
+ ( ( pODBCConn ) conn ) -> Sign = SQL_HANDLE_DBC;
// default values
- ( ( pODBCConn ) conn )->AccessMode = SQL_MODE_READ_ONLY;
- ( ( pODBCConn ) conn )->AutoIPD = SQL_FALSE;
- ( ( pODBCConn ) conn )->AsyncEnable = SQL_ASYNC_ENABLE_OFF;
- ( ( pODBCConn ) conn )->AutoCommit = SQL_AUTOCOMMIT_ON;
- ( ( pODBCConn ) conn )->TimeOut = 0;
- ( ( pODBCConn ) conn )->LoginTimeOut = 0;
- ( ( pODBCConn ) conn )->MetaDataID = SQL_FALSE;
- ( ( pODBCConn ) conn )->ODBCCursors = SQL_CUR_USE_DRIVER;
- ( ( pODBCConn ) conn )->Window = NULL;
- ( ( pODBCConn ) conn )->TxnIsolation = 0;
- ( ( pODBCConn ) conn )->MaxRows = 0;
- ( ( pODBCConn ) conn )->QueryTimeout = 0;
- ( ( pODBCConn ) conn )->Server = new char[BUFFERSIZE];
- ( ( pODBCConn ) conn )->UserName = new char[BUFFERSIZE];
- ( ( pODBCConn ) conn )->Password = new char[BUFFERSIZE];
- ( ( pODBCConn ) conn )->Project = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> AccessMode = SQL_MODE_READ_ONLY;
+ ( ( pODBCConn ) conn ) -> AutoIPD = SQL_FALSE;
+ ( ( pODBCConn ) conn ) -> AsyncEnable = SQL_ASYNC_ENABLE_OFF;
+ ( ( pODBCConn ) conn ) -> AutoCommit = SQL_AUTOCOMMIT_ON;
+ ( ( pODBCConn ) conn ) -> TimeOut = 0;
+ ( ( pODBCConn ) conn ) -> LoginTimeOut = 0;
+ ( ( pODBCConn ) conn ) -> MetaDataID = SQL_FALSE;
+ ( ( pODBCConn ) conn ) -> ODBCCursors = SQL_CUR_USE_DRIVER;
+ ( ( pODBCConn ) conn ) -> Window = NULL;
+ ( ( pODBCConn ) conn ) -> TxnIsolation = 0;
+ ( ( pODBCConn ) conn ) -> MaxRows = 0;
+ ( ( pODBCConn ) conn ) -> QueryTimeout = 0;
+ ( ( pODBCConn ) conn ) -> Server = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> UserName = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> Password = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> Project = new char[BUFFERSIZE];
return conn;
}
-static eGoodBad testGetMetadata ( char* serverStr, char* uidStr, char* pwdStr, long port, char* project ) {
- pODBCConn conn = createConn();
- strcpy ( ( ( pODBCConn ) conn )->Server, serverStr );
- strcpy ( ( ( pODBCConn ) conn )->UserName, uidStr );
- strcpy ( ( ( pODBCConn ) conn )->Password, pwdStr );
- strcpy ( ( ( pODBCConn ) conn )->Project, project );
- ( ( pODBCConn ) conn )->ServerPort = port;
+static eGoodBad testGetMetadata ( char* serverStr, char* uidStr, char* pwdStr, long port, char* project )
+{
+ pODBCConn conn = createConn ();
+ strcpy ( ( ( pODBCConn ) conn ) -> Server, serverStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> UserName, uidStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> Password, pwdStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> Project, project );
+ ( ( pODBCConn ) conn ) -> ServerPort = port;
RETCODE ret = TryFetchMetadata ( conn );
_SQLFreeDiag ( _DIAGCONN ( conn ) );
// disconnect
_SQLDisconnect ( conn );
// now free the structure itself
delete conn;
-
- if ( ret == SQL_ERROR ) {
+
+ if ( ret == SQL_ERROR )
+ {
//validation of data & other prompts goes here
__ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
return BAD;
}
-
+
return GOOD;
}
-static eGoodBad testConnection ( char* serverStr, char* uidStr, char* pwdStr, long port ) {
- pODBCConn conn = createConn();
- strcpy ( ( ( pODBCConn ) conn )->Server, serverStr );
- strcpy ( ( ( pODBCConn ) conn )->UserName, uidStr );
- strcpy ( ( ( pODBCConn ) conn )->Password, pwdStr );
- ( ( pODBCConn ) conn )->ServerPort = port;
+static eGoodBad testConnection ( char* serverStr, char* uidStr, char* pwdStr, long port )
+{
+ pODBCConn conn = createConn ();
+ strcpy ( ( ( pODBCConn ) conn ) -> Server, serverStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> UserName, uidStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> Password, pwdStr );
+ ( ( pODBCConn ) conn ) -> ServerPort = port;
RETCODE ret = TryAuthenticate ( conn );
_SQLFreeDiag ( _DIAGCONN ( conn ) );
// disconnect
_SQLDisconnect ( conn );
// now free the structure itself
delete conn;
-
- if ( ret == SQL_ERROR ) {
+
+ if ( ret == SQL_ERROR )
+ {
//validation of data & other prompts goes here
__ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
return BAD;
}
-
+
return GOOD;
}
static eGoodBad SaveConfigToODBCINI ( char* newDSN, char* serverStr, char* uidStr, char* pwdStr, long port,
- char* projectStr ) {
+ char* projectStr )
+{
char portStrBuffer[BUFFERSIZE];
SetValueInODBCINI ( newDSN, SERVERKEY, serverStr, INITFILE );
SetValueInODBCINI ( newDSN, PORTKEY, _itoa ( port, portStrBuffer, 10 ), INITFILE );
SetValueInODBCINI ( newDSN, UIDKEY, uidStr, INITFILE );
SetValueInODBCINI ( newDSN, PWDKEY, pwdStr, INITFILE );
SetValueInODBCINI ( newDSN, PROJECTKEY, projectStr, INITFILE );
-
+
//If a new dsn name comes, add a new entry in regedit
- if ( _stricmp ( newDSN, currentDSN ) != 0 ) {
+ if ( _stricmp ( newDSN, currentDSN ) != 0 )
+ {
AddDSN ( newDSN );
-
+
//it is a dsn renaming
- if ( strlen ( currentDSN ) != 0 ) {
+ if ( strlen ( currentDSN ) != 0 )
+ {
RemoveDSN ( currentDSN );
}
}
-
+
strcpy ( currentDSN, newDSN );
char temp[BUFFERSIZE];
GetValueFromODBCINI ( DRIVER_NAME, "Driver", DRIVER_DEFAULT_LOCATION, temp, BUFFERSIZE, INSTINIFILE );
@@ -362,7 +414,8 @@ static eGoodBad SaveConfigToODBCINI ( char* newDSN, char* serverStr, char* uidSt
return GOOD;
}
-static eGoodBad RetriveDlgDataToODBCINI ( HWND hDlg, bool onlyTest ) {
+static eGoodBad RetriveDlgDataToODBCINI ( HWND hDlg, bool onlyTest )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start retrieving the configurations to ODBC INI" ) );
Long x, port;
char newDSN[BUFFERSIZE];
@@ -370,151 +423,169 @@ static eGoodBad RetriveDlgDataToODBCINI ( HWND hDlg, bool onlyTest ) {
char uidStr[BUFFERSIZE];
char pwdStr[BUFFERSIZE];
char portStrBuffer[BUFFERSIZE];
-
- if ( !hDlg ) {
+
+ if ( !hDlg )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "RetriveDlgDataToODBCINI - Bad params: hDlg is NULL" ) );
return BAD;
}
-
- x = SendDlgItemMessage ( hDlg, IDC_DSNNAME, EM_LINELENGTH, 0, 0 ); // get text from dialog
-
- if ( x > 0 ) {
- GetDlgItemText ( hDlg, IDC_DSNNAME, newDSN, BUFFERSIZE ); // get text from dialog
+
+ x = SendDlgItemMessage ( hDlg, IDC_DSNNAME, EM_LINELENGTH, 0, 0 ); // get text from dialog
+
+ if ( x > 0 )
+ {
+ GetDlgItemText ( hDlg, IDC_DSNNAME, newDSN, BUFFERSIZE ); // get text from dialog
}
-
- else {
+
+ else
+ {
newDSN[0] = '\0';
}
-
+
////// server name/IP
// get length of input text
x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
- GetDlgItemText ( hDlg, IDC_SERVER, serverStr, BUFFERSIZE ); // get text from dialog
+
+ if ( x > 0 )
+ {
+ GetDlgItemText ( hDlg, IDC_SERVER, serverStr, BUFFERSIZE ); // get text from dialog
}
-
- else {
+
+ else
+ {
serverStr[0] = '\0';
}
-
+
///// Port
// get value
port = GetDlgItemInt ( hDlg, IDC_PORT, NULL, FALSE );
////// User name
// get length
x = SendDlgItemMessage ( hDlg, IDC_UID, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
// allocate space
GetDlgItemText ( hDlg, IDC_UID, uidStr, BUFFERSIZE );
}
-
- else {
+
+ else
+ {
uidStr[0] = '\0';
}
-
+
////// Password
// get length
x = SendDlgItemMessage ( hDlg, IDC_PWD, EM_LINELENGTH, 0, 0 );
-
- if ( x > 0 ) {
+
+ if ( x > 0 )
+ {
GetDlgItemText ( hDlg, IDC_PWD, pwdStr, BUFFERSIZE );
}
-
- else {
+
+ else
+ {
pwdStr[0] = '\0';
}
-
+
trimwhitespace ( newDSN );
trimwhitespace ( serverStr );
trimwhitespace ( uidStr );
trimwhitespace ( pwdStr );
-
- if ( strlen ( newDSN ) == 0 ) {
+
+ if ( strlen ( newDSN ) == 0 )
+ {
__ODBCPopMsg ( "DSN name cannot be empty" );
return BAD;
}
-
- if ( strlen ( serverStr ) == 0 ) {
+
+ if ( strlen ( serverStr ) == 0 )
+ {
__ODBCPopMsg ( "Server cannot be empty" );
return BAD;
}
-
- if ( strlen ( uidStr ) == 0 ) {
+
+ if ( strlen ( uidStr ) == 0 )
+ {
__ODBCPopMsg ( "Username cannot be empty" );
return BAD;
}
-
- if ( strlen ( pwdStr ) == 0 ) {
+
+ if ( strlen ( pwdStr ) == 0 )
+ {
__ODBCPopMsg ( "Password cannot be empty" );
return BAD;
}
-
- if ( port == 0 ) {
+
+ if ( port == 0 )
+ {
__ODBCPopMsg ( "Port cannot be 0" );
return BAD;
}
-
- if ( onlyTest ) {
- pODBCConn conn;
+
+ if ( onlyTest )
+ {
+ pODBCConn conn;
// allocate a conn
conn = new ODBCConn;
// clear the conn attributes
- memset ( conn, 0, sizeof ( ODBCConn ) );
+ memset ( conn, 0, sizeof ( ODBCConn) );
// set the handle signature
- ( ( pODBCConn ) conn )->Sign = SQL_HANDLE_DBC;
+ ( ( pODBCConn ) conn ) -> Sign = SQL_HANDLE_DBC;
// default values
- ( ( pODBCConn ) conn )->AccessMode = SQL_MODE_READ_ONLY;
- ( ( pODBCConn ) conn )->AutoIPD = SQL_FALSE;
- ( ( pODBCConn ) conn )->AsyncEnable = SQL_ASYNC_ENABLE_OFF;
- ( ( pODBCConn ) conn )->AutoCommit = SQL_AUTOCOMMIT_ON;
- ( ( pODBCConn ) conn )->TimeOut = 0;
- ( ( pODBCConn ) conn )->LoginTimeOut = 0;
- ( ( pODBCConn ) conn )->MetaDataID = SQL_FALSE;
- ( ( pODBCConn ) conn )->ODBCCursors = SQL_CUR_USE_DRIVER;
- ( ( pODBCConn ) conn )->Window = NULL;
- ( ( pODBCConn ) conn )->TxnIsolation = 0;
- ( ( pODBCConn ) conn )->MaxRows = 0;
- ( ( pODBCConn ) conn )->QueryTimeout = 0;
- ( ( pODBCConn ) conn )->Server = new char[BUFFERSIZE];
- ( ( pODBCConn ) conn )->UserName = new char[BUFFERSIZE];
- ( ( pODBCConn ) conn )->Password = new char[BUFFERSIZE];
- strcpy ( ( ( pODBCConn ) conn )->Server, serverStr );
- strcpy ( ( ( pODBCConn ) conn )->UserName, uidStr );
- strcpy ( ( ( pODBCConn ) conn )->Password, pwdStr );
- ( ( pODBCConn ) conn )->ServerPort = port;
+ ( ( pODBCConn ) conn ) -> AccessMode = SQL_MODE_READ_ONLY;
+ ( ( pODBCConn ) conn ) -> AutoIPD = SQL_FALSE;
+ ( ( pODBCConn ) conn ) -> AsyncEnable = SQL_ASYNC_ENABLE_OFF;
+ ( ( pODBCConn ) conn ) -> AutoCommit = SQL_AUTOCOMMIT_ON;
+ ( ( pODBCConn ) conn ) -> TimeOut = 0;
+ ( ( pODBCConn ) conn ) -> LoginTimeOut = 0;
+ ( ( pODBCConn ) conn ) -> MetaDataID = SQL_FALSE;
+ ( ( pODBCConn ) conn ) -> ODBCCursors = SQL_CUR_USE_DRIVER;
+ ( ( pODBCConn ) conn ) -> Window = NULL;
+ ( ( pODBCConn ) conn ) -> TxnIsolation = 0;
+ ( ( pODBCConn ) conn ) -> MaxRows = 0;
+ ( ( pODBCConn ) conn ) -> QueryTimeout = 0;
+ ( ( pODBCConn ) conn ) -> Server = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> UserName = new char[BUFFERSIZE];
+ ( ( pODBCConn ) conn ) -> Password = new char[BUFFERSIZE];
+ strcpy ( ( ( pODBCConn ) conn ) -> Server, serverStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> UserName, uidStr );
+ strcpy ( ( ( pODBCConn ) conn ) -> Password, pwdStr );
+ ( ( pODBCConn ) conn ) -> ServerPort = port;
RETCODE ret = TryAuthenticate ( conn );
_SQLFreeDiag ( _DIAGCONN ( conn ) );
// disconnect
_SQLDisconnect ( conn );
// now free the structure itself
delete conn;
-
- if ( ret == SQL_ERROR ) {
+
+ if ( ret == SQL_ERROR )
+ {
//validation of data & other prompts goes here
__ODBCPopMsg ( "Username/Password not authorized, or server out of service." );
return BAD;
}
-
+
return GOOD;
}
-
+
SetValueInODBCINI ( newDSN, SERVERKEY, serverStr, INITFILE );
SetValueInODBCINI ( newDSN, PORTKEY, _itoa ( port, portStrBuffer, 10 ), INITFILE );
SetValueInODBCINI ( newDSN, UIDKEY, uidStr, INITFILE );
SetValueInODBCINI ( newDSN, PWDKEY, pwdStr, INITFILE );
-
+
//If a new dsn name comes, add a new entry in regedit
- if ( _stricmp ( newDSN, currentDSN ) != 0 ) {
+ if ( _stricmp ( newDSN, currentDSN ) != 0 )
+ {
AddDSN ( newDSN );
-
+
//it is a dsn renaming
- if ( strlen ( currentDSN ) != 0 ) {
+ if ( strlen ( currentDSN ) != 0 )
+ {
RemoveDSN ( currentDSN );
}
}
-
+
strcpy ( currentDSN, newDSN );
char temp[BUFFERSIZE];
GetValueFromODBCINI ( DRIVER_NAME, "Driver", DRIVER_DEFAULT_LOCATION, temp, BUFFERSIZE, INSTINIFILE );
@@ -524,233 +595,267 @@ static eGoodBad RetriveDlgDataToODBCINI ( HWND hDlg, bool onlyTest ) {
}
-eGoodBad LoadODBCINIDataToConn ( pODBCConn pConn ) {
- Long x;
+eGoodBad LoadODBCINIDataToConn ( pODBCConn pConn )
+{
+ Long x;
char buffer[BUFFERSIZE];
int c;
-
+
// note
// no error handling is currently being done for
// GetDlgItemText/GetDlgItemInt/SetConnProp
// generally should not be a problem
-
+
// precaution
- if ( !pConn ) {
+ if ( !pConn )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "GetDataFromDlgDSNCfg1 - Bad params: pConn is NULL" ) );
return BAD;
}
-
+
////// server name/IP
c = GetValueFromODBCINI ( currentDSN, SERVERKEY, "", buffer, BUFFERSIZE, INITFILE );
-
- if ( c <= 0 ) {
+
+ if ( c <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "Please config the Kylin DSN in odbcad.exe before using it." ) );
return BAD;
}
-
+
// set value in struct
SetConnProp ( pConn, CONN_PROP_SERVER, buffer );
///// Port
c = GetValueFromODBCINI ( currentDSN, PORTKEY, "", buffer, BUFFERSIZE, INITFILE );
-
- if ( c <= 0 ) {
+
+ if ( c <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "Please config the Kylin DSN in odbcad.exe before using it." ) );
return BAD;
}
-
+
x = atoi ( buffer );
// set value in struct
SetConnProp ( pConn, CONN_PROP_PORT, &x );
////// User name
c = GetValueFromODBCINI ( currentDSN, UIDKEY, "", buffer, BUFFERSIZE, INITFILE );
-
- if ( c <= 0 ) {
+
+ if ( c <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "Please config the Kylin DSN in odbcad.exe before using it." ) );
return BAD;
}
-
+
// set value in struct
SetConnProp ( pConn, CONN_PROP_UID, buffer );
////// Password
c = GetValueFromODBCINI ( currentDSN, PWDKEY, "", buffer, BUFFERSIZE, INITFILE );
-
- if ( c <= 0 ) {
+
+ if ( c <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "Please config the Kylin DSN in odbcad.exe before using it." ) );
return BAD;
}
-
+
// set value in struct
SetConnProp ( pConn, CONN_PROP_PWD, buffer );
////// Project
c = GetValueFromODBCINI ( currentDSN, PROJECTKEY, "", buffer, BUFFERSIZE, INITFILE );
-
- if ( c <= 0 ) {
+
+ if ( c <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "Please config the Kylin DSN in odbcad.exe before using it." ) );
return BAD;
}
-
+
// set value in struct
SetConnProp ( pConn, CONN_PROP_PROJECT, buffer );
return GOOD;
}
-INT_PTR CALLBACK DlgDSNCfg2Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+INT_PTR CALLBACK DlgDSNCfg2Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
char* attributes = ( char* ) lParam;
- Long port;
- char newDSN[BUFFERSIZE];
- char serverStr[BUFFERSIZE];
- char uidStr[BUFFERSIZE];
- char pwdStr[BUFFERSIZE];
-
- switch ( uMsg ) {
- case WM_INITDIALOG: {
- // init protocol list
-
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[0]));
- SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[1]));
- SendMessage(hwndCombo, CB_SETCURSEL, 0, 0 );
+ Long port;
+ char newDSN[BUFFERSIZE];
+ char serverStr[BUFFERSIZE];
+ char uidStr[BUFFERSIZE];
+ char pwdStr[BUFFERSIZE];
+
+ switch ( uMsg )
+ {
+ case WM_INITDIALOG :
+ {
+ // init protocol list
+
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[0] ) );
+ SendMessage ( hwndCombo, CB_ADDSTRING, 0, reinterpret_cast <LPARAM> ( ( LPCTSTR )supportedProtocols[1] ) );
+ SendMessage ( hwndCombo, CB_SETCURSEL, 0, 0 );
SetCurrentDSN ( attributes, "DlgDSNCfg2Proc" );
// store the structure for future use
SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
-
+
// initialize the dialog with data from REGEDIT
if ( LoadODBCINIDataToDlgDSNCfg2 ( hDlg ) != GOOD )
- { return false; }
-
+ {
+ return false;
+ }
+
// set focus automatically
return TRUE;
- }
- case WM_COMMAND:
- switch ( LOWORD ( wParam ) ) {
- case IDC_PROTOCOL: {
- switch ( HIWORD ( wParam ) ) {
- case CBN_SELCHANGE: {
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
- int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
- if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) ) { return TRUE; }
-
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- case IDC_BTEST: {
- if ( RetriveDlgData ( hDlg, newDSN, serverStr, uidStr, pwdStr, &port ) == GOOD ) {
- if ( testConnection ( serverStr, uidStr, pwdStr, port ) == GOOD ) {
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
- HWND hwndOK = GetDlgItem ( hDlg, IDOK );
- //passed verification
- EnableWindow ( hwndCombo, TRUE );
-
- try {
- std::vector<string> projects;
- restListProjects ( serverStr, port, uidStr, pwdStr, projects );
-
- // reload project list
- SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
- for ( unsigned int i = 0 ; i < projects.size(); ++i ) {
- SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects.at ( i ).c_str() );
- }
-
- SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
- }
-
- catch ( exception& e ) {
- stringstream ss;
- ss << "Getting project list failed with error: " << e.what();
- __ODBCPopMsg ( ss.str().c_str() );
- return FALSE;
- }
-
- EnableWindow ( hwndOK, TRUE );
+ }
+ case WM_COMMAND :
+ switch ( LOWORD ( wParam ) )
+ {
+ case IDC_PROTOCOL :
+ {
+ switch ( HIWORD ( wParam ) )
+ {
+ case CBN_SELCHANGE :
+ {
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+ int portIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+ if ( SetDlgItemText ( hDlg, IDC_PORT, defaultPorts[portIndex] ) )
+ {
return TRUE;
}
-
- else {
- __ODBCPopMsg ( "Connection failed." );
+
+ return FALSE;
+ }
+ default :
+ break;
+ }
+ break;
+ }
+ case IDC_BTEST :
+ {
+ if ( RetriveDlgData ( hDlg, newDSN, serverStr, uidStr, pwdStr, &port ) == GOOD )
+ {
+ if ( testConnection ( serverStr, uidStr, pwdStr, port ) == GOOD )
+ {
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+ HWND hwndOK = GetDlgItem ( hDlg, IDOK );
+ //passed verification
+ EnableWindow ( hwndCombo, TRUE );
+
+ try
+ {
+ std::vector <string> projects;
+ restListProjects ( serverStr, port, uidStr, pwdStr, projects );
+
+ // reload project list
+ SendMessage ( hwndCombo, CB_RESETCONTENT, 0, 0 );
+ for ( unsigned int i = 0; i < projects . size (); ++i )
+ {
+ SendMessage ( hwndCombo, ( UINT ) CB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) projects . at ( i ) . c_str () );
+ }
+
+ SendMessage ( hwndCombo, CB_SETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+ }
+
+ catch ( exception& e )
+ {
+ stringstream ss;
+ ss << "Getting project list failed with error: " << e . what ();
+ __ODBCPopMsg ( ss . str () . c_str () );
+ return FALSE;
}
+
+ EnableWindow ( hwndOK, TRUE );
+ return TRUE;
}
-
- else {
- __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "RetriveDlgData failed." ));
+
+ else
+ {
+ __ODBCPopMsg ( "Connection failed." );
}
-
- return FALSE;
}
-
- case IDOK: {
- HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
- int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
- ( WPARAM ) 0, ( LPARAM ) 0 );
- TCHAR projectName[256];
- ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
- ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
-
- if ( RetriveDlgData ( hDlg, newDSN, serverStr, uidStr, pwdStr, &port ) == GOOD ) {
- if ( testGetMetadata ( serverStr, uidStr, pwdStr, port, projectName ) == GOOD ) {
- SaveConfigToODBCINI ( newDSN, serverStr, uidStr, pwdStr, port, projectName );
- EndDialog ( hDlg, wParam );
- return TRUE;
- }
+
+ else
+ {
+ __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "RetriveDlgData failed." ));
+ }
+
+ return FALSE;
+ }
+
+ case IDOK :
+ {
+ HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
+ int ItemIndex = SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETCURSEL,
+ ( WPARAM ) 0, ( LPARAM ) 0 );
+ TCHAR projectName[256];
+ ( TCHAR ) SendMessage ( ( HWND ) hwndCombo, ( UINT ) CB_GETLBTEXT,
+ ( WPARAM ) ItemIndex, ( LPARAM ) projectName );
+
+ if ( RetriveDlgData ( hDlg, newDSN, serverStr, uidStr, pwdStr, &port ) == GOOD )
+ {
+ if ( testGetMetadata ( serverStr, uidStr, pwdStr, port, projectName ) == GOOD )
+ {
+ SaveConfigToODBCINI ( newDSN, serverStr, uidStr, pwdStr, port, projectName );
+ EndDialog ( hDlg, wParam );
+ return TRUE;
}
-
- return FALSE;
}
-
- case IDCANCEL:
+
+ return FALSE;
+ }
+
+ case IDCANCEL :
// indicate end with control id as return value
EndDialog ( hDlg, wParam );
return TRUE;
}
}
-
+
return FALSE;
}
-BOOL INSTAPI ConfigDSN ( HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes ) {
+BOOL INSTAPI ConfigDSN ( HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "ConfigDSN %s is called %s, the fRequest is: %d", lpszDriver, lpszAttributes,
- fRequest ) );
-
- if ( fRequest == ODBC_REMOVE_DSN ) {
+ fRequest ) );
+
+ if ( fRequest == ODBC_REMOVE_DSN )
+ {
SetCurrentDSN ( ( char* ) lpszAttributes, "ConfigDSN" );
-
- if ( strlen ( currentDSN ) <= 0 ) {
+
+ if ( strlen ( currentDSN ) <= 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "The DSN name is not defined in the connection string!" ) );
return false;
}
-
+
BOOL ret = TRUE;
ret = RemoveDSN ( currentDSN );
-
- if ( !ret ) {
+
+ if ( !ret )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "The DSN is not found, removal failed!" ) );
return false;
}
-
+
return true;
}
-
+
//else is ODBC_CONFIG_DSN or ODBC_ADD_DSN
- int i;
+ int i;
i = DialogBoxParam ( ghInstDLL, MAKEINTRESOURCE ( IDD_DSN_CFG2 ), NULL, DlgDSNCfg2Proc, ( LPARAM ) lpszAttributes );
-
+
// check status
- switch ( i ) {
- case IDOK:
+ switch ( i )
+ {
+ case IDOK :
__ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "User click OK button on DSN config" ) );
- return true; // complete
-
- default:
+ return true; // complete
+
+ default :
__ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, "User click Cancel button on DSN config" ) );
- return false; // user-cancelled
+ return false; // user-cancelled
}
-
+
return true;
}
-
[06/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_DESC.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_DESC.CPP b/odbc/Driver/KO_DESC.CPP
index b72deab..7aa6ed0 100644
--- a/odbc/Driver/KO_DESC.CPP
+++ b/odbc/Driver/KO_DESC.CPP
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,8 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
+
// ----------------------------------------------------------------------------
//
@@ -60,119 +59,123 @@
// ------------------------ local functions -----------------------------------
-pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum );
-pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum );
-pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum );
-pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum );
-
-eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt );
-eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem );
-
-eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt );
-eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem );
-
-eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt );
-eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum );
-
-eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt );
-eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem );
-
-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 _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 _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 _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 _SQLFreeAPDContent ( const pODBCAPD pDesc );
-RETCODE SQL_API _SQLFreeIPDContent ( const pODBCIPD pDesc );
-RETCODE SQL_API _SQLFreeARDContent ( const pODBCARD pDesc );
-RETCODE SQL_API _SQLFreeIRDContent ( const pODBCIRD pDesc );
-
-eGoodBad _SQLAttachARDItem ( pODBCARD pDesc, pARDItem pDescItem );
-eGoodBad _SQLDetachARDItem ( pODBCARD pDesc, pARDItem pDescItem );
+pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum );
+pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum );
+pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum );
+pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum );
+
+eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt );
+eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem );
+
+eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt );
+eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem );
+
+eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt );
+eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum );
+
+eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt );
+eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem );
+
+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 _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 _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 _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 _SQLFreeAPDContent ( const pODBCAPD pDesc );
+RETCODE SQL_API _SQLFreeIPDContent ( const pODBCIPD pDesc );
+RETCODE SQL_API _SQLFreeARDContent ( const pODBCARD pDesc );
+RETCODE SQL_API _SQLFreeIRDContent ( const pODBCIRD pDesc );
+
+eGoodBad _SQLAttachARDItem ( pODBCARD pDesc, pARDItem pDescItem );
+eGoodBad _SQLDetachARDItem ( pODBCARD pDesc, pARDItem pDescItem );
// -----------------------------------------------------------------------
// to get value of specified descriptor field
// -----------------------------------------------------------------------
-RETCODE _SQLGetDescField_basic ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr,
- bool isANSI ) {
- bool invalidfld;
- bool headerfld;
- Word desctype;
-
+RETCODE _SQLGetDescField_basic ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr,
+ bool isANSI )
+{
+ bool invalidfld;
+ bool headerfld;
+ Word desctype;
+
// precaution
- if ( pDesc == NULL || pDataPtr == NULL ) {
+ if ( pDesc == NULL || pDataPtr == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescField - invalid params" ) );
return SQL_ERROR;
}
-
+
// initializations
invalidfld = FALSE;
- headerfld = TRUE;
- desctype = _DESCTYPE ( pDesc );
-
+ headerfld = TRUE;
+ desctype = _DESCTYPE ( pDesc );
+
// check if descriptor is valid & reset diags
- switch ( desctype ) {
- case SQL_DESC_APD:
- _SQLFreeDiag ( & ( ( ( pODBCAPD ) pDesc )->Stmt->Diag ) );
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
+ _SQLFreeDiag ( & ( ( ( pODBCAPD ) pDesc ) -> Stmt -> Diag ) );
break;
-
- case SQL_DESC_IPD:
- _SQLFreeDiag ( & ( ( ( pODBCIPD ) pDesc )->Stmt->Diag ) );
+
+ case SQL_DESC_IPD :
+ _SQLFreeDiag ( & ( ( ( pODBCIPD ) pDesc ) -> Stmt -> Diag ) );
break;
-
- case SQL_DESC_ARD:
- _SQLFreeDiag ( & ( ( ( pODBCARD ) pDesc )->Stmt->Diag ) );
+
+ case SQL_DESC_ARD :
+ _SQLFreeDiag ( & ( ( ( pODBCARD ) pDesc ) -> Stmt -> Diag ) );
break;
-
- case SQL_DESC_IRD:
- _SQLFreeDiag ( & ( ( ( pODBCIRD ) pDesc )->Stmt->Diag ) );
+
+ case SQL_DESC_IRD :
+ _SQLFreeDiag ( & ( ( ( pODBCIRD ) pDesc ) -> Stmt -> Diag ) );
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescField - Invalid descriptor handle" ) );
return SQL_ERROR;
}
-
+
// HEADER FIELDS
-
+
// check the field type - header field
- switch ( pFldID ) {
- case SQL_DESC_ALLOC_TYPE:
-
+ switch ( pFldID )
+ {
+ case SQL_DESC_ALLOC_TYPE :
+
/*****
SQLSMALLINT
ARD: R APD: R IRD: R IPD: R
@@ -181,882 +184,930 @@ RETCODE _SQLGetDescField_basic ( SQLHDESC pDesc,
IRD: SQL_DESC_ALLOC_AUTO
IPD: SQL_DESC_ALLOC_AUTO
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDField ( ( pODBCIPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDField ( ( pODBCIRD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
}
-
+
break;
-
- case SQL_DESC_ARRAY_SIZE:
-
+
+ case SQL_DESC_ARRAY_SIZE :
+
/*********
SQLUINTEGER
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD:[1] APD:[1] IRD: Unused IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_ARRAY_STATUS_PTR:
-
+
+ case SQL_DESC_ARRAY_STATUS_PTR :
+
/**********
SQLUSMALLINT*
ARD: R/W APD: R/W IRD: R/W IPD: R/W
ARD: Null ptr APD: Null ptr IRD: Null ptr IPD: Null ptr
**********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDField ( ( pODBCIPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDField ( ( pODBCIRD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
}
-
+
break;
-
- case SQL_DESC_BIND_OFFSET_PTR:
-
+
+ case SQL_DESC_BIND_OFFSET_PTR :
+
/**********
SQLINTEGER*
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD: Null ptr APD: Null ptr IRD: Unused IPD: Unused
**********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_BIND_TYPE:
-
+
+ case SQL_DESC_BIND_TYPE :
+
/**********
SQLINTEGER
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD: SQL_BIND_BY_COLUMN
APD: SQL_BIND_BY_COLUMN IRD: Unused IPD: Unused
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_COUNT:
-
+
+ case SQL_DESC_COUNT :
+
/**********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: 0 APD: 0 IRD: D IPD: 0
**********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDField ( ( pODBCAPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDField ( ( pODBCIPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDField ( ( pODBCARD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDField ( ( pODBCIRD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
}
-
+
break;
-
- case SQL_DESC_ROWS_PROCESSED_PTR:
-
+
+ case SQL_DESC_ROWS_PROCESSED_PTR :
+
/**********
SQLUINTEGER*
ARD: Unused APD: Unused IRD: R/W IPD: R/W
ARD: Unused APD: Unused IRD: Null ptr IPD: Null ptr
***********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDField ( ( pODBCIPD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDField ( ( pODBCIRD ) pDesc, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- default:
+
+ default :
headerfld = FALSE;
}
-
+
// check if not an header field
if ( headerfld == TRUE )
- { return SQL_SUCCESS; }
-
+ {
+ return SQL_SUCCESS;
+ }
+
// check if invalid field
- if ( invalidfld == TRUE ) {
+ if ( invalidfld == TRUE )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescField - Invalid field %d for descriptor %d", pFldID, desctype ) );
return SQL_ERROR;
}
-
+
// check the field type - record field
- switch ( pFldID ) {
- case SQL_DESC_AUTO_UNIQUE_VALUE:
-
+ switch ( pFldID )
+ {
+ case SQL_DESC_AUTO_UNIQUE_VALUE :
+
/***********
SQLINTEGER
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
*********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_BASE_COLUMN_NAME:
-
+
+ case SQL_DESC_BASE_COLUMN_NAME :
+
/**********
SQLCHAR *
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
**********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_BASE_TABLE_NAME:
-
+
+ case SQL_DESC_BASE_TABLE_NAME :
+
/********
SQLCHAR *
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
*******/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_CASE_SENSITIVE:
-
+
+ case SQL_DESC_CASE_SENSITIVE :
+
/**********
SQLINTEGER
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: D IPD: D
*******/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_CATALOG_NAME:
-
+
+ case SQL_DESC_CATALOG_NAME :
+
/**********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_CONCISE_TYPE:
-
+
+ case SQL_DESC_CONCISE_TYPE :
+
/**********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: SQL_C_DEFAULT APD: SQL_C_DEFAULT IRD: D IPD: ND
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_DATA_PTR:
-
+
+ case SQL_DESC_DATA_PTR :
+
/***********
SQLPOINTER
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD: Null ptr APD: Null ptr IRD: Unused IPD: Unused
************/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_DATETIME_INTERVAL_CODE:
-
+
+ case SQL_DESC_DATETIME_INTERVAL_CODE :
+
/**********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_DATETIME_INTERVAL_PRECISION:
-
+
+ case SQL_DESC_DATETIME_INTERVAL_PRECISION :
+
/*********
SQLINTEGER
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
**********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_DISPLAY_SIZE:
-
+
+ case SQL_DESC_DISPLAY_SIZE :
+
/*********
SQLINTEGER
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
**********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_FIXED_PREC_SCALE:
-
+
+ case SQL_DESC_FIXED_PREC_SCALE :
+
/*********
SQLSMALLINT
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: D IPD: D[1]
*********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_INDICATOR_PTR:
-
+
+ case SQL_DESC_INDICATOR_PTR :
+
/**********
SQLINTEGER *
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD: Null ptr APD: Null ptr IRD: Unused IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_LABEL:
-
+
+ case SQL_DESC_LABEL :
+
/*********
SQLCHAR *
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
***********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_LENGTH:
-
+
+ case SQL_DESC_LENGTH :
+
/********
SQLUINTEGER
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_ARD:
+ switch ( desctype )
+ {
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_APD:
+
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
}
-
+
break;
-
- case SQL_DESC_LITERAL_PREFIX:
-
+
+ case SQL_DESC_LITERAL_PREFIX :
+
/**********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
**********/
-
+
// a read-only IRD field
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_LITERAL_SUFFIX:
-
+
+ case SQL_DESC_LITERAL_SUFFIX :
+
/**********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
**********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_LOCAL_TYPE_NAME:
-
+
+ case SQL_DESC_LOCAL_TYPE_NAME :
+
/***********
SQLCHAR *
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: D IPD: D
***********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_NAME:
-
+
+ case SQL_DESC_NAME :
+
/***********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
*********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_NULLABLE:
-
+
+ case SQL_DESC_NULLABLE :
+
/**********
SQLSMALLINT
ARD: Unused APD: Unused IRD: R IPD: R
ARD: ND APD: ND IRD: D IPD: ND
***********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_NUM_PREC_RADIX:
-
+
+ case SQL_DESC_NUM_PREC_RADIX :
+
/*********
SQLINTEGER
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_OCTET_LENGTH:
-
+
+ case SQL_DESC_OCTET_LENGTH :
+
/**********
SQLINTEGER
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_OCTET_LENGTH_PTR:
-
+
+ case SQL_DESC_OCTET_LENGTH_PTR :
+
/******
SQLINTEGER*
ARD: R/W APD: R/W IRD: Unused IPD: Unused
ARD: Null ptr APD: Null ptr IRD: Unused IPD: Unused
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_PARAMETER_TYPE:
-
+
+ case SQL_DESC_PARAMETER_TYPE :
+
/*********
SQLSMALLINT
ARD: Unused APD: Unused IRD: Unused IPD: R/W
ARD: Unused APD: Unused IRD: Unused IPD: D=SQL_PARAM_INPUT
*********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_PRECISION:
-
+
+ case SQL_DESC_PRECISION :
+
/*********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_ROWVER:
-
+
+ case SQL_DESC_ROWVER :
+
/*********
SQLSMALLINT
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: ND IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_SCALE:
-
+
+ case SQL_DESC_SCALE :
+
/********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_SCHEMA_NAME:
-
+
+ case SQL_DESC_SCHEMA_NAME :
+
/*********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_SEARCHABLE:
-
+
+ case SQL_DESC_SEARCHABLE :
+
/*********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_TABLE_NAME:
-
+
+ case SQL_DESC_TABLE_NAME :
+
/********
SQLCHAR*
ARD: Unused APD: Unused IRD: R IPD: Unused
ARD: Unused APD: Unused IRD: D IPD: Unused
********/
- switch ( desctype ) {
- case SQL_DESC_IRD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_TYPE:
-
+
+ case SQL_DESC_TYPE :
+
/*********
SQLSMALLINT
ARD: R/W APD: R/W IRD: R IPD: R/W
ARD: SQL_C_DEFAULT APD: SQL_C_DEFAULT IRD: D IPD: ND
*********/
- switch ( desctype ) {
- case SQL_DESC_APD:
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
return _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
return _SQLGetARDItemField ( ( pODBCARD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
}
-
+
break;
-
- case SQL_DESC_TYPE_NAME:
-
+
+ case SQL_DESC_TYPE_NAME :
+
/*********
SQLCHAR *
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: D IPD: D
**********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_UNNAMED:
-
+
+ case SQL_DESC_UNNAMED :
+
/********
SQLSMALLINT
ARD: Unused APD: Unused IRD: R IPD: R/W
ARD: ND APD: ND IRD: D IPD: ND
********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- case SQL_DESC_UNSIGNED:
-
+
+ case SQL_DESC_UNSIGNED :
+
/*********
SQLSMALLINT
ARD: Unused APD: Unused IRD: R IPD: R
ARD: Unused APD: Unused IRD: D IPD: D
********/
- switch ( desctype ) {
- case SQL_DESC_IPD:
+ switch ( desctype )
+ {
+ case SQL_DESC_IPD :
return _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr );
-
- case SQL_DESC_IRD:
+
+ case SQL_DESC_IRD :
return _SQLGetIRDItemField ( ( pODBCIRD ) pDesc, NULL, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, isANSI );
-
- default:
+
+ default :
invalidfld = TRUE;
}
-
+
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescField - Unknown field %d", pFldID ) );
return SQL_ERROR;
}
-
+
// check if invalid field
- if ( invalidfld == TRUE ) {
+ if ( invalidfld == TRUE )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescField - Invalid field %d for descriptor %d", pFldID, desctype ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLGetDescFieldW ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr )
+RETCODE SQL_API SQLGetDescFieldW ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLGetDescFieldW called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc,
- ( pDesc ) ? * ( ( short* ) pDesc ) : 0, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr ) );
+ "SQLGetDescFieldW called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc,
+ ( pDesc ) ? * ( ( short* ) pDesc ) : 0, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr ) );
return _SQLGetDescField_basic ( pDesc, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, false );
}
-RETCODE SQL_API SQLGetDescField ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize,
- SQLINTEGER* pDataSizePtr ) {
+RETCODE SQL_API SQLGetDescField ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize,
+ SQLINTEGER* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLGetDescField called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc,
- ( pDesc ) ? * ( ( short* ) pDesc ) : 0, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr ) );
+ "SQLGetDescField called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc,
+ ( pDesc ) ? * ( ( short* ) pDesc ) : 0, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr ) );
return _SQLGetDescField_basic ( pDesc, pRecNum, pFldID, pDataPtr, pDataSize, pDataSizePtr, true );
}
// -----------------------------------------------------------------------
// to set a single field in a desc record
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLSetDescFieldW ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize ) {
+RETCODE SQL_API SQLSetDescFieldW ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLSetDescFieldW called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
- ( pDesc ) ? * ( ( short* ) pDesc ) : ( short ) pDesc, pRecNum, pFldID, pDataPtr, pDataSize ) );
+ "SQLSetDescFieldW called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
+ ( pDesc ) ? * ( ( short* ) pDesc ) : ( short ) pDesc, pRecNum, pFldID, pDataPtr, pDataSize ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetDescFieldW Not implemented" ) );
return SQL_ERROR;
}
-RETCODE SQL_API SQLSetDescField ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLINTEGER pDataSize ) {
+RETCODE SQL_API SQLSetDescField ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLSetDescField called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
- ( pDesc ) ? * ( ( short* ) pDesc ) : ( short ) pDesc, pRecNum, pFldID, pDataPtr, pDataSize ) );
+ "SQLSetDescField called, Desc: %d, Type: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
+ ( pDesc ) ? * ( ( short* ) pDesc ) : ( short ) pDesc, pRecNum, pFldID, pDataPtr, pDataSize ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetDescField Not implemented" ) );
return SQL_ERROR;
}
@@ -1066,116 +1117,121 @@ RETCODE SQL_API SQLSetDescField ( SQLHDESC pDesc,
// to get multiple fields from a desc record, at one shot
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetDescRec ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLCHAR* pName,
- SQLSMALLINT pNameSize,
- SQLSMALLINT* pNameSizePtr,
- SQLSMALLINT* pTypePtr,
- SQLSMALLINT* pSubTypePtr,
- SQLINTEGER* pLengthPtr,
- SQLSMALLINT* pPrecisionPtr,
- SQLSMALLINT* pScalePtr,
- SQLSMALLINT* pNullablePtr )
+RETCODE SQL_API SQLGetDescRec ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLCHAR* pName,
+ SQLSMALLINT pNameSize,
+ SQLSMALLINT* pNameSizePtr,
+ SQLSMALLINT* pTypePtr,
+ SQLSMALLINT* pSubTypePtr,
+ SQLINTEGER* pLengthPtr,
+ SQLSMALLINT* pPrecisionPtr,
+ SQLSMALLINT* pScalePtr,
+ SQLSMALLINT* pNullablePtr )
{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDescRec called Desc: %d, DescType: %d, RecNum: %d", pDesc,
- pDesc ? * ( ( short* ) pDesc ) : 0, pRecNum ) );
+ pDesc ? * ( ( short* ) pDesc ) : 0, pRecNum ) );
Word desctype;
Long i;
-
+
// precaution
- if ( pDesc == NULL ) {
+ if ( pDesc == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescRec - invalid params" ) );
return SQL_ERROR;
}
-
+
// initializations
- desctype = _DESCTYPE ( pDesc );
-
- switch ( desctype ) {
- case SQL_DESC_APD:
+ desctype = _DESCTYPE ( pDesc );
+
+ switch ( desctype )
+ {
+ case SQL_DESC_APD :
pAPDItem apditem;
- _SQLFreeDiag ( & ( ( ( pODBCAPD ) pDesc )->Stmt->Diag ) );
+ _SQLFreeDiag ( & ( ( ( pODBCAPD ) pDesc ) -> Stmt -> Diag ) );
// get item from APD
apditem = _SQLGetAPDItem ( ( pODBCAPD ) pDesc, pRecNum );
-
+
// check if item located
- if ( apditem == NULL ) {
+ if ( apditem == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLGetDescRec - invalid APD item" ) );
return SQL_ERROR;
}
-
+
// get the fields
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_NAME, pName, pNameSize, &i );
*pNameSizePtr = ( Word ) i;
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_TYPE, pTypePtr, -1, NULL );
- _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE , pSubTypePtr, -1,
+ _SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE, pSubTypePtr, -1,
NULL );
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_OCTET_LENGTH, pLengthPtr, -1, NULL );
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_PRECISION, pPrecisionPtr, -1, NULL );
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_SCALE, pScalePtr, -1, NULL );
_SQLGetAPDItemField ( ( pODBCAPD ) pDesc, apditem, pRecNum, SQL_DESC_NULLABLE, pNullablePtr, -1, NULL );
break;
-
- case SQL_DESC_IPD:
+
+ case SQL_DESC_IPD :
pIPDItem ipditem;
- _SQLFreeDiag ( & ( ( ( pODBCIPD ) pDesc )->Stmt->Diag ) );
+ _SQLFreeDiag ( & ( ( ( pODBCIPD ) pDesc ) -> Stmt -> Diag ) );
// get item from IPD
ipditem = _SQLGetIPDItem ( ( pODBCIPD ) pDesc, pRecNum );
-
+
// check if item located
- if ( ipditem == NULL ) {
+ if ( ipditem == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLGetDescRec - invalid IPD item" ) );
return SQL_ERROR;
}
-
+
// set the fields
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_NAME, pName, pNameSize, &i );
*pNameSizePtr = ( Word ) i;
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_TYPE, pTypePtr, -1, NULL );
- _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE , pSubTypePtr, -1,
+ _SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE, pSubTypePtr, -1,
NULL );
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_OCTET_LENGTH, pLengthPtr, -1, NULL );
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_PRECISION, pPrecisionPtr, -1, NULL );
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_SCALE, pScalePtr, -1, NULL );
_SQLGetIPDItemField ( ( pODBCIPD ) pDesc, ipditem, pRecNum, SQL_DESC_NULLABLE, pNullablePtr, -1, NULL );
break;
-
- case SQL_DESC_ARD:
+
+ case SQL_DESC_ARD :
pARDItem arditem;
- _SQLFreeDiag ( & ( ( ( pODBCARD ) pDesc )->Stmt->Diag ) );
+ _SQLFreeDiag ( & ( ( ( pODBCARD ) pDesc ) -> Stmt -> Diag ) );
// get item from ARD
arditem = _SQLGetARDItem ( ( pODBCARD ) pDesc, pRecNum );
-
+
// check if item located
- if ( arditem == NULL ) {
+ if ( arditem == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLGetDescRec - invalid ARD item" ) );
return SQL_ERROR;
}
-
+
// get the fields
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_NAME, pName, pNameSize, &i );
*pNameSizePtr = ( Word ) i;
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_TYPE, pTypePtr, -1, NULL );
- _SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE , pSubTypePtr, -1,
+ _SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_DATETIME_INTERVAL_CODE, pSubTypePtr, -1,
NULL );
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_OCTET_LENGTH, pLengthPtr, -1, NULL );
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_PRECISION, pPrecisionPtr, -1, NULL );
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_SCALE, pScalePtr, -1, NULL );
_SQLGetARDItemField ( ( pODBCARD ) pDesc, arditem, pRecNum, SQL_DESC_NULLABLE, pNullablePtr, -1, NULL );
break;
-
- case SQL_DESC_IRD:
- _SQLFreeDiag ( & ( ( ( pODBCIRD ) pDesc )->Stmt->Diag ) );
-
- // fall thru
-
- default:
+
+ case SQL_DESC_IRD :
+ _SQLFreeDiag ( & ( ( ( pODBCIRD ) pDesc ) -> Stmt -> Diag ) );
+
+ // fall thru
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLSetDescRec - Invalid descriptor handle" ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
@@ -1184,18 +1240,19 @@ RETCODE SQL_API SQLGetDescRec ( SQLHDESC pDesc,
// to set multiple fields in a desc record, at one shot
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLSetDescRec ( SQLHDESC pDesc,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pType,
- SQLSMALLINT pSubType,
- SQLINTEGER pLength,
- SQLSMALLINT pPrecision,
- SQLSMALLINT pScale,
- SQLPOINTER pDataPtr,
- SQLINTEGER* pDataSizePtr,
- SQLINTEGER* pDataIndPtr ) {
+RETCODE SQL_API SQLSetDescRec ( SQLHDESC pDesc,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pType,
+ SQLSMALLINT pSubType,
+ SQLINTEGER pLength,
+ SQLSMALLINT pPrecision,
+ SQLSMALLINT pScale,
+ SQLPOINTER pDataPtr,
+ SQLINTEGER* pDataSizePtr,
+ SQLINTEGER* pDataIndPtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLSetDescRec called Desc: %d, DescType: %d, RecNum: %d", pDesc,
- pDesc ? * ( ( short* ) pDesc ) : 0, pRecNum ) );
+ pDesc ? * ( ( short* ) pDesc ) : 0, pRecNum ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDescRec Not implemented" ) );
return SQL_ERROR;
}
@@ -1206,7 +1263,8 @@ RETCODE SQL_API SQLSetDescRec ( SQLHDESC pDesc,
// -----------------------------------------------------------------------
RETCODE SQL_API SQLCopyDesc ( SQLHDESC pSrcDescHandle,
- SQLHDESC pTgtDescHandle ) {
+ SQLHDESC pTgtDescHandle )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLCopyDesc called" ) );
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLCopyDesc not implemented" ) );
return SQL_ERROR;
@@ -1220,12 +1278,13 @@ RETCODE SQL_API SQLCopyDesc ( SQLHDESC pSrcDescHandle,
// to get a particular ARD item
// -----------------------------------------------------------------------
-pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum ) {
+pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum )
+{
pARDItem i;
-
+
// loop to see if binding for that col already exists
- for ( i = pDesc->BindCols; i != NULL && i->ColNum != pRecNum; i = i->Next );
-
+ for ( i = pDesc -> BindCols; i != NULL && i -> ColNum != pRecNum; i = i -> Next );
+
// return the ARD item
return i;
}
@@ -1235,12 +1294,13 @@ pARDItem _SQLGetARDItem ( const pODBCARD pDesc, Word pRecNum ) {
// to get a particular IPD item
// -----------------------------------------------------------------------
-pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum ) {
+pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum )
+{
pAPDItem i;
-
+
// loop to see if binding for that col already exists
- for ( i = pDesc->BindParams; i != NULL && i->ParamNum != pRecNum; i = i->Next );
-
+ for ( i = pDesc -> BindParams; i != NULL && i -> ParamNum != pRecNum; i = i -> Next );
+
// return the ARD item
return i;
}
@@ -1250,12 +1310,15 @@ pAPDItem _SQLGetAPDItem ( const pODBCAPD pDesc, Word pRecNum ) {
// to get a particular IRD item, mhb
// -----------------------------------------------------------------------
-pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum ) {
+pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum )
+{
// check if descriptor is valid
- if ( pDesc == NULL || pDesc->RowDesc == NULL )
- { return NULL; }
-
- return pDesc->RowDesc->columnMetas.at ( pRecNum - 1 );
+ if ( pDesc == NULL || pDesc -> RowDesc == NULL )
+ {
+ return NULL;
+ }
+
+ return pDesc -> RowDesc -> columnMetas . at ( pRecNum - 1 );
}
@@ -1263,18 +1326,18 @@ pIRDItem _SQLGetIRDItem ( const pODBCIRD pDesc, Word pRecNum ) {
// to get a particular IPD item
// -----------------------------------------------------------------------
-pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum ) {
+pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum )
+{
pIPDItem i;
-
+
// loop to see if binding for that col already exists
- for ( i = pDesc->BindParams; i != NULL && i->ParamNum != pRecNum; i = i->Next );
-
+ for ( i = pDesc -> BindParams; i != NULL && i -> ParamNum != pRecNum; i = i -> Next );
+
// return the ARD item
return i;
}
-
/////////////////////// DEFAULTS
@@ -1282,15 +1345,16 @@ pIPDItem _SQLGetIPDItem ( const pODBCIPD pDesc, Word pRecNum ) {
// to set default values of APD header
// -----------------------------------------------------------------------
-eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt ) {
+eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt )
+{
// reset all
- memset ( pDesc, 0, sizeof ( ODBCAPD ) );
+ memset ( pDesc, 0, sizeof ( ODBCAPD) );
// set explicit defaults
- pDesc->Sign = SQL_DESC_APD;
- pDesc->Stmt = pStmt;
- pDesc->AllocType = SQL_DESC_ALLOC_AUTO;
- pDesc->RowArraySize = 1;
- pDesc->BindTypeOrSize = SQL_BIND_BY_COLUMN;
+ pDesc -> Sign = SQL_DESC_APD;
+ pDesc -> Stmt = pStmt;
+ pDesc -> AllocType = SQL_DESC_ALLOC_AUTO;
+ pDesc -> RowArraySize = 1;
+ pDesc -> BindTypeOrSize = SQL_BIND_BY_COLUMN;
return GOOD;
}
@@ -1298,12 +1362,13 @@ eGoodBad _SQLSetAPDFieldsDefault ( pODBCAPD pDesc, const pODBCStmt pStmt ) {
// to set default values of APD item
// -----------------------------------------------------------------------
-eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem ) {
+eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem )
+{
// reset all
- memset ( pDescItem, 0, sizeof ( APDItem ) );
+ memset ( pDescItem, 0, sizeof ( APDItem) );
// set explicit defaults
- pDescItem->DataConciseType = SQL_C_DEFAULT;
- pDescItem->DataVerboseType = SQL_C_DEFAULT;
+ pDescItem -> DataConciseType = SQL_C_DEFAULT;
+ pDescItem -> DataVerboseType = SQL_C_DEFAULT;
return GOOD;
}
@@ -1311,12 +1376,13 @@ eGoodBad _SQLSetAPDItemFieldsDefault ( pAPDItem pDescItem ) {
// to set default values of IPD header
// -----------------------------------------------------------------------
-eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt ) {
+eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt )
+{
// reset all
- memset ( pDesc, 0, sizeof ( ODBCIPD ) );
+ memset ( pDesc, 0, sizeof ( ODBCIPD) );
// set explicit defaults
- pDesc->Sign = SQL_DESC_IPD;
- pDesc->Stmt = pStmt;
+ pDesc -> Sign = SQL_DESC_IPD;
+ pDesc -> Stmt = pStmt;
return GOOD;
}
@@ -1324,13 +1390,14 @@ eGoodBad _SQLSetIPDFieldsDefault ( pODBCIPD pDesc, const pODBCStmt pStmt ) {
// to set default values of IPD item
// -----------------------------------------------------------------------
-eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem ) {
+eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem )
+{
// reset all
- memset ( pDescItem, 0, sizeof ( IPDItem ) );
+ memset ( pDescItem, 0, sizeof ( IPDItem) );
// set explicit defaults
- pDescItem->ParamType = SQL_PARAM_INPUT;
- pDescItem->DataConciseType = SQL_DEFAULT;
- pDescItem->DataVerboseType = SQL_DEFAULT;
+ pDescItem -> ParamType = SQL_PARAM_INPUT;
+ pDescItem -> DataConciseType = SQL_DEFAULT;
+ pDescItem -> DataVerboseType = SQL_DEFAULT;
return GOOD;
}
@@ -1338,15 +1405,16 @@ eGoodBad _SQLSetIPDItemFieldsDefault ( pIPDItem pDescItem ) {
// to set default values of ARD header
// -----------------------------------------------------------------------
-eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt ) {
+eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt )
+{
// reset all
- memset ( pDesc, 0, sizeof ( ODBCARD ) );
+ memset ( pDesc, 0, sizeof ( ODBCARD) );
// set explicit defaults
- pDesc->Sign = SQL_DESC_ARD;
- pDesc->Stmt = pStmt;
- pDesc->AllocType = SQL_DESC_ALLOC_AUTO;
- pDesc->RowArraySize = 1;
- pDesc->BindTypeOrSize = SQL_BIND_BY_COLUMN;
+ pDesc -> Sign = SQL_DESC_ARD;
+ pDesc -> Stmt = pStmt;
+ pDesc -> AllocType = SQL_DESC_ALLOC_AUTO;
+ pDesc -> RowArraySize = 1;
+ pDesc -> BindTypeOrSize = SQL_BIND_BY_COLUMN;
return GOOD;
}
@@ -1354,13 +1422,14 @@ eGoodBad _SQLSetARDFieldsDefault ( pODBCARD pDesc, const pODBCStmt pStmt ) {
// to set default values of ARD item
// -----------------------------------------------------------------------
-eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum ) {
+eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum )
+{
// reset
- memset ( pDescItem, 0, sizeof ( ARDItem ) );
+ memset ( pDescItem, 0, sizeof ( ARDItem) );
// set explicit defaults
- pDescItem->ColNum = pRecNum;
- pDescItem->DataConciseType = SQL_C_DEFAULT;
- pDescItem->DataVerboseType = SQL_C_DEFAULT;
+ pDescItem -> ColNum = pRecNum;
+ pDescItem -> DataConciseType = SQL_C_DEFAULT;
+ pDescItem -> DataVerboseType = SQL_C_DEFAULT;
return GOOD;
}
@@ -1369,12 +1438,13 @@ eGoodBad _SQLSetARDItemFieldsDefault ( pARDItem pDescItem, Word pRecNum ) {
// to set default values of IRD header
// -----------------------------------------------------------------------
-eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt ) {
+eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt )
+{
// reset all
- memset ( pDesc, 0, sizeof ( ODBCIRD ) );
+ memset ( pDesc, 0, sizeof ( ODBCIRD) );
// set explicit defaults
- pDesc->Sign = SQL_DESC_IRD;
- pDesc->Stmt = pStmt;
+ pDesc -> Sign = SQL_DESC_IRD;
+ pDesc -> Stmt = pStmt;
return GOOD;
}
@@ -1382,7 +1452,8 @@ eGoodBad _SQLSetIRDFieldsDefault ( pODBCIRD pDesc, const pODBCStmt pStmt ) {
// to set default values of IRD item
// -----------------------------------------------------------------------
-eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem ) {
+eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem )
+{
return GOOD;
}
@@ -1395,46 +1466,49 @@ eGoodBad _SQLSetIRDItemFieldsDefault ( pIRDItem pDescItem ) {
// to set a field value in APD
// -----------------------------------------------------------------------
-RETCODE SQL_API _SQLSetAPDField ( pODBCAPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize ) {
+RETCODE SQL_API _SQLSetAPDField ( pODBCAPD pDesc, Word pFldID, const void* pDataPtr, Long pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLSetAPDField called, pDesc: %d, Fld: %d, DataPtr: %d, DataSize: %d",
- pDesc, pFldID, pDataPtr, pDataSize ) );
-
+ pDesc, pFldID, pDataPtr, pDataSize ) );
+
// precaution
- if ( pDesc == NULL ) {
+ if ( pDesc == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetAPDField - invalid params" ) );
return SQL_ERROR;
}
-
- switch ( pFldID ) {
- case SQL_DESC_ARRAY_SIZE:
- pDesc->RowArraySize = ( ULong ) pDataPtr;
+
+ switch ( pFldID )
+ {
+ case SQL_DESC_ARRAY_SIZE :
+ pDesc -> RowArraySize = ( ULong ) pDataPtr;
break;
-
- case SQL_DESC_ARRAY_STATUS_PTR:
- pDesc->ArrayStatusPtr = ( UWord* ) pDataPtr;
+
+ case SQL_DESC_ARRAY_STATUS_PTR :
+ pDesc -> ArrayStatusPtr = ( UWord* ) pDataPtr;
break;
-
- case SQL_DESC_BIND_OFFSET_PTR:
- pDesc->BindOffsetPtr = ( Long* ) pDataPtr;
+
+ case SQL_DESC_BIND_OFFSET_PTR :
+ pDesc -> BindOffsetPtr = ( Long* ) pDataPtr;
break;
-
- case SQL_DESC_BIND_TYPE:
- pDesc->BindTypeOrSize = ( Long ) pDataPtr;
+
+ case SQL_DESC_BIND_TYPE :
+ pDesc -> BindTypeOrSize = ( Long ) pDataPtr;
break;
-
- case SQL_DESC_COUNT:
+
+ case SQL_DESC_COUNT :
// ???? requires that all descriptors which r above the specified
// value are freed
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetAPDField - SQL_DESC_COUNT not implemented" ) );
return SQL_ERROR;
break;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetAPDField - unknown field (%d)", pFldID ) );
return SQL_ERROR;
break;
}
-
+
return SQL_SUCCESS;
}
@@ -1443,25 +1517,29 @@ RETCODE SQL_API _SQLSetAPDField ( pODBCAPD pDesc, Word pFldID, const void* pData
// -----------------------------------------------------------------------
RETCODE SQL_API _SQLSetAPDItemField ( pODBCAPD pDesc, pAPDItem pDescItem, Word pRecNum, Word pFldID,
- const void* pDataPtr, Long pDataSize ) {
+ const void* pDataPtr, Long pDataSize )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "_SQLSetAPDItemField called, pDesc: %d, pDescItem: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
- pDescItem, pRecNum, pFldID, pDataPtr, pDataSize ) );
- pAPDItem item;
-
+ "_SQLSetAPDItemField called, pDesc: %d, pDescItem: %d, Recnum: %d, Fld: %d, DataPtr: %d, DataSize: %d", pDesc,
+ pDescItem, pRecNum, pFldID, pDataPtr, pDataSize ) );
+ pAPDItem item;
+
// precaution
- if ( pDesc == NULL ) {
+ if ( pDesc == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetAPDItemField - invalid params" ) );
return SQL_ERROR;
}
-
+
// check if item has not been explicitly specified
- if ( pDescItem == NULL ) {
+ if ( pDescItem == NULL )
+ {
// get item from APD
item = _SQLGetAPDItem ( pDesc, pRecNum );
-
+
// check if item located
- if ( item == NULL ) {
+ if ( item == NULL )
+ {
// as a patch for SQL server it is temporarily ignoring the error
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLSetAPDItemField - invalid item" ) );
return SQL_SUCCESS;
@@ -1471,66 +1549,69 @@ RETCODE SQL_API _SQLSetAPDItemField ( pODBCAPD pDesc, pAPDItem pDescItem, Word p
/////////////////////////////////////////////////
}
}
-
+
else
- { item = pDescItem; }
-
+ {
+ item = pDescItem;
+ }
+
// as per required field
- switch ( pFldID ) {
- case SQL_DESC_CONCISE_TYPE:
- _SQLSetDataType ( & ( pDesc->Stmt->Diag ), SQL_DESC_CONCISE_TYPE, ( Word ) pDataPtr, & ( item->DataVerboseType ),
- & ( item->DataConciseType ), & ( item->DateTimeIntervalCode ) );
- break;
-
- case SQL_DESC_DATA_PTR:
- item->DataPtr = ( void* ) pDataPtr;
- break;
-
- case SQL_DESC_DATETIME_INTERVAL_CODE:
- _SQLSetDataType ( & ( pDesc->Stmt->Diag ), SQL_DESC_DATETIME_INTERVAL_CODE, ( Word ) pDataPtr,
- & ( item->DataVerboseType ), & ( item->DataConciseType ), & ( item->DateTimeIntervalCode ) );
- break;
-
- case SQL_DESC_DATETIME_INTERVAL_PRECISION:
- item->DateTimeIntervalPrec = ( Long ) pDataPtr;
- break;
-
- case SQL_DESC_INDICATOR_PTR:
- item->SizeIndPtr = ( Long* ) pDataPtr;
- break;
-
- case SQL_DESC_LENGTH:
- case SQL_DESC_OCTET_LENGTH:
- item->DataSize = ( Long ) pDataPtr;
- break;
-
- case SQL_DESC_NUM_PREC_RADIX:
- item->NumPrecRadix = ( Long ) pDataPtr;
- break;
-
- case SQL_DESC_OCTET_LENGTH_PTR:
- item->SizePtr = ( Long* ) pDataPtr;
- break;
-
- case SQL_DESC_PRECISION:
- item->DataSize = ( Word ) pDataPtr;
- break;
-
- case SQL_DESC_SCALE:
- item->Scale = ( Word ) pDataPtr;
- break;
-
- case SQL_DESC_TYPE:
- _SQLSetDataType ( & ( pDesc->Stmt->Diag ), SQL_DESC_TYPE, ( Word ) pDataPtr, & ( item->DataVerboseType ),
- & ( item->DataConciseType ), & ( item->DateTimeIntervalCode ) );
- break;
-
- default:
+ switch ( pFldID )
+ {
+ case SQL_DESC_CONCISE_TYPE :
+ _SQLSetDataType ( & ( pDesc -> Stmt -> Diag ), SQL_DESC_CONCISE_TYPE, ( Word ) pDataPtr, & ( item -> DataVerboseType ),
+ & ( item -> DataConciseType ), & ( item -> DateTimeIntervalCode ) );
+ break;
+
+ case SQL_DESC_DATA_PTR :
+ item -> DataPtr = ( void* ) pDataPtr;
+ break;
+
+ case SQL_DESC_DATETIME_INTERVAL_CODE :
+ _SQLSetDataType ( & ( pDesc -> Stmt -> Diag ), SQL_DESC_DATETIME_INTERVAL_CODE, ( Word ) pDataPtr,
+ & ( item -> DataVerboseType ), & ( item -> DataConciseType ), & ( item -> DateTimeIntervalCode ) );
+ break;
+
+ case SQL_DESC_DATETIME_INTERVAL_PRECISION :
+ item -> DateTimeIntervalPrec = ( Long ) pDataPtr;
+ break;
+
+ case SQL_DESC_INDICATOR_PTR :
+ item -> SizeIndPtr = ( Long* ) pDataPtr;
+ break;
+
+ case SQL_DESC_LENGTH :
+ case SQL_DESC_OCTET_LENGTH :
+ item -> DataSize = ( Long ) pDataPtr;
+ break;
+
+ case SQL_DESC_NUM_PREC_RADIX :
+ item -> NumPrecRadix = ( Long ) pDataPtr;
+ break;
+
+ case SQL_DESC_OCTET_LENGTH_PTR :
+ item -> SizePtr = ( Long* ) pDataPtr;
+ break;
+
+ case SQL_DESC_PRECISION :
+ item -> DataSize = ( Word ) pDataPtr;
+ break;
+
+ case SQL_DESC_SCALE :
+ item -> Scale = ( Word ) pDataPtr;
+ break;
+
+ case SQL_DESC_TYPE :
+ _SQLSetDataType ( & ( pDesc -> Stmt -> Diag ), SQL_DESC_TYPE, ( Word ) pDataPtr, & ( item -> DataVerboseType ),
+ & ( item -> DataConciseType ), & ( item -> DateTimeIntervalCode ) );
+ break;
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetAPDItemField - unknown field (%d)", pFldID ) );
return SQL_ERROR;
break;
}
-
+
return SQL_SUCCESS;
}
@@ -1539,49 +1620,52 @@ RETCODE SQL_API _SQLSetAPDItemField ( pODBCAPD pDesc, pAPDItem pDescItem, Word p
// -----------------------------------------------------------------------
RETCODE SQL_API _SQLGetAPDField ( const pODBCAPD pDesc, Word pFldID, void* pDataPtr, Long pDataSize,
- Long* pDataSizePtr ) {
+ Long* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "_SQLGetAPDField called, pDesc: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc, pFldID, pDataPtr,
- pDataSize, pDataSizePtr ) );
-
+ "_SQLGetAPDField called, pDesc: %d, Fld: %d, DataPtr: %d, DataSize: %d, DataSizePtr: %d", pDesc, pFldID, pDataPtr,
+ pDataSize, pDataSizePtr ) );
+
// precaution
- if ( pDesc == NULL || pDataPtr == NULL ) {
+ if ( pDesc == NULL || pDataPtr == NULL )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetAPDField - invalid params" ) );
return SQL_ERROR;
}
-
+
// as per required field
- switch ( pFldID ) {
- case SQL_DESC_ALLOC_TYPE:
- * ( ( Word* ) pDataPtr ) = pDesc->AllocType;
+ switch ( pFldID )
+ {
+ case SQL_DESC_ALLOC_TYPE :
+ * ( ( Word* ) pDataPtr ) = pDesc -> AllocType;
break;
-
- case SQL_DESC_ARRAY_SIZE:
- * ( ( ULong* ) pDataPtr ) = pDesc->RowArraySize;
+
+ case SQL_DESC_ARRAY_SIZE :
+ * ( ( ULong* ) pDataPtr ) = pDesc -> RowArraySize;
break;
-
- case SQL_DESC_ARRAY_STATUS_PTR:
- * ( ( UWord** ) pDataPtr ) = pDesc->ArrayStatusPtr;
+
+ case SQL_DESC_ARRAY_STATUS_PTR :
+ * ( ( UWord** ) pDataPtr ) = pDesc -> ArrayStatusPtr;
break;
-
- case SQL_DESC_BIND_OFFSET_PTR:
- * ( ( Long** ) pDataPtr ) = pDesc->BindOffsetPt
<TRUNCATED>
[05/11] kylin git commit: KYLIN-1389 ODBC - Reformatting C++ Code
Posted by li...@apache.org.
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_DIAG.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_DIAG.CPP b/odbc/Driver/KO_DIAG.CPP
index a74dd9d..e296335 100644
--- a/odbc/Driver/KO_DIAG.CPP
+++ b/odbc/Driver/KO_DIAG.CPP
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
// ----------------------------------------------------------------------------
//
@@ -65,441 +65,573 @@
#include <stdarg.h>
-
-
-
// --------------------- local functions ---------------------------------
-static pODBCDiagRow _SQLGetDiagRowX ( pODBCDiag pHandle, Word pRowNum );
-static pODBCDiag _SQLGetDiagHandle ( SQLSMALLINT pHandleType, SQLHANDLE pHandle );
+static pODBCDiagRow _SQLGetDiagRowX ( pODBCDiag pHandle, Word pRowNum );
+static pODBCDiag _SQLGetDiagHandle ( SQLSMALLINT pHandleType, SQLHANDLE pHandle );
// --------------------- local functions ---------------------------------
-static LogLevel currentLogLevel =
- LogLevel_INFO;// Global variable to be set at the begining of pragram starts
+static LogLevel currentLogLevel =
+LogLevel_INFO;// Global variable to be set at the begining of pragram starts
// -----------------------------------------------------------------------
// to get a specified field from the specified diag row
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetDiagFieldW ( SQLSMALLINT pHandleType,
- SQLHANDLE pHandle,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr ) {
+RETCODE SQL_API SQLGetDiagFieldW ( SQLSMALLINT pHandleType,
+ SQLHANDLE pHandle,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLGetDiagFieldW called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d", pHandleType, pRecNum, pFldID,
- pDataSize ) );
- bool c;
- pODBCDiag diag;
+ "SQLGetDiagFieldW called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d", pHandleType, pRecNum, pFldID,
+ pDataSize ) );
+ bool c;
+ pODBCDiag diag;
pODBCDiagRow diagrow;
SQLSMALLINT dummySize = 0;//used when pDataSizePtr is NULL
-
+
if ( pDataSizePtr == NULL )
- { pDataSizePtr = &dummySize; }
-
+ {
+ pDataSizePtr = &dummySize;
+ }
+
__CHK_HANDLE ( pHandle, pHandleType, SQL_ERROR );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
- if ( !diag ) { return SQL_ERROR; }
-
+
+ if ( !diag )
+ {
+ return SQL_ERROR;
+ }
+
// field may be in diag header
c = FALSE;
-
+
// check the field type - header fields
- switch ( pFldID ) {
- case SQL_DIAG_CURSOR_ROW_COUNT:
- case SQL_DIAG_ROW_COUNT: // rows affected by update/insert
- if ( pHandleType == SQL_HANDLE_STMT ) {
+ switch ( pFldID )
+ {
+ case SQL_DIAG_CURSOR_ROW_COUNT :
+ case SQL_DIAG_ROW_COUNT : // rows affected by update/insert
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
if ( pDataPtr )
- { * ( ( SQLLEN* ) pDataPtr ) = ( pHandle ) ? ( ( pODBCStmt ) pHandle )->RowCount : 0; }
-
+ {
+ * ( ( SQLLEN* ) pDataPtr ) = ( pHandle ) ? ( ( pODBCStmt ) pHandle ) -> RowCount : 0;
+ }
+
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
- case SQL_DIAG_DYNAMIC_FUNCTION:
- if ( pHandleType == SQL_HANDLE_STMT ) {
- _SQLCopyWCharDataW ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, ( ( pODBCStmt ) pHandle )->Stmt,
- ( ( pODBCStmt ) pHandle )->StmtLen );
+ {
+ return SQL_ERROR;
+ }
+
+ case SQL_DIAG_DYNAMIC_FUNCTION :
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
+ _SQLCopyWCharDataW ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, ( ( pODBCStmt ) pHandle ) -> Stmt,
+ ( ( pODBCStmt ) pHandle ) -> StmtLen );
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
+ {
+ return SQL_ERROR;
+ }
+
return SQL_ERROR;
-
- case SQL_DIAG_DYNAMIC_FUNCTION_CODE:
- if ( pHandleType == SQL_HANDLE_STMT ) {
+
+ case SQL_DIAG_DYNAMIC_FUNCTION_CODE :
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
if ( pDataPtr )
- { * ( ( StrPtr ) pDataPtr ) = 1; } // ??? debug test only
-
- _SQLCopyWCharDataW ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, ( ( pODBCStmt ) pHandle )->Stmt,
- ( ( ( pODBCStmt ) pHandle )->StmtLen ) );
+ {
+ * ( ( StrPtr ) pDataPtr ) = 1;
+ } // ??? debug test only
+
+ _SQLCopyWCharDataW ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, ( ( pODBCStmt ) pHandle ) -> Stmt,
+ ( ( ( pODBCStmt ) pHandle ) -> StmtLen ) );
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
- case SQL_DIAG_NUMBER: { // number of rows in diag
- Word i;
-
- // check if there r any diag rows
- if ( diag->DiagRows ) {
- // loop to count the rows
- for ( i = 1, diagrow = diag->DiagRows; diagrow != NULL; diagrow = diagrow->Next, i ++ );
-
- if ( pDataPtr ) { * ( ( Word* ) pDataPtr ) = i; }
+ {
+ return SQL_ERROR;
+ }
+
+ case SQL_DIAG_NUMBER :
+ { // number of rows in diag
+ Word i;
+
+ // check if there r any diag rows
+ if ( diag -> DiagRows )
+ {
+ // loop to count the rows
+ for ( i = 1 , diagrow = diag -> DiagRows; diagrow != NULL; diagrow = diagrow -> Next , i ++ );
+
+ if ( pDataPtr )
+ {
+ * ( ( Word* ) pDataPtr ) = i;
}
-
- else if ( pDataPtr ) { * ( ( Word* ) pDataPtr ) = 0; }
-
- return SQL_SUCCESS;
}
+
+ else if ( pDataPtr )
+ {
+ * ( ( Word* ) pDataPtr ) = 0;
+ }
+
+ return SQL_SUCCESS;
+ }
break;
-
- default:
+
+ default :
c = TRUE;
}
-
+
// check if only a header field was required
if ( c == FALSE )
- { return SQL_SUCCESS; }
-
+ {
+ return SQL_SUCCESS;
+ }
+
// check row and buffer
- if ( pRecNum <= 0 || pDataSize < 0 ) {
+ if ( pRecNum <= 0 || pDataSize < 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "GetDiagField xxx1" ) );
return SQL_ERROR;
}
-
+
// now get the desired row first
if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL )
- { return SQL_NO_DATA; }
-
+ {
+ return SQL_NO_DATA;
+ }
+
// now set info as per the field required
- switch ( pFldID ) {
- case SQL_DIAG_CLASS_ORIGIN:
+ switch ( pFldID )
+ {
+ case SQL_DIAG_CLASS_ORIGIN :
_SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, "ODBC 3.0", -1 );
break;
-
- case SQL_DIAG_COLUMN_NUMBER:
-
+
+ case SQL_DIAG_COLUMN_NUMBER :
+
// needs to be implemented
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->Col; }
-
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> Col;
+ }
+
break;
-
- case SQL_DIAG_CONNECTION_NAME:
- if ( pDataPtr ) { * ( ( char* ) pDataPtr ) = 0; }
-
- if ( pDataSizePtr ) { *pDataSizePtr = 0; }
-
+
+ case SQL_DIAG_CONNECTION_NAME :
+ if ( pDataPtr )
+ {
+ * ( ( char* ) pDataPtr ) = 0;
+ }
+
+ if ( pDataSizePtr )
+ {
+ *pDataSizePtr = 0;
+ }
+
break;
-
- case SQL_DIAG_MESSAGE_TEXT:
- return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->Msg, -1 );
-
- case SQL_DIAG_NATIVE:
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->NativeErrorCode; }
-
- if ( pDataSizePtr ) { *pDataSizePtr = 0; }
-
+
+ case SQL_DIAG_MESSAGE_TEXT :
+ return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> Msg, -1 );
+
+ case SQL_DIAG_NATIVE :
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> NativeErrorCode;
+ }
+
+ if ( pDataSizePtr )
+ {
+ *pDataSizePtr = 0;
+ }
+
break;
-
- case SQL_DIAG_ROW_NUMBER:
-
+
+ case SQL_DIAG_ROW_NUMBER :
+
// needs to be implemented
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->Row; }
-
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> Row;
+ }
+
break;
-
- case SQL_DIAG_SERVER_NAME: {
- CStrPtr svr;
-
- // if handle type is connection
- if ( pHandleType == SQL_HANDLE_DBC )
- { svr = ( ( pODBCConn ) pHandle )->Server; }
-
- else if ( pHandleType == SQL_HANDLE_STMT && ( ( pODBCStmt ) pHandle )->Conn )
- { svr = ( ( pODBCStmt ) pHandle )->Conn->Server; }
-
- else
- { svr = ""; }
-
- return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, svr, -1 );
- }
-
- case SQL_DIAG_SQLSTATE:
- return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->State, -1 );
-
- case SQL_DIAG_SUBCLASS_ORIGIN:
+
+ case SQL_DIAG_SERVER_NAME :
+ {
+ CStrPtr svr;
+
+ // if handle type is connection
+ if ( pHandleType == SQL_HANDLE_DBC )
+ {
+ svr = ( ( pODBCConn ) pHandle ) -> Server;
+ }
+
+ else if ( pHandleType == SQL_HANDLE_STMT && ( ( pODBCStmt ) pHandle ) -> Conn )
+ {
+ svr = ( ( pODBCStmt ) pHandle ) -> Conn -> Server;
+ }
+
+ else
+ {
+ svr = "";
+ }
+
+ return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, svr, -1 );
+ }
+
+ case SQL_DIAG_SQLSTATE :
+ return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> State, -1 );
+
+ case SQL_DIAG_SUBCLASS_ORIGIN :
// ??? dummy
- return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->State, -1 );
-
- default:
+ return _SQLCopyWCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> State, -1 );
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDiagField called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d",
- pHandleType, pRecNum, pFldID, pDataSize ) );
+ pHandleType, pRecNum, pFldID, pDataSize ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLGetDiagField ( SQLSMALLINT pHandleType,
- SQLHANDLE pHandle,
- SQLSMALLINT pRecNum,
- SQLSMALLINT pFldID,
- SQLPOINTER pDataPtr,
- SQLSMALLINT pDataSize,
- SQLSMALLINT* pDataSizePtr ) {
+RETCODE SQL_API SQLGetDiagField ( SQLSMALLINT pHandleType,
+ SQLHANDLE pHandle,
+ SQLSMALLINT pRecNum,
+ SQLSMALLINT pFldID,
+ SQLPOINTER pDataPtr,
+ SQLSMALLINT pDataSize,
+ SQLSMALLINT* pDataSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG,
- "SQLGetDiagField called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d", pHandleType, pRecNum, pFldID,
- pDataSize ) );
- bool c;
- pODBCDiag diag;
+ "SQLGetDiagField called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d", pHandleType, pRecNum, pFldID,
+ pDataSize ) );
+ bool c;
+ pODBCDiag diag;
pODBCDiagRow diagrow;
SQLSMALLINT dummySize = 0;//used when pDataSizePtr is NULL
-
+
if ( pDataSizePtr == NULL )
- { pDataSizePtr = &dummySize; }
-
+ {
+ pDataSizePtr = &dummySize;
+ }
+
__CHK_HANDLE ( pHandle, pHandleType, SQL_ERROR );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
- if ( !diag ) { return SQL_ERROR; }
-
+
+ if ( !diag )
+ {
+ return SQL_ERROR;
+ }
+
// field may be in diag header
c = FALSE;
-
+
// check the field type - header fields
- switch ( pFldID ) {
- case SQL_DIAG_CURSOR_ROW_COUNT:
- case SQL_DIAG_ROW_COUNT: // rows affected by update/insert
- if ( pHandleType == SQL_HANDLE_STMT ) {
+ switch ( pFldID )
+ {
+ case SQL_DIAG_CURSOR_ROW_COUNT :
+ case SQL_DIAG_ROW_COUNT : // rows affected by update/insert
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
if ( pDataPtr )
- { * ( ( SQLLEN* ) pDataPtr ) = ( pHandle ) ? ( ( pODBCStmt ) pHandle )->RowCount : 0; }
-
+ {
+ * ( ( SQLLEN* ) pDataPtr ) = ( pHandle ) ? ( ( pODBCStmt ) pHandle ) -> RowCount : 0;
+ }
+
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
- case SQL_DIAG_DYNAMIC_FUNCTION:
- if ( pHandleType == SQL_HANDLE_STMT ) {
- unique_ptr<char[]> p ( wchar2char ( ( ( pODBCStmt ) pHandle )->Stmt ) );
- _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, p.get(), ( ( pODBCStmt ) pHandle )->StmtLen );
+ {
+ return SQL_ERROR;
+ }
+
+ case SQL_DIAG_DYNAMIC_FUNCTION :
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
+ unique_ptr <char[]> p ( wchar2char ( ( ( pODBCStmt ) pHandle ) -> Stmt ) );
+ _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, p . get (), ( ( pODBCStmt ) pHandle ) -> StmtLen );
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
+ {
+ return SQL_ERROR;
+ }
+
return SQL_ERROR;
-
- case SQL_DIAG_DYNAMIC_FUNCTION_CODE:
- if ( pHandleType == SQL_HANDLE_STMT ) {
+
+ case SQL_DIAG_DYNAMIC_FUNCTION_CODE :
+ if ( pHandleType == SQL_HANDLE_STMT )
+ {
if ( pDataPtr )
- { * ( ( StrPtr ) pDataPtr ) = 1; } // ??? debug test only
-
- unique_ptr<char[]> p ( wchar2char ( ( ( pODBCStmt ) pHandle )->Stmt ) );
- _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, p.get(), ( ( ( pODBCStmt ) pHandle )->StmtLen ) );
+ {
+ * ( ( StrPtr ) pDataPtr ) = 1;
+ } // ??? debug test only
+
+ unique_ptr <char[]> p ( wchar2char ( ( ( pODBCStmt ) pHandle ) -> Stmt ) );
+ _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, p . get (), ( ( ( pODBCStmt ) pHandle ) -> StmtLen ) );
return SQL_SUCCESS;
}
-
+
else
- { return SQL_ERROR; }
-
- case SQL_DIAG_NUMBER: { // number of rows in diag
- Word i;
-
- // check if there r any diag rows
- if ( diag->DiagRows ) {
- // loop to count the rows
- for ( i = 1, diagrow = diag->DiagRows; diagrow != NULL; diagrow = diagrow->Next, i ++ );
-
- if ( pDataPtr ) { * ( ( Word* ) pDataPtr ) = i; }
+ {
+ return SQL_ERROR;
+ }
+
+ case SQL_DIAG_NUMBER :
+ { // number of rows in diag
+ Word i;
+
+ // check if there r any diag rows
+ if ( diag -> DiagRows )
+ {
+ // loop to count the rows
+ for ( i = 1 , diagrow = diag -> DiagRows; diagrow != NULL; diagrow = diagrow -> Next , i ++ );
+
+ if ( pDataPtr )
+ {
+ * ( ( Word* ) pDataPtr ) = i;
}
-
- else if ( pDataPtr ) { * ( ( Word* ) pDataPtr ) = 0; }
-
- return SQL_SUCCESS;
}
+
+ else if ( pDataPtr )
+ {
+ * ( ( Word* ) pDataPtr ) = 0;
+ }
+
+ return SQL_SUCCESS;
+ }
break;
-
- default:
+
+ default :
c = TRUE;
}
-
+
// check if only a header field was required
if ( c == FALSE )
- { return SQL_SUCCESS; }
-
+ {
+ return SQL_SUCCESS;
+ }
+
// check row and buffer
- if ( pRecNum <= 0 || pDataSize < 0 ) {
+ if ( pRecNum <= 0 || pDataSize < 0 )
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "GetDiagField xxx1" ) );
return SQL_ERROR;
}
-
+
// now get the desired row first
if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL )
- { return SQL_NO_DATA; }
-
+ {
+ return SQL_NO_DATA;
+ }
+
// now set info as per the field required
- switch ( pFldID ) {
- case SQL_DIAG_CLASS_ORIGIN:
+ switch ( pFldID )
+ {
+ case SQL_DIAG_CLASS_ORIGIN :
_SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, "ODBC 3.0", -1 );
break;
-
- case SQL_DIAG_COLUMN_NUMBER:
-
+
+ case SQL_DIAG_COLUMN_NUMBER :
+
// needs to be implemented
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->Col; }
-
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> Col;
+ }
+
break;
-
- case SQL_DIAG_CONNECTION_NAME:
- if ( pDataPtr ) { * ( ( char* ) pDataPtr ) = 0; }
-
- if ( pDataSizePtr ) { *pDataSizePtr = 0; }
-
+
+ case SQL_DIAG_CONNECTION_NAME :
+ if ( pDataPtr )
+ {
+ * ( ( char* ) pDataPtr ) = 0;
+ }
+
+ if ( pDataSizePtr )
+ {
+ *pDataSizePtr = 0;
+ }
+
break;
-
- case SQL_DIAG_MESSAGE_TEXT:
- return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->Msg, -1 );
-
- case SQL_DIAG_NATIVE:
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->NativeErrorCode; }
-
- if ( pDataSizePtr ) { *pDataSizePtr = 0; }
-
+
+ case SQL_DIAG_MESSAGE_TEXT :
+ return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> Msg, -1 );
+
+ case SQL_DIAG_NATIVE :
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> NativeErrorCode;
+ }
+
+ if ( pDataSizePtr )
+ {
+ *pDataSizePtr = 0;
+ }
+
break;
-
- case SQL_DIAG_ROW_NUMBER:
-
+
+ case SQL_DIAG_ROW_NUMBER :
+
// needs to be implemented
- if ( pDataPtr ) { * ( ( Long* ) pDataPtr ) = diagrow->Row; }
-
+ if ( pDataPtr )
+ {
+ * ( ( Long* ) pDataPtr ) = diagrow -> Row;
+ }
+
break;
-
- case SQL_DIAG_SERVER_NAME: {
- CStrPtr svr;
-
- // if handle type is connection
- if ( pHandleType == SQL_HANDLE_DBC )
- { svr = ( ( pODBCConn ) pHandle )->Server; }
-
- else if ( pHandleType == SQL_HANDLE_STMT && ( ( pODBCStmt ) pHandle )->Conn )
- { svr = ( ( pODBCStmt ) pHandle )->Conn->Server; }
-
- else
- { svr = ""; }
-
- return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, svr, -1 );
- }
-
- case SQL_DIAG_SQLSTATE:
- return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->State, -1 );
-
- case SQL_DIAG_SUBCLASS_ORIGIN:
+
+ case SQL_DIAG_SERVER_NAME :
+ {
+ CStrPtr svr;
+
+ // if handle type is connection
+ if ( pHandleType == SQL_HANDLE_DBC )
+ {
+ svr = ( ( pODBCConn ) pHandle ) -> Server;
+ }
+
+ else if ( pHandleType == SQL_HANDLE_STMT && ( ( pODBCStmt ) pHandle ) -> Conn )
+ {
+ svr = ( ( pODBCStmt ) pHandle ) -> Conn -> Server;
+ }
+
+ else
+ {
+ svr = "";
+ }
+
+ return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, svr, -1 );
+ }
+
+ case SQL_DIAG_SQLSTATE :
+ return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> State, -1 );
+
+ case SQL_DIAG_SUBCLASS_ORIGIN :
// ??? dummy
- return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow->State, -1 );
-
- default:
+ return _SQLCopyCharData ( diag, pDataPtr, pDataSize, pDataSizePtr, 16, diagrow -> State, -1 );
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDiagField called, HandleType: %d, RecNum: %d, InfoType: %d, BufLen: %d",
- pHandleType, pRecNum, pFldID, pDataSize ) );
+ pHandleType, pRecNum, pFldID, pDataSize ) );
return SQL_ERROR;
}
-
+
return SQL_SUCCESS;
}
-RETCODE SQL_API SQLGetDiagRecW ( SQLSMALLINT pHandleType,
- SQLHANDLE pHandle,
- SQLSMALLINT pRecNum,
- SQLWCHAR* pSqlstate,
- SQLINTEGER* pNativeErrorPtr,
- SQLWCHAR* pMsgTxtPtr,
- SQLSMALLINT pMsgTxtSize,
- SQLSMALLINT* pMsgTxtSizePtr ) {
+RETCODE SQL_API SQLGetDiagRecW ( SQLSMALLINT pHandleType,
+ SQLHANDLE pHandle,
+ SQLSMALLINT pRecNum,
+ SQLWCHAR* pSqlstate,
+ SQLINTEGER* pNativeErrorPtr,
+ SQLWCHAR* pMsgTxtPtr,
+ SQLSMALLINT pMsgTxtSize,
+ SQLSMALLINT* pMsgTxtSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDiagRecW called, HandleType: %d, RecNum: %d, BufLen: %d", pHandleType,
- pRecNum, pMsgTxtSize ) );
- pODBCDiag diag;
+ pRecNum, pMsgTxtSize ) );
+ pODBCDiag diag;
pODBCDiagRow diagrow;
__CHK_HANDLE ( pHandle, pHandleType, SQL_ERROR );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
- if ( !diag ) { return SQL_ERROR; }
-
+
+ if ( !diag )
+ {
+ return SQL_ERROR;
+ }
+
// now get the desired diag row
- if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL ) {
+ if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL )
+ {
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "sql no data" ) );
return SQL_NO_DATA;
}
-
+
// sql-state
- if ( pSqlstate ) {
- char2wchar ( diagrow->State, pSqlstate, -1 );
+ if ( pSqlstate )
+ {
+ char2wchar ( diagrow -> State, pSqlstate, -1 );
}
-
+
// native error code
if ( pNativeErrorPtr )
- { ( *pNativeErrorPtr ) = diagrow->NativeErrorCode; }
-
+ {
+ ( *pNativeErrorPtr ) = diagrow -> NativeErrorCode;
+ }
+
// msg
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The message is %s", diagrow->Msg ) );
- _SQLCopyWCharData ( diag, pMsgTxtPtr, pMsgTxtSize, pMsgTxtSizePtr, 16, diagrow->Msg, -1, false );
+ _SQLCopyWCharData ( diag, pMsgTxtPtr, pMsgTxtSize, pMsgTxtSizePtr, 16, diagrow -> Msg, -1, false );
// debug
//__ODBCLOG(_ODBCLogMsg(LogLevel_DEBUG,"SQLGetDiagRec msg: %s", pMsgTxtPtr ? ( StrPtr )pMsgTxtPtr : "(unknown)" ));
- RETCODE ret = ( pMsgTxtSizePtr && ( *pMsgTxtSizePtr ) > pMsgTxtSize ) ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
+ RETCODE ret = ( pMsgTxtSizePtr && ( *pMsgTxtSizePtr ) > pMsgTxtSize ) ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "The SQLGetDiagRecW return code is %d", ret ) );
return ret;
}
-
// -----------------------------------------------------------------------
// to get all details of a diag row on specified handle
// -----------------------------------------------------------------------
-RETCODE SQL_API SQLGetDiagRec ( SQLSMALLINT pHandleType,
- SQLHANDLE pHandle,
- SQLSMALLINT pRecNum,
- SQLCHAR* pSqlstate,
- SQLINTEGER* pNativeErrorPtr,
- SQLCHAR* pMsgTxtPtr,
- SQLSMALLINT pMsgTxtSize,
- SQLSMALLINT* pMsgTxtSizePtr ) {
+RETCODE SQL_API SQLGetDiagRec ( SQLSMALLINT pHandleType,
+ SQLHANDLE pHandle,
+ SQLSMALLINT pRecNum,
+ SQLCHAR* pSqlstate,
+ SQLINTEGER* pNativeErrorPtr,
+ SQLCHAR* pMsgTxtPtr,
+ SQLSMALLINT pMsgTxtSize,
+ SQLSMALLINT* pMsgTxtSizePtr )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDiagRec called, HandleType: %d, RecNum: %d, BufLen: %d", pHandleType,
- pRecNum, pMsgTxtSize ) );
- pODBCDiag diag;
+ pRecNum, pMsgTxtSize ) );
+ pODBCDiag diag;
pODBCDiagRow diagrow;
__CHK_HANDLE ( pHandle, pHandleType, SQL_ERROR );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
- if ( !diag ) { return SQL_ERROR; }
-
+
+ if ( !diag )
+ {
+ return SQL_ERROR;
+ }
+
// now get the desired diag row
if ( ( diagrow = _SQLGetDiagRowX ( diag, pRecNum ) ) == NULL )
- { return SQL_NO_DATA; }
-
+ {
+ return SQL_NO_DATA;
+ }
+
// sql-state
if ( pSqlstate )
- { strcpy ( ( char* ) pSqlstate, diagrow->State ); }
-
+ {
+ strcpy ( ( char* ) pSqlstate, diagrow -> State );
+ }
+
// native error code
if ( pNativeErrorPtr )
- { ( *pNativeErrorPtr ) = diagrow->NativeErrorCode; }
-
+ {
+ ( *pNativeErrorPtr ) = diagrow -> NativeErrorCode;
+ }
+
// msg
- _SQLCopyCharData ( diag, pMsgTxtPtr, pMsgTxtSize, pMsgTxtSizePtr, 16, diagrow->Msg, -1 );
+ _SQLCopyCharData ( diag, pMsgTxtPtr, pMsgTxtSize, pMsgTxtSizePtr, 16, diagrow -> Msg, -1 );
// debug
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "SQLGetDiagRec msg: %s", pMsgTxtPtr ? ( StrPtr ) pMsgTxtPtr : "(unknown)" ) );
return ( pMsgTxtSizePtr && ( *pMsgTxtSizePtr ) > pMsgTxtSize ) ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
@@ -510,59 +642,71 @@ RETCODE SQL_API SQLGetDiagRec ( SQLSMALLINT pHandleType,
// -----------------------------------------------------------------------
pODBCDiagRow _SQLPutDiagRow ( pODBCDiag pDiag, StrPtr pFunc, StrPtr pState, Long pNativeErrorCode,
- StrPtr pMsgArgs, va_list pArgs ) {
- Char s[4096]; // arbitary and maximum length of message
- pODBCDiagRow l;
- pODBCDiagRow r;
-
+ StrPtr pMsgArgs, va_list pArgs )
+{
+ Char s[4096]; // arbitary and maximum length of message
+ pODBCDiagRow l;
+ pODBCDiagRow r;
+
// first set the value of source function, assuming less than 64
if ( pFunc )
- { strcpy ( pDiag->Func, pFunc ); }
-
+ {
+ strcpy ( pDiag -> Func, pFunc );
+ }
+
// create message template
strcpy ( s, "[Kylin][ODBC 1.0(w) Driver]" );
-
+
// check if there is some message
if ( pMsgArgs )
- { vsprintf ( s + strlen ( s ), pMsgArgs, pArgs ); }
-
+ {
+ vsprintf ( s + strlen ( s ), pMsgArgs, pArgs );
+ }
+
else
- { strcat ( s, "(unknown)" ); }
-
+ {
+ strcat ( s, "(unknown)" );
+ }
+
// allocate a new row
r = new ODBCDiagRow;
// reset
- memset ( r, 0, sizeof ( ODBCDiagRow ) );
-
+ memset ( r, 0, sizeof ( ODBCDiagRow) );
+
// set the values for state and native error code
- if ( pState ) { strncpy ( r->State, pState, SQL_SQLSTATE_SIZE ); }
-
- r->NativeErrorCode = pNativeErrorCode;
+ if ( pState )
+ {
+ strncpy ( r -> State, pState, SQL_SQLSTATE_SIZE );
+ }
+
+ r -> NativeErrorCode = pNativeErrorCode;
// allocate space for message
- r->Msg = new Char[strlen ( s ) + 1];
- strcpy ( r->Msg, s );
+ r -> Msg = new Char[strlen ( s ) + 1];
+ strcpy ( r -> Msg, s );
// set the default row and col values
- r->Row = SQL_ROW_NUMBER_UNKNOWN;
- r->Col = SQL_COLUMN_NUMBER_UNKNOWN;
+ r -> Row = SQL_ROW_NUMBER_UNKNOWN;
+ r -> Col = SQL_COLUMN_NUMBER_UNKNOWN;
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "DiagMsg: %s", s ) );
-
+
// ATTACH TO LIST
-
+
// check for any existing rows
- if ( pDiag->DiagRows ) {
+ if ( pDiag -> DiagRows )
+ {
// iterate to last row
- for ( l = pDiag->DiagRows; l->Next != NULL; l = l->Next );
-
+ for ( l = pDiag -> DiagRows; l -> Next != NULL; l = l -> Next );
+
// attach
- l->Next = r; // next of last row
- r->Prev = l; // last row becomes the prev row of this row
+ l -> Next = r; // next of last row
+ r -> Prev = l; // last row becomes the prev row of this row
}
-
- else {
+
+ else
+ {
// make it the first row
- pDiag->DiagRows = r;
+ pDiag -> DiagRows = r;
}
-
+
return r;
}
@@ -571,19 +715,22 @@ pODBCDiagRow _SQLPutDiagRow ( pODBCDiag pDiag, StrPtr pFunc, StrPtr pState, Long
// -----------------------------------------------------------------------
eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState,
- Long pNativeErrorCode, StrPtr pMsgArgs, ... ) {
+ Long pNativeErrorCode, StrPtr pMsgArgs, ... )
+{
// note
// this implementation of function does not take row/col as param
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLPutDiagRow called, handle type is %d", pHandleType ) );
- va_list args;
- pODBCDiag diag;
- pODBCDiagRow r;
+ va_list args;
+ pODBCDiag diag;
+ pODBCDiagRow r;
__CHK_HANDLE ( pHandle, pHandleType, BAD );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
+
if ( !diag )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// get va_args
va_start ( args, pMsgArgs );
r = _SQLPutDiagRow ( diag, pFunc, pState, pNativeErrorCode, pMsgArgs, args );
@@ -596,30 +743,34 @@ eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFu
// -----------------------------------------------------------------------
eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFunc, StrPtr pState,
- Long pNativeErrorCode, Long pRow, Long pCol, StrPtr pMsgArgs, ... ) {
+ Long pNativeErrorCode, Long pRow, Long pCol, StrPtr pMsgArgs, ... )
+{
// note
// this implementation of function takes take row/col as param
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLPutDiagRow called" ) );
- va_list args;
- pODBCDiag diag;
- pODBCDiagRow r;
+ va_list args;
+ pODBCDiag diag;
+ pODBCDiagRow r;
__CHK_HANDLE ( pHandle, pHandleType, BAD );
diag = _SQLGetDiagHandle ( pHandleType, pHandle );
-
+
if ( !diag )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// get va_args
va_start ( args, pMsgArgs );
r = _SQLPutDiagRow ( diag, pFunc, pState, pNativeErrorCode, pMsgArgs, args );
va_end ( args );
-
- if ( r ) {
- r->Row = pRow;
- r->Col = pCol;
+
+ if ( r )
+ {
+ r -> Row = pRow;
+ r -> Col = pCol;
return GOOD;
}
-
+
return BAD;
}
@@ -627,32 +778,37 @@ eGoodBad _SQLPutDiagRow ( SQLSMALLINT pHandleType, SQLHANDLE pHandle, StrPtr pFu
// to free a specifed diag, plucks from parent/list AND FREEs it
// -----------------------------------------------------------------------
-eGoodBad _SQLFreeDiag ( pODBCDiag pHandle ) {
- pODBCDiagRow t;
-
+eGoodBad _SQLFreeDiag ( pODBCDiag pHandle )
+{
+ pODBCDiagRow t;
+
// check if rows r there to be freed
- while ( pHandle->DiagRows ) {
+ while ( pHandle -> DiagRows )
+ {
////// PLUCK
- t = pHandle->DiagRows;
- pHandle->DiagRows = t->Next;
-
- if ( pHandle->DiagRows )
- { ( pHandle->DiagRows )->Prev = NULL; }
-
+ t = pHandle -> DiagRows;
+ pHandle -> DiagRows = t -> Next;
+
+ if ( pHandle -> DiagRows )
+ {
+ ( pHandle -> DiagRows ) -> Prev = NULL;
+ }
+
////// PLUCKED
-
+
// free contents of row
- if ( t->Msg ) {
- delete[] t->Msg;
- t->Msg = NULL;
+ if ( t -> Msg )
+ {
+ delete[] t -> Msg;
+ t -> Msg = NULL;
}
-
+
// free the row itself
delete t;
// no rows
- pHandle->DiagRows = NULL;
+ pHandle -> DiagRows = NULL;
}
-
+
// free any other contents of the diag structure
return GOOD;
}
@@ -662,21 +818,23 @@ eGoodBad _SQLFreeDiag ( pODBCDiag pHandle ) {
// to get the diag handle out of specified handle
// -----------------------------------------------------------------------
-static pODBCDiag _SQLGetDiagHandle ( SQLSMALLINT pHandleType, SQLHANDLE pHandle ) {
+static pODBCDiag _SQLGetDiagHandle ( SQLSMALLINT pHandleType, SQLHANDLE pHandle )
+{
// first extract the diag details
- switch ( pHandleType ) {
- case SQL_HANDLE_ENV:
- return & ( ( ( pODBCEnv ) pHandle )->Diag );
-
- case SQL_HANDLE_DBC:
- return & ( ( ( pODBCConn ) pHandle )->Diag );
-
- case SQL_HANDLE_STMT:
- return & ( ( ( pODBCStmt ) pHandle )->Diag );
-
- default:
+ switch ( pHandleType )
+ {
+ case SQL_HANDLE_ENV :
+ return & ( ( ( pODBCEnv ) pHandle ) -> Diag );
+
+ case SQL_HANDLE_DBC :
+ return & ( ( ( pODBCConn ) pHandle ) -> Diag );
+
+ case SQL_HANDLE_STMT :
+ return & ( ( ( pODBCStmt ) pHandle ) -> Diag );
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "SQLGetDiagRec was called with desciptor handle" ) );
- return NULL; // ??? support for desc diag not available now
+ return NULL; // ??? support for desc diag not available now
}
}
@@ -685,13 +843,14 @@ static pODBCDiag _SQLGetDiagHandle ( SQLSMALLINT pHandleType, SQLHANDLE pHandle
// to get a specified diag row from link list
// -----------------------------------------------------------------------
-static pODBCDiagRow _SQLGetDiagRowX ( pODBCDiag pHandle, Word pRowNum ) {
- Word i;
- pODBCDiagRow r;
-
+static pODBCDiagRow _SQLGetDiagRowX ( pODBCDiag pHandle, Word pRowNum )
+{
+ Word i;
+ pODBCDiagRow r;
+
// loop to locate the specified row
- for ( i = 1, r = pHandle->DiagRows; r != NULL && i <= pRowNum && i != pRowNum; r = r->Next, i ++ );
-
+ for ( i = 1 , r = pHandle -> DiagRows; r != NULL && i <= pRowNum && i != pRowNum; r = r -> Next , i ++ );
+
// return the row or NULL as the case may be
return ( r != NULL && i == pRowNum ) ? r : NULL;
}
@@ -700,114 +859,134 @@ static pODBCDiagRow _SQLGetDiagRowX ( pODBCDiag pHandle, Word pRowNum ) {
// to show a message immmediately to a user
// -----------------------------------------------------------------------
-void _ODBCPopMsg ( const char* pMsgArgs, ... ) {
- Char s[4096]; // arbitary and maximum length of message
- va_list args;
-
+void _ODBCPopMsg ( const char* pMsgArgs, ... )
+{
+ Char s[4096]; // arbitary and maximum length of message
+ va_list args;
+
// check if there is some message
- if ( pMsgArgs ) {
+ if ( pMsgArgs )
+ {
// convert to full msg including parsed params
va_start ( args, pMsgArgs );
vsprintf ( s, pMsgArgs, args );
va_end ( args );
}
-
+
else
- { s[0] = 0; }
-
+ {
+ s[0] = 0;
+ }
+
_ODBCLogMsg ( LogLevel_FATAL, s );
- #ifdef SHIPPING
+#ifdef SHIPPING
// no thing
_ODBCLogMsg ( LogLevel_FATAL, "In Shipping mode, Skip popping up window..." );
- #else
+#else
// show as window
MessageBox ( GetDesktopWindow(), s, "Kylin ODBC Says :", MB_OK );
- #endif
+#endif
}
//pop directly
-void __ODBCPopMsg ( const char* pMsgArgs, ... ) {
- Char s[4096]; // arbitary and maximum length of message
- va_list args;
-
+void __ODBCPopMsg ( const char* pMsgArgs, ... )
+{
+ Char s[4096]; // arbitary and maximum length of message
+ va_list args;
+
// check if there is some message
- if ( pMsgArgs ) {
+ if ( pMsgArgs )
+ {
// convert to full msg including parsed params
va_start ( args, pMsgArgs );
vsprintf ( s, pMsgArgs, args );
va_end ( args );
}
-
+
else
- { s[0] = 0; }
-
- #ifdef _CONSOLE
+ {
+ s[0] = 0;
+ }
+
+#ifdef _CONSOLE
// show on console
fprintf ( stderr, s )
- #else
+#else
// show as window
- MessageBox ( GetDesktopWindow(), s, "Kylin ODBC Says:", MB_OK );
- #endif
+ MessageBox ( GetDesktopWindow (), s, "Kylin ODBC Says:", MB_OK );
+#endif
}
// -----------------------------------------------------------------------
// to start log for debugging
// -----------------------------------------------------------------------
-bool fileExist ( char* path ) {
+bool fileExist ( char* path )
+{
DWORD dwAttrib = GetFileAttributes ( path );
return ( dwAttrib != INVALID_FILE_ATTRIBUTES &&
- ! ( dwAttrib & FILE_ATTRIBUTE_DIRECTORY ) );
+ ! ( dwAttrib & FILE_ATTRIBUTE_DIRECTORY ) );
}
-void _ODBCLogStart ( void ) {
+void _ODBCLogStart ( void )
+{
OutputDebugString ( "ODBCLogStart is called\n" ); // for DBMON
- StrPtr t;
- time_t ltime;
-
+ StrPtr t;
+ time_t ltime;
+
// check if log file is open
- if ( gLogFile == -1 ) {
+ if ( gLogFile == -1 )
+ {
OutputDebugString ( "Try to init the log file\n" ); // for DBMON
-
- if ( GetFileAttributes ( "c:\\kylin" ) == INVALID_FILE_ATTRIBUTES ) {
- if ( !CreateDirectory ( "c:\\kylin", NULL ) ) {
- if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
+
+ if ( GetFileAttributes ( "c:\\kylin" ) == INVALID_FILE_ATTRIBUTES )
+ {
+ if ( !CreateDirectory ( "c:\\kylin", NULL ) )
+ {
+ if ( GetLastError () == ERROR_ALREADY_EXISTS )
+ {
// directory already exists
//good
OutputDebugString ( "Log folder already exist, ? \n" ); // for DBMON
}
-
- else {
+
+ else
+ {
// creation failed due to some other reason
OutputDebugString ( "Failed to creat log folder\n" ); // for DBMON
throw;
}
}
}
-
- else {
+
+ else
+ {
OutputDebugString ( "Log folder already exist\n" ); // for DBMON
}
-
+
bool debugMode = fileExist ( "c:\\kylin\\debug" ) || fileExist ( "c:\\kylin\\debug.txt" );
-
- if ( debugMode ) {
+
+ if ( debugMode )
+ {
currentLogLevel = LogLevel_DEBUG;
OutputDebugString ( "Debug mode is on" ); // for DBMON
}
-
+
OutputDebugString ( "Try to open log file\n" ); // for DBMON
- time_t now = time ( 0 );
- struct tm tstruct;
+ time_t now = time ( 0 );
+ struct tm tstruct;
char buffer[100];
tstruct = *localtime ( &now );
strftime ( buffer, 100, "%Y-%m-%d.%X", &tstruct );
-
- for ( unsigned int i = 0 ; i < strlen ( buffer ); i++ ) {
+
+ for ( unsigned int i = 0; i < strlen ( buffer ); i++ )
+ {
if ( buffer[i] == '.' || buffer[i] == ':' )
- { buffer[i] = '-'; }
+ {
+ buffer[i] = '-';
+ }
}
-
+
char file[256];
file[0] = '\0';
strcat ( file, "c:\\kylin\\odbc-" );
@@ -816,15 +995,17 @@ void _ODBCLogStart ( void ) {
printf ( file );
gLogFile = _open ( file, _O_CREAT | _O_APPEND | _O_RDWR, _S_IWRITE );
OutputDebugString ( "Finish to open log file\n" ); // for DBMON
-
- if ( gLogFile == -1 ) {
+
+ if ( gLogFile == -1 )
+ {
OutputDebugString ( "Open Log file failed.\n" ); // for DBMON
}
-
- else {
+
+ else
+ {
OutputDebugString ( "Open Log file succeed, logs are written to log file now.\n" ); // for DBMON
}
-
+
// set the log start time
time ( <ime );
t = ctime ( <ime );
@@ -834,12 +1015,15 @@ void _ODBCLogStart ( void ) {
//if(t!=NULL)
//delete[] t;
}
-
+
// check if file opened succesfully
if ( gLogFile != -1 )
- { ++ gLogUsage; } // increment log usage
-
- else {
+ {
+ ++ gLogUsage;
+ } // increment log usage
+
+ else
+ {
__ODBCPOPMSG ( ( __ODBCPopMsg ( "Log failed" ) ) );
}
}
@@ -848,19 +1032,22 @@ void _ODBCLogStart ( void ) {
// to stop log
// -----------------------------------------------------------------------
-void _ODBCLogStop ( int pForce ) {
- StrPtr t;
- time_t ltime;
-
+void _ODBCLogStop ( int pForce )
+{
+ StrPtr t;
+ time_t ltime;
+
// check if log file is being used
- if ( gLogUsage > 0 ) {
+ if ( gLogUsage > 0 )
+ {
// decrement log usage
-- gLogUsage;
// commit
_commit ( gLogFile );
-
+
// check if log needs to be closed
- if ( gLogUsage == 0 || pForce == 1 ) {
+ if ( gLogUsage == 0 || pForce == 1 )
+ {
// set the log start time
time ( <ime );
t = ctime ( <ime );
@@ -878,76 +1065,79 @@ void _ODBCLogStop ( int pForce ) {
// --------------------------------------------------------------------
// log a specified message
// --------------------------------------------------------------------
-void _ODBCLogMsg ( LogLevel level , const wchar_t* textW ) {
- unique_ptr<char[]> p ( wchar2char ( textW ) );
- _ODBCLogMsg ( level, p.get() );
+void _ODBCLogMsg ( LogLevel level, const wchar_t* textW )
+{
+ unique_ptr <char[]> p ( wchar2char ( textW ) );
+ _ODBCLogMsg ( level, p . get () );
}
-void _ODBCLogMsg ( LogLevel level, const char* pMsgArgs, ... ) {
- if ( level < currentLogLevel ) {
+void _ODBCLogMsg ( LogLevel level, const char* pMsgArgs, ... )
+{
+ if ( level < currentLogLevel )
+ {
return;//skip
}
-
- Char s[4096]; // arbitary and maximum length of message
- va_list args;
-
+
+ Char s[4096]; // arbitary and maximum length of message
+ va_list args;
+
// check if there is a log file
- if ( gLogFile != -1 ) {
- switch ( level ) {
- case LogLevel_DEBUG:
+ if ( gLogFile != -1 )
+ {
+ switch ( level )
+ {
+ case LogLevel_DEBUG :
_write ( gLogFile, "[DEBUG]", 7 );
break;
-
- case LogLevel_INFO:
+
+ case LogLevel_INFO :
_write ( gLogFile, "[INFO ]", 7 );
break;
-
- case LogLevel_WARN:
+
+ case LogLevel_WARN :
_write ( gLogFile, "[WARN ]", 7 );
break;
-
- case LogLevel_ERROR:
+
+ case LogLevel_ERROR :
_write ( gLogFile, "[ERROR]", 7 );
break;
-
- case LogLevel_FATAL:
+
+ case LogLevel_FATAL :
_write ( gLogFile, "[FATAL]", 7 );
break;
-
- default:
+
+ default :
break;
}
-
- time_t now = time ( 0 );
- struct tm tstruct;
+
+ time_t now = time ( 0 );
+ struct tm tstruct;
char buffer[100];
tstruct = *localtime ( &now );
strftime ( buffer, 100, "%Y-%m-%d.%X", &tstruct );
_write ( gLogFile, "[", 1 );
_write ( gLogFile, buffer, strlen ( buffer ) );
_write ( gLogFile, "]", 1 );
-
+
// MSG PARSING
-
+
// check if there is some message
- if ( pMsgArgs ) {
+ if ( pMsgArgs )
+ {
// convert to full msg including parsed params
va_start ( args, pMsgArgs );
vsprintf ( s, pMsgArgs, args );
va_end ( args );
}
-
+
else
- { s[0] = 0; }
-
+ {
+ s[0] = 0;
+ }
+
// LOG
_write ( gLogFile, s, strlen ( s ) );
_write ( gLogFile, "\n", 1 );
}
}
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/kylin/blob/3c2329dc/odbc/Driver/KO_DTYPE.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_DTYPE.CPP b/odbc/Driver/KO_DTYPE.CPP
index 62d6ee9..851fe70 100644
--- a/odbc/Driver/KO_DTYPE.CPP
+++ b/odbc/Driver/KO_DTYPE.CPP
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
// ----------------------------------------------------------------------------
//
@@ -47,47 +47,49 @@
// ---------------------- function prototypes --------------------------
-eGoodBad _SQLCheckDataType ( Word pDataType );
-eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode );
-eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* pVerboseDataType,
- Word* pConciseDataType, Word* pDateTimeIntervalCode );
-eGoodBad GetIRDDataTypeDefaults ( CStrPtr pDataType, Word* pSqlDataType, Word* pNativeDataType,
- Word* pPrecision, Word* pScale, Long* pLength, Long* pRadix );
+eGoodBad _SQLCheckDataType ( Word pDataType );
+eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode );
+eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* pVerboseDataType,
+ Word* pConciseDataType, Word* pDateTimeIntervalCode );
+eGoodBad GetIRDDataTypeDefaults ( CStrPtr pDataType, Word* pSqlDataType, Word* pNativeDataType,
+ Word* pPrecision, Word* pScale, Long* pLength, Long* pRadix );
// -----------------------------------------------------------------------
// to check if the specified type is a valid SQL data type
// -----------------------------------------------------------------------
-eGoodBad _SQLCheckDataType ( Word pDataType ) {
- switch ( pDataType ) {
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_WCHAR:
- case SQL_WVARCHAR:
- case SQL_C_SSHORT:
- case SQL_C_USHORT:
- case SQL_SMALLINT:
- case SQL_C_SLONG:
- case SQL_C_ULONG:
- case SQL_INTEGER:
- case SQL_NUMERIC:
- case SQL_DECIMAL:
- case SQL_FLOAT:
- case SQL_REAL:
- case SQL_DOUBLE:
- case SQL_TYPE_DATE:
- case SQL_TYPE_TIME:
- case SQL_TYPE_TIMESTAMP:
- case SQL_BIT:
- case SQL_DEFAULT:
- case SQL_C_SBIGINT :
+eGoodBad _SQLCheckDataType ( Word pDataType )
+{
+ switch ( pDataType )
+ {
+ case SQL_CHAR :
+ case SQL_VARCHAR :
+ case SQL_WCHAR :
+ case SQL_WVARCHAR :
+ case SQL_C_SSHORT :
+ case SQL_C_USHORT :
+ case SQL_SMALLINT :
+ case SQL_C_SLONG :
+ case SQL_C_ULONG :
+ case SQL_INTEGER :
+ case SQL_NUMERIC :
+ case SQL_DECIMAL :
+ case SQL_FLOAT :
+ case SQL_REAL :
+ case SQL_DOUBLE :
+ case SQL_TYPE_DATE :
+ case SQL_TYPE_TIME :
+ case SQL_TYPE_TIMESTAMP :
+ case SQL_BIT :
+ case SQL_DEFAULT :
+ case SQL_C_SBIGINT :
case SQL_C_UBIGINT :
- case SQL_C_TINYINT :
+ case SQL_C_TINYINT :
case SQL_C_STINYINT :
case SQL_C_UTINYINT :
return GOOD;
-
- default:
+
+ default :
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLCheckDataType: Unknown data type: %d", pDataType ) );
return BAD;
}
@@ -98,7 +100,8 @@ eGoodBad _SQLCheckDataType ( Word pDataType ) {
// to check if the specified type is a valid interval code
// -----------------------------------------------------------------------
-eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode ) {
+eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode )
+{
// can check the interval code
return GOOD;
}
@@ -109,7 +112,8 @@ eGoodBad _SQLCheckIntervalCode ( Word pIntervalCode ) {
// -----------------------------------------------------------------------
eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* pVerboseDataType,
- Word* pConciseDataType, Word* pDateTimeIntervalCode ) {
+ Word* pConciseDataType, Word* pDateTimeIntervalCode )
+{
__ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "_SQLSetDataType is called, pFldID:%d, pFldValue:%d", pFldID, pFldValue ) );
// note
// the data type, concise data type, datetime interval code r interdependent
@@ -118,253 +122,276 @@ eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* p
Word verbose_type;
Word datetime_interval;
// initial values
- concise_type = pConciseDataType ? *pConciseDataType : 0;
- verbose_type = pVerboseDataType ? *pVerboseDataType : 0;
- datetime_interval = pDateTimeIntervalCode ? *pDateTimeIntervalCode : 0;
-
+ concise_type = pConciseDataType ? *pConciseDataType : 0;
+ verbose_type = pVerboseDataType ? *pVerboseDataType : 0;
+ datetime_interval = pDateTimeIntervalCode ? *pDateTimeIntervalCode : 0;
+
// check if concise type has been specified
- if ( pFldID == SQL_DESC_CONCISE_TYPE ) {
+ if ( pFldID == SQL_DESC_CONCISE_TYPE )
+ {
// set the concise type itself first
concise_type = pFldValue;
-
+
// based on concise type set the verbose type and datetime interval
- switch ( concise_type ) {
- case SQL_TYPE_DATE:
+ switch ( concise_type )
+ {
+ case SQL_TYPE_DATE :
//case SQL_C_TYPE_DATE:
- verbose_type = SQL_DATETIME;
- datetime_interval = SQL_CODE_DATE;
+ verbose_type = SQL_DATETIME;
+ datetime_interval = SQL_CODE_DATE;
break;
-
- case SQL_TYPE_TIME:
+
+ case SQL_TYPE_TIME :
//case SQL_C_TYPE_TIME:
- verbose_type = SQL_DATETIME;
- datetime_interval = SQL_CODE_TIME;
+ verbose_type = SQL_DATETIME;
+ datetime_interval = SQL_CODE_TIME;
break;
-
- case SQL_TYPE_TIMESTAMP:
+
+ case SQL_TYPE_TIMESTAMP :
//case SQL_C_TYPE_TIMESTAMP:
- verbose_type = SQL_DATETIME;
- datetime_interval = SQL_CODE_TIMESTAMP;
+ verbose_type = SQL_DATETIME;
+ datetime_interval = SQL_CODE_TIMESTAMP;
break;
-
- case SQL_INTERVAL_MONTH:
+
+ case SQL_INTERVAL_MONTH :
//case SQL_C_INTERVAL_MONTH:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_MONTH;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_MONTH;
break;
-
- case SQL_INTERVAL_YEAR:
+
+ case SQL_INTERVAL_YEAR :
//case SQL_C_INTERVAL_YEAR:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_YEAR;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_YEAR;
break;
-
- case SQL_INTERVAL_YEAR_TO_MONTH:
+
+ case SQL_INTERVAL_YEAR_TO_MONTH :
//case SQL_C_INTERVAL_YEAR_TO_MONTH:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_YEAR_TO_MONTH;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_YEAR_TO_MONTH;
break;
-
- case SQL_INTERVAL_DAY:
+
+ case SQL_INTERVAL_DAY :
//case SQL_C_INTERVAL_DAY:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_DAY;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_DAY;
break;
-
- case SQL_INTERVAL_HOUR:
+
+ case SQL_INTERVAL_HOUR :
//case SQL_C_INTERVAL_HOUR:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_HOUR;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_HOUR;
break;
-
- case SQL_INTERVAL_MINUTE:
+
+ case SQL_INTERVAL_MINUTE :
//case SQL_C_INTERVAL_MINUTE:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_MINUTE;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_MINUTE;
break;
-
- case SQL_INTERVAL_SECOND:
+
+ case SQL_INTERVAL_SECOND :
//case SQL_C_INTERVAL_SECOND:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_SECOND;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_SECOND;
break;
-
- case SQL_INTERVAL_DAY_TO_HOUR:
+
+ case SQL_INTERVAL_DAY_TO_HOUR :
//case SQL_C_INTERVAL_DAY_TOHOUR:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_DAY_TO_HOUR;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_DAY_TO_HOUR;
break;
-
- case SQL_INTERVAL_DAY_TO_MINUTE:
+
+ case SQL_INTERVAL_DAY_TO_MINUTE :
//case SQL_C_INTERVAL_DAY_TO_MINUTE:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_DAY_TO_MINUTE;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_DAY_TO_MINUTE;
break;
-
- case SQL_INTERVAL_DAY_TO_SECOND:
+
+ case SQL_INTERVAL_DAY_TO_SECOND :
//case SQL_C_INTERVAL_DAY_TO_SECOND:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_DAY_TO_SECOND;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_DAY_TO_SECOND;
break;
-
- case SQL_INTERVAL_HOUR_TO_MINUTE:
+
+ case SQL_INTERVAL_HOUR_TO_MINUTE :
//case SQL_C_INTERVAL_HOUR_TO_MINUTE:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_HOUR_TO_MINUTE;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_HOUR_TO_MINUTE;
break;
-
- case SQL_INTERVAL_HOUR_TO_SECOND:
+
+ case SQL_INTERVAL_HOUR_TO_SECOND :
//case SQL_C_INTERVAL_HOUR_TO_SECOND:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_HOUR_TO_SECOND;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_HOUR_TO_SECOND;
break;
-
- case SQL_INTERVAL_MINUTE_TO_SECOND:
+
+ case SQL_INTERVAL_MINUTE_TO_SECOND :
//case SQL_C_INTERVAL_MINUTE_TO_SECOND:
- verbose_type = SQL_INTERVAL;
- datetime_interval = SQL_CODE_MINUTE_TO_SECOND;
+ verbose_type = SQL_INTERVAL;
+ datetime_interval = SQL_CODE_MINUTE_TO_SECOND;
break;
-
- default:
-
+
+ default :
+
// check if data type if valid
if ( _SQLCheckDataType ( concise_type ) != GOOD )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// concise type does not relate to datetime or interval
// hence both concise and verbose type r equal
- verbose_type = concise_type;
- datetime_interval = 0;
+ verbose_type = concise_type;
+ datetime_interval = 0;
}
}
-
+
// check if verbose data type is being set
- else if ( pFldID == SQL_DESC_TYPE ) {
+ else if ( pFldID == SQL_DESC_TYPE )
+ {
// set the verbose type itself first
verbose_type = pFldValue;
-
+
// based on verbose type & datetime interval code determine concise type
- switch ( verbose_type ) {
- case SQL_INTERVAL:
- switch ( datetime_interval ) {
- case SQL_CODE_DATE:
+ switch ( verbose_type )
+ {
+ case SQL_INTERVAL :
+ switch ( datetime_interval )
+ {
+ case SQL_CODE_DATE :
concise_type = SQL_TYPE_DATE;
break;
-
- case SQL_CODE_TIME:
+
+ case SQL_CODE_TIME :
concise_type = SQL_TYPE_TIME;
break;
-
- case SQL_CODE_TIMESTAMP:
+
+ case SQL_CODE_TIMESTAMP :
concise_type = SQL_TYPE_TIMESTAMP;
break;
-
- default:
+
+ default :
// interval should have been set
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetDataType: Interval code not yet set for SQL_INTERVAL" ) );
return BAD;
}
-
+
break;
-
- case SQL_DATETIME:
- switch ( datetime_interval ) {
- case SQL_CODE_MONTH:
+
+ case SQL_DATETIME :
+ switch ( datetime_interval )
+ {
+ case SQL_CODE_MONTH :
concise_type = SQL_INTERVAL_MONTH;
break;
-
- case SQL_CODE_YEAR:
+
+ case SQL_CODE_YEAR :
concise_type = SQL_INTERVAL_YEAR;
break;
-
- case SQL_CODE_YEAR_TO_MONTH:
+
+ case SQL_CODE_YEAR_TO_MONTH :
concise_type = SQL_INTERVAL_YEAR_TO_MONTH;
break;
-
- case SQL_CODE_DAY:
+
+ case SQL_CODE_DAY :
concise_type = SQL_INTERVAL_DAY;
break;
-
- case SQL_CODE_HOUR:
+
+ case SQL_CODE_HOUR :
concise_type = SQL_INTERVAL_HOUR;
break;
-
- case SQL_CODE_MINUTE:
+
+ case SQL_CODE_MINUTE :
concise_type = SQL_INTERVAL_MINUTE;
break;
-
- case SQL_CODE_SECOND:
+
+ case SQL_CODE_SECOND :
concise_type = SQL_INTERVAL_SECOND;
break;
-
- case SQL_CODE_DAY_TO_HOUR:
+
+ case SQL_CODE_DAY_TO_HOUR :
concise_type = SQL_INTERVAL_DAY_TO_HOUR;
break;
-
- case SQL_CODE_DAY_TO_MINUTE:
+
+ case SQL_CODE_DAY_TO_MINUTE :
concise_type = SQL_INTERVAL_DAY_TO_MINUTE;
break;
-
- case SQL_CODE_DAY_TO_SECOND:
+
+ case SQL_CODE_DAY_TO_SECOND :
concise_type = SQL_INTERVAL_DAY_TO_SECOND;
break;
-
- case SQL_CODE_HOUR_TO_MINUTE:
+
+ case SQL_CODE_HOUR_TO_MINUTE :
concise_type = SQL_INTERVAL_HOUR_TO_MINUTE;
break;
-
- case SQL_CODE_HOUR_TO_SECOND:
+
+ case SQL_CODE_HOUR_TO_SECOND :
concise_type = SQL_INTERVAL_HOUR_TO_SECOND;
break;
-
- case SQL_CODE_MINUTE_TO_SECOND:
+
+ case SQL_CODE_MINUTE_TO_SECOND :
concise_type = SQL_INTERVAL_MINUTE_TO_SECOND;
break;
-
- default:
+
+ default :
// interval should have been set
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetDataType: Interval code not yet set for SQL_DATETIME" ) );
return BAD;
}
-
+
break;
-
- default:
-
+
+ default :
+
// check if data type if valid
if ( _SQLCheckDataType ( verbose_type ) != GOOD )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// verbose type does not relate to datetime or interval
// hence both concise and verbose type r equal
- concise_type = verbose_type;
- datetime_interval = 0;
+ concise_type = verbose_type;
+ datetime_interval = 0;
break;
}
}
-
- else if ( pFldID == SQL_DESC_DATETIME_INTERVAL_CODE ) {
+
+ else if ( pFldID == SQL_DESC_DATETIME_INTERVAL_CODE )
+ {
// check if date interval code is valid
if ( _SQLCheckIntervalCode ( pFldValue ) != GOOD )
- { return BAD; }
-
+ {
+ return BAD;
+ }
+
// set the datetime interval code, autonomously
datetime_interval = pFldValue;
}
-
+
// unknown field to set
- else {
+ else
+ {
__ODBCPOPMSG ( _ODBCPopMsg ( "_SQLSetDataType: Unknown field type" ) );
return BAD;
}
-
+
// pass back values to caller
- if ( pVerboseDataType ) { *pVerboseDataType = verbose_type; }
-
- if ( pConciseDataType ) { *pConciseDataType = concise_type; }
-
- if ( pDateTimeIntervalCode ) { *pDateTimeIntervalCode = datetime_interval; }
-
+ if ( pVerboseDataType )
+ {
+ *pVerboseDataType = verbose_type;
+ }
+
+ if ( pConciseDataType )
+ {
+ *pConciseDataType = concise_type;
+ }
+
+ if ( pDateTimeIntervalCode )
+ {
+ *pDateTimeIntervalCode = datetime_interval;
+ }
+
return GOOD;
}
@@ -373,7 +400,8 @@ eGoodBad _SQLSetDataType ( pODBCDiag pDiag, Word pFldID, Word pFldValue, Word* p
// -----------------------------------------------------------------------
eGoodBad GetIRDDataTypeDefaults ( CStrPtr pDataType, Word* pSqlDataType, Word* pNativeDataType, Word* pPrecision,
- Word* pScale, Long* pLength, Long* pRadix ) {
+ Word* pScale, Long* pLength, Long* pRadix )
+{
return BAD;
}