Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
696b949a
提交
696b949a
authored
11月 27, 2013
作者:
noelgrandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extend support of "GRANT ALTER ANY SCHEMA TO <user>" to allow grantee ability to manipulate tables
上级
f8c487d8
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
9 行删除
+39
-9
changelog.html
h2/src/docsrc/html/changelog.html
+1
-0
User.java
h2/src/main/org/h2/engine/User.java
+4
-1
TestRights.java
h2/src/test/org/h2/test/db/TestRights.java
+34
-8
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
696b949a
...
@@ -42,6 +42,7 @@ Change Log
...
@@ -42,6 +42,7 @@ Change Log
</li><li>
Issue 522: Treat empty strings like NULL in Oracle compatibility mode, patch by Daniel Gredler.
</li><li>
Issue 522: Treat empty strings like NULL in Oracle compatibility mode, patch by Daniel Gredler.
</li><li>
Issue 527: Oracle compatibility mode: incorrect scale behavior, patch by Daniel Gredler.
</li><li>
Issue 527: Oracle compatibility mode: incorrect scale behavior, patch by Daniel Gredler.
</li><li>
Slightly reduce the memory cost of View metadata.
</li><li>
Slightly reduce the memory cost of View metadata.
</li><li>
Extend support of "GRANT ALTER ANY SCHEMA TO
<
user
>
" to allow grantee ability to manipulate tables
</li></ul>
</li></ul>
<h2>
Version 1.3.174 (2013-10-19)
</h2>
<h2>
Version 1.3.174 (2013-10-19)
</h2>
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
696b949a
...
@@ -125,6 +125,9 @@ public class User extends RightOwner {
...
@@ -125,6 +125,9 @@ public class User extends RightOwner {
return
true
;
return
true
;
}
}
if
(
table
!=
null
)
{
if
(
table
!=
null
)
{
if
(
hasRight
(
null
,
Right
.
ALTER_ANY_SCHEMA
))
{
return
true
;
}
String
tableType
=
table
.
getTableType
();
String
tableType
=
table
.
getTableType
();
if
(
Table
.
VIEW
.
equals
(
tableType
))
{
if
(
Table
.
VIEW
.
equals
(
tableType
))
{
TableView
v
=
(
TableView
)
table
;
TableView
v
=
(
TableView
)
table
;
...
@@ -212,7 +215,7 @@ public class User extends RightOwner {
...
@@ -212,7 +215,7 @@ public class User extends RightOwner {
* @throws DbException if this user is not a schema admin
* @throws DbException if this user is not a schema admin
*/
*/
public
void
checkSchemaAdmin
()
{
public
void
checkSchemaAdmin
()
{
if
(!
admin
&&
!
hasRight
(
null
,
Right
.
ALTER_ANY_SCHEMA
))
{
if
(!
hasRight
(
null
,
Right
.
ALTER_ANY_SCHEMA
))
{
throw
DbException
.
get
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
);
throw
DbException
.
get
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
);
}
}
}
}
...
...
h2/src/test/org/h2/test/db/TestRights.java
浏览文件 @
696b949a
...
@@ -212,15 +212,20 @@ public class TestRights extends TestBase {
...
@@ -212,15 +212,20 @@ public class TestRights extends TestBase {
testTableType
(
conn
,
"MEMORY"
);
testTableType
(
conn
,
"MEMORY"
);
testTableType
(
conn
,
"CACHED"
);
testTableType
(
conn
,
"CACHED"
);
/* make sure admin can still do it. */
executeSuccess
(
"CREATE USER SCHEMA_CREATOR PASSWORD 'xyz'"
);
executeSuccess
(
"CREATE USER SCHEMA_CREATOR PASSWORD 'xyz'"
);
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST"
);
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST"
);
executeSuccess
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST RENAME TO SCHEMA_RIGHT_TEST_RENAMED"
);
executeSuccess
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST RENAME TO SCHEMA_RIGHT_TEST_RENAMED"
);
executeSuccess
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_RENAMED"
);
executeSuccess
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_RENAMED"
);
/* create this for tests below */
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
executeSuccess
(
"CREATE TABLE SCHEMA_RIGHT_TEST_EXISTS.TEST_EXISTS(ID INT PRIMARY KEY, NAME VARCHAR)"
);
conn
.
close
();
conn
.
close
();
// try and fail
// try and fail
(no rights yet)
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
execute
(
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
execute
(
...
@@ -231,29 +236,42 @@ public class TestRights extends TestBase {
...
@@ -231,29 +236,42 @@ public class TestRights extends TestBase {
"DROP SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
"DROP SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
conn
.
close
();
conn
.
close
();
// g
ive them
// g
rant the right
conn
=
getConnection
(
"rights"
);
conn
=
getConnection
(
"rights"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
executeSuccess
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
executeSuccess
(
"GRANT ALTER ANY SCHEMA TO SCHEMA_CREATOR"
);
executeSuccess
(
"GRANT ALTER ANY SCHEMA TO SCHEMA_CREATOR"
);
conn
.
close
();
conn
.
close
();
// try and succeed
// try and succeed
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
/* should be able to create a schema and manipulate tables on that schema... */
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST"
);
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST"
);
executeSuccess
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST RENAME TO SCHEMA_RIGHT_TEST_RENAMED"
);
executeSuccess
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST RENAME TO S"
);
executeSuccess
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_RENAMED"
);
executeSuccess
(
"CREATE TABLE S.TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
executeSuccess
(
"CREATE SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
executeSuccess
(
"ALTER TABLE S.TEST ADD COLUMN QUESTION VARCHAR"
);
executeSuccess
(
"INSERT INTO S.TEST (ID, NAME) VALUES (42, 'Adams')"
);
executeSuccess
(
"UPDATE S.TEST Set NAME = 'Douglas'"
);
executeSuccess
(
"DELETE FROM S.TEST"
);
executeSuccess
(
"DROP SCHEMA S"
);
/* ...and on other schemata */
executeSuccess
(
"CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
executeSuccess
(
"ALTER TABLE TEST ADD COLUMN QUESTION VARCHAR"
);
executeSuccess
(
"INSERT INTO TEST (ID, NAME) VALUES (42, 'Adams')"
);
executeSuccess
(
"UPDATE TEST Set NAME = 'Douglas'"
);
executeSuccess
(
"DELETE FROM TEST"
);
conn
.
close
();
conn
.
close
();
// revoke the
m
// revoke the
right
conn
=
getConnection
(
"rights"
);
conn
=
getConnection
(
"rights"
);
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
executeSuccess
(
"REVOKE ALTER ANY SCHEMA FROM SCHEMA_CREATOR"
);
executeSuccess
(
"REVOKE ALTER ANY SCHEMA FROM SCHEMA_CREATOR"
);
conn
.
close
();
conn
.
close
();
// try and fail
// try a
gain a
nd fail
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
conn
=
getConnection
(
"rights;LOG=2"
,
"SCHEMA_CREATOR"
,
getPassword
(
"xyz"
));
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
...
@@ -262,6 +280,14 @@ public class TestRights extends TestBase {
...
@@ -262,6 +280,14 @@ public class TestRights extends TestBase {
execute
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST_EXISTS RENAME TO SCHEMA_RIGHT_TEST_RENAMED"
);
execute
(
"ALTER SCHEMA SCHEMA_RIGHT_TEST_EXISTS RENAME TO SCHEMA_RIGHT_TEST_RENAMED"
);
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
assertThrows
(
ErrorCode
.
ADMIN_RIGHTS_REQUIRED
,
stat
).
execute
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
execute
(
"DROP SCHEMA SCHEMA_RIGHT_TEST_EXISTS"
);
assertThrows
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
stat
).
execute
(
"CREATE TABLE SCHEMA_RIGHT_TEST_EXISTS.TEST(ID INT PRIMARY KEY, NAME VARCHAR)"
);
assertThrows
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
stat
).
execute
(
"INSERT INTO SCHEMA_RIGHT_TEST_EXISTS.TEST_EXISTS (ID, NAME) VALUES (42, 'Adams')"
);
assertThrows
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
stat
).
execute
(
"UPDATE SCHEMA_RIGHT_TEST_EXISTS.TEST_EXISTS Set NAME = 'Douglas'"
);
assertThrows
(
ErrorCode
.
NOT_ENOUGH_RIGHTS_FOR_1
,
stat
).
execute
(
"DELETE FROM SCHEMA_RIGHT_TEST_EXISTS.TEST_EXISTS"
);
conn
.
close
();
conn
.
close
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论