use of io.crate.exceptions.OperationOnInaccessibleRelationException in project crate by crate.
the class DropTableAnalyzer method analyze.
private <T extends TableInfo> AnalyzedDropTable<T> analyze(QualifiedName name, boolean dropIfExists, SessionContext sessionContext) {
T tableInfo;
RelationName tableName;
boolean maybeCorrupt = false;
try {
// noinspection unchecked
tableInfo = (T) schemas.resolveTableInfo(name, Operation.DROP, sessionContext.sessionUser(), sessionContext.searchPath());
tableName = tableInfo.ident();
} catch (SchemaUnknownException | RelationUnknown e) {
tableName = RelationName.of(name, sessionContext.searchPath().currentSchema());
var metadata = clusterService.state().metadata();
var indexNameOrAlias = tableName.indexNameOrAlias();
if (metadata.hasIndex(indexNameOrAlias) || metadata.templates().containsKey(indexNameOrAlias)) {
tableInfo = null;
maybeCorrupt = true;
} else if (dropIfExists) {
tableInfo = null;
} else {
throw e;
}
} catch (OperationOnInaccessibleRelationException e) {
throw e;
} catch (Throwable t) {
if (!sessionContext.sessionUser().isSuperUser()) {
throw t;
}
tableInfo = null;
maybeCorrupt = true;
tableName = RelationName.of(name, sessionContext.searchPath().currentSchema());
LOGGER.info("Unexpected error resolving table during DROP TABLE operation on {}. " + "Proceeding with operation as table schema may be corrupt (error={})", tableName, t);
}
return new AnalyzedDropTable<>(tableInfo, dropIfExists, tableName, maybeCorrupt);
}
Aggregations