我使用以下命令来描述Unix中的函数。
\df+ functionName
问题:无法阅读该功能的说明。
是否有其他方法可以通过适当的缩进来查看函数。
答案 0 :(得分:1)
如果您使用密钥psql
(-E
)启动psql -E
并运行\df+ functionName
,您会看到它需要pg_catalog.pg_proc
的定义,所以您可以像select prosrc from pg_proc where proname = 'functionName';'
\sf functionName
相同 - 它是pg_catalog.pg_get_functiondef
的总结。
最后,如果您按照\df+
的方式进行,只需在\x
之前运行,Source code
看起来会更好。
无论如何,在所有这些情况下,缩进都会被保存:
b=# create function p() returns text
b-# as
b-# $$
b$# begin
b$# --tab
b$# --two spaces
b$# --three spaces
b$# return 't';
b$# end;
b$# $$ language plpgsql
b-# ;
CREATE FUNCTION
b=# \x
Expanded display is on.
b=# \df+ p
List of functions
-[ RECORD 1 ]-------+------------------
Schema | public
Name | p
Result data type | text
Argument data types |
Type | normal
Security | invoker
Volatility | volatile
Owner | postgres
Language | plpgsql
Source code | +
| begin +
| --tab +
| --two spaces +
| --three spaces+
| return 't'; +
| end; +
|
Description |
b=# \sf p
CREATE OR REPLACE FUNCTION public.p()
RETURNS text
LANGUAGE plpgsql
AS $function$
begin
--tab
--two spaces
--three spaces
return 't';
end;
$function$