mpoeter commented on code in PR #5532:
URL: https://github.com/apache/ignite-3/pull/5532#discussion_r2022759815


##########
modules/platforms/cpp/ignite/client/detail/sql/sql_impl.cpp:
##########
@@ -88,8 +89,28 @@ void write_args(protocol::writer &writer, const 
std::vector<primitive> &args) {
     writer.write_binary(args_data);
 }
 
-void sql_impl::execute_async(transaction *tx, const sql_statement &statement, 
std::vector<primitive> &&args,
-    ignite_callback<result_set> &&callback) {
+void add_action(cancellation_token &token, node_connection &connection, 
std::int64_t req_id) {
+    auto writer_func = [req_id](protocol::writer &writer) {
+        writer.write(req_id);
+    };
+
+    cancellation_token_impl &token_impl = 
static_cast<cancellation_token_impl&>(token);
+    token_impl.add_action(connection.get_logger(), [req_id, &connection, 
writer_func] (ignite_callback<void> callback) {
+        
connection.perform_request<void>(protocol::client_operation::SQL_CANCEL_EXEC,
+            writer_func, [] (protocol::reader&){}, std::move(callback));
+    });

Review Comment:
   Is it guaranteed that `connection` lives long enough?



##########
modules/platforms/cpp/ignite/client/sql/sql.h:
##########
@@ -44,49 +45,57 @@ class sql {
     sql() = delete;
 
     /**
-     * Executes single SQL statement asynchronously and returns rows.
+     * Executes a single SQL statement asynchronously and returns rows.
      *
      * @param tx Optional transaction. If nullptr implicit transaction for 
this single operation is used.
+     * @param token Cancellation token. Can be @c nullptr.
      * @param statement Statement to execute.
      * @param args Arguments for the statement (can be empty).
      * @param callback A callback called on operation completion with SQL 
result set.
      */
-    IGNITE_API void execute_async(transaction *tx, const sql_statement 
&statement, std::vector<primitive> args,
-        ignite_callback<result_set> callback);
+    IGNITE_API void execute_async(transaction *tx, cancellation_token *token, 
const sql_statement &statement,
+        std::vector<primitive> args, ignite_callback<result_set> callback);

Review Comment:
   Should we for convenience also provide overloads without the 
`cancellation_token`? In the tests we usually just pass `nullptr`, but that 
isn't really descriptive. (Same of course also goes for the other functions.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to