vldpyatkov commented on code in PR #13099: URL: https://github.com/apache/ignite/pull/13099#discussion_r3194656142
########## modules/calcite/src/test/java/org/apache/ignite/internal/processors/tx/SqlTransactionsSavepointTest.java: ########## @@ -0,0 +1,240 @@ +/* + * 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.processors.tx; + +import java.util.List; +import org.apache.ignite.cache.query.FieldsQueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.calcite.CalciteQueryEngineConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.SqlConfiguration; +import org.apache.ignite.configuration.TransactionConfiguration; +import org.apache.ignite.internal.processors.query.IgniteSQLException; +import org.apache.ignite.internal.processors.query.QueryEngine; +import org.apache.ignite.internal.processors.query.calcite.QueryChecker; +import org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTest; +import org.apache.ignite.internal.processors.query.calcite.util.Commons; +import org.apache.ignite.transactions.Transaction; +import org.junit.Test; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.ignite.internal.processors.query.calcite.integration.AbstractBasicIntegrationTransactionalTest.SqlTransactionMode.ALL; +import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; +import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; + +/** Tests SQL savepoint commands executed by Calcite. */ +public class SqlTransactionsSavepointTest extends AbstractBasicIntegrationTest { + /** */ + private static final String TBL = "SAVEPOINT_TEST_TABLE"; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + return super.getConfiguration(igniteInstanceName) + .setTransactionConfiguration(new TransactionConfiguration() + .setTxAwareQueriesEnabled(true)) + .setSqlConfiguration(new SqlConfiguration() + .setQueryEnginesConfiguration(new CalciteQueryEngineConfiguration())); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + sql("CREATE TABLE " + TBL + "(ID INT PRIMARY KEY, VAL VARCHAR) WITH atomicity=transactional"); + } + + /** */ + @Test + public void testSavepointCommandsInSqlScript() { + try (Transaction tx = client.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { + sqlScript( + "INSERT INTO " + TBL + " VALUES (1, 'before_sp1');" + + "SAVEPOINT sp1;" + + "INSERT INTO " + TBL + " VALUES (2, 'after_sp1');" + + "SAVEPOINT sp2;" + + "UPDATE " + TBL + " SET VAL = 'after_sp2' WHERE ID = 1;" + + "DELETE FROM " + TBL + " WHERE ID = 2;" + + "ROLLBACK TO SAVEPOINT sp2" Review Comment: The behavior is also documented: `When a transaction is rolled back to a savepoint, savepoints created after the target savepoint are released.` -- 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]
