use of org.h2.engine.Right in project h2database by h2database.
the class Schema method removeChildrenAndResources.
@Override
public void removeChildrenAndResources(Session session) {
while (triggers != null && triggers.size() > 0) {
TriggerObject obj = (TriggerObject) triggers.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
while (constraints != null && constraints.size() > 0) {
Constraint obj = (Constraint) constraints.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
// There can be dependencies between tables e.g. using computed columns,
// so we might need to loop over them multiple times.
boolean runLoopAgain = false;
do {
runLoopAgain = false;
if (tablesAndViews != null) {
// Loop over a copy because the map is modified underneath us.
for (Table obj : new ArrayList<>(tablesAndViews.values())) {
// in one go underneath us.
if (obj.getName() != null) {
if (database.getDependentTable(obj, obj) == null) {
database.removeSchemaObject(session, obj);
} else {
runLoopAgain = true;
}
}
}
}
} while (runLoopAgain);
while (indexes != null && indexes.size() > 0) {
Index obj = (Index) indexes.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
while (sequences != null && sequences.size() > 0) {
Sequence obj = (Sequence) sequences.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
while (constants != null && constants.size() > 0) {
Constant obj = (Constant) constants.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
while (functions != null && functions.size() > 0) {
FunctionAlias obj = (FunctionAlias) functions.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
for (Right right : database.getAllRights()) {
if (right.getGrantedObject() == this) {
database.removeDatabaseObject(session, right);
}
}
database.removeMeta(session, getId());
owner = null;
invalidate();
}
use of org.h2.engine.Right in project h2database by h2database.
the class TestMVStore method testBackgroundExceptionListener.
private void testBackgroundExceptionListener() throws Exception {
String fileName = getBaseDir() + "/" + getTestName();
FileUtils.delete(fileName);
MVStore s;
final AtomicReference<Throwable> exRef = new AtomicReference<>();
s = new MVStore.Builder().fileName(fileName).backgroundExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
exRef.set(e);
}
}).open();
s.setAutoCommitDelay(10);
MVMap<Integer, String> m;
m = s.openMap("data");
s.getFileStore().getFile().close();
try {
m.put(1, "Hello");
for (int i = 0; i < 200; i++) {
if (exRef.get() != null) {
break;
}
sleep(10);
}
Throwable e = exRef.get();
assertNotNull(e);
assertEquals(DataUtils.ERROR_WRITING_FAILED, DataUtils.getErrorCode(e.getMessage()));
} catch (IllegalStateException e) {
// sometimes it is detected right away
assertEquals(DataUtils.ERROR_CLOSED, DataUtils.getErrorCode(e.getMessage()));
}
s.closeImmediately();
FileUtils.delete(fileName);
}
Aggregations