Unverified 提交 554c86a6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1031 from katzyn/schema

Drop schema rights together with schema
...@@ -18,6 +18,7 @@ import org.h2.engine.DbObject; ...@@ -18,6 +18,7 @@ import org.h2.engine.DbObject;
import org.h2.engine.DbObjectBase; import org.h2.engine.DbObjectBase;
import org.h2.engine.DbSettings; import org.h2.engine.DbSettings;
import org.h2.engine.FunctionAlias; import org.h2.engine.FunctionAlias;
import org.h2.engine.Right;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.engine.User; import org.h2.engine.User;
...@@ -172,6 +173,11 @@ public class Schema extends DbObjectBase { ...@@ -172,6 +173,11 @@ public class Schema extends DbObjectBase {
FunctionAlias obj = (FunctionAlias) functions.values().toArray()[0]; FunctionAlias obj = (FunctionAlias) functions.values().toArray()[0];
database.removeSchemaObject(session, obj); database.removeSchemaObject(session, obj);
} }
for (Right right : database.getAllRights()) {
if (right.getGrantedObject() == this) {
database.removeDatabaseObject(session, right);
}
}
database.removeMeta(session, getId()); database.removeMeta(session, getId());
owner = null; owner = null;
invalidate(); invalidate();
......
...@@ -48,6 +48,7 @@ public class TestRights extends TestBase { ...@@ -48,6 +48,7 @@ public class TestRights extends TestBase {
testSchemaRenameUser(); testSchemaRenameUser();
testAccessRights(); testAccessRights();
testSchemaAdminRole(); testSchemaAdminRole();
testSchemaDrop();
deleteDb("rights"); deleteDb("rights");
} }
...@@ -491,6 +492,24 @@ public class TestRights extends TestBase { ...@@ -491,6 +492,24 @@ public class TestRights extends TestBase {
conn.close(); 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 { private void testAccessRights() throws SQLException {
if (config.memory) { if (config.memory) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论