提交 866ade3e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Drop schema rights together with schema

上级 064d7ba8
......@@ -18,6 +18,7 @@ import org.h2.engine.DbObject;
import org.h2.engine.DbObjectBase;
import org.h2.engine.DbSettings;
import org.h2.engine.FunctionAlias;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.engine.SysProperties;
import org.h2.engine.User;
......@@ -172,6 +173,11 @@ public class Schema extends DbObjectBase {
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();
......
......@@ -48,6 +48,7 @@ public class TestRights extends TestBase {
testSchemaRenameUser();
testAccessRights();
testSchemaAdminRole();
testSchemaDrop();
deleteDb("rights");
}
......@@ -491,6 +492,24 @@ public class TestRights extends TestBase {
conn.close();
}
private void testSchemaDrop() throws SQLException {
if (config.memory) {
return;
}
deleteDb("rights");
Connection conn = getConnection("rights");
stat = conn.createStatement();
stat.execute("create user test password '' admin");
stat.execute("create schema b");
stat.execute("grant select on schema b to test");
stat.execute("drop schema b cascade");
conn.close();
conn = getConnection("rights");
stat = conn.createStatement();
stat.execute("drop user test");
conn.close();
}
private void testAccessRights() throws SQLException {
if (config.memory) {
return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论