Show "internal name" not "source code" in psql's \df+ command.

Our previous habit of showing the full function body is really
pretty unfriendly for tabular viewing of functions, and now that
we have \sf and \ef commands there seems no good reason why \df+
has to do it.  It still seems to make sense to show prosrc for
internal and C-language functions, since in those cases prosrc
is just the C function name; but then let's rename the column to
"Internal name" which is a more accurate descriptor.

Isaac Morland

Discussion: https://postgr.es/m/CAMsGm5eqKc6J1=Lwn=ZONG=6ZDYWRQ4cgZQLqMuZGB1aVt_JBg@mail.gmail.com
pull/132/head^2
Tom Lane 3 years ago
parent 1da569ca1f
commit 3dfae91f7a
  1. 5
      doc/src/sgml/ref/psql-ref.sgml
  2. 11
      src/bin/psql/describe.c
  3. 28
      src/test/regress/expected/psql.out
  4. 23
      src/test/regress/sql/psql.sql

@ -1650,7 +1650,10 @@ INSERT INTO tbl1 VALUES ($1, $2) \bind 'first value' 'second value' \g
If the form <literal>\df+</literal> is used, additional information
about each function is shown, including volatility,
parallel safety, owner, security classification, access privileges,
language, source code and description.
language, internal name (for C and internal functions only),
and description.
Source code for a specific function can be seen
using <literal>\sf</literal>.
</para>
</listitem>

@ -410,14 +410,9 @@ describeFunctions(const char *functypes, const char *func_pattern,
appendPQExpBuffer(&buf,
",\n l.lanname as \"%s\"",
gettext_noop("Language"));
if (pset.sversion >= 140000)
appendPQExpBuffer(&buf,
",\n COALESCE(pg_catalog.pg_get_function_sqlbody(p.oid), p.prosrc) as \"%s\"",
gettext_noop("Source code"));
else
appendPQExpBuffer(&buf,
",\n p.prosrc as \"%s\"",
gettext_noop("Source code"));
appendPQExpBuffer(&buf,
",\n CASE WHEN l.lanname IN ('internal', 'c') THEN p.prosrc END as \"%s\"",
gettext_noop("Internal name"));
appendPQExpBuffer(&buf,
",\n pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
gettext_noop("Description"));

@ -5247,6 +5247,34 @@ reset work_mem;
pg_catalog | && | anyarray | anyarray | boolean | overlaps
(1 row)
-- check \df+
begin;
-- we have to use functions with a predictable owner name, so make a role
create role regress_psql_user superuser;
set session authorization regress_psql_user;
create function psql_df_internal (float8)
returns float8
language internal immutable parallel safe strict
as 'dsin';
create function psql_df_sql (x integer)
returns integer
security definer
begin atomic select x + 1; end;
create function psql_df_plpgsql ()
returns void
language plpgsql
as $$ begin return; end; $$;
comment on function psql_df_plpgsql () is 'some comment';
\df+ psql_df_*
List of functions
Schema | Name | Result data type | Argument data types | Type | Volatility | Parallel | Owner | Security | Access privileges | Language | Internal name | Description
--------+------------------+------------------+---------------------+------+------------+----------+-------------------+----------+-------------------+----------+---------------+--------------
public | psql_df_internal | double precision | double precision | func | immutable | safe | regress_psql_user | invoker | | internal | dsin |
public | psql_df_plpgsql | void | | func | volatile | unsafe | regress_psql_user | invoker | | plpgsql | | some comment
public | psql_df_sql | integer | x integer | func | volatile | unsafe | regress_psql_user | definer | | sql | |
(3 rows)
rollback;
-- check \sf
\sf information_schema._pg_expandarray
CREATE OR REPLACE FUNCTION information_schema._pg_expandarray(anyarray, OUT x anyelement, OUT n integer)

@ -1275,6 +1275,29 @@ reset work_mem;
\do - pg_catalog.int4
\do && anyarray *
-- check \df+
begin;
-- we have to use functions with a predictable owner name, so make a role
create role regress_psql_user superuser;
set session authorization regress_psql_user;
create function psql_df_internal (float8)
returns float8
language internal immutable parallel safe strict
as 'dsin';
create function psql_df_sql (x integer)
returns integer
security definer
begin atomic select x + 1; end;
create function psql_df_plpgsql ()
returns void
language plpgsql
as $$ begin return; end; $$;
comment on function psql_df_plpgsql () is 'some comment';
\df+ psql_df_*
rollback;
-- check \sf
\sf information_schema._pg_expandarray
\sf+ information_schema._pg_expandarray

Loading…
Cancel
Save