Search in sources :

Example 1 with TransactionInfo

use of io.trino.transaction.TransactionInfo in project trino by trinodb.

the class TestStartTransactionTask method testStartTransactionExplicitModes.

@Test
public void testStartTransactionExplicitModes() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    getFutureValue(new StartTransactionTask(transactionManager).execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), stateMachine, emptyList(), WarningCollector.NOOP));
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
    TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
    assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
    assertTrue(transactionInfo.isReadOnly());
    assertFalse(transactionInfo.isAutoCommitContext());
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager) InMemoryTransactionManager(io.trino.transaction.InMemoryTransactionManager) TransactionAccessMode(io.trino.sql.tree.TransactionAccessMode) Isolation(io.trino.sql.tree.Isolation) TransactionInfo(io.trino.transaction.TransactionInfo) StartTransaction(io.trino.sql.tree.StartTransaction) Session(io.trino.Session) Test(org.testng.annotations.Test)

Example 2 with TransactionInfo

use of io.trino.transaction.TransactionInfo in project trino by trinodb.

the class TestStartTransactionTask method testStartTransaction.

@Test
public void testStartTransaction() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    getFutureValue(new StartTransactionTask(transactionManager).execute(new StartTransaction(ImmutableList.of()), stateMachine, emptyList(), WarningCollector.NOOP));
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
    TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
    assertFalse(transactionInfo.isAutoCommitContext());
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager) InMemoryTransactionManager(io.trino.transaction.InMemoryTransactionManager) TransactionInfo(io.trino.transaction.TransactionInfo) StartTransaction(io.trino.sql.tree.StartTransaction) Session(io.trino.Session) Test(org.testng.annotations.Test)

Aggregations

Session (io.trino.Session)2 StartTransaction (io.trino.sql.tree.StartTransaction)2 InMemoryTransactionManager (io.trino.transaction.InMemoryTransactionManager)2 InMemoryTransactionManager.createTestTransactionManager (io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager)2 TransactionInfo (io.trino.transaction.TransactionInfo)2 TransactionManager (io.trino.transaction.TransactionManager)2 Test (org.testng.annotations.Test)2 Isolation (io.trino.sql.tree.Isolation)1 TransactionAccessMode (io.trino.sql.tree.TransactionAccessMode)1