Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
688781d4
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,发现更多精彩内容 >>
提交
688781d4
编写于
4月 02, 2002
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix contrib/dbsize for schema-qualified table names.
上级
1dc43ea7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
31 deletion
+26
-31
contrib/dbsize/dbsize.c
contrib/dbsize/dbsize.c
+23
-28
contrib/dbsize/dbsize.sql.in
contrib/dbsize/dbsize.sql.in
+3
-3
未找到文件。
contrib/dbsize/dbsize.c
浏览文件 @
688781d4
#include "postgres.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "catalog/catalog.h"
#include "catalog/catname.h"
#include "catalog/pg_database.h"
#include "utils/fmgroids.h"
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "access/heapam.h"
#include "catalog/catalog.h"
#include "catalog/catname.h"
#include "catalog/namespace.h"
#include "catalog/pg_database.h"
#include "fmgr.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
static
char
*
psnprintf
(
size_t
len
,
const
char
*
fmt
,...)
...
...
@@ -38,6 +39,8 @@ psnprintf(size_t len, const char *fmt,...)
PG_FUNCTION_INFO_V1
(
database_size
);
Datum
database_size
(
PG_FUNCTION_ARGS
);
Datum
database_size
(
PG_FUNCTION_ARGS
)
{
...
...
@@ -107,39 +110,29 @@ database_size(PG_FUNCTION_ARGS)
/*
* SQL function: relation_size(
name
) returns bigint
* SQL function: relation_size(
text
) returns bigint
*/
PG_FUNCTION_INFO_V1
(
relation_size
);
Datum
relation_size
(
PG_FUNCTION_ARGS
);
Datum
relation_size
(
PG_FUNCTION_ARGS
)
{
Name
relname
=
PG_GETARG_NAME
(
0
);
text
*
relname
=
PG_GETARG_TEXT_P
(
0
);
HeapTuple
tuple
;
RangeVar
*
relrv
;
Relation
relation
;
ScanKeyData
scanKey
;
HeapScanDesc
scan
;
Oid
relnode
;
int64
totalsize
;
unsigned
int
segcount
;
relation
=
heap_openr
(
RelationRelationName
,
AccessShareLock
);
ScanKeyEntryInitialize
(
&
scanKey
,
0
,
Anum_pg_class_relname
,
F_NAMEEQ
,
NameGetDatum
(
relname
));
scan
=
heap_beginscan
(
relation
,
0
,
SnapshotNow
,
1
,
&
scanKey
);
tuple
=
heap_getnext
(
scan
,
0
);
relrv
=
makeRangeVarFromNameList
(
textToQualifiedNameList
(
relname
,
"relation_size"
));
relation
=
relation_openrv
(
relrv
,
AccessShareLock
);
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"relation %s does not exist"
,
NameStr
(
*
relname
));
relnode
=
((
Form_pg_class
)
GETSTRUCT
(
tuple
))
->
relfilenode
;
if
(
relnode
==
InvalidOid
)
elog
(
ERROR
,
"invalid relation node id"
);
heap_endscan
(
scan
);
heap_close
(
relation
,
NoLock
);
relnode
=
relation
->
rd_rel
->
relfilenode
;
totalsize
=
0
;
segcount
=
0
;
...
...
@@ -158,12 +151,14 @@ relation_size(PG_FUNCTION_ARGS)
if
(
errno
==
ENOENT
)
break
;
else
elog
(
ERROR
,
"could not stat %s: %
s"
,
fullname
,
strerror
(
errno
)
);
elog
(
ERROR
,
"could not stat %s: %
m"
,
fullname
);
}
totalsize
+=
statbuf
.
st_size
;
pfree
(
fullname
);
segcount
++
;
}
relation_close
(
relation
,
AccessShareLock
);
PG_RETURN_INT64
(
totalsize
);
}
contrib/dbsize/dbsize.sql.in
浏览文件 @
688781d4
CREATE FUNCTION database_size (name) RETURNS bigint
AS '
@MODULE_FILENAME@
', 'database_size'
AS '
MODULE_PATHNAME
', 'database_size'
LANGUAGE C WITH (isstrict);
CREATE FUNCTION relation_size (
name
) RETURNS bigint
AS '
@MODULE_FILENAME@
', 'relation_size'
CREATE FUNCTION relation_size (
text
) RETURNS bigint
AS '
MODULE_PATHNAME
', 'relation_size'
LANGUAGE C WITH (isstrict);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录