Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

public class DropCatalogTask
Expand Down Expand Up @@ -59,8 +60,9 @@ public ListenableFuture<Void> execute(
throw new TrinoException(NOT_SUPPORTED, "CASCADE is not yet supported for DROP SCHEMA");
}

accessControl.checkCanDropCatalog(stateMachine.getSession().toSecurityContext(), statement.getCatalogName().toString());
catalogManager.dropCatalog(new CatalogName(statement.getCatalogName().toString()), statement.isExists());
String catalogName = statement.getCatalogName().getValue().toLowerCase(ENGLISH);
accessControl.checkCanDropCatalog(stateMachine.getSession().toSecurityContext(), catalogName);
catalogManager.dropCatalog(new CatalogName(catalogName), statement.isExists());
return immediateVoidFuture();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static io.trino.execution.querystats.PlanOptimizersStatsCollector.createPlanOptimizersStatsCollector;
import static io.trino.testing.TestingSession.testSession;
import static java.util.Collections.emptyList;
import static java.util.Locale.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_METHOD;
Expand Down Expand Up @@ -98,6 +99,17 @@ public void testDuplicatedCreateCatalogIfNotExists()
assertThat(queryRunner.getPlannerContext().getMetadata().catalogExists(createNewQuery().getSession(), TEST_CATALOG)).isFalse();
}

@Test
void testCaseInsensitiveDropCatalog()
{
queryRunner.createCatalog(TEST_CATALOG, "tpch", ImmutableMap.of());
assertThat(queryRunner.getPlannerContext().getMetadata().catalogExists(createNewQuery().getSession(), TEST_CATALOG)).isTrue();

DropCatalog statement = new DropCatalog(new Identifier(TEST_CATALOG.toUpperCase(ENGLISH)), false, false);
getFutureValue(task.execute(statement, createNewQuery(), emptyList(), WarningCollector.NOOP));
assertThat(queryRunner.getPlannerContext().getMetadata().catalogExists(createNewQuery().getSession(), TEST_CATALOG)).isFalse();
}

private QueryStateMachine createNewQuery()
{
return QueryStateMachine.begin(
Expand Down