xtern commented on code in PR #2846:
URL: https://github.com/apache/ignite-3/pull/2846#discussion_r1411836415


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/tx/ScriptTransactionWrapper.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.sql.engine.tx;
+
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
+import org.apache.ignite.internal.sql.engine.SqlQueryType;
+import org.apache.ignite.internal.sql.engine.util.Commons;
+import org.apache.ignite.internal.tx.InternalTransaction;
+import org.apache.ignite.internal.util.AsyncCursor;
+import org.apache.ignite.tx.Transaction;
+
+/**
+ * Wraps a transaction, which is managed by SQL engine via {@link 
SqlQueryType#TX_CONTROL} statements.
+ * Responsible for tracking and releasing resources associated with this 
transaction.
+ */
+class ScriptTransactionWrapper implements QueryTransactionWrapper {
+    private final InternalTransaction transaction;
+
+    /** Future completes when all cursors associated with the current 
transaction are closed. */
+    private final CompletableFuture<Void> txFinishFuture = new 
CompletableFuture<>();
+
+    /** Opened cursors that must be closed before the transaction can 
complete. */
+    private final Map<UUID, CompletableFuture<? extends AsyncCursor<?>>> 
openedCursors = new ConcurrentHashMap<>();
+
+    /** Transaction action (commit or rollback) that will be performed when 
all dependent cursors are closed. */
+    private final AtomicReference<Function<InternalTransaction, 
CompletableFuture<Void>>> finishTxAction = new AtomicReference<>();
+
+    ScriptTransactionWrapper(InternalTransaction transaction) {
+        this.transaction = transaction;
+    }
+
+    @Override
+    public InternalTransaction unwrap() {
+        return transaction;
+    }
+
+    @Override
+    public CompletableFuture<Void> commitImplicit() {
+        return Commons.completedFuture();
+    }
+
+    @Override
+    public CompletableFuture<Void> rollback(Throwable cause) {

Review Comment:
   > Also i found that sql parsing errors are not informative,
   > it would be hard to found a problem if script will consist from numerous 
of lines
   
   I don't quite understand, the parser exception message contains the line 
number and position, what needs to be improved?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to