PostgreSQL 9.5:描述UNIX终端中的功能

时间:2016-11-23 05:41:02

标签: postgresql unix

我使用以下命令来描述Unix中的函数。

\df+ functionName

问题:无法阅读该功能的说明。

是否有其他方法可以通过适当的缩进来查看函数。

1 个答案:

答案 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$