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-6836: Implemented query timeout. This closes #3015
Date Wed, 15 Nov 2017 10:42:13 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 4589ff2d4 -> 8c278ca9b


IGNITE-6836: Implemented query timeout.
This closes #3015


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

Branch: refs/heads/master
Commit: 8c278ca9b67cd17dfd882e0eb65e19745798876d
Parents: 4589ff2
Author: Igor Sapego <isapego@gridgain.com>
Authored: Wed Nov 15 13:41:31 2017 +0300
Committer: Igor Sapego <isapego@gridgain.com>
Committed: Wed Nov 15 13:41:31 2017 +0300

----------------------------------------------------------------------
 .../processors/odbc/odbc/OdbcMessageParser.java | 14 ++++++-
 .../odbc/odbc/OdbcQueryExecuteBatchRequest.java | 16 +++++++-
 .../odbc/odbc/OdbcQueryExecuteRequest.java      | 16 +++++++-
 .../odbc/odbc/OdbcRequestHandler.java           |  9 ++--
 .../cpp/odbc-test/src/attributes_test.cpp       | 22 ++++++++++
 .../platforms/cpp/odbc-test/src/parser_test.cpp |  2 +-
 .../cpp/odbc/include/ignite/odbc/message.h      | 33 ++++++++++-----
 .../cpp/odbc/include/ignite/odbc/parser.h       |  2 +-
 .../include/ignite/odbc/query/batch_query.h     |  8 +++-
 .../odbc/include/ignite/odbc/query/data_query.h |  8 +++-
 .../cpp/odbc/include/ignite/odbc/statement.h    |  4 ++
 modules/platforms/cpp/odbc/src/message.cpp      | 34 ++++++++++------
 .../cpp/odbc/src/query/batch_query.cpp          |  9 ++--
 .../platforms/cpp/odbc/src/query/data_query.cpp |  9 ++--
 modules/platforms/cpp/odbc/src/statement.cpp    | 43 ++++++++++++++++++--
 15 files changed, 180 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
index fb17d2a..c2137bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcMessageParser.java
@@ -96,7 +96,12 @@ public class OdbcMessageParser implements ClientListenerMessageParser {
 
                 Object[] params = readParameterRow(reader, paramNum);
 
-                res = new OdbcQueryExecuteRequest(schema, sql, params);
+                int timeout = 0;
+
+                if (ver.compareTo(OdbcConnectionContext.VER_2_3_2) >= 0)
+                    timeout = reader.readInt();
+
+                res = new OdbcQueryExecuteRequest(schema, sql, params, timeout);
 
                 break;
             }
@@ -113,7 +118,12 @@ public class OdbcMessageParser implements ClientListenerMessageParser
{
                 for (int i = 0; i < rowNum; ++i)
                     params[i] = readParameterRow(reader, paramRowLen);
 
-                res = new OdbcQueryExecuteBatchRequest(schema, sql, last, params);
+                int timeout = 0;
+
+                if (ver.compareTo(OdbcConnectionContext.VER_2_3_2) >= 0)
+                    timeout = reader.readInt();
+
+                res = new OdbcQueryExecuteBatchRequest(schema, sql, last, params, timeout);
 
                 break;
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteBatchRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteBatchRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteBatchRequest.java
index 50d16e5..0e4effd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteBatchRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteBatchRequest.java
@@ -41,13 +41,19 @@ public class OdbcQueryExecuteBatchRequest extends OdbcRequest {
     @GridToStringExclude
     private final Object[][] args;
 
+    /** Query timeout in seconds. */
+    @GridToStringInclude
+    private final int timeout;
+
     /**
      * @param schema Schema.
      * @param sqlQry SQL query.
      * @param last Last page flag.
      * @param args Arguments list.
+     * @param timeout Timeout in seconds.
      */
-    public OdbcQueryExecuteBatchRequest(@Nullable String schema, String sqlQry, boolean last,
Object[][] args) {
+    public OdbcQueryExecuteBatchRequest(@Nullable String schema, String sqlQry, boolean last,
Object[][] args,
+        int timeout) {
         super(QRY_EXEC_BATCH);
 
         assert sqlQry != null : "SQL query should not be null";
@@ -57,6 +63,7 @@ public class OdbcQueryExecuteBatchRequest extends OdbcRequest {
         this.sqlQry = sqlQry;
         this.last = last;
         this.args = args;
+        this.timeout = timeout;
     }
 
     /**
@@ -88,6 +95,13 @@ public class OdbcQueryExecuteBatchRequest extends OdbcRequest {
         return last;
     }
 
+    /**
+     * @return Timeout in seconds.
+     */
+    public int timeout() {
+        return timeout;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(OdbcQueryExecuteBatchRequest.class, this, "args", args, true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteRequest.java
index 26d3328..1fde908 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcQueryExecuteRequest.java
@@ -37,12 +37,17 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
     @GridToStringExclude
     private final Object[] args;
 
+    /** Query timeout in seconds. */
+    @GridToStringInclude
+    private final int timeout;
+
     /**
      * @param schema Schema.
      * @param sqlQry SQL query.
      * @param args Arguments list.
+     * @param timeout Timeout in seconds.
      */
-    public OdbcQueryExecuteRequest(@Nullable String schema, String sqlQry, Object[] args)
{
+    public OdbcQueryExecuteRequest(@Nullable String schema, String sqlQry, Object[] args,
int timeout) {
         super(QRY_EXEC);
 
         assert sqlQry != null : "SQL query should not be null";
@@ -50,6 +55,7 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
         this.schema = schema;
         this.sqlQry = sqlQry;
         this.args = args;
+        this.timeout = timeout;
     }
 
     /**
@@ -73,8 +79,16 @@ public class OdbcQueryExecuteRequest extends OdbcRequest {
         return schema;
     }
 
+    /**
+     * @return Timeout in seconds.
+     */
+    public int timeout() {
+        return timeout;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(OdbcQueryExecuteRequest.class, this, "args", args, true);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
index 7f6b48d..3bc5a23 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
@@ -203,7 +204,7 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler
{
      * @param args Arguments.
      * @return Query instance.
      */
-    private SqlFieldsQueryEx makeQuery(String schema, String sql, Object[] args) {
+    private SqlFieldsQueryEx makeQuery(String schema, String sql, Object[] args, int timeout)
{
         SqlFieldsQueryEx qry = new SqlFieldsQueryEx(sql, null);
 
         qry.setArgs(args);
@@ -216,6 +217,8 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler
{
         qry.setSchema(schema);
         qry.setSkipReducerOnUpdate(skipReducerOnUpdate);
 
+        qry.setTimeout(timeout, TimeUnit.SECONDS);
+
         return qry;
     }
 
@@ -243,7 +246,7 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler
{
                 log.debug("ODBC query parsed [reqId=" + req.requestId() + ", original=" +
req.sqlQuery() +
                     ", parsed=" + sql + ']');
 
-            SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments());
+            SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments(), req.timeout());
 
             List<FieldsQueryCursor<List<?>>> cursors = ctx.query().querySqlFieldsNoCache(qry,
true, false);
 
@@ -285,7 +288,7 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler
{
                 log.debug("ODBC query parsed [reqId=" + req.requestId() + ", original=" +
req.sqlQuery() +
                         ", parsed=" + sql + ']');
 
-            SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments());
+            SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments(), req.timeout());
 
             Object[][] paramSet = req.arguments();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/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
index f8cb5ac..b87f4b9 100644
--- a/modules/platforms/cpp/odbc-test/src/attributes_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/attributes_test.cpp
@@ -205,4 +205,26 @@ BOOST_AUTO_TEST_CASE(ConnectionAttributeConnectionDeadSet)
     CheckSQLConnectionDiagnosticError("HY092");
 }
 
+BOOST_AUTO_TEST_CASE(StatementAttributeQueryTimeout)
+{
+    Connect("DRIVER={Apache Ignite};address=127.0.0.1:11110;schema=cache");
+
+    SQLULEN timeout = -1;
+    SQLRETURN ret = SQLGetStmtAttr(stmt, SQL_ATTR_QUERY_TIMEOUT, &timeout, 0, 0);
+
+    ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_STMT, stmt);
+    BOOST_REQUIRE_EQUAL(timeout, 0);
+
+    ret = SQLSetStmtAttr(stmt, SQL_ATTR_QUERY_TIMEOUT, reinterpret_cast<SQLPOINTER>(7),
0);
+
+    ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_STMT, stmt);
+
+    timeout = -1;
+
+    ret = SQLGetStmtAttr(stmt, SQL_ATTR_QUERY_TIMEOUT, &timeout, 0, 0);
+
+    ODBC_FAIL_ON_ERROR(ret, SQL_HANDLE_STMT, stmt);
+    BOOST_REQUIRE_EQUAL(timeout, 7);
+}
+
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc-test/src/parser_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/parser_test.cpp b/modules/platforms/cpp/odbc-test/src/parser_test.cpp
index 51539ae..af11369 100644
--- a/modules/platforms/cpp/odbc-test/src/parser_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/parser_test.cpp
@@ -42,7 +42,7 @@ struct TestMessage
         // No-op.
     }
 
-    void Write(ignite::impl::binary::BinaryWriterImpl& writer) const
+    void Write(ignite::impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const
     {
         writer.WriteInt32(a);
         writer.WriteString(b.data(), static_cast<int32_t>(b.size()));

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
index 8d6c906..51c0b41 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h
@@ -95,7 +95,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Protocol version. */
@@ -132,8 +132,10 @@ namespace ignite
              * @param schema Schema.
              * @param sql SQL query.
              * @param params Query arguments.
+             * @param timeout Timeout.
              */
-            QueryExecuteRequest(const std::string& schema, const std::string& sql,
const app::ParameterSet& params);
+            QueryExecuteRequest(const std::string& schema, const std::string& sql,
const app::ParameterSet& params,
+                int32_t timeout);
 
             /**
              * Destructor.
@@ -143,8 +145,9 @@ namespace ignite
             /**
              * Write request using provided writer.
              * @param writer Writer.
+             * @param ver Version.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&
ver) const;
 
         private:
             /** Schema name. */
@@ -155,6 +158,9 @@ namespace ignite
 
             /** Parameters bindings. */
             const app::ParameterSet& params;
+
+            /** Timeout. */
+            int32_t timeout;
         };
 
         /**
@@ -171,9 +177,10 @@ namespace ignite
              * @param params Query arguments.
              * @param begin Beginng of the interval.
              * @param end End of the interval.
+             * @param timeout Timeout.
              */
             QueryExecuteBatchtRequest(const std::string& schema, const std::string&
sql,
-                                          const app::ParameterSet& params, SqlUlen begin,
SqlUlen end, bool last);
+                const app::ParameterSet& params, SqlUlen begin, SqlUlen end, bool last,
int32_t timeout);
 
             /**
              * Destructor.
@@ -183,8 +190,9 @@ namespace ignite
             /**
              * Write request using provided writer.
              * @param writer Writer.
+             * @param ver Version.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&
ver) const;
 
         private:
             /** Schema name. */
@@ -204,6 +212,9 @@ namespace ignite
 
             /** Last page flag. */
             bool last;
+
+            /** Timeout. */
+            int32_t timeout;
         };
 
         /**
@@ -228,7 +239,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Query ID. */
@@ -258,7 +269,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Query ID. */
@@ -292,7 +303,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Schema search pattern. */
@@ -331,7 +342,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Column search pattern. */
@@ -378,7 +389,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Schema. */
@@ -419,7 +430,7 @@ namespace ignite
              * Write request using provided writer.
              * @param writer Writer.
              */
-            void Write(impl::binary::BinaryWriterImpl& writer) const;
+            void Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const;
 
         private:
             /** Query ID. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
index bfea67c..5ffb44c 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
@@ -79,7 +79,7 @@ namespace ignite
 
                 BinaryWriterImpl writer(&outStream, 0);
 
-                msg.Write(writer);
+                msg.Write(writer, protocolVer);
 
                 buf.resize(outStream.Position());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/include/ignite/odbc/query/batch_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/batch_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/batch_query.h
index 1e6c869..af319ab 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/query/batch_query.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/batch_query.h
@@ -44,9 +44,10 @@ namespace ignite
                  * @param connection Associated connection.
                  * @param sql SQL query string.
                  * @param params SQL params.
+                 * @param timeout Timeout in seconds.
                  */
-                BatchQuery(diagnostic::Diagnosable& diag, Connection& connection,
-                    const std::string& sql, const app::ParameterSet& params);
+                BatchQuery(diagnostic::Diagnosable& diag, Connection& connection,
const std::string& sql,
+                    const app::ParameterSet& params, int32_t& timeout);
 
                 /**
                  * Destructor.
@@ -156,6 +157,9 @@ namespace ignite
 
                 /** Query executed. */
                 bool executed;
+
+                /** Timeout. */
+                int32_t& timeout;
             };
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
index c476000..af39bdb 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/query/data_query.h
@@ -44,9 +44,10 @@ namespace ignite
                  * @param connection Associated connection.
                  * @param sql SQL query string.
                  * @param params SQL params.
+                 * @param timeout Timeout.
                  */
-                DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
-                    const std::string& sql, const app::ParameterSet& params);
+                DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
const std::string& sql,
+                    const app::ParameterSet& params, int32_t& timeout);
 
                 /**
                  * Destructor.
@@ -184,6 +185,9 @@ namespace ignite
 
                 /** Cached next result page. */
                 std::auto_ptr<ResultPage> cachedNextPage;
+
+                /** Timeout. */
+                int32_t& timeout;
             };
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h b/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
index 6d4b3ab..4cc30c3 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/statement.h
@@ -666,7 +666,11 @@ namespace ignite
             /** Offset added to pointers to change binding of column data. */
             int* columnBindOffset;
 
+            /** Parameters. */
             app::ParameterSet parameters;
+
+            /** Query timeout in seconds. */
+            int32_t timeout;
         };
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/src/message.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/message.cpp b/modules/platforms/cpp/odbc/src/message.cpp
index 32a5d91..57b7210 100644
--- a/modules/platforms/cpp/odbc/src/message.cpp
+++ b/modules/platforms/cpp/odbc/src/message.cpp
@@ -63,7 +63,7 @@ namespace ignite
             // No-op.
         }
 
-        void HandshakeRequest::Write(impl::binary::BinaryWriterImpl& writer) const
+        void HandshakeRequest::Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const
         {
             writer.WriteInt8(RequestType::HANDSHAKE);
 
@@ -86,10 +86,11 @@ namespace ignite
         }
 
         QueryExecuteRequest::QueryExecuteRequest(const std::string& schema, const std::string&
sql,
-            const app::ParameterSet& params):
+            const app::ParameterSet& params, int32_t timeout):
             schema(schema),
             sql(sql),
-            params(params)
+            params(params),
+            timeout(timeout)
         {
             // No-op.
         }
@@ -99,7 +100,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryExecuteRequest::Write(impl::binary::BinaryWriterImpl& writer) const
+        void QueryExecuteRequest::Write(impl::binary::BinaryWriterImpl& writer, const
ProtocolVersion& ver) const
         {
             writer.WriteInt8(RequestType::EXECUTE_SQL_QUERY);
 
@@ -111,16 +112,20 @@ namespace ignite
             writer.WriteObject<std::string>(sql);
 
             params.Write(writer);
+
+            if (ver >= ProtocolVersion::VERSION_2_3_2)
+                writer.WriteInt32(timeout);
         }
 
         QueryExecuteBatchtRequest::QueryExecuteBatchtRequest(const std::string& schema,
const std::string& sql,
-            const app::ParameterSet& params, SqlUlen begin, SqlUlen end, bool last):
+            const app::ParameterSet& params, SqlUlen begin, SqlUlen end, bool last, int32_t
timeout):
             schema(schema),
             sql(sql),
             params(params),
             begin(begin),
             end(end),
-            last(last)
+            last(last),
+            timeout(timeout)
         {
             // No-op.
         }
@@ -130,7 +135,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryExecuteBatchtRequest::Write(impl::binary::BinaryWriterImpl& writer)
const
+        void QueryExecuteBatchtRequest::Write(impl::binary::BinaryWriterImpl& writer,
const ProtocolVersion& ver) const
         {
             writer.WriteInt8(RequestType::EXECUTE_SQL_QUERY_BATCH);
 
@@ -142,6 +147,9 @@ namespace ignite
             writer.WriteObject<std::string>(sql);
 
             params.Write(writer, begin, end, last);
+
+            if (ver >= ProtocolVersion::VERSION_2_3_2)
+                writer.WriteInt32(timeout);
         }
 
         QueryCloseRequest::QueryCloseRequest(int64_t queryId): queryId(queryId)
@@ -154,7 +162,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryCloseRequest::Write(impl::binary::BinaryWriterImpl& writer) const
+        void QueryCloseRequest::Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const
         {
             writer.WriteInt8(RequestType::CLOSE_SQL_QUERY);
             writer.WriteInt64(queryId);
@@ -172,7 +180,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryFetchRequest::Write(impl::binary::BinaryWriterImpl& writer) const
+        void QueryFetchRequest::Write(impl::binary::BinaryWriterImpl& writer, const ProtocolVersion&)
const
         {
             writer.WriteInt8(RequestType::FETCH_SQL_QUERY);
 
@@ -194,7 +202,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryGetColumnsMetaRequest::Write(impl::binary::BinaryWriterImpl& writer)
const
+        void QueryGetColumnsMetaRequest::Write(impl::binary::BinaryWriterImpl& writer,
const ProtocolVersion&) const
         {
             writer.WriteInt8(RequestType::GET_COLUMNS_METADATA);
 
@@ -218,7 +226,7 @@ namespace ignite
             // No-op.
         }
 
-        void QueryGetTablesMetaRequest::Write(impl::binary::BinaryWriterImpl& writer)
const
+        void QueryGetTablesMetaRequest::Write(impl::binary::BinaryWriterImpl& writer,
const ProtocolVersion&) const
         {
             writer.WriteInt8(RequestType::GET_TABLES_METADATA);
 
@@ -228,7 +236,7 @@ namespace ignite
             writer.WriteObject<std::string>(tableTypes);
         }
 
-        void QueryGetParamsMetaRequest::Write(impl::binary::BinaryWriterImpl& writer)
const
+        void QueryGetParamsMetaRequest::Write(impl::binary::BinaryWriterImpl& writer,
const ProtocolVersion&) const
         {
             writer.WriteInt8(RequestType::GET_PARAMS_METADATA);
 
@@ -236,7 +244,7 @@ namespace ignite
             writer.WriteObject<std::string>(sqlQuery);
         }
 
-        void QueryMoreResultsRequest::Write(impl::binary::BinaryWriterImpl& writer) const
+        void QueryMoreResultsRequest::Write(impl::binary::BinaryWriterImpl& writer, const
ProtocolVersion&) const
         {
             writer.WriteInt8(RequestType::QUERY_MORE_RESULTS);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/src/query/batch_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/batch_query.cpp b/modules/platforms/cpp/odbc/src/query/batch_query.cpp
index 29d11ca..07d42d4 100644
--- a/modules/platforms/cpp/odbc/src/query/batch_query.cpp
+++ b/modules/platforms/cpp/odbc/src/query/batch_query.cpp
@@ -27,8 +27,8 @@ namespace ignite
     {
         namespace query
         {
-            BatchQuery::BatchQuery(diagnostic::Diagnosable& diag, Connection& connection,
-                const std::string& sql, const app::ParameterSet& params) :
+            BatchQuery::BatchQuery(diagnostic::Diagnosable& diag, Connection& connection,
const std::string& sql,
+                const app::ParameterSet& params, int32_t& timeout) :
                 Query(diag, QueryType::BATCH),
                 connection(connection),
                 sql(sql),
@@ -36,7 +36,8 @@ namespace ignite
                 resultMeta(),
                 rowsAffected(),
                 rowsAffectedIdx(0),
-                executed(false)
+                executed(false),
+                timeout(timeout)
             {
                 // No-op.
             }
@@ -147,7 +148,7 @@ namespace ignite
             {
                 const std::string& schema = connection.GetSchema();
 
-                QueryExecuteBatchtRequest req(schema, sql, params, begin, end, last);
+                QueryExecuteBatchtRequest req(schema, sql, params, begin, end, last, timeout);
                 QueryExecuteBatchResponse rsp;
 
                 try

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/src/query/data_query.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/query/data_query.cpp b/modules/platforms/cpp/odbc/src/query/data_query.cpp
index 012b026..0539af5 100644
--- a/modules/platforms/cpp/odbc/src/query/data_query.cpp
+++ b/modules/platforms/cpp/odbc/src/query/data_query.cpp
@@ -28,8 +28,8 @@ namespace ignite
     {
         namespace query
         {
-            DataQuery::DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
-                const std::string& sql, const app::ParameterSet& params) :
+            DataQuery::DataQuery(diagnostic::Diagnosable& diag, Connection& connection,
const std::string& sql,
+                const app::ParameterSet& params, int32_t& timeout) :
                 Query(diag, QueryType::DATA),
                 connection(connection),
                 sql(sql),
@@ -38,7 +38,8 @@ namespace ignite
                 cursor(),
                 rowsAffected(),
                 rowsAffectedIdx(0),
-                cachedNextPage()
+                cachedNextPage(),
+                timeout(timeout)
             {
                 // No-op.
             }
@@ -216,7 +217,7 @@ namespace ignite
             {
                 const std::string& schema = connection.GetSchema();
 
-                QueryExecuteRequest req(schema, sql, params);
+                QueryExecuteRequest req(schema, sql, params, timeout);
                 QueryExecuteResponse rsp;
 
                 try

http://git-wip-us.apache.org/repos/asf/ignite/blob/8c278ca9/modules/platforms/cpp/odbc/src/statement.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/statement.cpp b/modules/platforms/cpp/odbc/src/statement.cpp
index b167d44..898d44d 100644
--- a/modules/platforms/cpp/odbc/src/statement.cpp
+++ b/modules/platforms/cpp/odbc/src/statement.cpp
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+#include <limits>
+
 #include "ignite/odbc/system/odbc_constants.h"
 #include "ignite/odbc/query/batch_query.h"
 #include "ignite/odbc/query/data_query.h"
@@ -42,7 +44,8 @@ namespace ignite
             rowsFetched(0),
             rowStatuses(0),
             columnBindOffset(0),
-            parameters()
+            parameters(),
+            timeout(0)
         {
             // No-op.
         }
@@ -282,6 +285,29 @@ namespace ignite
                     break;
                 }
 
+                case SQL_ATTR_QUERY_TIMEOUT:
+                {
+                    SqlUlen uTimeout = reinterpret_cast<SqlUlen>(value);
+
+                    if (uTimeout > INT32_MAX)
+                    {
+                        timeout = INT32_MAX;
+
+                        std::stringstream ss;
+
+                        ss << "Value is too big: " << uTimeout << ", changing
to " << timeout << ".";
+                        std::string msg = ss.str();
+
+                        AddStatusRecord(SqlState::S01S02_OPTION_VALUE_CHANGED, msg);
+
+                        return SqlResult::AI_SUCCESS_WITH_INFO;
+                    }
+
+                    timeout = static_cast<int32_t>(uTimeout);
+
+                    break;
+                }
+
                 default:
                 {
                     AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
@@ -409,6 +435,15 @@ namespace ignite
                     break;
                 }
 
+                case SQL_ATTR_QUERY_TIMEOUT:
+                {
+                    SqlUlen *uTimeout = reinterpret_cast<SqlUlen*>(buf);
+
+                    *uTimeout = static_cast<SqlUlen>(timeout);
+
+                    break;
+                }
+
                 default:
                 {
                     AddStatusRecord(SqlState::SHYC00_OPTIONAL_FEATURE_NOT_IMPLEMENTED,
@@ -496,7 +531,7 @@ namespace ignite
             // Resetting parameters types as we are changing the query.
             parameters.Prepare();
 
-            currentQuery.reset(new query::DataQuery(*this, connection, query, parameters));
+            currentQuery.reset(new query::DataQuery(*this, connection, query, parameters,
timeout));
 
             return SqlResult::AI_SUCCESS;
         }
@@ -534,13 +569,13 @@ namespace ignite
             {
                 query::DataQuery& qry = static_cast<query::DataQuery&>(*currentQuery);
 
-                currentQuery.reset(new query::BatchQuery(*this, connection, qry.GetSql(),
parameters));
+                currentQuery.reset(new query::BatchQuery(*this, connection, qry.GetSql(),
parameters, timeout));
             }
             else if (parameters.GetParamSetSize() == 1 && currentQuery->GetType()
== query::QueryType::BATCH)
             {
                 query::BatchQuery& qry = static_cast<query::BatchQuery&>(*currentQuery);
 
-                currentQuery.reset(new query::DataQuery(*this, connection, qry.GetSql(),
parameters));
+                currentQuery.reset(new query::DataQuery(*this, connection, qry.GetSql(),
parameters, timeout));
             }
 
             if (parameters.IsDataAtExecNeeded())


Mime
View raw message