Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
a61b2464
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,发现更多精彩内容 >>
提交
a61b2464
编写于
5月 13, 2008
作者:
A
Alvaro Herrera
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change \du to use the new printTable API, improving the situation of very wide
tables. Brendan Jurd, with some help from me.
上级
e6a64bd3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
93 addition
and
30 deletion
+93
-30
src/bin/psql/describe.c
src/bin/psql/describe.c
+93
-30
未找到文件。
src/bin/psql/describe.c
浏览文件 @
a61b2464
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.17
2 2008/05/13 00:14:11
alvherre Exp $
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.17
3 2008/05/13 00:23:17
alvherre Exp $
*/
#include "postgres_fe.h"
...
...
@@ -24,6 +24,7 @@ static bool describeOneTableDetails(const char *schemaname,
bool
verbose
);
static
void
add_tablespace_footer
(
printTableContent
*
const
cont
,
char
relkind
,
Oid
tablespace
,
const
bool
newline
);
static
void
add_role_attribute
(
PQExpBuffer
buf
,
const
char
*
const
str
);
static
bool
listTSParsersVerbose
(
const
char
*
pattern
);
static
bool
describeOneTSParser
(
const
char
*
oid
,
const
char
*
nspname
,
const
char
*
prsname
);
...
...
@@ -1560,34 +1561,31 @@ describeRoles(const char *pattern, bool verbose)
{
PQExpBufferData
buf
;
PGresult
*
res
;
printQueryOpt
myopt
=
pset
.
popt
;
static
const
bool
trans_columns
[]
=
{
false
,
true
,
true
,
true
,
true
,
false
,
false
};
printTableContent
cont
;
printTableOpt
myopt
=
pset
.
popt
.
topt
;
int
ncols
=
3
;
int
nrows
=
0
;
int
i
;
int
conns
;
const
char
align
=
'l'
;
char
**
attr
;
initPQExpBuffer
(
&
buf
);
printfPQExpBuffer
(
&
buf
,
"SELECT r.rolname AS
\"
%s
\"
,
\n
"
" CASE WHEN r.rolsuper THEN '%s' ELSE '%s' END AS
\"
%s
\"
,
\n
"
" CASE WHEN r.rolcreaterole THEN '%s' ELSE '%s' END AS
\"
%s
\"
,
\n
"
" CASE WHEN r.rolcreatedb THEN '%s' ELSE '%s' END AS
\"
%s
\"
,
\n
"
" CASE WHEN r.rolconnlimit < 0 THEN CAST('%s' AS pg_catalog.text)
\n
"
" ELSE CAST(r.rolconnlimit AS pg_catalog.text)
\n
"
" END AS
\"
%s
\"
,
\n
"
" ARRAY(SELECT b.rolname FROM pg_catalog.pg_auth_members m JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid) WHERE m.member = r.oid) as
\"
%s
\"
"
,
gettext_noop
(
"Role name"
),
gettext_noop
(
"yes"
),
gettext_noop
(
"no"
),
gettext_noop
(
"Superuser"
),
gettext_noop
(
"yes"
),
gettext_noop
(
"no"
),
gettext_noop
(
"Create role"
),
gettext_noop
(
"yes"
),
gettext_noop
(
"no"
),
gettext_noop
(
"Create DB"
),
gettext_noop
(
"no limit"
),
gettext_noop
(
"Connections"
),
gettext_noop
(
"Member of"
));
appendPQExpBufferStr
(
&
buf
,
"SELECT r.rolname, r.rolsuper, r.rolinherit,
\n
"
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,
\n
"
" r.rolconnlimit,
\n
"
" ARRAY(SELECT b.rolname
\n
"
" FROM pg_catalog.pg_auth_members m
\n
"
" JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)
\n
"
" WHERE m.member = r.oid) as memberof"
);
if
(
verbose
)
appendPQExpBuffer
(
&
buf
,
"
\n
, pg_catalog.shobj_description(r.oid, 'pg_authid') AS
\"
%s
\"
"
,
gettext_noop
(
"Description"
));
{
appendPQExpBufferStr
(
&
buf
,
"
\n
, pg_catalog.shobj_description(r.oid, 'pg_authid') AS description"
);
ncols
++
;
}
appendPQExpBuffer
(
&
buf
,
"
\n
FROM pg_catalog.pg_roles r
\n
"
);
...
...
@@ -1597,21 +1595,86 @@ describeRoles(const char *pattern, bool verbose)
appendPQExpBuffer
(
&
buf
,
"ORDER BY 1;"
);
res
=
PSQLexec
(
buf
.
data
,
false
);
termPQExpBuffer
(
&
buf
);
if
(
!
res
)
return
false
;
myopt
.
nullPrint
=
NULL
;
myopt
.
title
=
_
(
"List of roles"
);
myopt
.
trans_headers
=
true
;
myopt
.
trans_columns
=
trans_columns
;
nrows
=
PQntuples
(
res
);
attr
=
pg_malloc_zero
((
nrows
+
1
)
*
sizeof
(
*
attr
));
printQuery
(
res
,
&
myopt
,
pset
.
queryFout
,
pset
.
logfile
);
printTableInit
(
&
cont
,
&
myopt
,
_
(
"List of roles"
),
ncols
,
nrows
);
printTableAddHeader
(
&
cont
,
gettext_noop
(
"Role name"
),
true
,
align
);
printTableAddHeader
(
&
cont
,
gettext_noop
(
"Attributes"
),
true
,
align
);
printTableAddHeader
(
&
cont
,
gettext_noop
(
"Member of"
),
true
,
align
);
if
(
verbose
)
printTableAddHeader
(
&
cont
,
gettext_noop
(
"Description"
),
true
,
align
);
for
(
i
=
0
;
i
<
nrows
;
i
++
)
{
printTableAddCell
(
&
cont
,
PQgetvalue
(
res
,
i
,
0
),
false
);
resetPQExpBuffer
(
&
buf
);
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
1
),
"t"
)
==
0
)
add_role_attribute
(
&
buf
,
_
(
"Superuser"
));
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
2
),
"t"
)
!=
0
)
add_role_attribute
(
&
buf
,
_
(
"No inheritance"
));
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
3
),
"t"
)
==
0
)
add_role_attribute
(
&
buf
,
_
(
"Create role"
));
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
4
),
"t"
)
==
0
)
add_role_attribute
(
&
buf
,
_
(
"Create DB"
));
if
(
strcmp
(
PQgetvalue
(
res
,
i
,
5
),
"t"
)
!=
0
)
add_role_attribute
(
&
buf
,
_
(
"Cannot login"
));
conns
=
atoi
(
PQgetvalue
(
res
,
i
,
6
));
if
(
conns
>=
0
)
{
if
(
buf
.
len
>
0
)
appendPQExpBufferStr
(
&
buf
,
"
\n
"
);
if
(
conns
==
0
)
appendPQExpBuffer
(
&
buf
,
_
(
"No connections"
));
else
if
(
conns
==
1
)
appendPQExpBuffer
(
&
buf
,
_
(
"1 connection"
));
else
appendPQExpBuffer
(
&
buf
,
_
(
"%d connections"
),
conns
);
}
attr
[
i
]
=
pg_strdup
(
buf
.
data
);
printTableAddCell
(
&
cont
,
attr
[
i
],
false
);
printTableAddCell
(
&
cont
,
PQgetvalue
(
res
,
i
,
7
),
false
);
if
(
verbose
)
printTableAddCell
(
&
cont
,
PQgetvalue
(
res
,
i
,
8
),
false
);
}
termPQExpBuffer
(
&
buf
);
printTable
(
&
cont
,
pset
.
queryFout
,
pset
.
logfile
);
printTableCleanup
(
&
cont
);
for
(
i
=
0
;
i
<
nrows
;
i
++
)
free
(
attr
[
i
]);
free
(
attr
);
PQclear
(
res
);
return
true
;
}
void
add_role_attribute
(
PQExpBuffer
buf
,
const
char
*
const
str
)
{
if
(
buf
->
len
>
0
)
appendPQExpBufferStr
(
buf
,
"
\n
"
);
appendPQExpBufferStr
(
buf
,
str
);
}
/*
* listTables()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录