Search in sources :

Example 1 with TransactionAccessMode

use of io.prestosql.sql.tree.TransactionAccessMode in project hetu-core by openlookeng.

the class TestSqlParser method testStartTransaction.

@Test
public void testStartTransaction() {
    assertStatement("START TRANSACTION", new StartTransaction(ImmutableList.of()));
    assertStatement("START TRANSACTION ISOLATION LEVEL READ UNCOMMITTED", new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.READ_UNCOMMITTED))));
    assertStatement("START TRANSACTION ISOLATION LEVEL READ COMMITTED", new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.READ_COMMITTED))));
    assertStatement("START TRANSACTION ISOLATION LEVEL REPEATABLE READ", new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.REPEATABLE_READ))));
    assertStatement("START TRANSACTION ISOLATION LEVEL SERIALIZABLE", new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE))));
    assertStatement("START TRANSACTION READ ONLY", new StartTransaction(ImmutableList.of(new TransactionAccessMode(true))));
    assertStatement("START TRANSACTION READ WRITE", new StartTransaction(ImmutableList.of(new TransactionAccessMode(false))));
    assertStatement("START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY", new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.READ_COMMITTED), new TransactionAccessMode(true))));
    assertStatement("START TRANSACTION READ ONLY, ISOLATION LEVEL READ COMMITTED", new StartTransaction(ImmutableList.of(new TransactionAccessMode(true), new Isolation(Isolation.Level.READ_COMMITTED))));
    assertStatement("START TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE", new StartTransaction(ImmutableList.of(new TransactionAccessMode(false), new Isolation(Isolation.Level.SERIALIZABLE))));
}
Also used : TransactionAccessMode(io.prestosql.sql.tree.TransactionAccessMode) Isolation(io.prestosql.sql.tree.Isolation) StartTransaction(io.prestosql.sql.tree.StartTransaction) Test(org.testng.annotations.Test)

Example 2 with TransactionAccessMode

use of io.prestosql.sql.tree.TransactionAccessMode in project hetu-core by openlookeng.

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().execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    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.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) TransactionAccessMode(io.prestosql.sql.tree.TransactionAccessMode) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) Isolation(io.prestosql.sql.tree.Isolation) TransactionInfo(io.prestosql.transaction.TransactionInfo) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 3 with TransactionAccessMode

use of io.prestosql.sql.tree.TransactionAccessMode in project hetu-core by openlookeng.

the class TestStartTransactionTask method testStartTransactionTooManyAccessModes.

@Test
public void testStartTransactionTooManyAccessModes() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    assertSemanticExceptionThrownBy(() -> getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of(new TransactionAccessMode(true), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(INVALID_TRANSACTION_MODE);
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) TransactionAccessMode(io.prestosql.sql.tree.TransactionAccessMode) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Aggregations

StartTransaction (io.prestosql.sql.tree.StartTransaction)3 TransactionAccessMode (io.prestosql.sql.tree.TransactionAccessMode)3 Test (org.testng.annotations.Test)3 Session (io.prestosql.Session)2 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)2 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)2 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)2 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)2 Isolation (io.prestosql.sql.tree.Isolation)2 InMemoryTransactionManager (io.prestosql.transaction.InMemoryTransactionManager)2 InMemoryTransactionManager.createTestTransactionManager (io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager)2 TransactionManager (io.prestosql.transaction.TransactionManager)2 TransactionInfo (io.prestosql.transaction.TransactionInfo)1