Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
e47cbb3b
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e47cbb3b
编写于
7月 12, 2004
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add has_tablespace_privilege().
Christopher Kings-Lynne
上级
1a0f3e47
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
254 addition
and
6 deletion
+254
-6
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+27
-1
src/backend/utils/adt/acl.c
src/backend/utils/adt/acl.c
+205
-1
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+13
-1
src/include/utils/builtins.h
src/include/utils/builtins.h
+7
-1
未找到文件。
doc/src/sgml/func.sgml
浏览文件 @
e47cbb3b
<!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.21
3 2004/07/02 22:49:45 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.21
4 2004/07/12 20:23:47 momjian
Exp $
PostgreSQL documentation
-->
...
...
@@ -6980,6 +6980,21 @@ SELECT set_config('log_statement_stats', 'off', false);
<entry><type>boolean</type></entry>
<entry>does current user have privilege for schema</entry>
</row>
<row>
<entry><literal><function>has_tablespace_privilege</function>(<parameter>user</parameter>,
<parameter>tablespace</parameter>,
<parameter>privilege</parameter>)</literal>
</entry>
<entry><type>boolean</type></entry>
<entry>does user have privilege for tablespace</entry>
</row>
<row>
<entry><literal><function>has_tablespace_privilege</function>(<parameter>tablespace</parameter>,
<parameter>privilege</parameter>)</literal>
</entry>
<entry><type>boolean</type></entry>
<entry>does current user have privilege for tablespace</entry>
</row>
</tbody>
</tgroup>
</table>
...
...
@@ -6999,6 +7014,9 @@ SELECT set_config('log_statement_stats', 'off', false);
<indexterm zone="functions-misc">
<primary>has_schema_privilege</primary>
</indexterm>
<indexterm zone="functions-misc">
<primary>has_tablespace_privilege</primary>
</indexterm>
<para>
<function>has_table_privilege</function> checks whether a user
...
...
@@ -7064,6 +7082,14 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
<literal>USAGE</literal>.
</para>
<para>
<function>has_tablespace_privilege</function> checks whether a user
can access a tablespace in a particular way. The possibilities for its
arguments are analogous to <function>has_table_privilege</function>.
The desired access privilege type must evaluate to
<literal>CREATE</literal>.
</para>
<para>
To evaluate whether a user holds a grant option on the privilege,
append <literal> WITH GRANT OPTION</literal> to the privilege key
...
...
src/backend/utils/adt/acl.c
浏览文件 @
e47cbb3b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.10
6 2004/06/18 06:13:49 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.10
7 2004/07/12 20:23:50 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -21,6 +21,7 @@
#include "catalog/pg_shadow.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/tablespace.h"
#include "miscadmin.h"
#include "utils/acl.h"
#include "utils/builtins.h"
...
...
@@ -54,6 +55,8 @@ static Oid convert_language_name(text *languagename);
static
AclMode
convert_language_priv_string
(
text
*
priv_type_text
);
static
Oid
convert_schema_name
(
text
*
schemaname
);
static
AclMode
convert_schema_priv_string
(
text
*
priv_type_text
);
static
Oid
convert_tablespace_name
(
text
*
tablespacename
);
static
AclMode
convert_tablespace_priv_string
(
text
*
priv_type_text
);
/*
...
...
@@ -2207,3 +2210,204 @@ convert_schema_priv_string(text *priv_type_text)
errmsg
(
"unrecognized privilege type:
\"
%s
\"
"
,
priv_type
)));
return
ACL_NO_RIGHTS
;
/* keep compiler quiet */
}
/*
* has_tablespace_privilege variants
* These are all named "has_tablespace_privilege" at the SQL level.
* They take various combinations of tablespace name, tablespace OID,
* user name, user sysid, or implicit user = current_user.
*
* The result is a boolean value: true if user has the indicated
* privilege, false if not.
*/
/*
* has_tablespace_privilege_name_name
* Check user privileges on a tablespace given
* name username, text tablespacename, and text priv name.
*/
Datum
has_tablespace_privilege_name_name
(
PG_FUNCTION_ARGS
)
{
Name
username
=
PG_GETARG_NAME
(
0
);
text
*
tablespacename
=
PG_GETARG_TEXT_P
(
1
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
2
);
int32
usesysid
;
Oid
tablespaceoid
;
AclMode
mode
;
AclResult
aclresult
;
usesysid
=
get_usesysid
(
NameStr
(
*
username
));
tablespaceoid
=
convert_tablespace_name
(
tablespacename
);
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* has_tablespace_privilege_name
* Check user privileges on a tablespace given
* text tablespacename and text priv name.
* current_user is assumed
*/
Datum
has_tablespace_privilege_name
(
PG_FUNCTION_ARGS
)
{
text
*
tablespacename
=
PG_GETARG_TEXT_P
(
0
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
1
);
AclId
usesysid
;
Oid
tablespaceoid
;
AclMode
mode
;
AclResult
aclresult
;
usesysid
=
GetUserId
();
tablespaceoid
=
convert_tablespace_name
(
tablespacename
);
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* has_tablespace_privilege_name_id
* Check user privileges on a tablespace given
* name usename, tablespace oid, and text priv name.
*/
Datum
has_tablespace_privilege_name_id
(
PG_FUNCTION_ARGS
)
{
Name
username
=
PG_GETARG_NAME
(
0
);
Oid
tablespaceoid
=
PG_GETARG_OID
(
1
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
2
);
int32
usesysid
;
AclMode
mode
;
AclResult
aclresult
;
usesysid
=
get_usesysid
(
NameStr
(
*
username
));
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* has_tablespace_privilege_id
* Check user privileges on a tablespace given
* tablespace oid, and text priv name.
* current_user is assumed
*/
Datum
has_tablespace_privilege_id
(
PG_FUNCTION_ARGS
)
{
Oid
tablespaceoid
=
PG_GETARG_OID
(
0
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
1
);
AclId
usesysid
;
AclMode
mode
;
AclResult
aclresult
;
usesysid
=
GetUserId
();
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* has_tablespace_privilege_id_name
* Check user privileges on a tablespace given
* usesysid, text tablespacename, and text priv name.
*/
Datum
has_tablespace_privilege_id_name
(
PG_FUNCTION_ARGS
)
{
int32
usesysid
=
PG_GETARG_INT32
(
0
);
text
*
tablespacename
=
PG_GETARG_TEXT_P
(
1
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
2
);
Oid
tablespaceoid
;
AclMode
mode
;
AclResult
aclresult
;
tablespaceoid
=
convert_tablespace_name
(
tablespacename
);
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* has_tablespace_privilege_id_id
* Check user privileges on a tablespace given
* usesysid, tablespace oid, and text priv name.
*/
Datum
has_tablespace_privilege_id_id
(
PG_FUNCTION_ARGS
)
{
int32
usesysid
=
PG_GETARG_INT32
(
0
);
Oid
tablespaceoid
=
PG_GETARG_OID
(
1
);
text
*
priv_type_text
=
PG_GETARG_TEXT_P
(
2
);
AclMode
mode
;
AclResult
aclresult
;
mode
=
convert_tablespace_priv_string
(
priv_type_text
);
aclresult
=
pg_tablespace_aclcheck
(
tablespaceoid
,
usesysid
,
mode
);
PG_RETURN_BOOL
(
aclresult
==
ACLCHECK_OK
);
}
/*
* Support routines for has_tablespace_privilege family.
*/
/*
* Given a tablespace name expressed as a string, look it up and return Oid
*/
static
Oid
convert_tablespace_name
(
text
*
tablespacename
)
{
char
*
spcname
;
Oid
oid
;
spcname
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
PointerGetDatum
(
tablespacename
)));
oid
=
get_tablespace_oid
(
spcname
);
if
(
!
OidIsValid
(
oid
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"tablespace
\"
%s
\"
does not exist"
,
spcname
)));
return
oid
;
}
/*
* convert_tablespace_priv_string
* Convert text string to AclMode value.
*/
static
AclMode
convert_tablespace_priv_string
(
text
*
priv_type_text
)
{
char
*
priv_type
;
priv_type
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
PointerGetDatum
(
priv_type_text
)));
/*
* Return mode from priv_type string
*/
if
(
pg_strcasecmp
(
priv_type
,
"CREATE"
)
==
0
)
return
ACL_CREATE
;
if
(
pg_strcasecmp
(
priv_type
,
"CREATE WITH GRANT OPTION"
)
==
0
)
return
ACL_GRANT_OPTION_FOR
(
ACL_CREATE
);
ereport
(
ERROR
,
(
errcode
(
ERRCODE_INVALID_PARAMETER_VALUE
),
errmsg
(
"unrecognized privilege type:
\"
%s
\"
"
,
priv_type
)));
return
ACL_NO_RIGHTS
;
/* keep compiler quiet */
}
src/include/catalog/catversion.h
浏览文件 @
e47cbb3b
...
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.24
3 2004/07/02 22:49:48 tgl
Exp $
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.24
4 2004/07/12 20:23:51 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 200407
022
#define CATALOG_VERSION_NO 200407
121
#endif
src/include/catalog/pg_proc.h
浏览文件 @
e47cbb3b
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.34
1 2004/07/02 22:49:48 tgl
Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.34
2 2004/07/12 20:23:53 momjian
Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -3181,6 +3181,18 @@ DESCR("current user privilege on schema by schema name");
DATA
(
insert
OID
=
2273
(
has_schema_privilege
PGNSP
PGUID
12
f
f
t
f
s
2
16
"26 25"
_null_
has_schema_privilege_id
-
_null_
));
DESCR
(
"current user privilege on schema by schema oid"
);
DATA
(
insert
OID
=
2390
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
3
16
"19 25 25"
_null_
has_tablespace_privilege_name_name
-
_null_
));
DESCR
(
"user privilege on tablespace by username, tablespace name"
);
DATA
(
insert
OID
=
2391
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
3
16
"19 26 25"
_null_
has_tablespace_privilege_name_id
-
_null_
));
DESCR
(
"user privilege on tablespace by username, tablespace oid"
);
DATA
(
insert
OID
=
2392
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
3
16
"23 25 25"
_null_
has_tablespace_privilege_id_name
-
_null_
));
DESCR
(
"user privilege on tablespace by usesysid, tablespace name"
);
DATA
(
insert
OID
=
2393
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
3
16
"23 26 25"
_null_
has_tablespace_privilege_id_id
-
_null_
));
DESCR
(
"user privilege on tablespace by usesysid, tablespace oid"
);
DATA
(
insert
OID
=
2394
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
2
16
"25 25"
_null_
has_tablespace_privilege_name
-
_null_
));
DESCR
(
"current user privilege on tablespace by tablespace name"
);
DATA
(
insert
OID
=
2395
(
has_tablespace_privilege
PGNSP
PGUID
12
f
f
t
f
s
2
16
"26 25"
_null_
has_tablespace_privilege_id
-
_null_
));
DESCR
(
"current user privilege on tablespace by tablespace oid"
);
DATA
(
insert
OID
=
2290
(
record_in
PGNSP
PGUID
12
f
f
t
f
v
2
2249
"2275 26"
_null_
record_in
-
_null_
));
DESCR
(
"I/O"
);
...
...
src/include/utils/builtins.h
浏览文件 @
e47cbb3b
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.24
5 2004/07/02 18:59:25 joe
Exp $
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.24
6 2004/07/12 20:23:59 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -52,6 +52,12 @@ extern Datum has_schema_privilege_id_name(PG_FUNCTION_ARGS);
extern
Datum
has_schema_privilege_id_id
(
PG_FUNCTION_ARGS
);
extern
Datum
has_schema_privilege_name
(
PG_FUNCTION_ARGS
);
extern
Datum
has_schema_privilege_id
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_name_name
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_name_id
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_id_name
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_id_id
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_name
(
PG_FUNCTION_ARGS
);
extern
Datum
has_tablespace_privilege_id
(
PG_FUNCTION_ARGS
);
/* bool.c */
extern
Datum
boolin
(
PG_FUNCTION_ARGS
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录