Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
c59e3c8f
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,体验更适合开发者的 AI 搜索 >>
提交
c59e3c8f
编写于
1月 22, 2018
作者:
P
Pengzhou Tang
提交者:
Tang Pengzhou
4月 23, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a syscache for pg_resgroup
This commit makes access to pg_resgroup a little bit faster
上级
a399d5b6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
53 addition
and
42 deletion
+53
-42
src/backend/commands/resgroupcmds.c
src/backend/commands/resgroupcmds.c
+23
-37
src/backend/commands/user.c
src/backend/commands/user.c
+2
-2
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/pgstatfuncs.c
+1
-1
src/backend/utils/cache/syscache.c
src/backend/utils/cache/syscache.c
+23
-0
src/include/commands/resgroupcmds.h
src/include/commands/resgroupcmds.h
+2
-2
src/include/utils/syscache.h
src/include/utils/syscache.h
+2
-0
未找到文件。
src/backend/commands/resgroupcmds.c
浏览文件 @
c59e3c8f
...
@@ -380,7 +380,7 @@ AlterResourceGroup(AlterResourceGroupStmt *stmt)
...
@@ -380,7 +380,7 @@ AlterResourceGroup(AlterResourceGroupStmt *stmt)
* Check the pg_resgroup relation to be certain the resource group already
* Check the pg_resgroup relation to be certain the resource group already
* exists.
* exists.
*/
*/
groupid
=
GetResGroupIdForName
(
stmt
->
name
,
RowExclusiveLock
);
groupid
=
GetResGroupIdForName
(
stmt
->
name
);
if
(
groupid
==
InvalidOid
)
if
(
groupid
==
InvalidOid
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
...
@@ -612,32 +612,27 @@ GetResGroupIdForRole(Oid roleid)
...
@@ -612,32 +612,27 @@ GetResGroupIdForRole(Oid roleid)
* to Oid.
* to Oid.
*/
*/
Oid
Oid
GetResGroupIdForName
(
const
char
*
name
,
LOCKMODE
lockmode
)
GetResGroupIdForName
(
const
char
*
name
)
{
{
Relation
rel
;
ScanKeyData
scankey
;
SysScanDesc
scan
;
HeapTuple
tuple
;
HeapTuple
tuple
;
Oid
rsgid
;
Oid
rsgid
;
rel
=
heap_open
(
ResGroupRelationId
,
lockmode
);
tuple
=
SearchSysCache1
(
RESGROUPNAME
,
CStringGetDatum
(
name
));
/* SELECT oid FROM pg_resgroup WHERE rsgname = :1 */
ScanKeyInit
(
&
scankey
,
Anum_pg_resgroup_rsgname
,
BTEqualStrategyNumber
,
F_NAMEEQ
,
CStringGetDatum
(
name
));
scan
=
systable_beginscan
(
rel
,
ResGroupRsgnameIndexId
,
true
,
SnapshotNow
,
1
,
&
scankey
);
tuple
=
systable_getnext
(
scan
);
if
(
HeapTupleIsValid
(
tuple
))
if
(
HeapTupleIsValid
(
tuple
))
rsgid
=
HeapTupleGetOid
(
tuple
);
{
bool
isnull
;
Datum
oidDatum
=
SysCacheGetAttr
(
RESGROUPNAME
,
tuple
,
ObjectIdAttributeNumber
,
&
isnull
);
Assert
(
!
isnull
);
rsgid
=
DatumGetObjectId
(
oidDatum
);
}
else
else
r
sgid
=
InvalidOid
;
r
eturn
InvalidOid
;
systable_endscan
(
scan
);
ReleaseSysCache
(
tuple
);
heap_close
(
rel
,
lockmode
);
return
rsgid
;
return
rsgid
;
}
}
...
@@ -646,37 +641,28 @@ GetResGroupIdForName(const char *name, LOCKMODE lockmode)
...
@@ -646,37 +641,28 @@ GetResGroupIdForName(const char *name, LOCKMODE lockmode)
* GetResGroupNameForId -- Return the resource group name for an Oid
* GetResGroupNameForId -- Return the resource group name for an Oid
*/
*/
char
*
char
*
GetResGroupNameForId
(
Oid
oid
,
LOCKMODE
lockmode
)
GetResGroupNameForId
(
Oid
oid
)
{
{
Relation
rel
;
ScanKeyData
scankey
;
SysScanDesc
scan
;
HeapTuple
tuple
;
HeapTuple
tuple
;
char
*
name
=
NULL
;
char
*
name
=
NULL
;
rel
=
heap_open
(
ResGroupRelationId
,
lockmode
);
tuple
=
SearchSysCache1
(
RESGROUPOID
,
ObjectIdGetDatum
(
oid
));
/* SELECT rsgname FROM pg_resgroup WHERE oid = :1 */
ScanKeyInit
(
&
scankey
,
ObjectIdAttributeNumber
,
BTEqualStrategyNumber
,
F_OIDEQ
,
ObjectIdGetDatum
(
oid
));
scan
=
systable_beginscan
(
rel
,
ResGroupOidIndexId
,
true
,
SnapshotNow
,
1
,
&
scankey
);
tuple
=
systable_getnext
(
scan
);
if
(
HeapTupleIsValid
(
tuple
))
if
(
HeapTupleIsValid
(
tuple
))
{
{
bool
isnull
;
bool
isnull
;
Datum
nameDatum
=
heap_getattr
(
tuple
,
Anum_pg_resgroup_rsgname
,
Datum
nameDatum
=
SysCacheGetAttr
(
RESGROUPOID
,
tuple
,
rel
->
rd_att
,
&
isnull
);
Anum_pg_resgroup_rsgname
,
&
isnull
);
Assert
(
!
isnull
);
Assert
(
!
isnull
);
Name
resGroupName
=
DatumGetName
(
nameDatum
);
Name
resGroupName
=
DatumGetName
(
nameDatum
);
name
=
pstrdup
(
NameStr
(
*
resGroupName
));
name
=
pstrdup
(
NameStr
(
*
resGroupName
));
}
}
else
return
"unknow"
;
systable_endscan
(
scan
);
ReleaseSysCache
(
tuple
);
heap_close
(
rel
,
lockmode
);
return
name
;
return
name
;
}
}
...
...
src/backend/commands/user.c
浏览文件 @
c59e3c8f
...
@@ -533,7 +533,7 @@ CreateRole(CreateRoleStmt *stmt)
...
@@ -533,7 +533,7 @@ CreateRole(CreateRoleStmt *stmt)
{
{
Oid
rsgid
;
Oid
rsgid
;
rsgid
=
GetResGroupIdForName
(
resgroup
,
ShareLock
);
rsgid
=
GetResGroupIdForName
(
resgroup
);
if
(
rsgid
==
InvalidOid
)
if
(
rsgid
==
InvalidOid
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
...
@@ -1195,7 +1195,7 @@ AlterRole(AlterRoleStmt *stmt)
...
@@ -1195,7 +1195,7 @@ AlterRole(AlterRoleStmt *stmt)
resgroup
)));
resgroup
)));
}
}
rsgid
=
GetResGroupIdForName
(
resgroup
,
ShareLock
);
rsgid
=
GetResGroupIdForName
(
resgroup
);
if
(
rsgid
==
InvalidOid
)
if
(
rsgid
==
InvalidOid
)
ereport
(
ERROR
,
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
...
...
src/backend/utils/adt/pgstatfuncs.c
浏览文件 @
c59e3c8f
...
@@ -633,7 +633,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
...
@@ -633,7 +633,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
if
(
funcctx
->
tuple_desc
->
natts
>
13
)
if
(
funcctx
->
tuple_desc
->
natts
>
13
)
{
{
Datum
now
=
TimestampTzGetDatum
(
GetCurrentTimestamp
());
Datum
now
=
TimestampTzGetDatum
(
GetCurrentTimestamp
());
char
*
groupName
=
GetResGroupNameForId
(
beentry
->
st_rsgid
,
AccessShareLock
);
char
*
groupName
=
GetResGroupNameForId
(
beentry
->
st_rsgid
);
values
[
13
]
=
ObjectIdGetDatum
(
beentry
->
st_rsgid
);
values
[
13
]
=
ObjectIdGetDatum
(
beentry
->
st_rsgid
);
...
...
src/backend/utils/cache/syscache.c
浏览文件 @
c59e3c8f
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
#include "catalog/pg_ts_template.h"
#include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h"
#include "catalog/pg_type.h"
#include "catalog/pg_window.h"
#include "catalog/pg_window.h"
#include "catalog/pg_resgroup.h"
#include "utils/syscache.h"
#include "utils/syscache.h"
...
@@ -509,6 +510,28 @@ static const struct cachedesc cacheinfo[] = {
...
@@ -509,6 +510,28 @@ static const struct cachedesc cacheinfo[] = {
},
},
1024
1024
},
},
{
ResGroupRelationId
,
/* RESGROUPOID */
ResGroupOidIndexId
,
1
,
{
ObjectIdAttributeNumber
,
0
,
0
,
0
},
128
},
{
ResGroupRelationId
,
/* RESGROUPNAME */
ResGroupRsgnameIndexId
,
1
,
{
Anum_pg_resgroup_rsgname
,
0
,
0
,
0
},
128
},
{
RewriteRelationId
,
/* RULERELNAME */
{
RewriteRelationId
,
/* RULERELNAME */
RewriteRelRulenameIndexId
,
RewriteRelRulenameIndexId
,
2
,
2
,
...
...
src/include/commands/resgroupcmds.h
浏览文件 @
c59e3c8f
...
@@ -32,8 +32,8 @@ extern void DropResourceGroup(DropResourceGroupStmt *stmt);
...
@@ -32,8 +32,8 @@ extern void DropResourceGroup(DropResourceGroupStmt *stmt);
extern
void
AlterResourceGroup
(
AlterResourceGroupStmt
*
stmt
);
extern
void
AlterResourceGroup
(
AlterResourceGroupStmt
*
stmt
);
/* catalog access function */
/* catalog access function */
extern
Oid
GetResGroupIdForName
(
const
char
*
name
,
LOCKMODE
lockmode
);
extern
Oid
GetResGroupIdForName
(
const
char
*
name
);
extern
char
*
GetResGroupNameForId
(
Oid
oid
,
LOCKMODE
lockmode
);
extern
char
*
GetResGroupNameForId
(
Oid
oid
);
extern
Oid
GetResGroupIdForRole
(
Oid
roleid
);
extern
Oid
GetResGroupIdForRole
(
Oid
roleid
);
extern
void
GetResGroupCapabilities
(
Relation
rel
,
extern
void
GetResGroupCapabilities
(
Relation
rel
,
Oid
groupId
,
Oid
groupId
,
...
...
src/include/utils/syscache.h
浏览文件 @
c59e3c8f
...
@@ -66,6 +66,8 @@ enum SysCacheIdentifier
...
@@ -66,6 +66,8 @@ enum SysCacheIdentifier
PROCOID
,
PROCOID
,
RELNAMENSP
,
RELNAMENSP
,
RELOID
,
RELOID
,
RESGROUPOID
,
RESGROUPNAME
,
RULERELNAME
,
RULERELNAME
,
STATRELATT
,
STATRELATT
,
TSCONFIGMAP
,
TSCONFIGMAP
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录