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();
}
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();
}
Aggregations