You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/03/17 11:53:23 UTC
[1/5] ignite git commit: IGNITE-2557: Added tests.
Repository: ignite
Updated Branches:
refs/heads/ignite-1786 929189111 -> 075ab6fbd
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/utility.cpp b/modules/platforms/cpp/odbc/src/utility.cpp
index 1c88e7a..b33b742 100644
--- a/modules/platforms/cpp/odbc/src/utility.cpp
+++ b/modules/platforms/cpp/odbc/src/utility.cpp
@@ -22,6 +22,20 @@
#include "ignite/odbc/utility.h"
#include "ignite/odbc/system/odbc_constants.h"
+#ifdef ODBC_DEBUG
+
+FILE* log_file = NULL;
+
+void logInit(const char* path)
+{
+ if (!log_file)
+ {
+ log_file = fopen(path, "w");
+ }
+}
+
+#endif //ODBC_DEBUG
+
namespace ignite
{
namespace utility
@@ -84,6 +98,17 @@ namespace ignite
swap(decimal, res);
}
+ void WriteDecimal(ignite::impl::binary::BinaryWriterImpl& writer, const Decimal& decimal)
+ {
+ writer.WriteInt8(ignite::impl::binary::IGNITE_TYPE_DECIMAL);
+
+ writer.WriteInt32(decimal.GetScale() | (decimal.IsNegative() ? 0x80000000 : 0));
+
+ writer.WriteInt32(decimal.GetLength());
+
+ impl::binary::BinaryUtils::WriteInt8Array(writer.GetStream(), decimal.GetMagnitude(), decimal.GetLength());
+ }
+
std::string SqlStringToString(const unsigned char* sqlStr, int32_t sqlStrLen)
{
std::string res;
[3/5] ignite git commit: IGNITE-2557: Added tests.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/entry_points.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/entry_points.cpp b/modules/platforms/cpp/odbc/src/entry_points.cpp
new file mode 100644
index 0000000..c8e78a5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/entry_points.cpp
@@ -0,0 +1,694 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/odbc.h"
+
+#include "ignite/odbc/utility.h"
+
+BOOL INSTAPI ConfigDSN(HWND hwndParent,
+ WORD req,
+ LPCSTR driver,
+ LPCSTR attributes)
+{
+ return ignite::ConfigDSN(hwndParent, req, driver, attributes);
+}
+
+SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
+ SQLUSMALLINT infoType,
+ SQLPOINTER infoValue,
+ SQLSMALLINT infoValueMax,
+ SQLSMALLINT* length)
+{
+ return ignite::SQLGetInfo(conn, infoType, infoValue, infoValueMax, length);
+}
+
+SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
+{
+ return ignite::SQLAllocHandle(type, parent, result);
+}
+
+SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env)
+{
+ return ignite::SQLAllocEnv(env);
+}
+
+SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn)
+{
+ return ignite::SQLAllocConnect(env, conn);
+}
+
+SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt)
+{
+ return ignite::SQLAllocStmt(conn, stmt);
+}
+
+SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle)
+{
+ return ignite::SQLFreeHandle(type, handle);
+}
+
+SQLRETURN SQL_API SQLFreeEnv(SQLHENV env)
+{
+ return ignite::SQLFreeEnv(env);
+}
+
+SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn)
+{
+ return ignite::SQLFreeConnect(conn);
+}
+
+SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
+{
+ return ignite::SQLFreeStmt(stmt, option);
+}
+
+SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt)
+{
+ return ignite::SQLCloseCursor(stmt);
+}
+
+SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn,
+ SQLHWND windowHandle,
+ SQLCHAR* inConnectionString,
+ SQLSMALLINT inConnectionStringLen,
+ SQLCHAR* outConnectionString,
+ SQLSMALLINT outConnectionStringBufferLen,
+ SQLSMALLINT* outConnectionStringLen,
+ SQLUSMALLINT driverCompletion)
+{
+ return ignite::SQLDriverConnect(conn, windowHandle, inConnectionString,
+ inConnectionStringLen, outConnectionString, outConnectionStringBufferLen,
+ outConnectionStringLen, driverCompletion);
+}
+
+SQLRETURN SQL_API SQLConnect(SQLHDBC conn,
+ SQLCHAR* serverName,
+ SQLSMALLINT serverNameLen,
+ SQLCHAR* userName,
+ SQLSMALLINT userNameLen,
+ SQLCHAR* auth,
+ SQLSMALLINT authLen)
+{
+ return ignite::SQLConnect(conn, serverName, serverNameLen,
+ userName, userNameLen, auth, authLen);
+}
+
+SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn)
+{
+ return ignite::SQLDisconnect(conn);
+}
+
+SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+{
+ return ignite::SQLPrepare(stmt, query, queryLen);
+}
+
+SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt)
+{
+ return ignite::SQLExecute(stmt);
+}
+
+SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+{
+ return ignite::SQLExecDirect(stmt, query, queryLen);
+}
+
+SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+{
+ return ignite::SQLBindCol(stmt, colNum, targetType,
+ targetValue, bufferLength, strLengthOrIndicator);
+}
+
+SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt)
+{
+ return ignite::SQLFetch(stmt);
+}
+
+SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt,
+ SQLSMALLINT orientation,
+ SQLLEN offset)
+{
+ return ignite::SQLFetchScroll(stmt, orientation, offset);
+}
+
+SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt,
+ SQLUSMALLINT orientation,
+ SQLLEN offset,
+ SQLULEN* rowCount,
+ SQLUSMALLINT* rowStatusArray)
+{
+ return ignite::SQLExtendedFetch(stmt, orientation,
+ offset, rowCount, rowStatusArray);
+}
+
+SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum)
+{
+ return ignite::SQLNumResultCols(stmt, columnNum);
+}
+
+SQLRETURN SQL_API SQLTables(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* tableType,
+ SQLSMALLINT tableTypeLen)
+{
+ return ignite::SQLTables(stmt, catalogName, catalogNameLen,
+ schemaName, schemaNameLen, tableName, tableNameLen,
+ tableType, tableTypeLen);
+}
+
+SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen)
+{
+ return ignite::SQLColumns(stmt, catalogName, catalogNameLen, schemaName,
+ schemaNameLen, tableName, tableNameLen, columnName, columnNameLen);
+}
+
+SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt)
+{
+ return ignite::SQLMoreResults(stmt);
+}
+
+SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt,
+ SQLUSMALLINT paramIdx,
+ SQLSMALLINT ioType,
+ SQLSMALLINT bufferType,
+ SQLSMALLINT paramSqlType,
+ SQLULEN columnSize,
+ SQLSMALLINT decDigits,
+ SQLPOINTER buffer,
+ SQLLEN bufferLen,
+ SQLLEN* resLen)
+{
+ return ignite::SQLBindParameter(stmt, paramIdx, ioType,
+ bufferType, paramSqlType, columnSize, decDigits,
+ buffer, bufferLen, resLen);
+}
+
+SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn,
+ SQLCHAR* inQuery,
+ SQLINTEGER inQueryLen,
+ SQLCHAR* outQueryBuffer,
+ SQLINTEGER outQueryBufferLen,
+ SQLINTEGER* outQueryLen)
+{
+ return ignite::SQLNativeSql(conn, inQuery, inQueryLen,
+ outQueryBuffer, outQueryBufferLen, outQueryLen);
+}
+
+SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttr,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* strAttrLen,
+ SQLLEN* numericAttr)
+{
+ return ignite::SQLColAttribute(stmt, columnNum, fieldId,
+ strAttr, bufferLen, strAttrLen, numericAttr);
+}
+
+SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLCHAR* columnNameBuf,
+ SQLSMALLINT columnNameBufLen,
+ SQLSMALLINT* columnNameLen,
+ SQLSMALLINT* dataType,
+ SQLULEN* columnSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable)
+{
+ return ignite::SQLDescribeCol(stmt, columnNum, columnNameBuf,
+ columnNameBufLen, columnNameLen, dataType, columnSize,
+ decimalDigits, nullable);
+}
+
+
+SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt)
+{
+ return ignite::SQLRowCount(stmt, rowCnt);
+}
+
+SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt,
+ SQLCHAR* primaryCatalogName,
+ SQLSMALLINT primaryCatalogNameLen,
+ SQLCHAR* primarySchemaName,
+ SQLSMALLINT primarySchemaNameLen,
+ SQLCHAR* primaryTableName,
+ SQLSMALLINT primaryTableNameLen,
+ SQLCHAR* foreignCatalogName,
+ SQLSMALLINT foreignCatalogNameLen,
+ SQLCHAR* foreignSchemaName,
+ SQLSMALLINT foreignSchemaNameLen,
+ SQLCHAR* foreignTableName,
+ SQLSMALLINT foreignTableNameLen)
+{
+ return ignite::SQLForeignKeys(stmt, primaryCatalogName,
+ primaryCatalogNameLen, primarySchemaName, primarySchemaNameLen,
+ primaryTableName, primaryTableNameLen, foreignCatalogName,
+ foreignCatalogNameLen, foreignSchemaName, foreignSchemaNameLen,
+ foreignTableName, foreignTableNameLen);
+}
+
+SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ return ignite::SQLGetStmtAttr(stmt, attr, valueBuf, valueBufLen, valueResLen);
+}
+
+SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ return ignite::SQLSetStmtAttr(stmt, attr, value, valueLen);
+}
+
+SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ return ignite::SQLPrimaryKeys(stmt, catalogName, catalogNameLen,
+ schemaName, schemaNameLen, tableName, tableNameLen);
+}
+
+SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
+{
+ return ignite::SQLNumParams(stmt, paramCnt);
+}
+
+SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLSMALLINT diagId,
+ SQLPOINTER buffer,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* resLen)
+{
+ return ignite::SQLGetDiagField(handleType, handle,
+ recNum, diagId, buffer, bufferLen, resLen);
+}
+
+SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLCHAR* sqlState,
+ SQLINTEGER* nativeError,
+ SQLCHAR* msgBuffer,
+ SQLSMALLINT msgBufferLen,
+ SQLSMALLINT* msgLen)
+{
+ return ignite::SQLGetDiagRec(handleType, handle, recNum,
+ sqlState, nativeError, msgBuffer, msgBufferLen, msgLen);
+}
+
+SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT type)
+{
+ return ignite::SQLGetTypeInfo(stmt, type);
+}
+
+SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT completionType)
+{
+ return ignite::SQLEndTran(handleType, handle, completionType);
+}
+
+SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+{
+ return ignite::SQLGetData(stmt, colNum, targetType,
+ targetValue, bufferLength, strLengthOrIndicator);
+}
+
+SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ return ignite::SQLSetEnvAttr(env, attr, value, valueLen);
+}
+
+SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ return ignite::SQLGetEnvAttr(env, attr,
+ valueBuf, valueBufLen, valueResLen);
+}
+
+SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt,
+ SQLSMALLINT idType,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLSMALLINT scope,
+ SQLSMALLINT nullable)
+{
+ return ignite::SQLSpecialColumns(stmt, idType, catalogName,
+ catalogNameLen, schemaName, schemaNameLen, tableName,
+ tableNameLen, scope, nullable);
+}
+
+//
+// ==== Not implemented ====
+//
+
+SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt)
+{
+ LOG_MSG("SQLCancel called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttrBuf,
+ SQLSMALLINT strAttrBufLen,
+ SQLSMALLINT* strAttrResLen,
+ SQLLEN* numAttrBuf)
+{
+ LOG_MSG("SQLColAttributes called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLError(SQLHENV env,
+ SQLHDBC conn,
+ SQLHSTMT stmt,
+ SQLCHAR* state,
+ SQLINTEGER* error,
+ SQLCHAR* msgBuf,
+ SQLSMALLINT msgBufLen,
+ SQLSMALLINT* msgResLen)
+{
+ LOG_MSG("SQLError called\n");
+ return SQL_ERROR;
+}
+
+SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt,
+ SQLCHAR* nameBuf,
+ SQLSMALLINT nameBufLen,
+ SQLSMALLINT* nameResLen)
+{
+ LOG_MSG("SQLGetCursorName called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt,
+ SQLCHAR* name,
+ SQLSMALLINT nameLen)
+{
+ LOG_MSG("SQLSetCursorName called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC conn,
+ SQLUSMALLINT option,
+ SQLPOINTER value)
+{
+ LOG_MSG("SQLGetConnectOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt,
+ SQLUSMALLINT option,
+ SQLPOINTER value)
+{
+ LOG_MSG("SQLGetStmtOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt,
+ SQLPOINTER* value)
+{
+ LOG_MSG("SQLParamData called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt,
+ SQLPOINTER data,
+ SQLLEN strLengthOrIndicator)
+{
+ LOG_MSG("SQLPutData called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC conn,
+ SQLUSMALLINT option,
+ SQLULEN value)
+{
+ LOG_MSG("SQLSetConnectOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt,
+ SQLUSMALLINT option,
+ SQLULEN value)
+{
+ LOG_MSG("SQLSetStmtOption called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLUSMALLINT unique,
+ SQLUSMALLINT reserved)
+{
+ LOG_MSG("SQLStatistics called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC conn,
+ SQLCHAR* inConnectionStr,
+ SQLSMALLINT inConnectionStrLen,
+ SQLCHAR* outConnectionStrBuf,
+ SQLSMALLINT outConnectionStrBufLen,
+ SQLSMALLINT* outConnectionStrResLen)
+{
+ LOG_MSG("SQLBrowseConnect called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt,
+ SQLCHAR * catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR * schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR * procName,
+ SQLSMALLINT procNameLen,
+ SQLCHAR * columnName,
+ SQLSMALLINT columnNameLen)
+{
+ LOG_MSG("SQLProcedureColumns called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt,
+ SQLSETPOSIROW rowNum,
+ SQLUSMALLINT operation,
+ SQLUSMALLINT lockType)
+{
+ LOG_MSG("SQLSetPos called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt,
+ SQLUSMALLINT concurrency,
+ SQLLEN crowKeyset,
+ SQLUSMALLINT crowRowset)
+{
+ LOG_MSG("SQLSetScrollOptions called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+{
+ LOG_MSG("SQLGetConnectAttr called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+{
+ LOG_MSG("SQLSetConnectAttr called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt,
+ SQLUSMALLINT operation)
+{
+ LOG_MSG("SQLBulkOperations called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ LOG_MSG("SQLTablePrivileges called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLCopyDesc(SQLHDESC src, SQLHDESC dst)
+{
+ LOG_MSG("SQLCopyDesc called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetDescField(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT fieldId,
+ SQLPOINTER buffer,
+ SQLINTEGER bufferLen,
+ SQLINTEGER* resLen)
+{
+ LOG_MSG("SQLGetDescField called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
+ SQLSMALLINT RecNumber,
+ SQLCHAR* nameBuffer,
+ SQLSMALLINT nameBufferLen,
+ SQLSMALLINT* strLen,
+ SQLSMALLINT* type,
+ SQLSMALLINT* subType,
+ SQLLEN* len,
+ SQLSMALLINT* precision,
+ SQLSMALLINT* scale,
+ SQLSMALLINT* nullable)
+{
+ LOG_MSG("SQLGetDescRec called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetDescField(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT fieldId,
+ SQLPOINTER buffer,
+ SQLINTEGER bufferLen)
+{
+ LOG_MSG("SQLSetDescField called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLSetDescRec(SQLHDESC descr,
+ SQLSMALLINT recNum,
+ SQLSMALLINT type,
+ SQLSMALLINT subType,
+ SQLLEN len,
+ SQLSMALLINT precision,
+ SQLSMALLINT scale,
+ SQLPOINTER buffer,
+ SQLLEN* resLen,
+ SQLLEN* id)
+{
+ LOG_MSG("SQLSetDescRec called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLColumnPrivileges(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen)
+{
+ LOG_MSG("SQLColumnPrivileges called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT stmt,
+ SQLUSMALLINT paramNum,
+ SQLSMALLINT* dataType,
+ SQLULEN* paramSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable)
+{
+ LOG_MSG("SQLDescribeParam called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLParamOptions(SQLHSTMT stmt,
+ SQLULEN paramSetSize,
+ SQLULEN* paramsProcessed)
+{
+ LOG_MSG("SQLParamOptions called\n");
+ return SQL_SUCCESS;
+}
+
+SQLRETURN SQL_API SQLProcedures(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+{
+ LOG_MSG("SQLProcedures called\n");
+ return SQL_SUCCESS;
+}
[5/5] ignite git commit: IGNITE-2557: Added tests.
Posted by vo...@apache.org.
IGNITE-2557: Added tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/075ab6fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/075ab6fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/075ab6fb
Branch: refs/heads/ignite-1786
Commit: 075ab6fbd11b3c8e98b6b5945a71b89a9e706e2b
Parents: 9291891
Author: isapego <is...@gridgain.com>
Authored: Thu Mar 17 13:53:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Mar 17 13:53:16 2016 +0300
----------------------------------------------------------------------
.../platforms/cpp/binary/include/ignite/date.h | 14 +-
.../platforms/cpp/binary/include/ignite/guid.h | 31 +-
.../cpp/binary/include/ignite/timestamp.h | 14 +-
modules/platforms/cpp/binary/src/date.cpp | 14 +-
modules/platforms/cpp/binary/src/guid.cpp | 2 +-
.../src/impl/binary/binary_reader_impl.cpp | 2 +
modules/platforms/cpp/binary/src/timestamp.cpp | 14 +-
.../cpp/common/include/ignite/common/utils.h | 32 +
.../platforms/cpp/common/os/linux/src/utils.cpp | 21 +
.../platforms/cpp/common/os/win/src/utils.cpp | 21 +
.../cpp/core-test/src/cache_query_test.cpp | 2 +-
modules/platforms/cpp/odbc-test/Makefile.am | 6 +-
.../cpp/odbc-test/config/queries-test.xml | 90 +
.../include/teamcity/teamcity_messages.h | 55 +
.../cpp/odbc-test/include/teamcity_messages.h | 55 -
.../platforms/cpp/odbc-test/include/test_type.h | 130 ++
.../cpp/odbc-test/include/test_utils.h | 57 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 28 +-
.../project/vs/odbc-test.vcxproj.filters | 63 +-
.../src/application_data_buffer_test.cpp | 329 +--
.../cpp/odbc-test/src/configuration_test.cpp | 20 +-
.../cpp/odbc-test/src/queries_test.cpp | 510 ++++
.../odbc-test/src/teamcity/teamcity_boost.cpp | 159 ++
.../src/teamcity/teamcity_messages.cpp | 150 ++
.../cpp/odbc-test/src/teamcity_boost.cpp | 159 --
.../cpp/odbc-test/src/teamcity_messages.cpp | 150 --
.../platforms/cpp/odbc-test/src/test_utils.cpp | 80 +
modules/platforms/cpp/odbc/Makefile.am | 1 +
.../platforms/cpp/odbc/include/ignite/odbc.h | 258 +++
.../ignite/odbc/app/application_data_buffer.h | 7 +
.../cpp/odbc/include/ignite/odbc/decimal.h | 17 +-
.../cpp/odbc/include/ignite/odbc/utility.h | 8 +
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 2 +
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 6 +
.../odbc/src/app/application_data_buffer.cpp | 76 +-
.../platforms/cpp/odbc/src/app/parameter.cpp | 18 +-
.../cpp/odbc/src/config/configuration.cpp | 6 +
modules/platforms/cpp/odbc/src/connection.cpp | 2 +-
modules/platforms/cpp/odbc/src/decimal.cpp | 42 +-
modules/platforms/cpp/odbc/src/entry_points.cpp | 694 ++++++
modules/platforms/cpp/odbc/src/odbc.cpp | 2193 ++++++++----------
modules/platforms/cpp/odbc/src/utility.cpp | 25 +
42 files changed, 3680 insertions(+), 1883 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/include/ignite/date.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/date.h b/modules/platforms/cpp/binary/include/ignite/date.h
index def073f..31fe5d0 100644
--- a/modules/platforms/cpp/binary/include/ignite/date.h
+++ b/modules/platforms/cpp/binary/include/ignite/date.h
@@ -83,7 +83,7 @@ namespace ignite
* @param val2 Second value.
* @return True if equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator==(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator==(const Date& val1, const Date& val2);
/**
* Comparison operator override.
@@ -92,7 +92,7 @@ namespace ignite
* @param val2 Second value.
* @return True if not equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator!=(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator!=(const Date& val1, const Date& val2);
/**
* Comparison operator override.
@@ -101,7 +101,7 @@ namespace ignite
* @param val2 Second value.
* @return True if less.
*/
- friend bool IGNITE_IMPORT_EXPORT operator<(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator<(const Date& val1, const Date& val2);
/**
* Comparison operator override.
@@ -110,7 +110,7 @@ namespace ignite
* @param val2 Second value.
* @return True if less or equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator<=(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator<=(const Date& val1, const Date& val2);
/**
* Comparison operator override.
@@ -119,7 +119,7 @@ namespace ignite
* @param val2 Second value.
* @return True if gretter.
*/
- friend bool IGNITE_IMPORT_EXPORT operator>(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator>(const Date& val1, const Date& val2);
/**
* Comparison operator override.
@@ -128,11 +128,11 @@ namespace ignite
* @param val2 Second value.
* @return True if gretter or equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator>=(Date& val1, Date& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator>=(const Date& val1, const Date& val2);
private:
/** Number of milliseconds since 00:00 hours, Jan 1, 1970 UTC. */
int64_t milliseconds;
};
}
-#endif //_IGNITE_DATE
\ No newline at end of file
+#endif //_IGNITE_DATE
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/include/ignite/guid.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/guid.h b/modules/platforms/cpp/binary/include/ignite/guid.h
index 97ab117..9a045e6 100644
--- a/modules/platforms/cpp/binary/include/ignite/guid.h
+++ b/modules/platforms/cpp/binary/include/ignite/guid.h
@@ -105,7 +105,7 @@ namespace ignite
* @param val2 Second value.
* @return True if equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator== (Guid& val1, Guid& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator== (const Guid& val1, const Guid& val2);
private:
/** Most significant bits. */
int64_t most;
@@ -138,6 +138,35 @@ namespace ignite
return os;
}
+
+ /**
+ * Input operator.
+ *
+ * @param is Input stream.
+ * @param guid Guid to input.
+ * @return Reference to the first param.
+ */
+ template<typename C>
+ std::basic_istream<C>& operator>>(std::basic_istream<C>& is, Guid& guid)
+ {
+ uint64_t parts[5];
+
+ C delim;
+
+ for (int i = 0; i < 4; ++i)
+ {
+ is >> std::hex >> parts[i] >> delim;
+
+ if (delim != static_cast<C>('-'))
+ return is;
+ }
+
+ is >> std::hex >> parts[4];
+
+ guid = Guid((parts[0] << 32) | (parts[1] << 16) | parts[2], (parts[3] << 48) | parts[4]);
+
+ return is;
+ }
}
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/include/ignite/timestamp.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/timestamp.h b/modules/platforms/cpp/binary/include/ignite/timestamp.h
index 3f14aec..4528e53 100644
--- a/modules/platforms/cpp/binary/include/ignite/timestamp.h
+++ b/modules/platforms/cpp/binary/include/ignite/timestamp.h
@@ -108,7 +108,7 @@ namespace ignite
* @param val2 Second value.
* @return True if equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator==(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator==(const Timestamp& val1, const Timestamp& val2);
/**
* Comparison operator override.
@@ -117,7 +117,7 @@ namespace ignite
* @param val2 Second value.
* @return True if not equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator!=(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator!=(const Timestamp& val1, const Timestamp& val2);
/**
* Comparison operator override.
@@ -126,7 +126,7 @@ namespace ignite
* @param val2 Second value.
* @return True if less.
*/
- friend bool IGNITE_IMPORT_EXPORT operator<(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator<(const Timestamp& val1, const Timestamp& val2);
/**
* Comparison operator override.
@@ -135,7 +135,7 @@ namespace ignite
* @param val2 Second value.
* @return True if less or equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator<=(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator<=(const Timestamp& val1, const Timestamp& val2);
/**
* Comparison operator override.
@@ -144,7 +144,7 @@ namespace ignite
* @param val2 Second value.
* @return True if gretter.
*/
- friend bool IGNITE_IMPORT_EXPORT operator>(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator>(const Timestamp& val1, const Timestamp& val2);
/**
* Comparison operator override.
@@ -153,7 +153,7 @@ namespace ignite
* @param val2 Second value.
* @return True if gretter or equal.
*/
- friend bool IGNITE_IMPORT_EXPORT operator>=(Timestamp& val1, Timestamp& val2);
+ friend bool IGNITE_IMPORT_EXPORT operator>=(const Timestamp& val1, const Timestamp& val2);
private:
/** Number of seconds since 00:00 hours, Jan 1, 1970 UTC. */
int64_t seconds;
@@ -163,4 +163,4 @@ namespace ignite
};
}
-#endif //_IGNITE_TIMESTAMP
\ No newline at end of file
+#endif //_IGNITE_TIMESTAMP
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/src/date.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/date.cpp b/modules/platforms/cpp/binary/src/date.cpp
index 56cca6d..2bdcfd5 100644
--- a/modules/platforms/cpp/binary/src/date.cpp
+++ b/modules/platforms/cpp/binary/src/date.cpp
@@ -51,33 +51,33 @@ namespace ignite
return milliseconds / 1000;
}
- bool operator==(Date& val1, Date& val2)
+ bool operator==(const Date& val1, const Date& val2)
{
return val1.milliseconds == val2.milliseconds;
}
- bool operator!=(Date& val1, Date& val2)
+ bool operator!=(const Date& val1, const Date& val2)
{
return val1.milliseconds != val2.milliseconds;
}
- bool operator<(Date& val1, Date& val2)
+ bool operator<(const Date& val1, const Date& val2)
{
return val1.milliseconds < val2.milliseconds;
}
- bool operator<=(Date& val1, Date& val2)
+ bool operator<=(const Date& val1, const Date& val2)
{
return val1.milliseconds <= val2.milliseconds;
}
- bool operator>(Date& val1, Date& val2)
+ bool operator>(const Date& val1, const Date& val2)
{
return val1.milliseconds > val2.milliseconds;
}
- bool operator>=(Date& val1, Date& val2)
+ bool operator>=(const Date& val1, const Date& val2)
{
return val1.milliseconds >= val2.milliseconds;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/src/guid.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/guid.cpp b/modules/platforms/cpp/binary/src/guid.cpp
index 77997e4..50d6d1d 100644
--- a/modules/platforms/cpp/binary/src/guid.cpp
+++ b/modules/platforms/cpp/binary/src/guid.cpp
@@ -58,7 +58,7 @@ namespace ignite
return static_cast<int32_t>(hilo >> 32) ^ static_cast<int32_t>(hilo);
}
- bool operator==(Guid& val1, Guid& val2)
+ bool operator==(const Guid& val1, const Guid& val2)
{
return val1.least == val2.least && val1.most == val2.most;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
index a91f36e..dd915fe 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
@@ -744,6 +744,8 @@ namespace ignite
if (typeId == IGNITE_TYPE_DATE)
return BinaryUtils::ReadDate(stream);
+ else if (typeId == IGNITE_TYPE_TIMESTAMP)
+ return Date(BinaryUtils::ReadTimestamp(stream).GetMilliseconds());
else if (typeId == IGNITE_HDR_NULL)
return Date();
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/binary/src/timestamp.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/timestamp.cpp b/modules/platforms/cpp/binary/src/timestamp.cpp
index a56587e..e554950 100644
--- a/modules/platforms/cpp/binary/src/timestamp.cpp
+++ b/modules/platforms/cpp/binary/src/timestamp.cpp
@@ -75,43 +75,43 @@ namespace ignite
return Date(GetMilliseconds());
}
- bool operator==(Timestamp& val1, Timestamp& val2)
+ bool operator==(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds == val2.seconds &&
val1.fractionNs == val2.fractionNs;
}
- bool operator!=(Timestamp& val1, Timestamp& val2)
+ bool operator!=(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds != val2.seconds ||
val1.fractionNs != val2.fractionNs;
}
- bool operator<(Timestamp& val1, Timestamp& val2)
+ bool operator<(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds < val2.seconds ||
(val1.seconds == val2.seconds &&
val1.fractionNs < val2.fractionNs);
}
- bool operator<=(Timestamp& val1, Timestamp& val2)
+ bool operator<=(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds < val2.seconds ||
(val1.seconds == val2.seconds &&
val1.fractionNs <= val2.fractionNs);
}
- bool operator>(Timestamp& val1, Timestamp& val2)
+ bool operator>(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds > val2.seconds ||
(val1.seconds == val2.seconds &&
val1.fractionNs > val2.fractionNs);
}
- bool operator>=(Timestamp& val1, Timestamp& val2)
+ bool operator>=(const Timestamp& val1, const Timestamp& val2)
{
return val1.seconds > val2.seconds ||
(val1.seconds == val2.seconds &&
val1.fractionNs >= val2.fractionNs);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index abed714..05f3595 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -17,6 +17,8 @@
#ifndef _IGNITE_COMMON_UTILS
#define _IGNITE_COMMON_UTILS
+#include <stdint.h>
+
#include <cstring>
#include <string>
#include <sstream>
@@ -84,6 +86,36 @@ namespace ignite
}
/**
+ * Get number of leading zeroes in octet.
+ *
+ * @param octet Octet.
+ * @return Number of leading zero-bits.
+ */
+ IGNITE_IMPORT_EXPORT int LeadingZeroesForOctet(int8_t octet);
+
+ /**
+ * Get number of significant bits in octet.
+ *
+ * @param octet Octet.
+ * @return Number of significant bits.
+ */
+ inline int BitLengthForOctet(int8_t octet)
+ {
+ return 8 - LeadingZeroesForOctet(octet);
+ }
+
+ /**
+ * Check if the number is power of two.
+ *
+ * @param num Integer number.
+ * @return True if the number is power of two.
+ */
+ inline bool PowerOfTwo(int num)
+ {
+ return (num & (num - 1)) == 0;
+ }
+
+ /**
* Copy characters.
*
* @param val Value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/common/os/linux/src/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/src/utils.cpp b/modules/platforms/cpp/common/os/linux/src/utils.cpp
index 625844f..5c6df36 100644
--- a/modules/platforms/cpp/common/os/linux/src/utils.cpp
+++ b/modules/platforms/cpp/common/os/linux/src/utils.cpp
@@ -296,6 +296,27 @@ namespace ignite
return res;
}
+ int LeadingZeroesForOctet(int8_t octet) {
+ if (octet == 0)
+ return 8;
+
+ int zeroes = 1;
+
+ if (octet >> 4 == 0) {
+ zeroes += 4;
+ octet <<= 4;
+ }
+
+ if (octet >> 6 == 0) {
+ zeroes += 2;
+ octet <<= 2;
+ }
+
+ zeroes -= octet >> 7;
+
+ return zeroes;
+ }
+
char* CopyChars(const char* val)
{
if (val) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/common/os/win/src/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/utils.cpp b/modules/platforms/cpp/common/os/win/src/utils.cpp
index 493ee9a..2f28645 100644
--- a/modules/platforms/cpp/common/os/win/src/utils.cpp
+++ b/modules/platforms/cpp/common/os/win/src/utils.cpp
@@ -290,6 +290,27 @@ namespace ignite
return res;
}
+ int LeadingZeroesForOctet(int8_t octet) {
+ if (octet == 0)
+ return 8;
+
+ int zeroes = 1;
+
+ if (octet >> 4 == 0) {
+ zeroes += 4;
+ octet <<= 4;
+ }
+
+ if (octet >> 6 == 0) {
+ zeroes += 2;
+ octet <<= 2;
+ }
+
+ zeroes -= octet >> 7;
+
+ return zeroes;
+ }
+
char* CopyChars(const char* val)
{
if (val) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index 1630704..a22ddad 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -1095,4 +1095,4 @@ BOOST_AUTO_TEST_CASE(TestFieldsQueryTimestamp)
CheckEmpty(cursor);
}
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index f8966f0..700ca75 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = "-Im4"
SUBDIRS = .
DIST_SUBDIRS = .
-AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc/include -DIGNITE_IMPL
+AM_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/../odbc/include -I$(srcdir)/../common/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
AM_CXXFLAGS = -Wall -std=c++0x
noinst_PROGRAMS = ignite-odbc-tests
@@ -34,6 +34,8 @@ ignite_odbc_tests_SOURCES = src/teamcity_boost.cpp \
src/configuration_test.cpp \
src/row_test.cpp \
src/utility_test.cpp \
+ src/queries_test.cpp \
+ src/test_utils.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
@@ -44,7 +46,7 @@ ignite_odbc_tests_SOURCES = src/teamcity_boost.cpp \
../odbc/src/utility.cpp \
../odbc/src/result_page.cpp
-ignite_odbc_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite-binary -ldl
+ignite_odbc_tests_LDFLAGS = -static-libtool-libs -L/usr/local/lib -ldl -lignite-binary -lignite -lodbc
run-check: check
./ignite-odbc-tests -p
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/config/queries-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml
new file mode 100644
index 0000000..fa87f82
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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 regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Set to true to enable distributed class loading for examples, default is false. -->
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="writeSynchronizationMode" value="PRIMARY_SYNC"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="typeMetadata">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="keyType" value="java.lang.Long"/>
+ <property name="valueType" value="TestType"/>
+ <property name="queryFields">
+ <map>
+ <entry key="i8Field" value="java.lang.Byte"/>
+ <entry key="i16Field" value="java.lang.Short"/>
+ <entry key="i32Field" value="java.lang.Integer"/>
+ <entry key="i64Field" value="java.lang.Long"/>
+ <entry key="strField" value="java.lang.String"/>
+ <entry key="floatField" value="java.lang.Float"/>
+ <entry key="doubleField" value="java.lang.Double"/>
+ <entry key="boolField" value="java.lang.Boolean"/>
+ <entry key="guidField" value="java.util.UUID"/>
+ <entry key="dateField" value="java.util.Date"/>
+ <entry key="timestampField" value="java.sql.Timestamp"/>
+ </map>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery.
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h b/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h
new file mode 100644
index 0000000..81a915b
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/teamcity/teamcity_messages.h
@@ -0,0 +1,55 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Revision: 88625 $
+*/
+
+#ifndef H_TEAMCITY_MESSAGES
+#define H_TEAMCITY_MESSAGES
+
+#include <string>
+#include <iostream>
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment();
+bool underTeamcity();
+
+class TeamcityMessages {
+ std::ostream *m_out;
+
+protected:
+ std::string escape(std::string s);
+
+ void openMsg(const std::string &name);
+ void writeProperty(std::string name, std::string value);
+ void closeMsg();
+
+public:
+ TeamcityMessages();
+
+ void setOutput(std::ostream &);
+
+ void suiteStarted(std::string name, std::string flowid = "");
+ void suiteFinished(std::string name, std::string flowid = "");
+
+ void testStarted(std::string name, std::string flowid = "");
+ void testFailed(std::string name, std::string message, std::string details, std::string flowid = "");
+ void testIgnored(std::string name, std::string message, std::string flowid = "");
+ void testFinished(std::string name, int durationMs = -1, std::string flowid = "");
+};
+
+}
+
+#endif /* H_TEAMCITY_MESSAGES */
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/teamcity_messages.h b/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
deleted file mode 100644
index 8cf23d0..0000000
--- a/modules/platforms/cpp/odbc-test/include/teamcity_messages.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Revision: 88625 $
-*/
-
-#ifndef H_TEAMCITY_MESSAGES
-#define H_TEAMCITY_MESSAGES
-
-#include <string>
-#include <iostream>
-
-namespace JetBrains {
-
-std::string getFlowIdFromEnvironment();
-bool underTeamcity();
-
-class TeamcityMessages {
- std::ostream *m_out;
-
-protected:
- std::string escape(std::string s);
-
- void openMsg(const std::string &name);
- void writeProperty(std::string name, std::string value);
- void closeMsg();
-
-public:
- TeamcityMessages();
-
- void setOutput(std::ostream &);
-
- void suiteStarted(std::string name, std::string flowid = "");
- void suiteFinished(std::string name, std::string flowid = "");
-
- void testStarted(std::string name, std::string flowid = "");
- void testFailed(std::string name, std::string message, std::string details, std::string flowid = "");
- void testIgnored(std::string name, std::string message, std::string flowid = "");
- void testFinished(std::string name, int durationMs = -1, std::string flowid = "");
-};
-
-}
-
-#endif /* H_TEAMCITY_MESSAGES */
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/include/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/test_type.h b/modules/platforms/cpp/odbc-test/include/test_type.h
new file mode 100644
index 0000000..2a4a979
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/test_type.h
@@ -0,0 +1,130 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_TEST_TYPE
+#define _IGNITE_ODBC_TEST_TEST_TYPE
+
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+namespace ignite
+{
+ struct TestType
+ {
+ TestType() :
+ i8Field(0),
+ i16Field(0),
+ i32Field(0),
+ i64Field(0),
+ floatField(0.0f),
+ doubleField(0.0),
+ boolField(false),
+ dateField(),
+ timestampField()
+ {
+ // No-op.
+ }
+
+ TestType(int8_t i8Field, int16_t i16Field, int32_t i32Field,
+ int64_t i64Field, const std::string& strField, float floatField,
+ double doubleField, bool boolField, const Guid& guidField,
+ const Date& dateField, const Timestamp& timestampField) :
+ i8Field(i8Field),
+ i16Field(i16Field),
+ i32Field(i32Field),
+ i64Field(i64Field),
+ strField(strField),
+ floatField(floatField),
+ doubleField(doubleField),
+ boolField(boolField),
+ guidField(guidField),
+ dateField(dateField),
+ timestampField(timestampField)
+ {
+ // No-op.
+ }
+
+ int8_t i8Field;
+ int16_t i16Field;
+ int32_t i32Field;
+ int64_t i64Field;
+ std::string strField;
+ float floatField;
+ double doubleField;
+ bool boolField;
+ Guid guidField;
+ Date dateField;
+ Timestamp timestampField;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::TestType)
+
+ typedef ignite::TestType TestType;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestType)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestType)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(TestType)
+ IGNITE_BINARY_IS_NULL_FALSE(TestType)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
+
+ void Write(BinaryWriter& writer, TestType obj)
+ {
+ writer.WriteInt8("i8Field", obj.i8Field);
+ writer.WriteInt16("i16Field", obj.i16Field);
+ writer.WriteInt32("i32Field", obj.i32Field);
+ writer.WriteInt64("i64Field", obj.i64Field);
+ writer.WriteString("strField", obj.strField);
+ writer.WriteFloat("floatField", obj.floatField);
+ writer.WriteDouble("doubleField", obj.doubleField);
+ writer.WriteBool("boolField", obj.boolField);
+ writer.WriteGuid("guidField", obj.guidField);
+ writer.WriteDate("dateField", obj.dateField);
+ writer.WriteTimestamp("timestampField", obj.timestampField);
+ }
+
+ TestType Read(BinaryReader& reader)
+ {
+ int8_t i8Field = reader.ReadInt8("i8Field");
+ int16_t i16Field = reader.ReadInt16("i16Field");
+ int32_t i32Field = reader.ReadInt32("i32Field");
+ int64_t i64Field = reader.ReadInt64("i64Field");
+ std::string strField = reader.ReadString("strField");
+ float floatField = reader.ReadFloat("floatField");
+ double doubleField = reader.ReadDouble("doubleField");
+ bool boolField = reader.ReadBool("boolField");
+ Guid guidField = reader.ReadGuid("guidField");
+ Date dateField = reader.ReadDate("dateField");
+ Timestamp timestampField = reader.ReadTimestamp("timestampField");
+
+ return TestType(i8Field, i16Field, i32Field, i64Field, strField,
+ floatField, doubleField, boolField, guidField, dateField,
+ timestampField);
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
+
+#endif // _IGNITE_ODBC_TEST_TEST_TYPE
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/include/test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/test_utils.h b/modules/platforms/cpp/odbc-test/include/test_utils.h
new file mode 100644
index 0000000..602f68f
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/test_utils.h
@@ -0,0 +1,57 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_TEST_UTILS_H
+#define _IGNITE_ODBC_TEST_TEST_UTILS_H
+
+#include "ignite/date.h"
+#include "ignite/timestamp.h"
+
+namespace test_utils
+{
+ /**
+ * Make Date in human understandable way.
+ *
+ * @param year Year.
+ * @param month Month.
+ * @param day Day.
+ * @param hour Hour.
+ * @param min Min.
+ * @param sec Sec.
+ * @return Date.
+ */
+ ignite::Date MakeDate(int year = 1900, int month = 1, int day = 1,
+ int hour = 0, int min = 0, int sec = 0);
+
+ /**
+ * Make Date in human understandable way.
+ *
+ * @param year Year.
+ * @param month Month.
+ * @param day Day.
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @param ns Nanosecond.
+ * @return Timestamp.
+ */
+ ignite::Timestamp MakeTimestamp(int year = 1900, int month = 1, int day = 1,
+ int hour = 0, int min = 0, int sec = 0, long ns = 0);
+} // namespace test_utils
+
+#endif // _IGNITE_ODBC_TEST_TEST_UTILS_H
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index f39e071..ddeabcb 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -91,8 +91,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;IGNITE_TESTS_32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
@@ -105,7 +105,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
@@ -122,8 +122,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;IGNITE_TESTS_32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
@@ -140,7 +140,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\src;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\odbc\include;$(ProjectDir)\..\..\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;BOOST_DATE_TIME_NO_LIB;BOOST_REGEX_NO_LIB;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
@@ -166,14 +166,18 @@
<ClCompile Include="..\..\src\configuration_test.cpp" />
<ClCompile Include="..\..\src\connection_info_test.cpp" />
<ClCompile Include="..\..\src\cursor_test.cpp" />
+ <ClCompile Include="..\..\src\queries_test.cpp" />
<ClCompile Include="..\..\src\parser_test.cpp" />
<ClCompile Include="..\..\src\row_test.cpp" />
- <ClCompile Include="..\..\src\teamcity_boost.cpp" />
- <ClCompile Include="..\..\src\teamcity_messages.cpp" />
+ <ClCompile Include="..\..\src\test_utils.cpp" />
+ <ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" />
+ <ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" />
<ClCompile Include="..\..\src\utility_test.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\include\teamcity_messages.h" />
+ <ClInclude Include="..\..\include\teamcity\teamcity_messages.h" />
+ <ClInclude Include="..\..\include\test_type.h" />
+ <ClInclude Include="..\..\include\test_utils.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
@@ -182,6 +186,12 @@
<ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
<Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
</ProjectReference>
+ <ProjectReference Include="..\..\..\core\project\vs\core.vcxproj">
+ <Project>{e2dea693-f2ea-43c2-a813-053378f6e4db}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\config\queries-test.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 3031b1c..d5f22b3 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -5,11 +5,17 @@
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
- <Filter Include="Code\teamcity">
+ <Filter Include="Externals">
+ <UniqueIdentifier>{cc75fc86-c08d-428a-8ae3-f9979e4588ab}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\CacheTypes">
+ <UniqueIdentifier>{43a56b9a-0f5c-4c22-8836-1102252497a4}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Code\TeamCity">
<UniqueIdentifier>{5438a56d-1009-412a-86e3-ceb1112af275}</UniqueIdentifier>
</Filter>
- <Filter Include="External">
- <UniqueIdentifier>{cc75fc86-c08d-428a-8ae3-f9979e4588ab}</UniqueIdentifier>
+ <Filter Include="Configs">
+ <UniqueIdentifier>{fe8a65d3-4f84-4051-ac62-cf4e0f788b43}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
@@ -22,12 +28,6 @@
<ClCompile Include="..\..\src\parser_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\teamcity_boost.cpp">
- <Filter>Code\teamcity</Filter>
- </ClCompile>
- <ClCompile Include="..\..\src\teamcity_messages.cpp">
- <Filter>Code\teamcity</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\application_data_buffer_test.cpp">
<Filter>Code</Filter>
</ClCompile>
@@ -44,36 +44,59 @@
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\app\application_data_buffer.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\column.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\config\configuration.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\cursor.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\decimal.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\result_page.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\row.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
</ClCompile>
<ClCompile Include="..\..\..\odbc\src\utility.cpp">
- <Filter>External</Filter>
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp">
+ <Filter>Code\TeamCity</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp">
+ <Filter>Code\TeamCity</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\queries_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\test_utils.cpp">
+ <Filter>Code</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\include\teamcity_messages.h">
- <Filter>Code\teamcity</Filter>
+ <ClInclude Include="..\..\include\test_type.h">
+ <Filter>Code\CacheTypes</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\test_utils.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\teamcity\teamcity_messages.h">
+ <Filter>Code\TeamCity</Filter>
</ClInclude>
</ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\config\queries-test.xml">
+ <Filter>Configs</Filter>
+ </None>
+ </ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
index 5a840ca..1eac1de 100644
--- a/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/application_data_buffer_test.cpp
@@ -28,6 +28,8 @@
#include <ignite/odbc/app/application_data_buffer.h>
#include <ignite/odbc/utility.h>
+#include "test_utils.h"
+
#define FLOAT_PRECISION 0.0000001f
using namespace ignite;
@@ -35,62 +37,7 @@ using namespace ignite::odbc;
using namespace ignite::odbc::app;
using namespace ignite::odbc::type_traits;
-/**
- * Make Date in human understandable way.
- *
- * @param year Year.
- * @param month Month.
- * @param day Day.
- * @param hour Hour.
- * @param min Min.
- * @param sec Sec.
- * @return Date.
- */
-Date MakeDate(int year = 1900, int month = 1, int day = 1, int hour = 0,
- int min = 0, int sec = 0)
-{
- tm date;
-
- date.tm_year = year - 1900;
- date.tm_mon = month - 1;
- date.tm_mday = day;
- date.tm_hour = hour;
- date.tm_min = min;
- date.tm_sec = sec;
-
- time_t ct = mktime(&date) - timezone;
-
- return Date(ct * 1000);
-}
-
-/**
- * Make Date in human understandable way.
- *
- * @param year Year.
- * @param month Month.
- * @param day Day.
- * @param hour Hour.
- * @param min Minute.
- * @param sec Second.
- * @param ns Nanosecond.
- * @return Timestamp.
- */
-Timestamp MakeTimestamp(int year = 1900, int month = 1, int day = 1,
- int hour = 0, int min = 0, int sec = 0, long ns = 0)
-{
- tm date;
-
- date.tm_year = year - 1900;
- date.tm_mon = month - 1;
- date.tm_mday = day;
- date.tm_hour = hour;
- date.tm_min = min;
- date.tm_sec = sec;
-
- time_t ct = mktime(&date) - timezone;
-
- return Timestamp(ct, ns);
-}
+using namespace test_utils;
BOOST_AUTO_TEST_SUITE(ApplicationDataBufferTestSuite)
@@ -103,28 +50,28 @@ BOOST_AUTO_TEST_CASE(TestPutIntToString)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
appBuf.PutInt8(12);
- BOOST_REQUIRE(!strcmp(buffer, "12"));
- BOOST_REQUIRE(reslen == strlen("12"));
+ BOOST_CHECK(!strcmp(buffer, "12"));
+ BOOST_CHECK(reslen == strlen("12"));
appBuf.PutInt8(-12);
- BOOST_REQUIRE(!strcmp(buffer, "-12"));
- BOOST_REQUIRE(reslen == strlen("-12"));
+ BOOST_CHECK(!strcmp(buffer, "-12"));
+ BOOST_CHECK(reslen == strlen("-12"));
appBuf.PutInt16(9876);
- BOOST_REQUIRE(!strcmp(buffer, "9876"));
- BOOST_REQUIRE(reslen == strlen("9876"));
+ BOOST_CHECK(!strcmp(buffer, "9876"));
+ BOOST_CHECK(reslen == strlen("9876"));
appBuf.PutInt16(-9876);
- BOOST_REQUIRE(!strcmp(buffer, "-9876"));
- BOOST_REQUIRE(reslen == strlen("-9876"));
+ BOOST_CHECK(!strcmp(buffer, "-9876"));
+ BOOST_CHECK(reslen == strlen("-9876"));
appBuf.PutInt32(1234567);
- BOOST_REQUIRE(!strcmp(buffer, "1234567"));
- BOOST_REQUIRE(reslen == strlen("1234567"));
+ BOOST_CHECK(!strcmp(buffer, "1234567"));
+ BOOST_CHECK(reslen == strlen("1234567"));
appBuf.PutInt32(-1234567);
- BOOST_REQUIRE(!strcmp(buffer, "-1234567"));
- BOOST_REQUIRE(reslen == strlen("-1234567"));
+ BOOST_CHECK(!strcmp(buffer, "-1234567"));
+ BOOST_CHECK(reslen == strlen("-1234567"));
}
BOOST_AUTO_TEST_CASE(TestPutFloatToString)
@@ -136,20 +83,20 @@ BOOST_AUTO_TEST_CASE(TestPutFloatToString)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer), &reslen, &offset);
appBuf.PutFloat(12.42f);
- BOOST_REQUIRE(!strcmp(buffer, "12.42"));
- BOOST_REQUIRE(reslen == strlen("12.42"));
+ BOOST_CHECK(!strcmp(buffer, "12.42"));
+ BOOST_CHECK(reslen == strlen("12.42"));
appBuf.PutFloat(-12.42f);
- BOOST_REQUIRE(!strcmp(buffer, "-12.42"));
- BOOST_REQUIRE(reslen == strlen("-12.42"));
+ BOOST_CHECK(!strcmp(buffer, "-12.42"));
+ BOOST_CHECK(reslen == strlen("-12.42"));
appBuf.PutDouble(1000.21);
- BOOST_REQUIRE(!strcmp(buffer, "1000.21"));
- BOOST_REQUIRE(reslen == strlen("1000.21"));
+ BOOST_CHECK(!strcmp(buffer, "1000.21"));
+ BOOST_CHECK(reslen == strlen("1000.21"));
appBuf.PutDouble(-1000.21);
- BOOST_REQUIRE(!strcmp(buffer, "-1000.21"));
- BOOST_REQUIRE(reslen == strlen("-1000.21"));
+ BOOST_CHECK(!strcmp(buffer, "-1000.21"));
+ BOOST_CHECK(reslen == strlen("-1000.21"));
}
BOOST_AUTO_TEST_CASE(TestPutGuidToString)
@@ -164,8 +111,20 @@ BOOST_AUTO_TEST_CASE(TestPutGuidToString)
appBuf.PutGuid(guid);
- BOOST_REQUIRE(!strcmp(buffer, "1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
- BOOST_REQUIRE(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
+ BOOST_CHECK(!strcmp(buffer, "1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
+ BOOST_CHECK(reslen == strlen("1da1ef8f-39ff-4d62-8b72-e8e9f3371801"));
+}
+
+BOOST_AUTO_TEST_CASE(TestGetGuidFromString)
+{
+ char buffer[] = "1da1ef8f-39ff-4d62-8b72-e8e9f3371801";
+ SqlLen reslen;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_CHAR, buffer, sizeof(buffer) - 1, &reslen, 0);
+
+ ignite::Guid guid = appBuf.GetGuid();
+
+ BOOST_CHECK_EQUAL(guid, Guid(0x1da1ef8f39ff4d62ULL, 0x8b72e8e9f3371801ULL));
}
BOOST_AUTO_TEST_CASE(TestPutBinaryToString)
@@ -180,8 +139,8 @@ BOOST_AUTO_TEST_CASE(TestPutBinaryToString)
appBuf.PutBinaryData(binary, sizeof(binary));
- BOOST_REQUIRE(!strcmp(buffer, "2184f4dc0100fff0"));
- BOOST_REQUIRE(reslen == strlen("2184f4dc0100fff0"));
+ BOOST_CHECK(!strcmp(buffer, "2184f4dc0100fff0"));
+ BOOST_CHECK(reslen == strlen("2184f4dc0100fff0"));
}
BOOST_AUTO_TEST_CASE(TestPutStringToString)
@@ -196,8 +155,8 @@ BOOST_AUTO_TEST_CASE(TestPutStringToString)
appBuf.PutString(testString);
- BOOST_REQUIRE(!strcmp(buffer, testString.c_str()));
- BOOST_REQUIRE(reslen == testString.size());
+ BOOST_CHECK(!strcmp(buffer, testString.c_str()));
+ BOOST_CHECK(reslen == testString.size());
}
BOOST_AUTO_TEST_CASE(TestPutStringToWstring)
@@ -211,7 +170,7 @@ BOOST_AUTO_TEST_CASE(TestPutStringToWstring)
std::string testString("Test string");
appBuf.PutString(testString);
- BOOST_REQUIRE(!wcscmp(buffer, L"Test string"));
+ BOOST_CHECK(!wcscmp(buffer, L"Test string"));
}
BOOST_AUTO_TEST_CASE(TestPutStringToLong)
@@ -223,10 +182,10 @@ BOOST_AUTO_TEST_CASE(TestPutStringToLong)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_LONG, &numBuf, sizeof(numBuf), &reslen, &offset);
appBuf.PutString("424242424");
- BOOST_REQUIRE(numBuf == 424242424L);
+ BOOST_CHECK(numBuf == 424242424L);
appBuf.PutString("-424242424");
- BOOST_REQUIRE(numBuf == -424242424L);
+ BOOST_CHECK(numBuf == -424242424L);
}
BOOST_AUTO_TEST_CASE(TestPutStringToTiny)
@@ -238,10 +197,10 @@ BOOST_AUTO_TEST_CASE(TestPutStringToTiny)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_TINYINT, &numBuf, sizeof(numBuf), &reslen, &offset);
appBuf.PutString("12");
- BOOST_REQUIRE(numBuf == 12);
+ BOOST_CHECK(numBuf == 12);
appBuf.PutString("-12");
- BOOST_REQUIRE(numBuf == -12);
+ BOOST_CHECK(numBuf == -12);
}
BOOST_AUTO_TEST_CASE(TestPutStringToFloat)
@@ -253,10 +212,10 @@ BOOST_AUTO_TEST_CASE(TestPutStringToFloat)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
appBuf.PutString("12.21");
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 12.21, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 12.21, FLOAT_PRECISION);
appBuf.PutString("-12.21");
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -12.21, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, -12.21, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestPutIntToFloat)
@@ -268,22 +227,22 @@ BOOST_AUTO_TEST_CASE(TestPutIntToFloat)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_FLOAT, &numBuf, sizeof(numBuf), &reslen, &offset);
appBuf.PutInt8(5);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 5.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 5.0, FLOAT_PRECISION);
appBuf.PutInt8(-5);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -5.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, -5.0, FLOAT_PRECISION);
appBuf.PutInt16(4242);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 4242.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 4242.0, FLOAT_PRECISION);
appBuf.PutInt16(-4242);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -4242.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, -4242.0, FLOAT_PRECISION);
appBuf.PutInt32(1234567);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 1234567.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 1234567.0, FLOAT_PRECISION);
appBuf.PutInt32(-1234567);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -1234567.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, -1234567.0, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestPutFloatToShort)
@@ -295,16 +254,16 @@ BOOST_AUTO_TEST_CASE(TestPutFloatToShort)
ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_SIGNED_SHORT, &numBuf, sizeof(numBuf), &reslen, &offset);
appBuf.PutDouble(5.42);
- BOOST_REQUIRE(numBuf == 5);
+ BOOST_CHECK(numBuf == 5);
appBuf.PutDouble(-5.42);
- BOOST_REQUIRE(numBuf == -5.0);
+ BOOST_CHECK(numBuf == -5.0);
appBuf.PutFloat(42.99f);
- BOOST_REQUIRE(numBuf == 42);
+ BOOST_CHECK(numBuf == 42);
appBuf.PutFloat(-42.99f);
- BOOST_REQUIRE(numBuf == -42);
+ BOOST_CHECK(numBuf == -42);
}
BOOST_AUTO_TEST_CASE(TestPutDecimalToDouble)
@@ -316,24 +275,24 @@ BOOST_AUTO_TEST_CASE(TestPutDecimalToDouble)
Decimal decimal;
- BOOST_REQUIRE_CLOSE_FRACTION(static_cast<double>(decimal), 0.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(static_cast<double>(decimal), 0.0, FLOAT_PRECISION);
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 0.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 0.0, FLOAT_PRECISION);
int8_t mag1[] = { 1, 0 };
decimal = Decimal(0, mag1, sizeof(mag1));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, 256.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, 256.0, FLOAT_PRECISION);
int8_t mag2[] = { 2, 23 };
decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE_CLOSE_FRACTION(numBuf, -53.5, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(numBuf, -53.5, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestPutDecimalToLong)
@@ -346,21 +305,21 @@ BOOST_AUTO_TEST_CASE(TestPutDecimalToLong)
Decimal decimal;
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == 0);
+ BOOST_CHECK(numBuf == 0);
int8_t mag1[] = { 1, 0 };
decimal = Decimal(0, mag1, sizeof(mag1));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == 256);
+ BOOST_CHECK(numBuf == 256);
int8_t mag2[] = { 2, 23 };
decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(numBuf == -53);
+ BOOST_CHECK(numBuf == -53);
}
BOOST_AUTO_TEST_CASE(TestPutDecimalToString)
@@ -373,21 +332,72 @@ BOOST_AUTO_TEST_CASE(TestPutDecimalToString)
Decimal decimal;
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "0");
+ BOOST_CHECK(std::string(strBuf, reslen) == "0");
int8_t mag1[] = { 1, 0 };
decimal = Decimal(0, mag1, sizeof(mag1));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "256");
+ BOOST_CHECK(std::string(strBuf, reslen) == "256");
int8_t mag2[] = { 2, 23 };
decimal = Decimal(1 | 0x80000000, mag2, sizeof(mag2));
appBuf.PutDecimal(decimal);
- BOOST_REQUIRE(std::string(strBuf, reslen) == "-53.5");
+ BOOST_CHECK(std::string(strBuf, reslen) == "-53.5");
+}
+
+BOOST_AUTO_TEST_CASE(TestPutDecimalToNumeric)
+{
+ SQL_NUMERIC_STRUCT buf;
+ SqlLen reslen;
+
+ ApplicationDataBuffer appBuf(IGNITE_ODBC_C_TYPE_NUMERIC, &buf, sizeof(buf), &reslen, 0);
+
+ Decimal decimal;
+
+ appBuf.PutDecimal(decimal);
+ BOOST_CHECK_EQUAL(1, buf.sign); // Positive
+ BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification
+ BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20.
+
+ for (int i = 0; i < SQL_MAX_NUMERIC_LEN; ++i)
+ BOOST_CHECK_EQUAL(0, buf.val[i]);
+
+ // Trying to store 123.45 => 12345 => 0x3039 => [0x30, 0x39].
+ uint8_t mag1[] = { 0x30, 0x39 };
+
+ decimal = Decimal(2, reinterpret_cast<int8_t*>(mag1), sizeof(mag1));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_CHECK_EQUAL(1, buf.sign); // Positive
+ BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification
+ BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20.
+
+ // 123.45 => (scale=0) 123 => 0x7B => [0x7B].
+ BOOST_CHECK_EQUAL(buf.val[0], 0x7B);
+
+ for (int i = 1; i < SQL_MAX_NUMERIC_LEN; ++i)
+ BOOST_CHECK_EQUAL(0, buf.val[i]);
+
+ // Trying to store 12345.678 => 12345678 => 0xBC614E => [0xBC, 0x61, 0x4E].
+ uint8_t mag2[] = { 0xBC, 0x61, 0x4E };
+
+ decimal = Decimal(3 | 0x80000000, reinterpret_cast<int8_t*>(mag2), sizeof(mag2));
+
+ appBuf.PutDecimal(decimal);
+ BOOST_CHECK_EQUAL(2, buf.sign); // Negative
+ BOOST_CHECK_EQUAL(0, buf.scale); // Scale is 0 by default according to specification
+ BOOST_CHECK_EQUAL(20, buf.precision); // Precision is driver specific. We use 20.
+
+ // 12345.678 => (scale=0) 12345 => 0x3039 => [0x39, 0x30].
+ BOOST_CHECK_EQUAL(buf.val[0], 0x39);
+ BOOST_CHECK_EQUAL(buf.val[1], 0x30);
+
+ for (int i = 2; i < SQL_MAX_NUMERIC_LEN; ++i)
+ BOOST_CHECK_EQUAL(0, buf.val[i]);
}
BOOST_AUTO_TEST_CASE(TestPutDateToString)
@@ -513,13 +523,13 @@ BOOST_AUTO_TEST_CASE(TestGetStringFromLong)
std::string res = appBuf.GetString(32);
- BOOST_REQUIRE(res == "42");
+ BOOST_CHECK(res == "42");
numBuf = -77;
res = appBuf.GetString(32);
- BOOST_REQUIRE(res == "-77");
+ BOOST_CHECK(res == "-77");
}
BOOST_AUTO_TEST_CASE(TestGetStringFromDouble)
@@ -532,13 +542,13 @@ BOOST_AUTO_TEST_CASE(TestGetStringFromDouble)
std::string res = appBuf.GetString(32);
- BOOST_REQUIRE(res == "43.36");
+ BOOST_CHECK(res == "43.36");
numBuf = -58.91;
res = appBuf.GetString(32);
- BOOST_REQUIRE(res == "-58.91");
+ BOOST_CHECK(res == "-58.91");
}
BOOST_AUTO_TEST_CASE(TestGetStringFromString)
@@ -551,7 +561,7 @@ BOOST_AUTO_TEST_CASE(TestGetStringFromString)
std::string res = appBuf.GetString(reslen);
- BOOST_REQUIRE(res.compare(buf));
+ BOOST_CHECK(res.compare(buf));
}
BOOST_AUTO_TEST_CASE(TestGetFloatFromUshort)
@@ -564,11 +574,11 @@ BOOST_AUTO_TEST_CASE(TestGetFloatFromUshort)
float resFloat = appBuf.GetFloat();
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 7162.0f, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resFloat, 7162.0f, FLOAT_PRECISION);
double resDouble = appBuf.GetDouble();
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 7162.0, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resDouble, 7162.0, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestGetFloatFromString)
@@ -581,11 +591,11 @@ BOOST_AUTO_TEST_CASE(TestGetFloatFromString)
float resFloat = appBuf.GetFloat();
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 28.562f, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resFloat, 28.562f, FLOAT_PRECISION);
double resDouble = appBuf.GetDouble();
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 28.562, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resDouble, 28.562, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestGetFloatFromFloat)
@@ -598,11 +608,11 @@ BOOST_AUTO_TEST_CASE(TestGetFloatFromFloat)
float resFloat = appBuf.GetFloat();
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 207.49f, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resFloat, 207.49f, FLOAT_PRECISION);
double resDouble = appBuf.GetDouble();
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 207.49, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resDouble, 207.49, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestGetFloatFromDouble)
@@ -615,11 +625,11 @@ BOOST_AUTO_TEST_CASE(TestGetFloatFromDouble)
float resFloat = appBuf.GetFloat();
- BOOST_REQUIRE_CLOSE_FRACTION(resFloat, 893.162f, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resFloat, 893.162f, FLOAT_PRECISION);
double resDouble = appBuf.GetDouble();
- BOOST_REQUIRE_CLOSE_FRACTION(resDouble, 893.162, FLOAT_PRECISION);
+ BOOST_CHECK_CLOSE_FRACTION(resDouble, 893.162, FLOAT_PRECISION);
}
BOOST_AUTO_TEST_CASE(TestGetIntFromString)
@@ -632,19 +642,19 @@ BOOST_AUTO_TEST_CASE(TestGetIntFromString)
int64_t resInt64 = appBuf.GetInt64();
- BOOST_REQUIRE(resInt64 == 39);
+ BOOST_CHECK(resInt64 == 39);
int32_t resInt32 = appBuf.GetInt32();
- BOOST_REQUIRE(resInt32 == 39);
+ BOOST_CHECK(resInt32 == 39);
int16_t resInt16 = appBuf.GetInt16();
- BOOST_REQUIRE(resInt16 == 39);
+ BOOST_CHECK(resInt16 == 39);
int8_t resInt8 = appBuf.GetInt8();
- BOOST_REQUIRE(resInt8 == 39);
+ BOOST_CHECK(resInt8 == 39);
}
BOOST_AUTO_TEST_CASE(TestGetIntFromFloat)
@@ -657,19 +667,19 @@ BOOST_AUTO_TEST_CASE(TestGetIntFromFloat)
int64_t resInt64 = appBuf.GetInt64();
- BOOST_REQUIRE(resInt64 == -107);
+ BOOST_CHECK(resInt64 == -107);
int32_t resInt32 = appBuf.GetInt32();
- BOOST_REQUIRE(resInt32 == -107);
+ BOOST_CHECK(resInt32 == -107);
int16_t resInt16 = appBuf.GetInt16();
- BOOST_REQUIRE(resInt16 == -107);
+ BOOST_CHECK(resInt16 == -107);
int8_t resInt8 = appBuf.GetInt8();
- BOOST_REQUIRE(resInt8 == -107);
+ BOOST_CHECK(resInt8 == -107);
}
BOOST_AUTO_TEST_CASE(TestGetIntFromDouble)
@@ -682,19 +692,19 @@ BOOST_AUTO_TEST_CASE(TestGetIntFromDouble)
int64_t resInt64 = appBuf.GetInt64();
- BOOST_REQUIRE(resInt64 == 42);
+ BOOST_CHECK(resInt64 == 42);
int32_t resInt32 = appBuf.GetInt32();
- BOOST_REQUIRE(resInt32 == 42);
+ BOOST_CHECK(resInt32 == 42);
int16_t resInt16 = appBuf.GetInt16();
- BOOST_REQUIRE(resInt16 == 42);
+ BOOST_CHECK(resInt16 == 42);
int8_t resInt8 = appBuf.GetInt8();
- BOOST_REQUIRE(resInt8 == 42);
+ BOOST_CHECK(resInt8 == 42);
}
BOOST_AUTO_TEST_CASE(TestGetIntFromBigint)
@@ -707,19 +717,19 @@ BOOST_AUTO_TEST_CASE(TestGetIntFromBigint)
int64_t resInt64 = appBuf.GetInt64();
- BOOST_REQUIRE(resInt64 == 19);
+ BOOST_CHECK(resInt64 == 19);
int32_t resInt32 = appBuf.GetInt32();
- BOOST_REQUIRE(resInt32 == 19);
+ BOOST_CHECK(resInt32 == 19);
int16_t resInt16 = appBuf.GetInt16();
- BOOST_REQUIRE(resInt16 == 19);
+ BOOST_CHECK(resInt16 == 19);
int8_t resInt8 = appBuf.GetInt8();
- BOOST_REQUIRE(resInt8 == 19);
+ BOOST_CHECK(resInt8 == 19);
}
BOOST_AUTO_TEST_CASE(TestGetIntWithOffset)
@@ -742,19 +752,19 @@ BOOST_AUTO_TEST_CASE(TestGetIntWithOffset)
int64_t val = appBuf.GetInt64();
- BOOST_REQUIRE(val == 12);
+ BOOST_CHECK(val == 12);
offset += sizeof(TestStruct);
val = appBuf.GetInt64();
- BOOST_REQUIRE(val == 42);
+ BOOST_CHECK(val == 42);
offsetPtr = 0;
val = appBuf.GetInt64();
- BOOST_REQUIRE(val == 12);
+ BOOST_CHECK(val == 12);
}
BOOST_AUTO_TEST_CASE(TestSetStringWithOffset)
@@ -779,9 +789,9 @@ BOOST_AUTO_TEST_CASE(TestSetStringWithOffset)
std::string res(buf[0].val, buf[0].reslen);
- BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
- BOOST_REQUIRE(res == "Hello Ignite!");
- BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
+ BOOST_CHECK(buf[0].reslen == strlen("Hello Ignite!"));
+ BOOST_CHECK(res == "Hello Ignite!");
+ BOOST_CHECK(res.size() == strlen("Hello Ignite!"));
offset += sizeof(TestStruct);
@@ -789,15 +799,15 @@ BOOST_AUTO_TEST_CASE(TestSetStringWithOffset)
res.assign(buf[0].val, buf[0].reslen);
- BOOST_REQUIRE(res == "Hello Ignite!");
- BOOST_REQUIRE(res.size() == strlen("Hello Ignite!"));
- BOOST_REQUIRE(buf[0].reslen == strlen("Hello Ignite!"));
+ BOOST_CHECK(res == "Hello Ignite!");
+ BOOST_CHECK(res.size() == strlen("Hello Ignite!"));
+ BOOST_CHECK(buf[0].reslen == strlen("Hello Ignite!"));
res.assign(buf[1].val, buf[1].reslen);
- BOOST_REQUIRE(res == "Hello with offset!");
- BOOST_REQUIRE(res.size() == strlen("Hello with offset!"));
- BOOST_REQUIRE(buf[1].reslen == strlen("Hello with offset!"));
+ BOOST_CHECK(res == "Hello with offset!");
+ BOOST_CHECK(res.size() == strlen("Hello with offset!"));
+ BOOST_CHECK(buf[1].reslen == strlen("Hello with offset!"));
}
BOOST_AUTO_TEST_CASE(TestGetDateFromString)
@@ -814,7 +824,7 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromString)
time_t cTime = utility::DateToCTime(date);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -828,6 +838,11 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromString)
BOOST_AUTO_TEST_CASE(TestGetTimestampFromString)
{
+ LOG_MSG("Test\n");
+ LOG_MSG("Test\n");
+ LOG_MSG("Test\n");
+ LOG_MSG("Test\n");
+
char buf[] = "2018-11-01 17:45:59";
SqlLen reslen = sizeof(buf);
@@ -840,7 +855,7 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromString)
time_t cTime = utility::TimestampToCTime(date);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -871,7 +886,7 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromDate)
time_t cTime = utility::DateToCTime(date);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -902,7 +917,7 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromDate)
time_t cTime = utility::TimestampToCTime(ts);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -937,7 +952,7 @@ BOOST_AUTO_TEST_CASE(TestGetTimestampFromTimestamp)
time_t cTime = utility::TimestampToCTime(ts);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -973,7 +988,7 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromTimestamp)
time_t cTime = utility::DateToCTime(date);
- tm *tmDate = gmtime(&cTime);
+ tm *tmDate = std::gmtime(&cTime);
BOOST_REQUIRE(tmDate != 0);
@@ -985,4 +1000,4 @@ BOOST_AUTO_TEST_CASE(TestGetDateFromTimestamp)
BOOST_CHECK_EQUAL(51, tmDate->tm_sec);
}
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
index fba46cc..85aa3ff 100644
--- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -103,6 +103,24 @@ BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
CheckConnectionConfig(cfg);
}
+BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated)
+{
+ Configuration cfg;
+
+ std::stringstream constructor;
+
+ constructor << "driver={" << testDriverName << "};"
+ << "server=" << testServerHost << ";"
+ << "port=" << testServerPort << ";"
+ << "cache=" << testCacheName;
+
+ const std::string& connectStr = constructor.str();
+
+ cfg.FillFromConnectString(connectStr.c_str(), connectStr.size() + 1);
+
+ CheckConnectionConfig(cfg);
+}
+
BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
{
Configuration cfg;
@@ -203,4 +221,4 @@ BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END()
[2/5] ignite git commit: IGNITE-2557: Added tests.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index 84e312a..53717c7 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -28,1660 +28,1337 @@
#include "ignite/odbc/environment.h"
#include "ignite/odbc/connection.h"
#include "ignite/odbc/statement.h"
+#include "ignite/odbc.h"
-#ifdef ODBC_DEBUG
-
-FILE* log_file = NULL;
-
-void logInit(const char* path)
+namespace ignite
{
- if (!log_file)
+
+ BOOL ConfigDSN(HWND hwndParent,
+ WORD req,
+ LPCSTR driver,
+ LPCSTR attributes)
{
- log_file = fopen(path, "w");
- }
-}
+ LOG_MSG("ConfigDSN called\n");
-#endif //ODBC_DEBUG
+ ignite::odbc::config::Configuration config;
-BOOL INSTAPI ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
-{
- LOG_MSG("ConfigDSN called\n");
+ config.FillFromConfigAttributes(attributes);
- ignite::odbc::config::Configuration config;
+ if (!SQLValidDSN(config.GetDsn().c_str()))
+ return SQL_FALSE;
- config.FillFromConfigAttributes(attributes);
+ LOG_MSG("Driver: %s\n", driver);
+ LOG_MSG("Attributes: %s\n", attributes);
- if (!SQLValidDSN(config.GetDsn().c_str()))
- return SQL_FALSE;
+ LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
- LOG_MSG("Driver: %s\n", driver);
- LOG_MSG("Attributes: %s\n", attributes);
+ switch (req)
+ {
+ case ODBC_ADD_DSN:
+ {
+ LOG_MSG("ODBC_ADD_DSN\n");
+
+ return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
+ }
+
+ case ODBC_CONFIG_DSN:
+ {
+ LOG_MSG("ODBC_CONFIG_DSN\n");
+ break;
+ }
+
+ case ODBC_REMOVE_DSN:
+ {
+ LOG_MSG("ODBC_REMOVE_DSN\n");
+
+ return SQLRemoveDSNFromIni(config.GetDsn().c_str());
+ }
+
+ default:
+ {
+ return SQL_FALSE;
+ }
+ }
- LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
+ return SQL_TRUE;
+ }
- switch (req)
+ SQLRETURN SQLGetInfo(SQLHDBC conn,
+ SQLUSMALLINT infoType,
+ SQLPOINTER infoValue,
+ SQLSMALLINT infoValueMax,
+ SQLSMALLINT* length)
{
- case ODBC_ADD_DSN:
- {
- LOG_MSG("ODBC_ADD_DSN\n");
+ using ignite::odbc::Connection;
+ using ignite::odbc::config::ConnectionInfo;
- return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
- }
+ LOG_MSG("SQLGetInfo called: %d (%s), %p, %d, %p\n",
+ infoType, ConnectionInfo::InfoTypeToString(infoType),
+ infoValue, infoValueMax, length);
- case ODBC_CONFIG_DSN:
- {
- LOG_MSG("ODBC_CONFIG_DSN\n");
- break;
- }
+ Connection *connection = reinterpret_cast<Connection*>(conn);
- case ODBC_REMOVE_DSN:
- {
- LOG_MSG("ODBC_REMOVE_DSN\n");
+ if (!connection)
+ return SQL_INVALID_HANDLE;
- return SQLRemoveDSNFromIni(config.GetDsn().c_str());
- }
+ connection->GetInfo(infoType, infoValue, infoValueMax, length);
- default:
- {
- return SQL_FALSE;
- }
+ return connection->GetDiagnosticRecords().GetReturnCode();
}
- return SQL_TRUE;
-}
-
-SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
- SQLUSMALLINT infoType,
- SQLPOINTER infoValue,
- SQLSMALLINT infoValueMax,
- SQLSMALLINT* length)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::config::ConnectionInfo;
-
- LOG_MSG("SQLGetInfo called: %d (%s)\n", infoType, ConnectionInfo::InfoTypeToString(infoType));
+ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
+ {
+ //LOG_MSG("SQLAllocHandle called\n");
+ switch (type)
+ {
+ case SQL_HANDLE_ENV:
+ return SQLAllocEnv(result);
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ case SQL_HANDLE_DBC:
+ return SQLAllocConnect(parent, result);
- if (!connection)
- return SQL_INVALID_HANDLE;
+ case SQL_HANDLE_STMT:
+ return SQLAllocStmt(parent, result);
- connection->GetInfo(infoType, infoValue, infoValueMax, length);
+ case SQL_HANDLE_DESC:
+ default:
+ break;
+ }
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
+ *result = 0;
+ return SQL_ERROR;
+ }
-SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
-{
- //LOG_MSG("SQLAllocHandle called\n");
- switch (type)
+ SQLRETURN SQLAllocEnv(SQLHENV* env)
{
- case SQL_HANDLE_ENV:
- return SQLAllocEnv(result);
+ using ignite::odbc::Environment;
- case SQL_HANDLE_DBC:
- return SQLAllocConnect(parent, result);
+ LOG_MSG("SQLAllocEnv called\n");
- case SQL_HANDLE_STMT:
- return SQLAllocStmt(parent, result);
+ *env = reinterpret_cast<SQLHENV>(new Environment());
- case SQL_HANDLE_DESC:
- default:
- break;
+ return SQL_SUCCESS;
}
- *result = 0;
- return SQL_ERROR;
-}
+ SQLRETURN SQLAllocConnect(SQLHENV env, SQLHDBC* conn)
+ {
+ using ignite::odbc::Environment;
+ using ignite::odbc::Connection;
-SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env)
-{
- using ignite::odbc::Environment;
+ LOG_MSG("SQLAllocConnect called\n");
- LOG_MSG("SQLAllocEnv called\n");
+ *conn = SQL_NULL_HDBC;
- *env = reinterpret_cast<SQLHENV>(new Environment());
+ Environment *environment = reinterpret_cast<Environment*>(env);
- return SQL_SUCCESS;
-}
+ if (!environment)
+ return SQL_INVALID_HANDLE;
-SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn)
-{
- using ignite::odbc::Environment;
- using ignite::odbc::Connection;
+ Connection *connection = environment->CreateConnection();
- LOG_MSG("SQLAllocConnect called\n");
+ if (!connection)
+ return environment->GetDiagnosticRecords().GetReturnCode();
- *conn = SQL_NULL_HDBC;
+ *conn = reinterpret_cast<SQLHDBC>(connection);
- Environment *environment = reinterpret_cast<Environment*>(env);
+ return SQL_SUCCESS;
+ }
- if (!environment)
- return SQL_INVALID_HANDLE;
+ SQLRETURN SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt)
+ {
+ using ignite::odbc::Connection;
+ using ignite::odbc::Statement;
- Connection *connection = environment->CreateConnection();
+ LOG_MSG("SQLAllocStmt called\n");
- if (!connection)
- return environment->GetDiagnosticRecords().GetReturnCode();
+ *stmt = SQL_NULL_HDBC;
- *conn = reinterpret_cast<SQLHDBC>(connection);
+ Connection *connection = reinterpret_cast<Connection*>(conn);
- return SQL_SUCCESS;
-}
+ if (!connection)
+ return SQL_INVALID_HANDLE;
-SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::Statement;
+ Statement *statement = connection->CreateStatement();
- LOG_MSG("SQLAllocStmt called\n");
+ *stmt = reinterpret_cast<SQLHSTMT>(statement);
- *stmt = SQL_NULL_HDBC;
+ return connection->GetDiagnosticRecords().GetReturnCode();
+ }
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle)
+ {
+ switch (type)
+ {
+ case SQL_HANDLE_ENV:
+ return SQLFreeEnv(handle);
- if (!connection)
- return SQL_INVALID_HANDLE;
+ case SQL_HANDLE_DBC:
+ return SQLFreeConnect(handle);
- Statement *statement = connection->CreateStatement();
+ case SQL_HANDLE_STMT:
+ return SQLFreeStmt(handle, SQL_DROP);
- *stmt = reinterpret_cast<SQLHSTMT>(statement);
+ case SQL_HANDLE_DESC:
+ default:
+ break;
+ }
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
+ return SQL_ERROR;
+ }
-SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle)
-{
- switch (type)
+ SQLRETURN SQLFreeEnv(SQLHENV env)
{
- case SQL_HANDLE_ENV:
- return SQLFreeEnv(handle);
+ using ignite::odbc::Environment;
- case SQL_HANDLE_DBC:
- return SQLFreeConnect(handle);
+ LOG_MSG("SQLFreeEnv called\n");
- case SQL_HANDLE_STMT:
- return SQLFreeStmt(handle, SQL_DROP);
+ Environment *environment = reinterpret_cast<Environment*>(env);
- case SQL_HANDLE_DESC:
- default:
- break;
- }
+ if (!environment)
+ return SQL_INVALID_HANDLE;
- return SQL_ERROR;
-}
+ delete environment;
-SQLRETURN SQL_API SQLFreeEnv(SQLHENV env)
-{
- using ignite::odbc::Environment;
+ return SQL_SUCCESS;
+ }
- LOG_MSG("SQLFreeEnv called\n");
+ SQLRETURN SQLFreeConnect(SQLHDBC conn)
+ {
+ using ignite::odbc::Connection;
- Environment *environment = reinterpret_cast<Environment*>(env);
+ LOG_MSG("SQLFreeConnect called\n");
- if (!environment)
- return SQL_INVALID_HANDLE;
+ Connection *connection = reinterpret_cast<Connection*>(conn);
- delete environment;
+ if (!connection)
+ return SQL_INVALID_HANDLE;
- return SQL_SUCCESS;
-}
+ delete connection;
-SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn)
-{
- using ignite::odbc::Connection;
+ return SQL_SUCCESS;
+ }
- LOG_MSG("SQLFreeConnect called\n");
+ SQLRETURN SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
+ {
+ using ignite::odbc::Statement;
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ LOG_MSG("SQLFreeStmt called\n");
- if (!connection)
- return SQL_INVALID_HANDLE;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- delete connection;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- return SQL_SUCCESS;
-}
+ switch (option)
+ {
+ case SQL_DROP:
+ {
+ delete statement;
-SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option)
-{
- using ignite::odbc::Statement;
+ break;
+ }
- LOG_MSG("SQLFreeStmt called\n");
+ case SQL_CLOSE:
+ {
+ return SQLCloseCursor(stmt);
+ }
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ case SQL_UNBIND:
+ {
+ statement->UnbindAllColumns();
- if (!statement)
- return SQL_INVALID_HANDLE;
+ break;
+ }
- switch (option)
- {
- case SQL_DROP:
- {
- delete statement;
+ case SQL_RESET_PARAMS:
+ {
+ statement->UnbindAllParameters();
- break;
- }
+ break;
+ }
- case SQL_CLOSE:
- {
- return SQLCloseCursor(stmt);
+ default:
+ return SQL_ERROR;
}
- case SQL_UNBIND:
- {
- statement->UnbindAllColumns();
+ return SQL_SUCCESS;
+ }
- break;
- }
+ SQLRETURN SQLCloseCursor(SQLHSTMT stmt)
+ {
+ using ignite::odbc::Statement;
- case SQL_RESET_PARAMS:
- {
- statement->UnbindAllParameters();
+ LOG_MSG("SQLCloseCursor called\n");
- break;
- }
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- default:
- return SQL_ERROR;
- }
+ statement->Close();
- return SQL_SUCCESS;
-}
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
-SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
+ SQLRETURN SQLDriverConnect(SQLHDBC conn,
+ SQLHWND windowHandle,
+ SQLCHAR* inConnectionString,
+ SQLSMALLINT inConnectionStringLen,
+ SQLCHAR* outConnectionString,
+ SQLSMALLINT outConnectionStringBufferLen,
+ SQLSMALLINT* outConnectionStringLen,
+ SQLUSMALLINT driverCompletion)
+ {
+ using ignite::odbc::Connection;
+ using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::utility::SqlStringToString;
+ using ignite::utility::CopyStringToBuffer;
- LOG_MSG("SQLCloseCursor called\n");
+ UNREFERENCED_PARAMETER(windowHandle);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ LOG_MSG("SQLDriverConnect called\n");
+ LOG_MSG("Connection String: [%s]\n", inConnectionString);
- statement->Close();
+ Connection *connection = reinterpret_cast<Connection*>(conn);
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ if (!connection)
+ return SQL_INVALID_HANDLE;
-SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn,
- SQLHWND windowHandle,
- SQLCHAR* inConnectionString,
- SQLSMALLINT inConnectionStringLen,
- SQLCHAR* outConnectionString,
- SQLSMALLINT outConnectionStringBufferLen,
- SQLSMALLINT* outConnectionStringLen,
- SQLUSMALLINT driverCompletion)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
- using ignite::utility::CopyStringToBuffer;
+ std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
- UNREFERENCED_PARAMETER(windowHandle);
+ ignite::odbc::config::Configuration config;
- LOG_MSG("SQLDriverConnect called\n");
- LOG_MSG("Connection String: [%s]\n", inConnectionString);
+ config.FillFromConnectString(connectStr);
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
- if (!connection)
- return SQL_INVALID_HANDLE;
+ const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
- std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
+ if (!diag.IsSuccessful())
+ return diag.GetReturnCode();
- ignite::odbc::config::Configuration config;
+ std::string outConnectStr = config.ToConnectString();
- config.FillFromConnectString(connectStr);
+ size_t reslen = CopyStringToBuffer(outConnectStr,
+ reinterpret_cast<char*>(outConnectionString),
+ static_cast<size_t>(outConnectionStringBufferLen));
- connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
+ if (outConnectionStringLen)
+ *outConnectionStringLen = static_cast<SQLSMALLINT>(reslen);
- const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
+ LOG_MSG("%s\n", outConnectionString);
- if (!diag.IsSuccessful())
return diag.GetReturnCode();
+ }
- std::string outConnectStr = config.ToConnectString();
-
- size_t reslen = CopyStringToBuffer(outConnectStr,
- reinterpret_cast<char*>(outConnectionString),
- static_cast<size_t>(outConnectionStringBufferLen));
-
- if (outConnectionStringLen)
- *outConnectionStringLen = static_cast<SQLSMALLINT>(reslen);
+ SQLRETURN SQLConnect(SQLHDBC conn,
+ SQLCHAR* serverName,
+ SQLSMALLINT serverNameLen,
+ SQLCHAR* userName,
+ SQLSMALLINT userNameLen,
+ SQLCHAR* auth,
+ SQLSMALLINT authLen)
+ {
+ using ignite::odbc::Connection;
+ using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::utility::SqlStringToString;
- LOG_MSG("%s\n", outConnectionString);
+ LOG_MSG("SQLConnect called\n");
- return diag.GetReturnCode();
-}
+ Connection *connection = reinterpret_cast<Connection*>(conn);
-SQLRETURN SQL_API SQLConnect(SQLHDBC conn,
- SQLCHAR* serverName,
- SQLSMALLINT serverNameLen,
- SQLCHAR* userName,
- SQLSMALLINT userNameLen,
- SQLCHAR* auth,
- SQLSMALLINT authLen)
-{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
+ if (!connection)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLConnect called\n");
+ std::string server = SqlStringToString(serverName, serverNameLen);
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ connection->Establish(server);
- if (!connection)
- return SQL_INVALID_HANDLE;
+ return connection->GetDiagnosticRecords().GetReturnCode();
+ }
- std::string server = SqlStringToString(serverName, serverNameLen);
+ SQLRETURN SQLDisconnect(SQLHDBC conn)
+ {
+ using ignite::odbc::Connection;
- connection->Establish(server);
+ LOG_MSG("SQLDisconnect called\n");
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
+ Connection *connection = reinterpret_cast<Connection*>(conn);
-SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn)
-{
- using ignite::odbc::Connection;
+ if (!connection)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLDisconnect called\n");
+ connection->Release();
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ return connection->GetDiagnosticRecords().GetReturnCode();
+ }
- if (!connection)
- return SQL_INVALID_HANDLE;
+ SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
- connection->Release();
+ LOG_MSG("SQLPrepare called\n");
- return connection->GetDiagnosticRecords().GetReturnCode();
-}
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
-SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLPrepare called\n");
+ std::string sql = SqlStringToString(query, queryLen);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ LOG_MSG("SQL: %s\n", sql.c_str());
- if (!statement)
- return SQL_INVALID_HANDLE;
+ statement->PrepareSqlQuery(sql);
- std::string sql = SqlStringToString(query, queryLen);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- LOG_MSG("SQL: %s\n", sql.c_str());
+ SQLRETURN SQLExecute(SQLHSTMT stmt)
+ {
+ using ignite::odbc::Statement;
- statement->PrepareSqlQuery(sql);
+ LOG_MSG("SQLExecute called\n");
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
-SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLExecute called\n");
+ statement->ExecuteSqlQuery();
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- if (!statement)
- return SQL_INVALID_HANDLE;
+ SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
- statement->ExecuteSqlQuery();
+ LOG_MSG("SQLExecDirect called\n");
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
-SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLExecDirect called\n");
+ std::string sql = SqlStringToString(query, queryLen);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ LOG_MSG("SQL: %s\n", sql.c_str());
- if (!statement)
- return SQL_INVALID_HANDLE;
+ statement->ExecuteSqlQuery(sql);
- std::string sql = SqlStringToString(query, queryLen);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- LOG_MSG("SQL: %s\n", sql.c_str());
+ SQLRETURN SQLBindCol(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+ {
+ using namespace ignite::odbc::type_traits;
- statement->ExecuteSqlQuery(sql);
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ LOG_MSG("SQLBindCol called: index=%d, type=%d\n", colNum, targetType);
-SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLSMALLINT targetType,
- SQLPOINTER targetValue,
- SQLLEN bufferLength,
- SQLLEN* strLengthOrIndicator)
-{
- using namespace ignite::odbc::type_traits;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLBindCol called: index=%d, type=%d\n", colNum, targetType);
+ IgniteSqlType driverType = ToDriverType(targetType);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ return SQL_ERROR;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ if (bufferLength < 0)
+ return SQL_ERROR;
- IgniteSqlType driverType = ToDriverType(targetType);
+ if (targetValue || strLengthOrIndicator)
+ {
+ ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
- return SQL_ERROR;
+ statement->BindColumn(colNum, dataBuffer);
+ }
+ else
+ statement->UnbindColumn(colNum);
- if (bufferLength < 0)
- return SQL_ERROR;
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- if (targetValue || strLengthOrIndicator)
+ SQLRETURN SQLFetch(SQLHSTMT stmt)
{
- ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
+ using ignite::odbc::Statement;
- statement->BindColumn(colNum, dataBuffer);
- }
- else
- statement->UnbindColumn(colNum);
+ LOG_MSG("SQLFetch called\n");
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
-SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLFetch called\n");
+ statement->FetchRow();
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- if (!statement)
- return SQL_INVALID_HANDLE;
+ SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT orientation, SQLLEN offset)
+ {
+ LOG_MSG("SQLFetchScroll called\n");
+ LOG_MSG("Orientation: %d, Offset: %d\n", orientation, offset);
- statement->FetchRow();
+ if (orientation != SQL_FETCH_NEXT)
+ return SQL_ERROR;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ return SQLFetch(stmt);
+ }
-SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt,
- SQLSMALLINT orientation,
- SQLLEN offset)
-{
- LOG_MSG("SQLFetchScroll called\n");
- LOG_MSG("Orientation: %d, Offset: %d\n", orientation, offset);
+ SQLRETURN SQLExtendedFetch(SQLHSTMT stmt,
+ SQLUSMALLINT orientation,
+ SQLLEN offset,
+ SQLULEN* rowCount,
+ SQLUSMALLINT* rowStatusArray)
+ {
+ LOG_MSG("SQLExtendedFetch called\n");
- if (orientation != SQL_FETCH_NEXT)
- return SQL_ERROR;
+ SQLRETURN res = SQLFetchScroll(stmt, orientation, offset);
- return SQLFetch(stmt);
-}
+ if (res == SQL_SUCCESS || res == SQL_NO_DATA)
+ {
+ if (rowCount)
+ *rowCount = 1;
-SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt,
- SQLUSMALLINT orientation,
- SQLLEN offset,
- SQLULEN* rowCount,
- SQLUSMALLINT* rowStatusArray)
-{
- LOG_MSG("SQLExtendedFetch called\n");
+ if (rowStatusArray)
+ rowStatusArray[0] = SQL_ROW_SUCCESS;
+ }
- SQLRETURN res = SQLFetchScroll(stmt, orientation, offset);
+ return res;
+ }
- if (res == SQL_SUCCESS || res == SQL_NO_DATA)
+ SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum)
{
- if (rowCount)
- *rowCount = 1;
+ using ignite::odbc::Statement;
+ using ignite::odbc::meta::ColumnMetaVector;
- if (rowStatusArray)
- rowStatusArray[0] = SQL_ROW_SUCCESS;
- }
+ LOG_MSG("SQLNumResultCols called\n");
- return res;
-}
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
-SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::meta::ColumnMetaVector;
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLNumResultCols called\n");
+ int32_t res = statement->GetColumnNumber();
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ *columnNum = static_cast<SQLSMALLINT>(res);
- if (!statement)
- return SQL_INVALID_HANDLE;
-
- int32_t res = statement->GetColumnNumber();
+ LOG_MSG("columnNum: %d\n", *columnNum);
- *columnNum = static_cast<SQLSMALLINT>(res);
-
- LOG_MSG("columnNum: %d\n", *columnNum);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ SQLRETURN SQLTables(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* tableType,
+ SQLSMALLINT tableTypeLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
-SQLRETURN SQL_API SQLTables(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLCHAR* tableType,
- SQLSMALLINT tableTypeLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ LOG_MSG("SQLTables called\n");
- LOG_MSG("SQLTables called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+ std::string tableTypeStr = SqlStringToString(tableType, tableTypeLen);
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
- std::string tableTypeStr = SqlStringToString(tableType, tableTypeLen);
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+ LOG_MSG("tableType: %s\n", tableTypeStr.c_str());
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
- LOG_MSG("tableType: %s\n", tableTypeStr.c_str());
+ statement->ExecuteGetTablesMetaQuery(catalog, schema, table, tableTypeStr);
- statement->ExecuteGetTablesMetaQuery(catalog, schema, table, tableTypeStr);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ SQLRETURN SQLColumns(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
-SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLCHAR* columnName,
- SQLSMALLINT columnNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ LOG_MSG("SQLColumns called\n");
- LOG_MSG("SQLColumns called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
+ std::string column = SqlStringToString(columnName, columnNameLen);
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
- std::string column = SqlStringToString(columnName, columnNameLen);
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
+ LOG_MSG("column: %s\n", column.c_str());
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
- LOG_MSG("column: %s\n", column.c_str());
+ statement->ExecuteGetColumnsMetaQuery(schema, table, column);
- statement->ExecuteGetColumnsMetaQuery(schema, table, column);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ SQLRETURN SQLMoreResults(SQLHSTMT stmt)
+ {
+ using ignite::odbc::Statement;
-SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt)
-{
- using ignite::odbc::Statement;
+ LOG_MSG("SQLMoreResults called\n");
- LOG_MSG("SQLMoreResults called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ //TODO: reset diagnostic here.
+ return statement->DataAvailable() ? SQL_SUCCESS : SQL_NO_DATA;
+ }
- //TODO: reset diagnostic here.
- return statement->DataAvailable() ? SQL_SUCCESS : SQL_NO_DATA;
-}
+ SQLRETURN SQLBindParameter(SQLHSTMT stmt,
+ SQLUSMALLINT paramIdx,
+ SQLSMALLINT ioType,
+ SQLSMALLINT bufferType,
+ SQLSMALLINT paramSqlType,
+ SQLULEN columnSize,
+ SQLSMALLINT decDigits,
+ SQLPOINTER buffer,
+ SQLLEN bufferLen,
+ SQLLEN* resLen)
+ {
+ using namespace ignite::odbc::type_traits;
-SQLRETURN SQL_API SQLBindParameter(SQLHSTMT stmt,
- SQLUSMALLINT paramIdx,
- SQLSMALLINT ioType,
- SQLSMALLINT bufferType,
- SQLSMALLINT paramSqlType,
- SQLULEN columnSize,
- SQLSMALLINT decDigits,
- SQLPOINTER buffer,
- SQLLEN bufferLen,
- SQLLEN* resLen)
-{
- using namespace ignite::odbc::type_traits;
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
+ using ignite::odbc::app::Parameter;
+ using ignite::odbc::type_traits::IsSqlTypeSupported;
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
- using ignite::odbc::app::Parameter;
- using ignite::odbc::type_traits::IsSqlTypeSupported;
+ LOG_MSG("SQLBindParameter called\n");
- LOG_MSG("SQLBindParameter called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ if (ioType != SQL_PARAM_INPUT)
+ return SQL_ERROR;
- if (ioType != SQL_PARAM_INPUT)
- return SQL_ERROR;
+ if (*resLen == SQL_DATA_AT_EXEC || *resLen <= SQL_LEN_DATA_AT_EXEC_OFFSET)
+ return SQL_ERROR;
- if (*resLen == SQL_DATA_AT_EXEC || *resLen <= SQL_LEN_DATA_AT_EXEC_OFFSET)
- return SQL_ERROR;
+ if (!IsSqlTypeSupported(paramSqlType))
+ return SQL_ERROR;
- if (!IsSqlTypeSupported(paramSqlType))
- return SQL_ERROR;
+ IgniteSqlType driverType = ToDriverType(bufferType);
- IgniteSqlType driverType = ToDriverType(bufferType);
+ if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
+ return SQL_ERROR;
- if (driverType == IGNITE_ODBC_C_TYPE_UNSUPPORTED)
- return SQL_ERROR;
+ if (buffer)
+ {
+ ApplicationDataBuffer dataBuffer(driverType, buffer, bufferLen, resLen);
- if (buffer)
- {
- ApplicationDataBuffer dataBuffer(driverType, buffer, bufferLen, resLen);
+ Parameter param(dataBuffer, paramSqlType, columnSize, decDigits);
- Parameter param(dataBuffer, paramSqlType, columnSize, decDigits);
+ statement->BindParameter(paramIdx, param);
+ }
+ else
+ statement->UnbindParameter(paramIdx);
- statement->BindParameter(paramIdx, param);
+ return statement->GetDiagnosticRecords().GetReturnCode();
}
- else
- statement->UnbindParameter(paramIdx);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn,
- SQLCHAR* inQuery,
- SQLINTEGER inQueryLen,
- SQLCHAR* outQueryBuffer,
- SQLINTEGER outQueryBufferLen,
- SQLINTEGER* outQueryLen)
-{
- using namespace ignite::utility;
-
- LOG_MSG("SQLNativeSql called\n");
-
- std::string in = SqlStringToString(inQuery, inQueryLen);
-
- CopyStringToBuffer(in, reinterpret_cast<char*>(outQueryBuffer),
- static_cast<size_t>(outQueryBufferLen));
- *outQueryLen = std::min(outQueryBufferLen, static_cast<SQLINTEGER>(in.size()));
+ SQLRETURN SQLNativeSql(SQLHDBC conn,
+ SQLCHAR* inQuery,
+ SQLINTEGER inQueryLen,
+ SQLCHAR* outQueryBuffer,
+ SQLINTEGER outQueryBufferLen,
+ SQLINTEGER* outQueryLen)
+ {
+ using namespace ignite::utility;
- return SQL_SUCCESS;
-}
+ LOG_MSG("SQLNativeSql called\n");
-SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt,
- SQLUSMALLINT columnNum,
- SQLUSMALLINT fieldId,
- SQLPOINTER strAttr,
- SQLSMALLINT bufferLen,
- SQLSMALLINT* strAttrLen,
- SQLLEN* numericAttr)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::meta::ColumnMetaVector;
- using ignite::odbc::meta::ColumnMeta;
+ std::string in = SqlStringToString(inQuery, inQueryLen);
- LOG_MSG("SQLColAttribute called: %d (%s)\n", fieldId, ColumnMeta::AttrIdToString(fieldId));
+ CopyStringToBuffer(in, reinterpret_cast<char*>(outQueryBuffer),
+ static_cast<size_t>(outQueryBufferLen));
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ *outQueryLen = std::min(outQueryBufferLen, static_cast<SQLINTEGER>(in.size()));
- if (!statement)
- return SQL_INVALID_HANDLE;
+ return SQL_SUCCESS;
+ }
- // This is a special case
- if (fieldId == SQL_DESC_COUNT)
+ SQLRETURN SQLColAttribute(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttr,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* strAttrLen,
+ SQLLEN* numericAttr)
{
- SQLSMALLINT val = 0;
+ using ignite::odbc::Statement;
+ using ignite::odbc::meta::ColumnMetaVector;
+ using ignite::odbc::meta::ColumnMeta;
- SQLRETURN res = SQLNumResultCols(stmt, &val);
+ LOG_MSG("SQLColAttribute called: %d (%s)\n", fieldId, ColumnMeta::AttrIdToString(fieldId));
- if (res == SQL_SUCCESS)
- *numericAttr = val;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- return res;
- }
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- statement->GetColumnAttribute(columnNum, fieldId, reinterpret_cast<char*>(strAttr),
- bufferLen, strAttrLen, numericAttr);
-
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
-
-SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt,
- SQLUSMALLINT columnNum,
- SQLCHAR* columnNameBuf,
- SQLSMALLINT columnNameBufLen,
- SQLSMALLINT* columnNameLen,
- SQLSMALLINT* dataType,
- SQLULEN* columnSize,
- SQLSMALLINT* decimalDigits,
- SQLSMALLINT* nullable)
-{
- using ignite::odbc::Statement;
- using ignite::odbc::SqlLen;
+ // This is a special case
+ if (fieldId == SQL_DESC_COUNT)
+ {
+ SQLSMALLINT val = 0;
- LOG_MSG("SQLDescribeCol called\n");
+ SQLRETURN res = SQLNumResultCols(stmt, &val);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (res == SQL_SUCCESS)
+ *numericAttr = val;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ return res;
+ }
- statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
- reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
+ statement->GetColumnAttribute(columnNum, fieldId, reinterpret_cast<char*>(strAttr),
+ bufferLen, strAttrLen, numericAttr);
- SqlLen dataTypeRes;
- SqlLen columnSizeRes;
- SqlLen decimalDigitsRes;
- SqlLen nullableRes;
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
- statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
+ SQLRETURN SQLDescribeCol(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLCHAR* columnNameBuf,
+ SQLSMALLINT columnNameBufLen,
+ SQLSMALLINT* columnNameLen,
+ SQLSMALLINT* dataType,
+ SQLULEN* columnSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable)
+ {
+ using ignite::odbc::Statement;
+ using ignite::odbc::SqlLen;
- LOG_MSG("columnNum: %lld\n", columnNum);
- LOG_MSG("dataTypeRes: %lld\n", dataTypeRes);
- LOG_MSG("columnSizeRes: %lld\n", columnSizeRes);
- LOG_MSG("decimalDigitsRes: %lld\n", decimalDigitsRes);
- LOG_MSG("nullableRes: %lld\n", nullableRes);
- LOG_MSG("columnNameBuf: %s\n", columnNameBuf);
- LOG_MSG("columnNameLen: %d\n", *columnNameLen);
+ LOG_MSG("SQLDescribeCol called\n");
- *dataType = static_cast<SQLSMALLINT>(dataTypeRes);
- *columnSize = static_cast<SQLULEN>(columnSizeRes);
- *decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
- *nullable = static_cast<SQLSMALLINT>(nullableRes);
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ if (!statement)
+ return SQL_INVALID_HANDLE;
+ statement->GetColumnAttribute(columnNum, SQL_DESC_NAME,
+ reinterpret_cast<char*>(columnNameBuf), columnNameBufLen, columnNameLen, 0);
-SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt)
-{
- using ignite::odbc::Statement;
+ SqlLen dataTypeRes;
+ SqlLen columnSizeRes;
+ SqlLen decimalDigitsRes;
+ SqlLen nullableRes;
- LOG_MSG("SQLRowCount called\n");
+ statement->GetColumnAttribute(columnNum, SQL_DESC_TYPE, 0, 0, 0, &dataTypeRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_PRECISION, 0, 0, 0, &columnSizeRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_SCALE, 0, 0, 0, &decimalDigitsRes);
+ statement->GetColumnAttribute(columnNum, SQL_DESC_NULLABLE, 0, 0, 0, &nullableRes);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ LOG_MSG("columnNum: %lld\n", columnNum);
+ LOG_MSG("dataTypeRes: %lld\n", dataTypeRes);
+ LOG_MSG("columnSizeRes: %lld\n", columnSizeRes);
+ LOG_MSG("decimalDigitsRes: %lld\n", decimalDigitsRes);
+ LOG_MSG("nullableRes: %lld\n", nullableRes);
+ LOG_MSG("columnNameBuf: %s\n", columnNameBuf);
+ LOG_MSG("columnNameLen: %d\n", *columnNameLen);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ *dataType = static_cast<SQLSMALLINT>(dataTypeRes);
+ *columnSize = static_cast<SQLULEN>(columnSizeRes);
+ *decimalDigits = static_cast<SQLSMALLINT>(decimalDigitsRes);
+ *nullable = static_cast<SQLSMALLINT>(nullableRes);
- int64_t res = statement->AffectedRows();
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- *rowCnt = static_cast<SQLLEN>(res);
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ SQLRETURN SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt)
+ {
+ using ignite::odbc::Statement;
-SQLRETURN SQL_API SQLForeignKeys(SQLHSTMT stmt,
- SQLCHAR* primaryCatalogName,
- SQLSMALLINT primaryCatalogNameLen,
- SQLCHAR* primarySchemaName,
- SQLSMALLINT primarySchemaNameLen,
- SQLCHAR* primaryTableName,
- SQLSMALLINT primaryTableNameLen,
- SQLCHAR* foreignCatalogName,
- SQLSMALLINT foreignCatalogNameLen,
- SQLCHAR* foreignSchemaName,
- SQLSMALLINT foreignSchemaNameLen,
- SQLCHAR* foreignTableName,
- SQLSMALLINT foreignTableNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ LOG_MSG("SQLRowCount called\n");
- LOG_MSG("SQLForeignKeys called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!statement)
- return SQL_INVALID_HANDLE;
+ int64_t res = statement->AffectedRows();
- std::string primaryCatalog = SqlStringToString(primaryCatalogName, primaryCatalogNameLen);
- std::string primarySchema = SqlStringToString(primarySchemaName, primarySchemaNameLen);
- std::string primaryTable = SqlStringToString(primaryTableName, primaryTableNameLen);
- std::string foreignCatalog = SqlStringToString(foreignCatalogName, foreignCatalogNameLen);
- std::string foreignSchema = SqlStringToString(foreignSchemaName, foreignSchemaNameLen);
- std::string foreignTable = SqlStringToString(foreignTableName, foreignTableNameLen);
+ *rowCnt = static_cast<SQLLEN>(res);
- LOG_MSG("primaryCatalog: %s\n", primaryCatalog.c_str());
- LOG_MSG("primarySchema: %s\n", primarySchema.c_str());
- LOG_MSG("primaryTable: %s\n", primaryTable.c_str());
- LOG_MSG("foreignCatalog: %s\n", foreignCatalog.c_str());
- LOG_MSG("foreignSchema: %s\n", foreignSchema.c_str());
- LOG_MSG("foreignTable: %s\n", foreignTable.c_str());
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- statement->ExecuteGetForeignKeysQuery(primaryCatalog, primarySchema,
- primaryTable, foreignCatalog, foreignSchema, foreignTable);
+ SQLRETURN SQLForeignKeys(SQLHSTMT stmt,
+ SQLCHAR* primaryCatalogName,
+ SQLSMALLINT primaryCatalogNameLen,
+ SQLCHAR* primarySchemaName,
+ SQLSMALLINT primarySchemaNameLen,
+ SQLCHAR* primaryTableName,
+ SQLSMALLINT primaryTableNameLen,
+ SQLCHAR* foreignCatalogName,
+ SQLSMALLINT foreignCatalogNameLen,
+ SQLCHAR* foreignSchemaName,
+ SQLSMALLINT foreignSchemaNameLen,
+ SQLCHAR* foreignTableName,
+ SQLSMALLINT foreignTableNameLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ LOG_MSG("SQLForeignKeys called\n");
-SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- using ignite::odbc::Statement;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- LOG_MSG("SQLGetStmtAttr called");
+ if (!statement)
+ return SQL_INVALID_HANDLE;
-#ifdef ODBC_DEBUG
- using ignite::odbc::type_traits::StatementAttrIdToString;
+ std::string primaryCatalog = SqlStringToString(primaryCatalogName, primaryCatalogNameLen);
+ std::string primarySchema = SqlStringToString(primarySchemaName, primarySchemaNameLen);
+ std::string primaryTable = SqlStringToString(primaryTableName, primaryTableNameLen);
+ std::string foreignCatalog = SqlStringToString(foreignCatalogName, foreignCatalogNameLen);
+ std::string foreignSchema = SqlStringToString(foreignSchemaName, foreignSchemaNameLen);
+ std::string foreignTable = SqlStringToString(foreignTableName, foreignTableNameLen);
- LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
-#endif //ODBC_DEBUG
+ LOG_MSG("primaryCatalog: %s\n", primaryCatalog.c_str());
+ LOG_MSG("primarySchema: %s\n", primarySchema.c_str());
+ LOG_MSG("primaryTable: %s\n", primaryTable.c_str());
+ LOG_MSG("foreignCatalog: %s\n", foreignCatalog.c_str());
+ LOG_MSG("foreignSchema: %s\n", foreignSchema.c_str());
+ LOG_MSG("foreignTable: %s\n", foreignTable.c_str());
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ statement->ExecuteGetForeignKeysQuery(primaryCatalog, primarySchema,
+ primaryTable, foreignCatalog, foreignSchema, foreignTable);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- //TODO: move this logic into Statement.
- switch (attr)
+ SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
{
- case SQL_ATTR_APP_ROW_DESC:
- case SQL_ATTR_APP_PARAM_DESC:
- case SQL_ATTR_IMP_ROW_DESC:
- case SQL_ATTR_IMP_PARAM_DESC:
- {
- SQLPOINTER *val = reinterpret_cast<SQLPOINTER*>(valueBuf);
+ using ignite::odbc::Statement;
- *val = static_cast<SQLPOINTER>(stmt);
+ LOG_MSG("SQLGetStmtAttr called");
- break;
- }
+ #ifdef ODBC_DEBUG
+ using ignite::odbc::type_traits::StatementAttrIdToString;
- case SQL_ATTR_ROW_ARRAY_SIZE:
- {
- SQLINTEGER *val = reinterpret_cast<SQLINTEGER*>(valueBuf);
+ LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
+ #endif //ODBC_DEBUG
- *val = static_cast<SQLINTEGER>(1);
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- break;
- }
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- case SQL_ATTR_ROWS_FETCHED_PTR:
+ //TODO: move this logic into Statement.
+ switch (attr)
{
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+ case SQL_ATTR_APP_ROW_DESC:
+ case SQL_ATTR_APP_PARAM_DESC:
+ case SQL_ATTR_IMP_ROW_DESC:
+ case SQL_ATTR_IMP_PARAM_DESC:
+ {
+ SQLPOINTER *val = reinterpret_cast<SQLPOINTER*>(valueBuf);
- *val = reinterpret_cast<SQLULEN*>(statement->GetRowsFetchedPtr());
+ *val = static_cast<SQLPOINTER>(stmt);
- break;
- }
+ break;
+ }
- case SQL_ATTR_ROW_STATUS_PTR:
- {
- SQLUSMALLINT** val = reinterpret_cast<SQLUSMALLINT**>(valueBuf);
+ case SQL_ATTR_ROW_ARRAY_SIZE:
+ {
+ SQLINTEGER *val = reinterpret_cast<SQLINTEGER*>(valueBuf);
- *val = reinterpret_cast<SQLUSMALLINT*>(statement->GetRowStatusesPtr());
+ *val = static_cast<SQLINTEGER>(1);
- break;
- }
+ break;
+ }
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- {
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+ case SQL_ATTR_ROWS_FETCHED_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
- *val = reinterpret_cast<SQLULEN*>(statement->GetParamBindOffsetPtr());
+ *val = reinterpret_cast<SQLULEN*>(statement->GetRowsFetchedPtr());
- break;
- }
+ break;
+ }
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- {
- SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
+ case SQL_ATTR_ROW_STATUS_PTR:
+ {
+ SQLUSMALLINT** val = reinterpret_cast<SQLUSMALLINT**>(valueBuf);
- *val = reinterpret_cast<SQLULEN*>(statement->GetColumnBindOffsetPtr());
+ *val = reinterpret_cast<SQLUSMALLINT*>(statement->GetRowStatusesPtr());
- break;
- }
+ break;
+ }
- default:
- return SQL_ERROR;
- }
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
- return SQL_SUCCESS;
-}
+ *val = reinterpret_cast<SQLULEN*>(statement->GetParamBindOffsetPtr());
-SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Statement;
+ break;
+ }
- LOG_MSG("SQLSetStmtAttr called");
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR:
+ {
+ SQLULEN** val = reinterpret_cast<SQLULEN**>(valueBuf);
-#ifdef ODBC_DEBUG
- using ignite::odbc::type_traits::StatementAttrIdToString;
+ *val = reinterpret_cast<SQLULEN*>(statement->GetColumnBindOffsetPtr());
- LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
-#endif //ODBC_DEBUG
+ break;
+ }
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ default:
+ return SQL_ERROR;
+ }
- if (!statement)
- return SQL_INVALID_HANDLE;
+ return SQL_SUCCESS;
+ }
- //TODO: move this logic into Statement.
- switch (attr)
+ SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
{
- case SQL_ATTR_ROW_ARRAY_SIZE:
- {
- SQLULEN val = reinterpret_cast<SQLULEN>(value);
+ using ignite::odbc::Statement;
- LOG_MSG("Value: %d\n", val);
+ LOG_MSG("SQLSetStmtAttr called");
- if (val != 1)
- return SQL_ERROR;
+ #ifdef ODBC_DEBUG
+ using ignite::odbc::type_traits::StatementAttrIdToString;
- break;
- }
+ LOG_MSG("Attr: %s (%d)\n", StatementAttrIdToString(attr), attr);
+ #endif //ODBC_DEBUG
- case SQL_ATTR_ROWS_FETCHED_PTR:
- {
- statement->SetRowsFetchedPtr(reinterpret_cast<size_t*>(value));
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- break;
- }
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- case SQL_ATTR_ROW_STATUS_PTR:
+ //TODO: move this logic into Statement.
+ switch (attr)
{
- statement->SetRowStatusesPtr(reinterpret_cast<uint16_t*>(value));
+ case SQL_ATTR_ROW_ARRAY_SIZE:
+ {
+ SQLULEN val = reinterpret_cast<SQLULEN>(value);
- break;
- }
+ LOG_MSG("Value: %d\n", val);
- case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
- {
- statement->SetParamBindOffsetPtr(reinterpret_cast<size_t*>(value));
+ if (val != 1)
+ return SQL_ERROR;
- break;
- }
+ break;
+ }
- case SQL_ATTR_ROW_BIND_OFFSET_PTR:
- {
- statement->SetColumnBindOffsetPtr(reinterpret_cast<size_t*>(value));
+ case SQL_ATTR_ROWS_FETCHED_PTR:
+ {
+ statement->SetRowsFetchedPtr(reinterpret_cast<size_t*>(value));
- break;
- }
+ break;
+ }
- default:
- return SQL_ERROR;
- }
+ case SQL_ATTR_ROW_STATUS_PTR:
+ {
+ statement->SetRowStatusesPtr(reinterpret_cast<uint16_t*>(value));
- return SQL_SUCCESS;
-}
+ break;
+ }
-SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen)
-{
- using ignite::odbc::Statement;
- using ignite::utility::SqlStringToString;
+ case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
+ {
+ statement->SetParamBindOffsetPtr(reinterpret_cast<size_t*>(value));
- LOG_MSG("SQLPrimaryKeys called\n");
+ break;
+ }
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ case SQL_ATTR_ROW_BIND_OFFSET_PTR:
+ {
+ statement->SetColumnBindOffsetPtr(reinterpret_cast<size_t*>(value));
- if (!statement)
- return SQL_INVALID_HANDLE;
+ break;
+ }
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
+ default:
+ return SQL_ERROR;
+ }
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
+ return SQL_SUCCESS;
+ }
- statement->ExecuteGetPrimaryKeysQuery(catalog, schema, table);
+ SQLRETURN SQLPrimaryKeys(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen)
+ {
+ using ignite::odbc::Statement;
+ using ignite::utility::SqlStringToString;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ LOG_MSG("SQLPrimaryKeys called\n");
-SQLRETURN SQL_API SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
-{
- using ignite::odbc::Statement;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- LOG_MSG("SQLNumParams called\n");
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
- *paramCnt = static_cast<SQLSMALLINT>(statement->GetParametersNumber());
+ statement->ExecuteGetPrimaryKeysQuery(catalog, schema, table);
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
-SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT recNum,
- SQLSMALLINT diagId,
- SQLPOINTER buffer,
- SQLSMALLINT bufferLen,
- SQLSMALLINT* resLen)
-{
- using namespace ignite::odbc;
- using namespace ignite::odbc::diagnostic;
- using namespace ignite::odbc::type_traits;
+ SQLRETURN SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt)
+ {
+ using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
+ LOG_MSG("SQLNumParams called\n");
- LOG_MSG("SQLGetDiagField called: %d\n", recNum);
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, buffer, bufferLen, &outResLen);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- SqlResult result;
+ *paramCnt = static_cast<SQLSMALLINT>(statement->GetParametersNumber());
- DiagnosticField field = DiagnosticFieldToInternal(diagId);
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- switch (handleType)
+ SQLRETURN SQLGetDiagField(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLSMALLINT diagId,
+ SQLPOINTER buffer,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* resLen)
{
- case SQL_HANDLE_ENV:
- case SQL_HANDLE_DBC:
- case SQL_HANDLE_STMT:
- {
- Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::diagnostic;
+ using namespace ignite::odbc::type_traits;
- result = diag->GetDiagnosticRecords().GetField(recNum, field, outBuffer);
+ using ignite::odbc::app::ApplicationDataBuffer;
- break;
- }
+ LOG_MSG("SQLGetDiagField called: %d\n", recNum);
- default:
- {
- result = SQL_RESULT_NO_DATA;
- break;
- }
- }
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, buffer, bufferLen, &outResLen);
- if (result == SQL_RESULT_SUCCESS)
- *resLen = static_cast<SQLSMALLINT>(outResLen);
+ SqlResult result;
- return SqlResultToReturnCode(result);
-}
+ DiagnosticField field = DiagnosticFieldToInternal(diagId);
-SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT recNum,
- SQLCHAR* sqlState,
- SQLINTEGER* nativeError,
- SQLCHAR* msgBuffer,
- SQLSMALLINT msgBufferLen,
- SQLSMALLINT* msgLen)
-{
- using namespace ignite::utility;
- using namespace ignite::odbc;
- using namespace ignite::odbc::diagnostic;
- using namespace ignite::odbc::type_traits;
-
- using ignite::odbc::app::ApplicationDataBuffer;
-
- LOG_MSG("SQLGetDiagRec called\n");
-
- const DiagnosticRecordStorage* records = 0;
-
- switch (handleType)
- {
- case SQL_HANDLE_ENV:
- case SQL_HANDLE_DBC:
- case SQL_HANDLE_STMT:
+ switch (handleType)
{
- Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
-
- records = &diag->GetDiagnosticRecords();
-
- break;
+ case SQL_HANDLE_ENV:
+ case SQL_HANDLE_DBC:
+ case SQL_HANDLE_STMT:
+ {
+ Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
+
+ result = diag->GetDiagnosticRecords().GetField(recNum, field, outBuffer);
+
+ break;
+ }
+
+ default:
+ {
+ result = SQL_RESULT_NO_DATA;
+ break;
+ }
}
- default:
- break;
- }
+ if (result == SQL_RESULT_SUCCESS)
+ *resLen = static_cast<SQLSMALLINT>(outResLen);
- if (!records || recNum < 1 || recNum > records->GetStatusRecordsNumber())
- return SQL_NO_DATA;
+ return SqlResultToReturnCode(result);
+ }
- const DiagnosticRecord& record = records->GetStatusRecord(recNum);
+ SQLRETURN SQLGetDiagRec(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLCHAR* sqlState,
+ SQLINTEGER* nativeError,
+ SQLCHAR* msgBuffer,
+ SQLSMALLINT msgBufferLen,
+ SQLSMALLINT* msgLen)
+ {
+ using namespace ignite::utility;
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::diagnostic;
+ using namespace ignite::odbc::type_traits;
- if (sqlState)
- CopyStringToBuffer(record.GetSqlState(), reinterpret_cast<char*>(sqlState), 6);
+ using ignite::odbc::app::ApplicationDataBuffer;
- if (nativeError)
- *nativeError = 0;
+ LOG_MSG("SQLGetDiagRec called\n");
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
+ const DiagnosticRecordStorage* records = 0;
- outBuffer.PutString(record.GetMessage());
+ switch (handleType)
+ {
+ case SQL_HANDLE_ENV:
+ case SQL_HANDLE_DBC:
+ case SQL_HANDLE_STMT:
+ {
+ Diagnosable *diag = reinterpret_cast<Diagnosable*>(handle);
- *msgLen = static_cast<SQLSMALLINT>(outResLen);
+ records = &diag->GetDiagnosticRecords();
- return SQL_SUCCESS;
-}
+ break;
+ }
-SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt,
- SQLSMALLINT type)
-{
- using ignite::odbc::Statement;
+ default:
+ break;
+ }
- LOG_MSG("SQLGetTypeInfo called\n");
+ if (!records || recNum < 1 || recNum > records->GetStatusRecordsNumber())
+ return SQL_NO_DATA;
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ const DiagnosticRecord& record = records->GetStatusRecord(recNum);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ if (sqlState)
+ CopyStringToBuffer(record.GetSqlState(), reinterpret_cast<char*>(sqlState), 6);
- statement->ExecuteGetTypeInfoQuery(static_cast<int16_t>(type));
+ if (nativeError)
+ *nativeError = 0;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
-SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType,
- SQLHANDLE handle,
- SQLSMALLINT completionType)
-{
- using namespace ignite::odbc;
+ outBuffer.PutString(record.GetMessage());
- LOG_MSG("SQLEndTran called\n");
+ *msgLen = static_cast<SQLSMALLINT>(outResLen);
- SQLRETURN result;
+ return SQL_SUCCESS;
+ }
- switch (handleType)
+ SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT type)
{
- case SQL_HANDLE_ENV:
- {
- Environment *env = reinterpret_cast<Environment*>(handle);
-
- if (!env)
- return SQL_INVALID_HANDLE;
-
- if (completionType == SQL_COMMIT)
- env->TransactionCommit();
- else
- env->TransactionRollback();
-
- result = env->GetDiagnosticRecords().GetReturnCode();
-
- break;
- }
-
- case SQL_HANDLE_DBC:
- {
- Connection *conn = reinterpret_cast<Connection*>(handle);
+ using ignite::odbc::Statement;
- if (!conn)
- return SQL_INVALID_HANDLE;
+ LOG_MSG("SQLGetTypeInfo called\n");
- if (completionType == SQL_COMMIT)
- conn->TransactionCommit();
- else
- conn->TransactionRollback();
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- result = conn->GetDiagnosticRecords().GetReturnCode();
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- break;
- }
-
- default:
- {
- result = SQL_INVALID_HANDLE;
+ statement->ExecuteGetTypeInfoQuery(static_cast<int16_t>(type));
- break;
- }
+ return statement->GetDiagnosticRecords().GetReturnCode();
}
- return result;
-}
-
-SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLSMALLINT targetType,
- SQLPOINTER targetValue,
- SQLLEN bufferLength,
- SQLLEN* strLengthOrIndicator)
-{
- using namespace ignite::odbc::type_traits;
+ SQLRETURN SQLEndTran(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT completionType)
+ {
+ using namespace ignite::odbc;
- using ignite::odbc::Statement;
- using ignite::odbc::app::ApplicationDataBuffer;
+ LOG_MSG("SQLEndTran called\n");
- LOG_MSG("SQLGetData called\n");
+ SQLRETURN result;
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ switch (handleType)
+ {
+ case SQL_HANDLE_ENV:
+ {
+ Environment *env = reinterpret_cast<Environment*>(handle);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ if (!env)
+ return SQL_INVALID_HANDLE;
- IgniteSqlType driverType = ToDriverType(targetType);
+ if (completionType == SQL_COMMIT)
+ env->TransactionCommit();
+ else
+ env->TransactionRollback();
- ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
+ result = env->GetDiagnosticRecords().GetReturnCode();
- statement->GetColumnData(colNum, dataBuffer);
+ break;
+ }
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ case SQL_HANDLE_DBC:
+ {
+ Connection *conn = reinterpret_cast<Connection*>(handle);
-SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Environment;
+ if (!conn)
+ return SQL_INVALID_HANDLE;
- LOG_MSG("SQLSetEnvAttr called\n");
+ if (completionType == SQL_COMMIT)
+ conn->TransactionCommit();
+ else
+ conn->TransactionRollback();
- Environment *environment = reinterpret_cast<Environment*>(env);
+ result = conn->GetDiagnosticRecords().GetReturnCode();
- if (!environment)
- return SQL_INVALID_HANDLE;
+ break;
+ }
- environment->SetAttribute(attr, value, valueLen);
+ default:
+ {
+ result = SQL_INVALID_HANDLE;
- return environment->GetDiagnosticRecords().GetReturnCode();
-}
+ break;
+ }
+ }
-SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- using namespace ignite::odbc;
- using namespace ignite::odbc::type_traits;
+ return result;
+ }
- using ignite::odbc::app::ApplicationDataBuffer;
+ SQLRETURN SQLGetData(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator)
+ {
+ using namespace ignite::odbc::type_traits;
- LOG_MSG("SQLGetEnvAttr called\n");
+ using ignite::odbc::Statement;
+ using ignite::odbc::app::ApplicationDataBuffer;
- Environment *environment = reinterpret_cast<Environment*>(env);
+ LOG_MSG("SQLGetData called\n");
- if (!environment)
- return SQL_INVALID_HANDLE;
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- SqlLen outResLen;
- ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, valueBuf,
- static_cast<int32_t>(valueBufLen), &outResLen);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- environment->GetAttribute(attr, outBuffer);
+ IgniteSqlType driverType = ToDriverType(targetType);
- *valueResLen = static_cast<SQLSMALLINT>(outResLen);
+ ApplicationDataBuffer dataBuffer(driverType, targetValue, bufferLength, strLengthOrIndicator);
- return environment->GetDiagnosticRecords().GetReturnCode();
-}
+ statement->GetColumnData(colNum, dataBuffer);
-SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT stmt,
- SQLSMALLINT idType,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLSMALLINT scope,
- SQLSMALLINT nullable)
-{
- using namespace ignite::odbc;
+ return statement->GetDiagnosticRecords().GetReturnCode();
+ }
- using ignite::utility::SqlStringToString;
+ SQLRETURN SQLSetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen)
+ {
+ using ignite::odbc::Environment;
- LOG_MSG("SQLSpecialColumns called\n");
+ LOG_MSG("SQLSetEnvAttr called\n");
- Statement *statement = reinterpret_cast<Statement*>(stmt);
+ Environment *environment = reinterpret_cast<Environment*>(env);
- if (!statement)
- return SQL_INVALID_HANDLE;
+ if (!environment)
+ return SQL_INVALID_HANDLE;
- std::string catalog = SqlStringToString(catalogName, catalogNameLen);
- std::string schema = SqlStringToString(schemaName, schemaNameLen);
- std::string table = SqlStringToString(tableName, tableNameLen);
+ environment->SetAttribute(attr, value, valueLen);
- LOG_MSG("catalog: %s\n", catalog.c_str());
- LOG_MSG("schema: %s\n", schema.c_str());
- LOG_MSG("table: %s\n", table.c_str());
+ return environment->GetDiagnosticRecords().GetReturnCode();
+ }
- statement->ExecuteSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
+ SQLRETURN SQLGetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen)
+ {
+ using namespace ignite::odbc;
+ using namespace ignite::odbc::type_traits;
- return statement->GetDiagnosticRecords().GetReturnCode();
-}
+ using ignite::odbc::app::ApplicationDataBuffer;
-//
-// ==== Not implemented ====
-//
+ LOG_MSG("SQLGetEnvAttr called\n");
-SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt)
-{
- LOG_MSG("SQLCancel called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLColAttributes(SQLHSTMT stmt,
- SQLUSMALLINT colNum,
- SQLUSMALLINT fieldId,
- SQLPOINTER strAttrBuf,
- SQLSMALLINT strAttrBufLen,
- SQLSMALLINT* strAttrResLen,
- SQLLEN* numAttrBuf)
-{
- LOG_MSG("SQLColAttributes called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLError(SQLHENV env,
- SQLHDBC conn,
- SQLHSTMT stmt,
- SQLCHAR* state,
- SQLINTEGER* error,
- SQLCHAR* msgBuf,
- SQLSMALLINT msgBufLen,
- SQLSMALLINT* msgResLen)
-{
- LOG_MSG("SQLError called\n");
- return(SQL_NO_DATA_FOUND);
-}
-
-SQLRETURN SQL_API SQLGetCursorName(SQLHSTMT stmt,
- SQLCHAR* nameBuf,
- SQLSMALLINT nameBufLen,
- SQLSMALLINT* nameResLen)
-{
- LOG_MSG("SQLGetCursorName called\n");
- return SQL_SUCCESS;
-}
+ Environment *environment = reinterpret_cast<Environment*>(env);
-SQLRETURN SQL_API SQLSetCursorName(SQLHSTMT stmt,
- SQLCHAR* name,
- SQLSMALLINT nameLen)
-{
- LOG_MSG("SQLSetCursorName called\n");
- return SQL_SUCCESS;
-}
+ if (!environment)
+ return SQL_INVALID_HANDLE;
-SQLRETURN SQL_API SQLGetConnectOption(SQLHDBC conn,
- SQLUSMALLINT option,
- SQLPOINTER value)
-{
- LOG_MSG("SQLGetConnectOption called\n");
- return SQL_SUCCESS;
-}
+ SqlLen outResLen;
+ ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_DEFAULT, valueBuf,
+ static_cast<int32_t>(valueBufLen), &outResLen);
-SQLRETURN SQL_API SQLGetFunctions(SQLHDBC conn,
- SQLUSMALLINT funcId,
- SQLUSMALLINT* supported)
-{
- LOG_MSG("SQLGetFunctions called\n");
- return SQL_SUCCESS;
-}
+ environment->GetAttribute(attr, outBuffer);
-SQLRETURN SQL_API SQLGetStmtOption(SQLHSTMT stmt,
- SQLUSMALLINT option,
- SQLPOINTER value)
-{
- LOG_MSG("SQLGetStmtOption called\n");
- return SQL_SUCCESS;
-}
+ if (valueResLen)
+ *valueResLen = static_cast<SQLSMALLINT>(outResLen);
-SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt,
- SQLPOINTER* value)
-{
- LOG_MSG("SQLParamData called\n");
- return SQL_SUCCESS;
-}
+ return environment->GetDiagnosticRecords().GetReturnCode();
+ }
-SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt,
- SQLPOINTER data,
- SQLLEN strLengthOrIndicator)
-{
- LOG_MSG("SQLPutData called\n");
- return SQL_SUCCESS;
-}
+ SQLRETURN SQLSpecialColumns(SQLHSTMT stmt,
+ SQLSMALLINT idType,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLSMALLINT scope,
+ SQLSMALLINT nullable)
+ {
+ using namespace ignite::odbc;
-SQLRETURN SQL_API SQLSetConnectOption(SQLHDBC conn,
- SQLUSMALLINT option,
- SQLULEN value)
-{
- LOG_MSG("SQLSetConnectOption called\n");
- return SQL_SUCCESS;
-}
+ using ignite::utility::SqlStringToString;
-SQLRETURN SQL_API SQLSetStmtOption(SQLHSTMT stmt,
- SQLUSMALLINT option,
- SQLULEN value)
-{
- LOG_MSG("SQLSetStmtOption called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLStatistics(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen,
- SQLUSMALLINT unique,
- SQLUSMALLINT reserved)
-{
- LOG_MSG("SQLStatistics called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLBrowseConnect(SQLHDBC conn,
- SQLCHAR* inConnectionStr,
- SQLSMALLINT inConnectionStrLen,
- SQLCHAR* outConnectionStrBuf,
- SQLSMALLINT outConnectionStrBufLen,
- SQLSMALLINT* outConnectionStrResLen)
-{
- LOG_MSG("SQLBrowseConnect called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLProcedureColumns(SQLHSTMT stmt,
- SQLCHAR * catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR * schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR * procName,
- SQLSMALLINT procNameLen,
- SQLCHAR * columnName,
- SQLSMALLINT columnNameLen)
-{
- LOG_MSG("SQLProcedureColumns called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetPos(SQLHSTMT stmt,
- SQLSETPOSIROW rowNum,
- SQLUSMALLINT operation,
- SQLUSMALLINT lockType)
-{
- LOG_MSG("SQLSetPos called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT stmt,
- SQLUSMALLINT concurrency,
- SQLLEN crowKeyset,
- SQLUSMALLINT crowRowset)
-{
- LOG_MSG("SQLSetScrollOptions called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn,
- SQLINTEGER attr,
- SQLPOINTER valueBuf,
- SQLINTEGER valueBufLen,
- SQLINTEGER* valueResLen)
-{
- LOG_MSG("SQLGetConnectAttr called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn,
- SQLINTEGER attr,
- SQLPOINTER value,
- SQLINTEGER valueLen)
-{
- using ignite::odbc::Connection;
+ LOG_MSG("SQLSpecialColumns called\n");
- LOG_MSG("SQLSetConnectAttr called\n");
+ Statement *statement = reinterpret_cast<Statement*>(stmt);
- Connection *connection = reinterpret_cast<Connection*>(conn);
+ if (!statement)
+ return SQL_INVALID_HANDLE;
- if (!connection)
- return SQL_INVALID_HANDLE;
+ std::string catalog = SqlStringToString(catalogName, catalogNameLen);
+ std::string schema = SqlStringToString(schemaName, schemaNameLen);
+ std::string table = SqlStringToString(tableName, tableNameLen);
- return SQL_SUCCESS;
-}
+ LOG_MSG("catalog: %s\n", catalog.c_str());
+ LOG_MSG("schema: %s\n", schema.c_str());
+ LOG_MSG("table: %s\n", table.c_str());
-SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT stmt,
- SQLUSMALLINT operation)
-{
- LOG_MSG("SQLBulkOperations called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLTablePrivileges(SQLHSTMT stmt,
- SQLCHAR* catalogName,
- SQLSMALLINT catalogNameLen,
- SQLCHAR* schemaName,
- SQLSMALLINT schemaNameLen,
- SQLCHAR* tableName,
- SQLSMALLINT tableNameLen)
-{
- LOG_MSG("SQLTablePrivileges called\n");
- return SQL_SUCCESS;
-}
+ statement->ExecuteSpecialColumnsQuery(idType, catalog, schema, table, scope, nullable);
-SQLRETURN SQL_API SQLCopyDesc(SQLHDESC src, SQLHDESC dst)
-{
- LOG_MSG("SQLCopyDesc called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetDescField(SQLHDESC descr,
- SQLSMALLINT recNum,
- SQLSMALLINT fieldId,
- SQLPOINTER buffer,
- SQLINTEGER bufferLen,
- SQLINTEGER* resLen)
-{
- LOG_MSG("SQLGetDescField called\n");
- return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
- SQLSMALLINT RecNumber,
- SQLCHAR* nameBuffer,
-
<TRUNCATED>
[4/5] ignite git commit: IGNITE-2557: Added tests.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
new file mode 100644
index 0000000..0ca5dad
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -0,0 +1,510 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <vector>
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+#include "test_type.h"
+#include "test_utils.h"
+
+using namespace test_utils;
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::common::utils;
+
+using namespace boost::unit_test;
+
+/** Read buffer size. */
+enum { ODBC_BUFFER_SIZE = 1024 };
+
+/**
+ * Extract error message.
+ *
+ * @param handleType Type of the handle.
+ * @param handle Handle.
+ * @return Error message.
+ */
+std::string GetOdbcErrorMessage(SQLSMALLINT handleType, SQLHANDLE handle)
+{
+ SQLCHAR sqlstate[7] = {};
+ SQLINTEGER nativeCode;
+
+ SQLCHAR message[ODBC_BUFFER_SIZE];
+ SQLSMALLINT reallen = 0;
+
+ SQLGetDiagRec(handleType, handle, 1, sqlstate, &nativeCode, message, ODBC_BUFFER_SIZE, &reallen);
+
+ return std::string(reinterpret_cast<char*>(sqlstate)) + ": " +
+ std::string(reinterpret_cast<char*>(message), reallen);
+}
+
+/**
+ * Test setup fixture.
+ */
+struct QueriesTestSuiteFixture
+{
+ /**
+ * Constructor.
+ */
+ QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ {
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
+ cfg.springCfgPath = std::string(cfgPath).append("/").append("queries-test.xml");
+
+ IgniteError err;
+
+ grid = Ignition::Start(cfg, &err);
+
+ if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+ {
+ Ignition::Stop(grid.GetName(), true);
+
+ BOOST_FAIL(err.GetText());
+ }
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+
+ // Allocate an environment handle
+ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
+
+ BOOST_REQUIRE(env != NULL);
+
+ // We want ODBC 3 support
+ SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
+
+ // Allocate a connection handle
+ SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
+
+ BOOST_REQUIRE(dbc != NULL);
+
+ // Connect string
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=11443;CACHE=cache";
+
+ SQLCHAR outstr[ODBC_BUFFER_SIZE];
+ SQLSMALLINT outstrlen;
+
+ // Connecting to ODBC server.
+ SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
+ outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
+
+ if (!SQL_SUCCEEDED(ret))
+ {
+ Ignition::Stop(grid.GetName(), true);
+
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc));
+ }
+
+ // Allocate a statement handle
+ SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
+
+ BOOST_REQUIRE(stmt != NULL);
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueriesTestSuiteFixture()
+ {
+ // Releasing statement handle.
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+
+ // Disconneting from the server.
+ SQLDisconnect(dbc);
+
+ // Releasing allocated handles.
+ SQLFreeHandle(SQL_HANDLE_DBC, dbc);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+
+ Ignition::Stop(grid.GetName(), true);
+ }
+
+ template<typename T>
+ void CheckTwoRowsInt(SQLSMALLINT type)
+ {
+ SQLRETURN ret;
+
+ testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+ testCache.Put(2, TestType(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 456)));
+
+ const size_t columnsCnt = 11;
+
+ T columns[columnsCnt] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, type, &columns[i], sizeof(columns[i]), 0);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
+ "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+
+ ret = SQLExecDirect(stmt, request, SQL_NTS);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLFetch(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(columns[0], 1);
+ BOOST_CHECK_EQUAL(columns[1], 2);
+ BOOST_CHECK_EQUAL(columns[2], 3);
+ BOOST_CHECK_EQUAL(columns[3], 4);
+ BOOST_CHECK_EQUAL(columns[4], 5);
+ BOOST_CHECK_EQUAL(columns[5], 6);
+ BOOST_CHECK_EQUAL(columns[6], 7);
+ BOOST_CHECK_EQUAL(columns[7], 1);
+ BOOST_CHECK_EQUAL(columns[8], 0);
+ BOOST_CHECK_EQUAL(columns[9], 0);
+ BOOST_CHECK_EQUAL(columns[10], 0);
+
+ SQLLEN columnLens[columnsCnt] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, type, &columns[i], sizeof(columns[i]), &columnLens[i]);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(columns[0], 8);
+ BOOST_CHECK_EQUAL(columns[1], 7);
+ BOOST_CHECK_EQUAL(columns[2], 6);
+ BOOST_CHECK_EQUAL(columns[3], 5);
+ BOOST_CHECK_EQUAL(columns[4], 4);
+ BOOST_CHECK_EQUAL(columns[5], 3);
+ BOOST_CHECK_EQUAL(columns[6], 2);
+ BOOST_CHECK_EQUAL(columns[7], 0);
+ BOOST_CHECK_EQUAL(columns[8], 0);
+ BOOST_CHECK_EQUAL(columns[9], 0);
+ BOOST_CHECK_EQUAL(columns[10], 0);
+
+ BOOST_CHECK_EQUAL(columnLens[0], 0);
+ BOOST_CHECK_EQUAL(columnLens[1], 0);
+ BOOST_CHECK_EQUAL(columnLens[2], 0);
+ BOOST_CHECK_EQUAL(columnLens[3], 0);
+ BOOST_CHECK_EQUAL(columnLens[4], 0);
+ BOOST_CHECK_EQUAL(columnLens[5], 0);
+ BOOST_CHECK_EQUAL(columnLens[6], 0);
+ BOOST_CHECK_EQUAL(columnLens[7], 0);
+ BOOST_CHECK_EQUAL(columnLens[8], SQL_NO_TOTAL);
+ BOOST_CHECK_EQUAL(columnLens[9], SQL_NO_TOTAL);
+ BOOST_CHECK_EQUAL(columnLens[10], SQL_NO_TOTAL);
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA);
+ }
+
+ /** Node started during the test. */
+ Ignite grid;
+
+ /** Test cache instance. */
+ Cache<int64_t, TestType> testCache;
+
+ /** ODBC Environment. */
+ SQLHENV env;
+
+ /** ODBC Connect. */
+ SQLHDBC dbc;
+
+ /** ODBC Statement. */
+ SQLHSTMT stmt;
+};
+
+BOOST_FIXTURE_TEST_SUITE(QueriesTestSuite, QueriesTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsInt8)
+{
+ CheckTwoRowsInt<int8_t>(SQL_C_STINYINT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsUint8)
+{
+ CheckTwoRowsInt<uint8_t>(SQL_C_UTINYINT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsInt16)
+{
+ CheckTwoRowsInt<int16_t>(SQL_C_SSHORT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsUint16)
+{
+ CheckTwoRowsInt<uint16_t>(SQL_C_USHORT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsInt32)
+{
+ CheckTwoRowsInt<int32_t>(SQL_C_SLONG);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsUint32)
+{
+ CheckTwoRowsInt<uint32_t>(SQL_C_ULONG);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsInt64)
+{
+ CheckTwoRowsInt<int64_t>(SQL_C_SBIGINT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsUint64)
+{
+ CheckTwoRowsInt<uint64_t>(SQL_C_UBIGINT);
+}
+
+BOOST_AUTO_TEST_CASE(TestTwoRowsString)
+{
+ SQLRETURN ret;
+
+ testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+ testCache.Put(2, TestType(8, 7, 6, 5, "4", 3.0f, 2.0, false, Guid(1, 0), MakeDate(1976, 1, 12), MakeTimestamp(1978, 8, 21, 23, 13, 45, 999999999)));
+
+ const size_t columnsCnt = 11;
+
+ SQLCHAR columns[columnsCnt][ODBC_BUFFER_SIZE] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, SQL_C_CHAR, &columns[i], ODBC_BUFFER_SIZE, 0);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
+ "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+
+ ret = SQLExecDirect(stmt, request, SQL_NTS);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLFetch(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[0])), "1");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[1])), "2");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[2])), "3");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[3])), "4");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[4])), "5");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[5])), "6");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[6])), "7");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[7])), "1");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0008-0000-000000000009");
+ // Such format is used because Date returned as Timestamp.
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1987-06-05 00:00:00");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1998-12-27 01:02:03");
+
+ SQLLEN columnLens[columnsCnt] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, SQL_C_CHAR, &columns[i], ODBC_BUFFER_SIZE, &columnLens[i]);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[0])), "8");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[1])), "7");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[2])), "6");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[3])), "5");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[4])), "4");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[5])), "3");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[6])), "2");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[7])), "0");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0001-0000-000000000000");
+ // Such format is used because Date returned as Timestamp.
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1976-01-12 00:00:00");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1978-08-21 23:13:45");
+
+ BOOST_CHECK_EQUAL(columnLens[0], 1);
+ BOOST_CHECK_EQUAL(columnLens[1], 1);
+ BOOST_CHECK_EQUAL(columnLens[2], 1);
+ BOOST_CHECK_EQUAL(columnLens[3], 1);
+ BOOST_CHECK_EQUAL(columnLens[4], 1);
+ BOOST_CHECK_EQUAL(columnLens[5], 1);
+ BOOST_CHECK_EQUAL(columnLens[6], 1);
+ BOOST_CHECK_EQUAL(columnLens[7], 1);
+ BOOST_CHECK_EQUAL(columnLens[8], 36);
+ BOOST_CHECK_EQUAL(columnLens[9], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 19);
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA);
+}
+
+BOOST_AUTO_TEST_CASE(TestOneRowString)
+{
+ SQLRETURN ret;
+
+ testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+
+ const size_t columnsCnt = 11;
+
+ SQLCHAR columns[columnsCnt][ODBC_BUFFER_SIZE] = { 0 };
+
+ SQLLEN columnLens[columnsCnt] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, SQL_C_CHAR, &columns[i], ODBC_BUFFER_SIZE, &columnLens[i]);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
+ "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+
+ ret = SQLExecDirect(stmt, request, SQL_NTS);
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[0])), "1");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[1])), "2");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[2])), "3");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[3])), "4");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[4])), "5");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[5])), "6");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[6])), "7");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[7])), "1");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[8])), "00000000-0000-0008-0000-000000000009");
+ // Such format is used because Date returned as Timestamp.
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[9])), "1987-06-05 00:00:00");
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(columns[10])), "1998-12-27 01:02:03");
+
+ BOOST_CHECK_EQUAL(columnLens[0], 1);
+ BOOST_CHECK_EQUAL(columnLens[1], 1);
+ BOOST_CHECK_EQUAL(columnLens[2], 1);
+ BOOST_CHECK_EQUAL(columnLens[3], 1);
+ BOOST_CHECK_EQUAL(columnLens[4], 1);
+ BOOST_CHECK_EQUAL(columnLens[5], 1);
+ BOOST_CHECK_EQUAL(columnLens[6], 1);
+ BOOST_CHECK_EQUAL(columnLens[7], 1);
+ BOOST_CHECK_EQUAL(columnLens[8], 36);
+ BOOST_CHECK_EQUAL(columnLens[9], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 19);
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA);
+}
+
+BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
+{
+ SQLRETURN ret;
+
+ testCache.Put(1, TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), MakeDate(1987, 6, 5), MakeTimestamp(1998, 12, 27, 1, 2, 3, 456)));
+
+ const size_t columnsCnt = 11;
+
+ SQLLEN columnLens[columnsCnt] = { 0 };
+
+ // Binding colums.
+ for (SQLSMALLINT i = 0; i < columnsCnt; ++i)
+ {
+ ret = SQLBindCol(stmt, i + 1, SQL_C_CHAR, 0, 0, &columnLens[i]);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+ }
+
+ SQLCHAR request[] = "SELECT i8Field, i16Field, i32Field, i64Field, strField, "
+ "floatField, doubleField, boolField, guidField, dateField, timestampField FROM TestType";
+
+ ret = SQLExecDirect(stmt, request, SQL_NTS);
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ BOOST_CHECK_EQUAL(columnLens[0], 1);
+ BOOST_CHECK_EQUAL(columnLens[1], 1);
+ BOOST_CHECK_EQUAL(columnLens[2], 1);
+ BOOST_CHECK_EQUAL(columnLens[3], 1);
+ BOOST_CHECK_EQUAL(columnLens[4], 1);
+ BOOST_CHECK_EQUAL(columnLens[5], 1);
+ BOOST_CHECK_EQUAL(columnLens[6], 1);
+ BOOST_CHECK_EQUAL(columnLens[7], 1);
+ BOOST_CHECK_EQUAL(columnLens[8], 36);
+ BOOST_CHECK_EQUAL(columnLens[9], 19);
+ BOOST_CHECK_EQUAL(columnLens[10], 19);
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_boost.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_boost.cpp b/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_boost.cpp
new file mode 100644
index 0000000..9a14fe9
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_boost.cpp
@@ -0,0 +1,159 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Revision: 88625 $
+*/
+
+#define BOOST_TEST_MODULE IgniteOdbcTest
+
+#include <sstream>
+
+#include <boost/test/unit_test_suite_impl.hpp>
+#include <boost/test/results_collector.hpp>
+#include <boost/test/utils/basic_cstring/io.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <boost/test/included/unit_test.hpp>
+
+#include "teamcity/teamcity_messages.h"
+
+using namespace boost::unit_test;
+using namespace std;
+
+namespace JetBrains {
+
+// Custom formatter for TeamCity messages
+class TeamcityBoostLogFormatter: public boost::unit_test::unit_test_log_formatter {
+ TeamcityMessages messages;
+ std::string currentDetails;
+ std::string flowId;
+
+public:
+ TeamcityBoostLogFormatter(const std::string &_flowId);
+ TeamcityBoostLogFormatter();
+
+ void log_start(std::ostream&, boost::unit_test::counter_t test_cases_amount);
+ void log_finish(std::ostream&);
+ void log_build_info(std::ostream&);
+
+ void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu);
+ void test_unit_finish(std::ostream&,
+ boost::unit_test::test_unit const& tu,
+ unsigned long elapsed);
+ void test_unit_skipped(std::ostream&, boost::unit_test::test_unit const& tu);
+
+ void log_exception(std::ostream&,
+ boost::unit_test::log_checkpoint_data const&,
+ boost::unit_test::const_string explanation);
+
+ void log_entry_start(std::ostream&,
+ boost::unit_test::log_entry_data const&,
+ log_entry_types let);
+ void log_entry_value(std::ostream&, boost::unit_test::const_string value);
+ void log_entry_finish(std::ostream&);
+};
+
+// Fake fixture to register formatter
+struct TeamcityFormatterRegistrar {
+ TeamcityFormatterRegistrar() {
+ if (JetBrains::underTeamcity()) {
+ boost::unit_test::unit_test_log.set_formatter(new JetBrains::TeamcityBoostLogFormatter());
+ boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
+ }
+ }
+};
+BOOST_GLOBAL_FIXTURE(TeamcityFormatterRegistrar);
+
+// Formatter implementation
+string toString(const_string bstr) {
+ stringstream ss;
+
+ ss << bstr;
+
+ return ss.str();
+}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter(const std::string &_flowId)
+: flowId(_flowId)
+{}
+
+TeamcityBoostLogFormatter::TeamcityBoostLogFormatter()
+: flowId(getFlowIdFromEnvironment())
+{}
+
+void TeamcityBoostLogFormatter::log_start(ostream &out, counter_t test_cases_amount)
+{}
+
+void TeamcityBoostLogFormatter::log_finish(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::log_build_info(ostream &out)
+{}
+
+void TeamcityBoostLogFormatter::test_unit_start(ostream &out, test_unit const& tu) {
+ messages.setOutput(out);
+
+ if (tu.p_type == tut_case) {
+ messages.testStarted(tu.p_name, flowId);
+ } else {
+ messages.suiteStarted(tu.p_name, flowId);
+ }
+
+ currentDetails.clear();
+}
+
+void TeamcityBoostLogFormatter::test_unit_finish(ostream &out, test_unit const& tu, unsigned long elapsed) {
+ messages.setOutput(out);
+
+ test_results const& tr = results_collector.results(tu.p_id);
+ if (tu.p_type == tut_case) {
+ if(!tr.passed()) {
+ if(tr.p_skipped) {
+ messages.testIgnored(tu.p_name, "ignored", flowId);
+ } else if (tr.p_aborted) {
+ messages.testFailed(tu.p_name, "aborted", currentDetails, flowId);
+ } else {
+ messages.testFailed(tu.p_name, "failed", currentDetails, flowId);
+ }
+ }
+
+ messages.testFinished(tu.p_name, elapsed / 1000, flowId);
+ } else {
+ messages.suiteFinished(tu.p_name, flowId);
+ }
+}
+
+void TeamcityBoostLogFormatter::test_unit_skipped(ostream &out, test_unit const& tu)
+{}
+
+void TeamcityBoostLogFormatter::log_exception(ostream &out, log_checkpoint_data const&, const_string explanation) {
+ string what = toString(explanation);
+
+ out << what << endl;
+ currentDetails += what + "\n";
+}
+
+void TeamcityBoostLogFormatter::log_entry_start(ostream&, log_entry_data const&, log_entry_types let)
+{}
+
+void TeamcityBoostLogFormatter::log_entry_value(ostream &out, const_string value) {
+ out << value;
+ currentDetails += toString(value);
+}
+
+void TeamcityBoostLogFormatter::log_entry_finish(ostream &out) {
+ out << endl;
+ currentDetails += "\n";
+}
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_messages.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_messages.cpp b/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_messages.cpp
new file mode 100644
index 0000000..1f224af
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/teamcity/teamcity_messages.cpp
@@ -0,0 +1,150 @@
+/* Copyright 2011 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Revision: 88625 $
+*/
+
+#include <stdlib.h>
+#include <sstream>
+
+#include "teamcity/teamcity_messages.h"
+
+using namespace std;
+
+namespace JetBrains {
+
+std::string getFlowIdFromEnvironment() {
+ const char *flowId = getenv("TEAMCITY_PROCESS_FLOW_ID");
+ return flowId == NULL ? "" : flowId;
+}
+
+bool underTeamcity() {
+ return getenv("TEAMCITY_PROJECT_NAME") != NULL;
+}
+
+TeamcityMessages::TeamcityMessages()
+: m_out(&cout)
+{}
+
+void TeamcityMessages::setOutput(ostream &out) {
+ m_out = &out;
+}
+
+string TeamcityMessages::escape(string s) {
+ string result;
+
+ for (size_t i = 0; i < s.length(); i++) {
+ char c = s[i];
+
+ switch (c) {
+ case '\n': result.append("|n"); break;
+ case '\r': result.append("|r"); break;
+ case '\'': result.append("|'"); break;
+ case '|': result.append("||"); break;
+ case ']': result.append("|]"); break;
+ default: result.append(1, c);
+ }
+ }
+
+ return result;
+}
+
+void TeamcityMessages::openMsg(const string &name) {
+ // endl for http://jetbrains.net/tracker/issue/TW-4412
+ *m_out << endl << "##teamcity[" << name;
+}
+
+void TeamcityMessages::closeMsg() {
+ *m_out << "]";
+ // endl for http://jetbrains.net/tracker/issue/TW-4412
+ *m_out << endl;
+ m_out->flush();
+}
+
+void TeamcityMessages::writeProperty(string name, string value) {
+ *m_out << " " << name << "='" << escape(value) << "'";
+}
+
+void TeamcityMessages::suiteStarted(string name, string flowid) {
+ openMsg("testSuiteStarted");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::suiteFinished(string name, string flowid) {
+ openMsg("testSuiteFinished");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testStarted(string name, string flowid) {
+ openMsg("testStarted");
+ writeProperty("name", name);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testFinished(string name, int durationMs, string flowid) {
+ openMsg("testFinished");
+
+ writeProperty("name", name);
+
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ if(durationMs >= 0) {
+ stringstream out;
+ out << durationMs;
+ writeProperty("duration", out.str());
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testFailed(string name, string message, string details, string flowid) {
+ openMsg("testFailed");
+ writeProperty("name", name);
+ writeProperty("message", message);
+ writeProperty("details", details);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+void TeamcityMessages::testIgnored(std::string name, std::string message, string flowid) {
+ openMsg("testIgnored");
+ writeProperty("name", name);
+ writeProperty("message", message);
+ if(flowid.length() > 0) {
+ writeProperty("flowId", flowid);
+ }
+
+ closeMsg();
+}
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp b/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
deleted file mode 100644
index 45c666d..0000000
--- a/modules/platforms/cpp/odbc-test/src/teamcity_boost.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Revision: 88625 $
-*/
-
-#define BOOST_TEST_MODULE IgniteCoreTest
-
-#include <sstream>
-
-#include <boost/test/unit_test_suite_impl.hpp>
-#include <boost/test/results_collector.hpp>
-#include <boost/test/utils/basic_cstring/io.hpp>
-#include <boost/test/unit_test_log.hpp>
-#include <boost/test/included/unit_test.hpp>
-
-#include "teamcity_messages.h"
-
-using namespace boost::unit_test;
-using namespace std;
-
-namespace JetBrains {
-
-// Custom formatter for TeamCity messages
-class TeamcityBoostLogFormatter: public boost::unit_test::unit_test_log_formatter {
- TeamcityMessages messages;
- std::string currentDetails;
- std::string flowId;
-
-public:
- TeamcityBoostLogFormatter(const std::string &_flowId);
- TeamcityBoostLogFormatter();
-
- void log_start(std::ostream&, boost::unit_test::counter_t test_cases_amount);
- void log_finish(std::ostream&);
- void log_build_info(std::ostream&);
-
- void test_unit_start(std::ostream&, boost::unit_test::test_unit const& tu);
- void test_unit_finish(std::ostream&,
- boost::unit_test::test_unit const& tu,
- unsigned long elapsed);
- void test_unit_skipped(std::ostream&, boost::unit_test::test_unit const& tu);
-
- void log_exception(std::ostream&,
- boost::unit_test::log_checkpoint_data const&,
- boost::unit_test::const_string explanation);
-
- void log_entry_start(std::ostream&,
- boost::unit_test::log_entry_data const&,
- log_entry_types let);
- void log_entry_value(std::ostream&, boost::unit_test::const_string value);
- void log_entry_finish(std::ostream&);
-};
-
-// Fake fixture to register formatter
-struct TeamcityFormatterRegistrar {
- TeamcityFormatterRegistrar() {
- if (JetBrains::underTeamcity()) {
- boost::unit_test::unit_test_log.set_formatter(new JetBrains::TeamcityBoostLogFormatter());
- boost::unit_test::unit_test_log.set_threshold_level(boost::unit_test::log_successful_tests);
- }
- }
-};
-BOOST_GLOBAL_FIXTURE(TeamcityFormatterRegistrar);
-
-// Formatter implementation
-string toString(const_string bstr) {
- stringstream ss;
-
- ss << bstr;
-
- return ss.str();
-}
-
-TeamcityBoostLogFormatter::TeamcityBoostLogFormatter(const std::string &_flowId)
-: flowId(_flowId)
-{}
-
-TeamcityBoostLogFormatter::TeamcityBoostLogFormatter()
-: flowId(getFlowIdFromEnvironment())
-{}
-
-void TeamcityBoostLogFormatter::log_start(ostream &out, counter_t test_cases_amount)
-{}
-
-void TeamcityBoostLogFormatter::log_finish(ostream &out)
-{}
-
-void TeamcityBoostLogFormatter::log_build_info(ostream &out)
-{}
-
-void TeamcityBoostLogFormatter::test_unit_start(ostream &out, test_unit const& tu) {
- messages.setOutput(out);
-
- if (tu.p_type == tut_case) {
- messages.testStarted(tu.p_name, flowId);
- } else {
- messages.suiteStarted(tu.p_name, flowId);
- }
-
- currentDetails.clear();
-}
-
-void TeamcityBoostLogFormatter::test_unit_finish(ostream &out, test_unit const& tu, unsigned long elapsed) {
- messages.setOutput(out);
-
- test_results const& tr = results_collector.results(tu.p_id);
- if (tu.p_type == tut_case) {
- if(!tr.passed()) {
- if(tr.p_skipped) {
- messages.testIgnored(tu.p_name, "ignored", flowId);
- } else if (tr.p_aborted) {
- messages.testFailed(tu.p_name, "aborted", currentDetails, flowId);
- } else {
- messages.testFailed(tu.p_name, "failed", currentDetails, flowId);
- }
- }
-
- messages.testFinished(tu.p_name, elapsed / 1000, flowId);
- } else {
- messages.suiteFinished(tu.p_name, flowId);
- }
-}
-
-void TeamcityBoostLogFormatter::test_unit_skipped(ostream &out, test_unit const& tu)
-{}
-
-void TeamcityBoostLogFormatter::log_exception(ostream &out, log_checkpoint_data const&, const_string explanation) {
- string what = toString(explanation);
-
- out << what << endl;
- currentDetails += what + "\n";
-}
-
-void TeamcityBoostLogFormatter::log_entry_start(ostream&, log_entry_data const&, log_entry_types let)
-{}
-
-void TeamcityBoostLogFormatter::log_entry_value(ostream &out, const_string value) {
- out << value;
- currentDetails += toString(value);
-}
-
-void TeamcityBoostLogFormatter::log_entry_finish(ostream &out) {
- out << endl;
- currentDetails += "\n";
-}
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp b/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
deleted file mode 100644
index 087409e..0000000
--- a/modules/platforms/cpp/odbc-test/src/teamcity_messages.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Copyright 2011 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Revision: 88625 $
-*/
-
-#include <stdlib.h>
-#include <sstream>
-
-#include "teamcity_messages.h"
-
-using namespace std;
-
-namespace JetBrains {
-
-std::string getFlowIdFromEnvironment() {
- const char *flowId = getenv("TEAMCITY_PROCESS_FLOW_ID");
- return flowId == NULL ? "" : flowId;
-}
-
-bool underTeamcity() {
- return getenv("TEAMCITY_PROJECT_NAME") != NULL;
-}
-
-TeamcityMessages::TeamcityMessages()
-: m_out(&cout)
-{}
-
-void TeamcityMessages::setOutput(ostream &out) {
- m_out = &out;
-}
-
-string TeamcityMessages::escape(string s) {
- string result;
-
- for (size_t i = 0; i < s.length(); i++) {
- char c = s[i];
-
- switch (c) {
- case '\n': result.append("|n"); break;
- case '\r': result.append("|r"); break;
- case '\'': result.append("|'"); break;
- case '|': result.append("||"); break;
- case ']': result.append("|]"); break;
- default: result.append(&c, 1);
- }
- }
-
- return result;
-}
-
-void TeamcityMessages::openMsg(const string &name) {
- // endl for http://jetbrains.net/tracker/issue/TW-4412
- *m_out << endl << "##teamcity[" << name;
-}
-
-void TeamcityMessages::closeMsg() {
- *m_out << "]";
- // endl for http://jetbrains.net/tracker/issue/TW-4412
- *m_out << endl;
- m_out->flush();
-}
-
-void TeamcityMessages::writeProperty(string name, string value) {
- *m_out << " " << name << "='" << escape(value) << "'";
-}
-
-void TeamcityMessages::suiteStarted(string name, string flowid) {
- openMsg("testSuiteStarted");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::suiteFinished(string name, string flowid) {
- openMsg("testSuiteFinished");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testStarted(string name, string flowid) {
- openMsg("testStarted");
- writeProperty("name", name);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testFinished(string name, int durationMs, string flowid) {
- openMsg("testFinished");
-
- writeProperty("name", name);
-
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- if(durationMs >= 0) {
- stringstream out;
- out << durationMs;
- writeProperty("duration", out.str());
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testFailed(string name, string message, string details, string flowid) {
- openMsg("testFailed");
- writeProperty("name", name);
- writeProperty("message", message);
- writeProperty("details", details);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-void TeamcityMessages::testIgnored(std::string name, std::string message, string flowid) {
- openMsg("testIgnored");
- writeProperty("name", name);
- writeProperty("message", message);
- if(flowid.length() > 0) {
- writeProperty("flowId", flowid);
- }
-
- closeMsg();
-}
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc-test/src/test_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/test_utils.cpp b/modules/platforms/cpp/odbc-test/src/test_utils.cpp
new file mode 100644
index 0000000..1f7ed82
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/test_utils.cpp
@@ -0,0 +1,80 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ctime>
+
+#include "test_utils.h"
+
+namespace test_utils
+{
+ /**
+ * Make Date in human understandable way.
+ *
+ * @param year Year.
+ * @param month Month.
+ * @param day Day.
+ * @param hour Hour.
+ * @param min Min.
+ * @param sec Sec.
+ * @return Date.
+ */
+ ignite::Date MakeDate(int year, int month, int day, int hour, int min, int sec)
+ {
+ tm date;
+
+ date.tm_year = year - 1900;
+ date.tm_mon = month - 1;
+ date.tm_mday = day;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ time_t ct = mktime(&date) - timezone;
+
+ return ignite::Date(ct * 1000);
+ }
+
+ /**
+ * Make Date in human understandable way.
+ *
+ * @param year Year.
+ * @param month Month.
+ * @param day Day.
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @param ns Nanosecond.
+ * @return Timestamp.
+ */
+ ignite::Timestamp MakeTimestamp(int year, int month, int day, int hour,
+ int min, int sec, long ns)
+ {
+ tm date;
+
+ date.tm_year = year - 1900;
+ date.tm_mon = month - 1;
+ date.tm_mday = day;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ time_t ct = mktime(&date) - timezone;
+
+ return ignite::Timestamp(ct, ns);
+ }
+
+} // namespace test_utils
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
index e9b83e5..f0cb2fc 100644
--- a/modules/platforms/cpp/odbc/Makefile.am
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -40,6 +40,7 @@ COMMON_SRC = os/linux/src/system/socket_client.cpp \
src/meta/column_meta.cpp \
src/meta/table_meta.cpp \
src/odbc.cpp \
+ src/entry_points.cpp \
src/query/column_metadata_query.cpp \
src/query/data_query.cpp \
src/query/foreign_keys_query.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/include/ignite/odbc.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc.h b/modules/platforms/cpp/odbc/include/ignite/odbc.h
new file mode 100644
index 0000000..f613491
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc.h
@@ -0,0 +1,258 @@
+/*
+ * 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 regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _IGNITE_ODBC
+#define _IGNITE_ODBC
+
+#include "ignite/odbc/system/odbc_constants.h"
+
+
+/**
+ * @file odbc.h
+ *
+ * Functions here are placed to the ignite namespace so there are no
+ * collisions with standard ODBC functions when we call driver API
+ * functions from other API functions. I.e, when we call SQLAllocEnv
+ * from SQLAllocHandle linker can place Driver Manager call here,
+ * instead of internal driver call. On other hand if we call
+ * ignite::SQLAllocEnv from ignite::SQLAllocHandle we can be sure
+ * there are no collisions.
+ */
+
+namespace ignite
+{
+ BOOL ConfigDSN(HWND hwndParent,
+ WORD req,
+ LPCSTR driver,
+ LPCSTR attributes);
+
+ SQLRETURN SQLGetInfo(SQLHDBC conn,
+ SQLUSMALLINT infoType,
+ SQLPOINTER infoValue,
+ SQLSMALLINT infoValueMax,
+ SQLSMALLINT* length);
+
+ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result);
+
+ SQLRETURN SQLAllocEnv(SQLHENV* env);
+
+ SQLRETURN SQLAllocConnect(SQLHENV env, SQLHDBC* conn);
+
+ SQLRETURN SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt);
+
+ SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle);
+
+ SQLRETURN SQLFreeEnv(SQLHENV env);
+
+ SQLRETURN SQLFreeConnect(SQLHDBC conn);
+
+ SQLRETURN SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option);
+
+ SQLRETURN SQLCloseCursor(SQLHSTMT stmt);
+
+ SQLRETURN SQLDriverConnect(SQLHDBC conn,
+ SQLHWND windowHandle,
+ SQLCHAR* inConnectionString,
+ SQLSMALLINT inConnectionStringLen,
+ SQLCHAR* outConnectionString,
+ SQLSMALLINT outConnectionStringBufferLen,
+ SQLSMALLINT* outConnectionStringLen,
+ SQLUSMALLINT driverCompletion);
+
+ SQLRETURN SQLConnect(SQLHDBC conn,
+ SQLCHAR* serverName,
+ SQLSMALLINT serverNameLen,
+ SQLCHAR* userName,
+ SQLSMALLINT userNameLen,
+ SQLCHAR* auth,
+ SQLSMALLINT authLen);
+
+ SQLRETURN SQLDisconnect(SQLHDBC conn);
+
+ SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen);
+
+ SQLRETURN SQLExecute(SQLHSTMT stmt);
+
+ SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLCHAR* query, SQLINTEGER queryLen);
+
+ SQLRETURN SQLBindCol(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator);
+
+ SQLRETURN SQLFetch(SQLHSTMT stmt);
+
+ SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT orientation, SQLLEN offset);
+
+ SQLRETURN SQLExtendedFetch(SQLHSTMT stmt,
+ SQLUSMALLINT orientation,
+ SQLLEN offset,
+ SQLULEN* rowCount,
+ SQLUSMALLINT* rowStatusArray);
+
+ SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT *columnNum);
+
+ SQLRETURN SQLTables(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* tableType,
+ SQLSMALLINT tableTypeLen);
+
+ SQLRETURN SQLColumns(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLCHAR* columnName,
+ SQLSMALLINT columnNameLen);
+
+ SQLRETURN SQLMoreResults(SQLHSTMT stmt);
+
+ SQLRETURN SQLBindParameter(SQLHSTMT stmt,
+ SQLUSMALLINT paramIdx,
+ SQLSMALLINT ioType,
+ SQLSMALLINT bufferType,
+ SQLSMALLINT paramSqlType,
+ SQLULEN columnSize,
+ SQLSMALLINT decDigits,
+ SQLPOINTER buffer,
+ SQLLEN bufferLen,
+ SQLLEN* resLen);
+
+ SQLRETURN SQLNativeSql(SQLHDBC conn,
+ SQLCHAR* inQuery,
+ SQLINTEGER inQueryLen,
+ SQLCHAR* outQueryBuffer,
+ SQLINTEGER outQueryBufferLen,
+ SQLINTEGER* outQueryLen);
+
+ SQLRETURN SQLColAttribute(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLUSMALLINT fieldId,
+ SQLPOINTER strAttr,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* strAttrLen,
+ SQLLEN* numericAttr);
+
+ SQLRETURN SQLDescribeCol(SQLHSTMT stmt,
+ SQLUSMALLINT columnNum,
+ SQLCHAR* columnNameBuf,
+ SQLSMALLINT columnNameBufLen,
+ SQLSMALLINT* columnNameLen,
+ SQLSMALLINT* dataType,
+ SQLULEN* columnSize,
+ SQLSMALLINT* decimalDigits,
+ SQLSMALLINT* nullable);
+
+ SQLRETURN SQLRowCount(SQLHSTMT stmt, SQLLEN* rowCnt);
+
+ SQLRETURN SQLForeignKeys(SQLHSTMT stmt,
+ SQLCHAR* primaryCatalogName,
+ SQLSMALLINT primaryCatalogNameLen,
+ SQLCHAR* primarySchemaName,
+ SQLSMALLINT primarySchemaNameLen,
+ SQLCHAR* primaryTableName,
+ SQLSMALLINT primaryTableNameLen,
+ SQLCHAR* foreignCatalogName,
+ SQLSMALLINT foreignCatalogNameLen,
+ SQLCHAR* foreignSchemaName,
+ SQLSMALLINT foreignSchemaNameLen,
+ SQLCHAR* foreignTableName,
+ SQLSMALLINT foreignTableNameLen);
+
+ SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen);
+
+ SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen);
+
+ SQLRETURN SQLPrimaryKeys(SQLHSTMT stmt,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen);
+
+ SQLRETURN SQLNumParams(SQLHSTMT stmt, SQLSMALLINT* paramCnt);
+
+ SQLRETURN SQLGetDiagField(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLSMALLINT diagId,
+ SQLPOINTER buffer,
+ SQLSMALLINT bufferLen,
+ SQLSMALLINT* resLen);
+
+ SQLRETURN SQLGetDiagRec(SQLSMALLINT handleType,
+ SQLHANDLE handle,
+ SQLSMALLINT recNum,
+ SQLCHAR* sqlState,
+ SQLINTEGER* nativeError,
+ SQLCHAR* msgBuffer,
+ SQLSMALLINT msgBufferLen,
+ SQLSMALLINT* msgLen);
+
+ SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT type);
+
+ SQLRETURN SQLEndTran(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT completionType);
+
+ SQLRETURN SQLGetData(SQLHSTMT stmt,
+ SQLUSMALLINT colNum,
+ SQLSMALLINT targetType,
+ SQLPOINTER targetValue,
+ SQLLEN bufferLength,
+ SQLLEN* strLengthOrIndicator);
+
+ SQLRETURN SQLSetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER value,
+ SQLINTEGER valueLen);
+
+ SQLRETURN SQLGetEnvAttr(SQLHENV env,
+ SQLINTEGER attr,
+ SQLPOINTER valueBuf,
+ SQLINTEGER valueBufLen,
+ SQLINTEGER* valueResLen);
+
+ SQLRETURN SQLSpecialColumns(SQLHSTMT stmt,
+ SQLSMALLINT idType,
+ SQLCHAR* catalogName,
+ SQLSMALLINT catalogNameLen,
+ SQLCHAR* schemaName,
+ SQLSMALLINT schemaNameLen,
+ SQLCHAR* tableName,
+ SQLSMALLINT tableNameLen,
+ SQLSMALLINT scope,
+ SQLSMALLINT nullable);
+
+} // namespace ignite
+
+#endif //_IGNITE_ODBC
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
index 8a4e70d..061e030 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/app/application_data_buffer.h
@@ -230,6 +230,13 @@ namespace ignite
double GetDouble() const;
/**
+ * Get value of type GUID.
+ *
+ * @return Value of type Guid.
+ */
+ Guid GetGuid() const;
+
+ /**
* Get value of type Date.
*
* @return Value of type Date.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h b/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
index abf7f34..27ca0b7 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/decimal.h
@@ -22,7 +22,11 @@
namespace ignite
{
- //TODO: move to binary or common library.
+
+ /**
+ * Big decimal number implementation.
+ * @todo Move to binary or common library.
+ */
class Decimal
{
friend void swap(Decimal& first, Decimal& second);
@@ -88,13 +92,20 @@ namespace ignite
bool IsNegative() const;
/**
- * Get magnitude length.
+ * Get magnitude length in bytes.
*
- * @return Magnitude length.
+ * @return Magnitude length in bytes.
*/
int32_t GetLength() const;
/**
+ * Get number of significant bits of the magnitude.
+ *
+ * @return Number of significant bits of the magnitude.
+ */
+ int32_t BitLength() const;
+
+ /**
* Get magnitude pointer.
*
* @return Magnitude pointer.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
index 9efaba5..43fdb96 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/utility.h
@@ -159,6 +159,14 @@ namespace ignite
void ReadDecimal(ignite::impl::binary::BinaryReaderImpl& reader, Decimal& decimal);
/**
+ * Write decimal value using writer.
+ *
+ * @param writer Writer.
+ * @param decimal Decimal value.
+ */
+ void WriteDecimal(ignite::impl::binary::BinaryWriterImpl& writer, const Decimal& decimal);
+
+ /**
* Convert SQL string buffer to std::string.
*
* @param sqlStr SQL string buffer.
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
index 8cc612f..56f4e57 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -162,6 +162,7 @@
<ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
+ <ClCompile Include="..\..\src\entry_points.cpp" />
<ClCompile Include="..\..\src\environment.cpp" />
<ClCompile Include="..\..\src\meta\column_meta.cpp" />
<ClCompile Include="..\..\src\meta\table_meta.cpp" />
@@ -183,6 +184,7 @@
<None Include="module.def" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\include\ignite\odbc.h" />
<ClInclude Include="..\..\include\ignite\odbc\app\application_data_buffer.h" />
<ClInclude Include="..\..\include\ignite\odbc\app\parameter.h" />
<ClInclude Include="..\..\include\ignite\odbc\column.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
index d47684a..901c93b 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -115,6 +115,9 @@
<ClCompile Include="..\..\src\query\special_columns_query.cpp">
<Filter>Code\query</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\entry_points.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="module.def">
@@ -225,5 +228,8 @@
<ClInclude Include="..\..\include\ignite\odbc\query\special_columns_query.h">
<Filter>Code\query</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
index 66c8831..d108f39 100644
--- a/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
+++ b/modules/platforms/cpp/odbc/src/app/application_data_buffer.cpp
@@ -150,13 +150,12 @@ namespace ignite
SQL_NUMERIC_STRUCT* out =
reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
- out->precision = 0;
+ out->precision = 20; // Max int64_t precision
out->scale = 0;
- out->sign = value > 0 ? 1 : 0;
+ out->sign = value < 0 ? 2 : 1;
memset(out->val, 0, SQL_MAX_NUMERIC_LEN);
- // TODO: implement propper conversation to numeric type.
int64_t intVal = static_cast<int64_t>(std::abs(value));
memcpy(out->val, &intVal, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(intVal)));
@@ -547,24 +546,9 @@ namespace ignite
case IGNITE_ODBC_C_TYPE_DOUBLE:
case IGNITE_ODBC_C_TYPE_CHAR:
case IGNITE_ODBC_C_TYPE_WCHAR:
- {
- PutNum<double>(static_cast<double>(value));
-
- break;
- }
-
case IGNITE_ODBC_C_TYPE_NUMERIC:
{
- if (GetData())
- {
- SQL_NUMERIC_STRUCT* numeric =
- reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());
-
- numeric->sign = value.IsNegative() ? 1 : 0;
- numeric->precision = 0;
- numeric->scale = value.GetScale();
- memcpy(numeric->val, value.GetMagnitude(), std::min<size_t>(SQL_MAX_NUMERIC_LEN, value.GetLength()));
- }
+ PutNum<double>(static_cast<double>(value));
break;
}
@@ -611,7 +595,7 @@ namespace ignite
*GetResLen() = strlen(buffer);
}
else if (GetResLen())
- *GetResLen() = sizeof("HHHH-MM-DD");
+ *GetResLen() = sizeof("HHHH-MM-DD") - 1;
break;
}
@@ -637,7 +621,7 @@ namespace ignite
*GetResLen() = toCopy;
}
else if (GetResLen())
- *GetResLen() = sizeof("HHHH-MM-DD");
+ *GetResLen() = sizeof("HHHH-MM-DD") - 1;
break;
}
@@ -722,7 +706,7 @@ namespace ignite
*GetResLen() = strlen(buffer);
}
else if (GetResLen())
- *GetResLen() = sizeof("HHHH-MM-DD HH:MM:SS");
+ *GetResLen() = sizeof("HHHH-MM-DD HH:MM:SS") - 1;
break;
}
@@ -748,7 +732,7 @@ namespace ignite
*GetResLen() = toCopy;
}
else if (GetResLen())
- *GetResLen() = sizeof("HHHH-MM-DD HH:MM:SS");
+ *GetResLen() = sizeof("HHHH-MM-DD HH:MM:SS") - 1;
break;
}
@@ -914,6 +898,50 @@ namespace ignite
return GetNum<double>();
}
+ Guid ApplicationDataBuffer::GetGuid() const
+ {
+ using namespace type_traits;
+
+ Guid res;
+
+ switch (type)
+ {
+ case IGNITE_ODBC_C_TYPE_CHAR:
+ {
+ std::string str(reinterpret_cast<const char*>(GetData()), static_cast<size_t>(buflen));
+
+ std::stringstream converter(str);
+
+ converter >> res;
+
+ break;
+ }
+
+ case IGNITE_ODBC_C_TYPE_GUID:
+ {
+ const SQLGUID* guid = reinterpret_cast<const SQLGUID*>(GetData());
+
+ uint64_t msb = static_cast<uint64_t>(guid->Data1) << 32 |
+ static_cast<uint64_t>(guid->Data2) << 16 |
+ static_cast<uint64_t>(guid->Data3);
+
+ uint64_t lsb = 0;
+
+ for (size_t i = 0; i < sizeof(guid->Data4); ++i)
+ lsb = guid->Data4[i] << (sizeof(guid->Data4) - i - 1) * 8;
+
+ res = Guid(msb, lsb);
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return res;
+ }
+
const void* ApplicationDataBuffer::GetData() const
{
return ApplyOffset(buffer);
@@ -1036,7 +1064,7 @@ namespace ignite
// TODO: implement propper conversation from numeric type.
memcpy(&resInt, numeric->val, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(resInt)));
- if (numeric->sign)
+ if (numeric->sign == 2)
resInt *= -1;
double resDouble = static_cast<double>(resInt);
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/app/parameter.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/app/parameter.cpp b/modules/platforms/cpp/odbc/src/app/parameter.cpp
index 26570c4..3ced3e8 100644
--- a/modules/platforms/cpp/odbc/src/app/parameter.cpp
+++ b/modules/platforms/cpp/odbc/src/app/parameter.cpp
@@ -109,6 +109,11 @@ namespace ignite
}
case SQL_TINYINT:
+ {
+ writer.WriteInt8(buffer.GetInt8());
+ break;
+ }
+
case SQL_BIT:
{
writer.WriteBool(buffer.GetInt8() != 0);
@@ -143,8 +148,19 @@ namespace ignite
}
case SQL_GUID:
+ {
+ writer.WriteGuid(buffer.GetGuid());
+
+ break;
+ }
+
+ case SQL_DECIMAL:
+ {
+ //TODO: Add Decimal type support.
+ break;
+ }
+
default:
- //TODO: Add GUID type support.
break;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
index 2ff05bc..1979823 100644
--- a/modules/platforms/cpp/odbc/src/config/configuration.cpp
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -86,6 +86,12 @@ namespace ignite
{
ArgumentMap connect_attributes;
+ // Ignoring terminating zero byte if present.
+ // Some Driver Managers pass zero-terminated connection string
+ // while others don't.
+ if (len && !str[len - 1])
+ --len;
+
ParseAttributeList(str, len, ';', connect_attributes);
ArgumentMap::const_iterator it;
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
index 37e81d0..b58b8f9 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -172,7 +172,7 @@ namespace ignite
OdbcProtocolHeader hdr;
- hdr.len = len;
+ hdr.len = static_cast<int32_t>(len);
int sent = socket.Send(reinterpret_cast<int8_t*>(&hdr), sizeof(hdr));
http://git-wip-us.apache.org/repos/asf/ignite/blob/075ab6fb/modules/platforms/cpp/odbc/src/decimal.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/decimal.cpp b/modules/platforms/cpp/odbc/src/decimal.cpp
index 0fa37fb..dcdc5b4 100644
--- a/modules/platforms/cpp/odbc/src/decimal.cpp
+++ b/modules/platforms/cpp/odbc/src/decimal.cpp
@@ -18,6 +18,8 @@
#include <cstring>
#include <utility>
+#include "ignite/common/utils.h"
+
#include "ignite/odbc/decimal.h"
namespace ignite
@@ -63,19 +65,11 @@ namespace ignite
{
double res = 0;
- int32_t localScale = GetScale();
-
for (int32_t i = 0; i < len; ++i)
- {
- res = (res * 256) + magnitude[i];
-
- while (localScale && res > 10.0)
- {
- res /= 10.0;
+ res = (res * 256) + static_cast<uint8_t>(magnitude[i]);
- --localScale;
- }
- }
+ for (int32_t i = 0; i < GetScale(); ++i)
+ res /= 10.0;
return res * GetSign();
}
@@ -97,7 +91,31 @@ namespace ignite
int32_t Decimal::GetLength() const
{
- return scale;
+ return len;
+ }
+
+ int32_t Decimal::BitLength() const
+ {
+ using namespace common::utils;
+
+ if (len == 0)
+ return 0;
+
+ int32_t bitsLen = (len - 1) * 8 +
+ BitLengthForOctet(magnitude[len - 1]);
+
+ if (IsNegative()) {
+
+ // Check if magnitude is a power of two
+ bool pow2 = PowerOfTwo(magnitude[len - 1]);
+ for (int i = 0; i < len - 1 && pow2; ++i)
+ pow2 = (magnitude[i] == 0);
+
+ if (pow2)
+ --bitsLen;
+ }
+
+ return bitsLen;
}
const int8_t* Decimal::GetMagnitude() const