ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From isap...@apache.org
Subject ignite git commit: IGNITE-6151: Impemented getting and setting of the SQL_ATTR_CONNECTION_DEAD
Date Tue, 12 Sep 2017 11:44:42 GMT
Repository: ignite
Updated Branches:
  refs/heads/master f5bbc709f -> 0bc1d8477


IGNITE-6151: Impemented getting and setting of the SQL_ATTR_CONNECTION_DEAD


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0bc1d847
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0bc1d847
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0bc1d847

Branch: refs/heads/master
Commit: 0bc1d8477c0f0783cc046cabed9a0bb7d3518b0f
Parents: f5bbc70
Author: Igor Sapego <isapego@gridgain.com>
Authored: Tue Sep 12 14:44:07 2017 +0300
Committer: Igor Sapego <isapego@gridgain.com>
Committed: Tue Sep 12 14:44:07 2017 +0300

----------------------------------------------------------------------
 modules/platforms/cpp/odbc-test/Makefile.am     |   1 +
 .../cpp/odbc-test/project/vs/odbc-test.vcxproj  |   1 +
 .../project/vs/odbc-test.vcxproj.filters        |   3 +
 .../cpp/odbc-test/src/attributes_test.cpp       | 208 +++++++++++++++++++
 .../platforms/cpp/odbc/include/ignite/odbc.h    |  22 +-
 .../cpp/odbc/include/ignite/odbc/connection.h   |  47 +++++
 modules/platforms/cpp/odbc/src/connection.cpp   | 100 ++++++++-
 modules/platforms/cpp/odbc/src/entry_points.cpp |  65 +++---
 modules/platforms/cpp/odbc/src/odbc.cpp         |  46 +++-
 9 files changed, 440 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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 7756181..69b62f9 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -78,6 +78,7 @@ ignite_odbc_tests_SOURCES = \
     src/sql_date_time_functions_test.cpp \
     src/sql_outer_join_test.cpp \
     src/api_robustness_test.cpp \
+    src/attributes_test.cpp \
     ../odbc/src/cursor.cpp \
     ../odbc/src/config/connection_info.cpp \
     ../odbc/src/app/application_data_buffer.cpp \

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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 d06064b..3977a24 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -164,6 +164,7 @@
     <ClCompile Include="..\..\..\odbc\src\utility.cpp" />
     <ClCompile Include="..\..\src\api_robustness_test.cpp" />
     <ClCompile Include="..\..\src\application_data_buffer_test.cpp" />
+    <ClCompile Include="..\..\src\attributes_test.cpp" />
     <ClCompile Include="..\..\src\column_test.cpp" />
     <ClCompile Include="..\..\src\configuration_test.cpp" />
     <ClCompile Include="..\..\src\connection_info_test.cpp" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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 91c029e..2a0c7b4 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
@@ -124,6 +124,9 @@
     <ClCompile Include="..\..\src\meta_queries_test.cpp">
       <Filter>Code</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\attributes_test.cpp">
+      <Filter>Code</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\include\test_type.h">

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/modules/platforms/cpp/odbc-test/src/attributes_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/attributes_test.cpp b/modules/platforms/cpp/odbc-test/src/attributes_test.cpp
new file mode 100644
index 0000000..3ac46cb
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/attributes_test.cpp
@@ -0,0 +1,208 @@
+/*
+ * 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 "ignite/impl/binary/binary_utils.h"
+
+#include "test_type.h"
+#include "test_utils.h"
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::common;
+using namespace ignite_test;
+
+using namespace boost::unit_test;
+
+using ignite::impl::binary::BinaryUtils;
+
+/**
+ * Test setup fixture.
+ */
+struct AttributesTestSuiteFixture
+{
+    void Prepare()
+    {
+        // 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);
+    }
+
+    /**
+     * Establish connection to node.
+     *
+     * @param connectStr Connection string.
+     */
+    void Connect(const std::string& connectStr)
+    {
+        Prepare();
+
+        // Connect string
+        std::vector<SQLCHAR> connectStr0;
+
+        connectStr0.reserve(connectStr.size() + 1);
+        std::copy(connectStr.begin(), connectStr.end(), std::back_inserter(connectStr0));
+
+        SQLCHAR outstr[ODBC_BUFFER_SIZE];
+        SQLSMALLINT outstrlen;
+
+        // Connecting to ODBC server.
+        SQLRETURN ret = SQLDriverConnect(dbc, NULL, &connectStr0[0], static_cast<SQLSMALLINT>(connectStr0.size()),
+            outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
+
+        ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_DBC, dbc);
+
+        // Allocate a statement handle
+        SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
+
+        BOOST_REQUIRE(stmt != NULL);
+    }
+
+    void Disconnect()
+    {
+        // 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);
+    }
+
+    /**
+     * Constructor.
+     */
+    AttributesTestSuiteFixture() :
+        env(NULL),
+        dbc(NULL),
+        stmt(NULL)
+    {
+        const char* config = NULL;
+
+#ifdef IGNITE_TESTS_32
+          config = "queries-test-32.xml";
+#else
+          config = "queries-test.xml";
+#endif
+
+        grid = StartNode(config, "NodeMain");
+    }
+
+    void CheckSQLDiagnosticError(int16_t handleType, SQLHANDLE handle, const std::string&
expectSqlState)
+    {
+        SQLCHAR state[ODBC_BUFFER_SIZE];
+        SQLINTEGER nativeError = 0;
+        SQLCHAR message[ODBC_BUFFER_SIZE];
+        SQLSMALLINT messageLen = 0;
+
+        SQLRETURN ret = SQLGetDiagRec(handleType, handle, 1, state, &nativeError, message,
sizeof(message), &messageLen);
+
+        const std::string sqlState = reinterpret_cast<char*>(state);
+        BOOST_REQUIRE_EQUAL(ret, SQL_SUCCESS);
+        BOOST_REQUIRE_EQUAL(sqlState, expectSqlState);
+        BOOST_REQUIRE(messageLen > 0);
+    }
+
+    void CheckSQLConnectionDiagnosticError(const std::string& expectSqlState)
+    {
+        CheckSQLDiagnosticError(SQL_HANDLE_DBC, dbc, expectSqlState);
+    }
+
+    /**
+     * Destructor.
+     */
+    ~AttributesTestSuiteFixture()
+    {
+        Disconnect();
+
+        Ignition::StopAll(true);
+    }
+
+    /** Node started during the test. */
+    Ignite grid;
+
+    /** ODBC Environment. */
+    SQLHENV env;
+
+    /** ODBC Connect. */
+    SQLHDBC dbc;
+
+    /** ODBC Statement. */
+    SQLHSTMT stmt;
+};
+
+BOOST_FIXTURE_TEST_SUITE(AttributesTestSuite, AttributesTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(ConnectionAttributeConnectionDeadGet)
+{
+    Connect("DRIVER={Apache Ignite};address=127.0.0.1:11110;schema=cache");
+
+    SQLINTEGER dead = SQL_CD_TRUE;
+    SQLRETURN ret;
+
+    ret = SQLGetConnectAttr(dbc, SQL_ATTR_CONNECTION_DEAD, &dead, 0, 0);
+
+    ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_DBC, dbc);
+
+    BOOST_REQUIRE_EQUAL(dead, SQL_CD_FALSE);
+}
+
+BOOST_AUTO_TEST_CASE(ConnectionAttributeConnectionDeadSet)
+{
+    Connect("DRIVER={Apache Ignite};address=127.0.0.1:11110;schema=cache");
+
+    SQLINTEGER dead = SQL_CD_TRUE;
+    SQLRETURN ret;
+
+    ret = SQLSetConnectAttr(dbc, SQL_ATTR_CONNECTION_DEAD, &dead, 0);
+
+    BOOST_REQUIRE_EQUAL(ret, SQL_ERROR);
+
+    // According to https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetconnectattr-function#diagnostics
+    CheckSQLConnectionDiagnosticError("HY092");
+}
+
+BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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
index 639a02a..402d737 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc.h
@@ -251,6 +251,13 @@ namespace ignite
 
     SQLRETURN SQLPutData(SQLHSTMT stmt, SQLPOINTER data, SQLLEN strLengthOrIndicator);
 
+    SQLRETURN SQLDescribeParam(SQLHSTMT     stmt,
+                               SQLUSMALLINT paramNum,
+                               SQLSMALLINT* dataType,
+                               SQLULEN*     paramSize,
+                               SQLSMALLINT* decimalDigits,
+                               SQLSMALLINT* nullable);
+
     SQLRETURN SQLError(SQLHENV      env,
                        SQLHDBC      conn,
                        SQLHSTMT     stmt,
@@ -260,13 +267,16 @@ namespace ignite
                        SQLSMALLINT  msgBufLen,
                        SQLSMALLINT* msgResLen);
 
-    SQLRETURN SQLDescribeParam(SQLHSTMT     stmt,
-                               SQLUSMALLINT paramNum,
-                               SQLSMALLINT* dataType,
-                               SQLULEN*     paramSize,
-                               SQLSMALLINT* decimalDigits,
-                               SQLSMALLINT* nullable);
+    SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC    conn,
+                                        SQLINTEGER attr,
+                                        SQLPOINTER valueBuf,
+                                        SQLINTEGER valueBufLen,
+                                        SQLINTEGER* valueResLen);
 
+    SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC    conn,
+                                        SQLINTEGER attr,
+                                        SQLPOINTER value,
+                                        SQLINTEGER valueLen);
 } // namespace ignite
 
 #endif //_IGNITE_ODBC

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
index da19e1b..fa80a01 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
@@ -162,6 +162,25 @@ namespace ignite
              */
             void TransactionRollback();
 
+            /**
+             * Get connection attribute.
+             *
+             * @param attr Attribute type.
+             * @param buf Buffer for value.
+             * @param bufLen Buffer length.
+             * @param valueLen Resulting value length.
+             */
+            void GetAttribute(int attr, void* buf, SQLINTEGER bufLen, SQLINTEGER *valueLen);
+
+            /**
+             * Set connection attribute.
+             *
+             * @param attr Attribute type.
+             * @param value Value pointer.
+             * @param valueLen Value length.
+             */
+            void SetAttribute(int attr, void* value, SQLINTEGER valueLen);
+
         private:
             IGNITE_NO_COPY_ASSIGNMENT(Connection);
 
@@ -192,6 +211,11 @@ namespace ignite
             SqlResult::Type InternalRelease();
 
             /**
+             * Close connection.
+             */
+            void Close();
+
+            /**
              * Get info of any type.
              * Internal call.
              *
@@ -229,6 +253,29 @@ namespace ignite
             SqlResult::Type InternalTransactionRollback();
 
             /**
+             * Get connection attribute.
+             * Internal call.
+             *
+             * @param attr Attribute type.
+             * @param buf Buffer for value.
+             * @param bufLen Buffer length.
+             * @param valueLen Resulting value length.
+             * @return Operation result.
+             */
+            SqlResult::Type InternalGetAttribute(int attr, void* buf, SQLINTEGER bufLen,
SQLINTEGER* valueLen);
+
+            /**
+             * Set connection attribute.
+             * Internal call.
+             *
+             * @param attr Attribute type.
+             * @param value Value pointer.
+             * @param valueLen Value length.
+             * @return Operation result.
+             */
+            SqlResult::Type InternalSetAttribute(int attr, void* value, SQLINTEGER valueLen);
+
+            /**
              * Receive specified number of bytes.
              *
              * @param dst Buffer for data.

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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 80d1695..53626d1 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -136,7 +136,12 @@ namespace ignite
                 return SqlResult::AI_ERROR;
             }
 
-            return MakeRequestHandshake();
+            SqlResult::Type res = MakeRequestHandshake();
+
+            if (res == SqlResult::AI_ERROR)
+                Close();
+
+            return res;
         }
 
         void Connection::Release()
@@ -153,11 +158,16 @@ namespace ignite
                 return SqlResult::AI_ERROR;
             }
 
+            Close();
+
+            return SqlResult::AI_SUCCESS;
+        }
+
+        void Connection::Close()
+        {
             socket.Close();
 
             connected = false;
-
-            return SqlResult::AI_SUCCESS;
         }
 
         Statement* Connection::CreateStatement()
@@ -217,7 +227,11 @@ namespace ignite
                 LOG_MSG("Sent: " << res);
 
                 if (res <= 0)
+                {
+                    Close();
+
                     return sent;
+                }
 
                 sent += res;
             }
@@ -240,7 +254,11 @@ namespace ignite
                 IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Can not receive message
header");
 
             if (hdr.len < 0)
-                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Message lenght is negative");
+            {
+                Close();
+
+                IGNITE_ERROR_1(IgniteError::IGNITE_ERR_GENERIC, "Message length is negative");
+            }
 
             if (hdr.len == 0)
                 return;
@@ -272,7 +290,11 @@ namespace ignite
                 LOG_MSG("Receive res: " << res << " remain: " << remain);
 
                 if (res <= 0)
+                {
+                    Close();
+
                     return received;
+                }
 
                 remain -= static_cast<size_t>(res);
             }
@@ -311,6 +333,74 @@ namespace ignite
             IGNITE_ODBC_API_CALL(InternalTransactionRollback());
         }
 
+        void Connection::GetAttribute(int attr, void* buf, SQLINTEGER bufLen, SQLINTEGER*
valueLen)
+        {
+            IGNITE_ODBC_API_CALL(InternalGetAttribute(attr, buf, bufLen, valueLen));
+        }
+
+        SqlResult::Type Connection::InternalGetAttribute(int attr, void* buf, SQLINTEGER
bufLen, SQLINTEGER* valueLen)
+        {
+            if (!buf)
+            {
+                AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "Data buffer is NULL.");
+
+                return SqlResult::AI_ERROR;
+            }
+
+            switch (attr)
+            {
+                case SQL_ATTR_CONNECTION_DEAD:
+                {
+                    SQLINTEGER *val = reinterpret_cast<SQLINTEGER*>(buf);
+
+                    *val = static_cast<SQLINTEGER>(connected ? SQL_CD_FALSE : SQL_CD_TRUE);
+
+                    if (valueLen)
+                        *valueLen = SQL_IS_INTEGER;
+
+                    break;
+                }
+
+                default:
+                {
+                    AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+                        "Specified attribute is not supported.");
+
+                    return SqlResult::AI_ERROR;
+                }
+            }
+
+            return SqlResult::AI_SUCCESS;
+        }
+
+        void Connection::SetAttribute(int attr, void* value, SQLINTEGER valueLen)
+        {
+            IGNITE_ODBC_API_CALL(InternalSetAttribute(attr, value, valueLen));
+        }
+
+        SqlResult::Type Connection::InternalSetAttribute(int attr, void* value, SQLINTEGER
valueLen)
+        {
+            switch (attr)
+            {
+                case SQL_ATTR_CONNECTION_DEAD:
+                {
+                    AddStatusRecord(SqlState::SHY092_OPTION_TYPE_OUT_OF_RANGE, "Attribute
can not be retrieved.");
+
+                    return SqlResult::AI_ERROR;
+                }
+
+                default:
+                {
+                    AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
+                        "Specified attribute is not supported.");
+
+                    return SqlResult::AI_ERROR;
+                }
+            }
+
+            return SqlResult::AI_SUCCESS;
+        }
+
         SqlResult::Type Connection::InternalTransactionRollback()
         {
             AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
@@ -383,8 +473,6 @@ namespace ignite
 
                 AddStatusRecord(SqlState::S08001_CANNOT_CONNECT, constructor.str());
 
-                InternalRelease();
-
                 return SqlResult::AI_ERROR;
             }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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
index e241a9f..d3c9e26 100644
--- a/modules/platforms/cpp/odbc/src/entry_points.cpp
+++ b/modules/platforms/cpp/odbc/src/entry_points.cpp
@@ -216,8 +216,7 @@ SQLRETURN SQL_API SQLNativeSql(SQLHDBC      conn,
                                SQLINTEGER   outQueryBufferLen,
                                SQLINTEGER*  outQueryLen)
 {
-    return ignite::SQLNativeSql(conn, inQuery, inQueryLen,
-        outQueryBuffer, outQueryBufferLen, outQueryLen);
+    return ignite::SQLNativeSql(conn, inQuery, inQueryLen, outQueryBuffer, outQueryBufferLen,
outQueryLen);
 }
 
 
@@ -239,8 +238,7 @@ SQLRETURN SQL_API SQLColAttribute(SQLHSTMT       stmt,
                                   SQLPOINTER     numericAttr)
 #endif
 {
-    return ignite::SQLColAttribute(stmt, columnNum, fieldId,
-        strAttr, bufferLen, strAttrLen, (SQLLEN*)numericAttr);
+    return ignite::SQLColAttribute(stmt, columnNum, fieldId, strAttr, bufferLen, strAttrLen,
(SQLLEN*)numericAttr);
 }
 
 SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT       stmt,
@@ -327,8 +325,7 @@ SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT   handleType,
                                   SQLSMALLINT   bufferLen,
                                   SQLSMALLINT*  resLen)
 {
-    return ignite::SQLGetDiagField(handleType, handle,
-        recNum, diagId, buffer, bufferLen, resLen);
+    return ignite::SQLGetDiagField(handleType, handle, recNum, diagId, buffer, bufferLen,
resLen);
 }
 
 SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT     handleType,
@@ -340,8 +337,7 @@ SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT     handleType,
                                 SQLSMALLINT     msgBufferLen,
                                 SQLSMALLINT*    msgLen)
 {
-    return ignite::SQLGetDiagRec(handleType, handle, recNum,
-        sqlState, nativeError, msgBuffer, msgBufferLen, msgLen);
+    return ignite::SQLGetDiagRec(handleType, handle, recNum, sqlState, nativeError, msgBuffer,
msgBufferLen, msgLen);
 }
 
 SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT type)
@@ -349,9 +345,7 @@ SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT type)
     return ignite::SQLGetTypeInfo(stmt, type);
 }
 
-SQLRETURN SQL_API SQLEndTran(SQLSMALLINT    handleType,
-                             SQLHANDLE      handle,
-                             SQLSMALLINT    completionType)
+SQLRETURN SQL_API SQLEndTran(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT completionType)
 {
     return ignite::SQLEndTran(handleType, handle, completionType);
 }
@@ -381,8 +375,7 @@ SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV     env,
                                 SQLINTEGER  valueBufLen,
                                 SQLINTEGER* valueResLen)
 {
-    return ignite::SQLGetEnvAttr(env, attr,
-        valueBuf, valueBufLen, valueResLen);
+    return ignite::SQLGetEnvAttr(env, attr, valueBuf, valueBufLen, valueResLen);
 }
 
 SQLRETURN SQL_API SQLSpecialColumns(SQLHSTMT    stmt,
@@ -405,9 +398,7 @@ SQLRETURN SQL_API SQLParamData(SQLHSTMT stmt, SQLPOINTER* value)
     return ignite::SQLParamData(stmt, value);
 }
 
-SQLRETURN SQL_API SQLPutData(SQLHSTMT     stmt,
-                             SQLPOINTER   data,
-                             SQLLEN       strLengthOrIndicator)
+SQLRETURN SQL_API SQLPutData(SQLHSTMT stmt, SQLPOINTER data, SQLLEN strLengthOrIndicator)
 {
     return ignite::SQLPutData(stmt, data, strLengthOrIndicator);
 }
@@ -419,8 +410,7 @@ SQLRETURN SQL_API SQLDescribeParam(SQLHSTMT     stmt,
                                    SQLSMALLINT* decimalDigits,
                                    SQLSMALLINT* nullable)
 {
-    return ignite::SQLDescribeParam(stmt, paramNum, dataType,
-     paramSize, decimalDigits, nullable);
+    return ignite::SQLDescribeParam(stmt, paramNum, dataType, paramSize, decimalDigits, nullable);
 }
 
 SQLRETURN SQL_API SQLError(SQLHENV      env,
@@ -432,8 +422,24 @@ SQLRETURN SQL_API SQLError(SQLHENV      env,
                            SQLSMALLINT  msgBufLen,
                            SQLSMALLINT* msgResLen)
 {
-    return ignite::SQLError(env, conn, stmt, state,
-        error, msgBuf, msgBufLen, msgResLen);
+    return ignite::SQLError(env, conn, stmt, state, error, msgBuf, msgBufLen, msgResLen);
+}
+
+SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC     conn,
+                                    SQLINTEGER  attr,
+                                    SQLPOINTER  valueBuf,
+                                    SQLINTEGER  valueBufLen,
+                                    SQLINTEGER* valueResLen)
+{
+    return ignite::SQLGetConnectAttr(conn, attr, valueBuf, valueBufLen, valueResLen);
+}
+
+SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC     conn,
+                                    SQLINTEGER  attr,
+                                    SQLPOINTER  value,
+                                    SQLINTEGER  valueLen)
+{
+    return ignite::SQLSetConnectAttr(conn, attr, value, valueLen);
 }
 
 //
@@ -564,25 +570,6 @@ SQLRETURN SQL_API SQLSetScrollOptions(SQLHSTMT      stmt,
     return SQL_SUCCESS;
 }
 
-SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC     conn,
-                                    SQLINTEGER  attr,
-                                    SQLPOINTER  valueBuf,
-                                    SQLINTEGER  valueBufLen,
-                                    SQLINTEGER* valueResLen)
-{
-    LOG_MSG("SQLGetConnectAttr called");
-    return SQL_SUCCESS;
-}
-
-SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC     conn,
-                                    SQLINTEGER  attr,
-                                    SQLPOINTER  value,
-                                    SQLINTEGER  valueLen)
-{
-    LOG_MSG("SQLSetConnectAttr called");
-    return SQL_SUCCESS;
-}
-
 SQLRETURN SQL_API SQLBulkOperations(SQLHSTMT       stmt,
                                     SQLUSMALLINT   operation)
 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0bc1d847/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 1862465..baa276a 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -1140,9 +1140,9 @@ namespace ignite
                             SQLINTEGER* valueResLen)
     {
         using namespace odbc;
-        using namespace odbc::type_traits;
+        using namespace type_traits;
 
-        using odbc::app::ApplicationDataBuffer;
+        using app::ApplicationDataBuffer;
 
         LOG_MSG("SQLGetEnvAttr called");
 
@@ -1310,4 +1310,46 @@ namespace ignite
         return SQL_SUCCESS;
     }
 
+    SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC    conn,
+                                        SQLINTEGER attr,
+                                        SQLPOINTER valueBuf,
+                                        SQLINTEGER valueBufLen,
+                                        SQLINTEGER* valueResLen)
+    {
+        using namespace odbc;
+        using namespace type_traits;
+
+        using app::ApplicationDataBuffer;
+
+        LOG_MSG("SQLGetConnectAttr called");
+
+        Connection *connection = reinterpret_cast<Connection*>(conn);
+
+        if (!connection)
+            return SQL_INVALID_HANDLE;
+
+        connection->GetAttribute(attr, valueBuf, valueBufLen, valueResLen);
+
+        return connection->GetDiagnosticRecords().GetReturnCode();
+    }
+
+    SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC    conn,
+                                        SQLINTEGER attr,
+                                        SQLPOINTER value,
+                                        SQLINTEGER valueLen)
+    {
+        using odbc::Connection;
+
+        LOG_MSG("SQLSetConnectAttr called");
+
+        Connection *connection = reinterpret_cast<Connection*>(conn);
+
+        if (!connection)
+            return SQL_INVALID_HANDLE;
+
+        connection->SetAttribute(attr, value, valueLen);
+
+        return connection->GetDiagnosticRecords().GetReturnCode();
+    }
+
 } // namespace ignite;


Mime
View raw message