Search in sources :

Example 1 with Deallocate

use of io.trino.sql.tree.Deallocate in project trino by trinodb.

the class PrepareTask method execute.

@Override
public ListenableFuture<Void> execute(Prepare prepare, QueryStateMachine stateMachine, List<Expression> parameters, WarningCollector warningCollector) {
    Statement statement = prepare.getStatement();
    if ((statement instanceof Prepare) || (statement instanceof Execute) || (statement instanceof Deallocate)) {
        String type = statement.getClass().getSimpleName().toUpperCase(ENGLISH);
        throw new TrinoException(NOT_SUPPORTED, "Invalid statement type for prepared statement: " + type);
    }
    String sql = getFormattedSql(statement, sqlParser);
    stateMachine.addPreparedStatement(prepare.getName().getValue(), sql);
    return immediateVoidFuture();
}
Also used : Execute(io.trino.sql.tree.Execute) Deallocate(io.trino.sql.tree.Deallocate) Statement(io.trino.sql.tree.Statement) Prepare(io.trino.sql.tree.Prepare) TrinoException(io.trino.spi.TrinoException)

Example 2 with Deallocate

use of io.trino.sql.tree.Deallocate in project trino by trinodb.

the class TestDeallocateTask method executeDeallocate.

private Set<String> executeDeallocate(String statementName, String sqlString, Session session) {
    TransactionManager transactionManager = createTestTransactionManager();
    AccessControlManager accessControl = new AccessControlManager(transactionManager, emptyEventListenerManager(), new AccessControlConfig(), DefaultSystemAccessControl.NAME);
    accessControl.setSystemAccessControls(List.of(AllowAllSystemAccessControl.INSTANCE));
    QueryStateMachine stateMachine = QueryStateMachine.begin(Optional.empty(), sqlString, Optional.empty(), session, URI.create("fake://uri"), new ResourceGroupId("test"), false, transactionManager, accessControl, executor, metadata, WarningCollector.NOOP, Optional.empty());
    Deallocate deallocate = new Deallocate(new Identifier(statementName));
    new DeallocateTask().execute(deallocate, stateMachine, emptyList(), WarningCollector.NOOP);
    return stateMachine.getDeallocatedPreparedStatements();
}
Also used : AccessControlManager(io.trino.security.AccessControlManager) AccessControlConfig(io.trino.security.AccessControlConfig) Identifier(io.trino.sql.tree.Identifier) ResourceGroupId(io.trino.spi.resourcegroups.ResourceGroupId) Deallocate(io.trino.sql.tree.Deallocate) TransactionManager(io.trino.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager)

Aggregations

Deallocate (io.trino.sql.tree.Deallocate)2 AccessControlConfig (io.trino.security.AccessControlConfig)1 AccessControlManager (io.trino.security.AccessControlManager)1 TrinoException (io.trino.spi.TrinoException)1 ResourceGroupId (io.trino.spi.resourcegroups.ResourceGroupId)1 Execute (io.trino.sql.tree.Execute)1 Identifier (io.trino.sql.tree.Identifier)1 Prepare (io.trino.sql.tree.Prepare)1 Statement (io.trino.sql.tree.Statement)1 InMemoryTransactionManager.createTestTransactionManager (io.trino.transaction.InMemoryTransactionManager.createTestTransactionManager)1 TransactionManager (io.trino.transaction.TransactionManager)1