Thread: How to reveal the codes of functions properly?

How to reveal the codes of functions properly?

From
Shaozhong SHI
Date:
Any one can shed the light on this?

Regards,

David

Re: How to reveal the codes of functions properly?

From
Rob Sargent
Date:
On 11/30/21 9:30 AM, Shaozhong SHI wrote:
Any one can shed the light on this?

Regards,

David
\sf+ function_name

Re: How to reveal the codes of functions properly?

From
Shaozhong SHI
Date:
In what environment, that did not work.


On Tuesday, 30 November 2021, Rob Sargent <robjsargent@gmail.com> wrote:
On 11/30/21 9:30 AM, Shaozhong SHI wrote:
Any one can shed the light on this?

Regards,

David
\sf+ function_name

Re: How to reveal the codes of functions properly?

From
Rob Sargent
Date:
On 11/30/21 1:17 PM, Shaozhong SHI wrote:
In what environment, that did not work.


On Tuesday, 30 November 2021, Rob Sargent <robjsargent@gmail.com> wrote:
On 11/30/21 9:30 AM, Shaozhong SHI wrote:
Any one can shed the light on this?

Regards,

David
\sf+ function_name
psql

Re: How to reveal the codes of functions properly?

From
Wicher
Date:
On Tue, 30 Nov 2021 20:17:32 +0000
Shaozhong SHI <shishaozhong@gmail.com> wrote:

> In what environment, that did not work.
> 
> 
> On Tuesday, 30 November 2021, Rob Sargent <robjsargent@gmail.com> wrote:
> 
> > On 11/30/21 9:30 AM, Shaozhong SHI wrote:
> >
> > Any one can shed the light on this?
> >
> > Regards,
> >
> > David
> >
> > \sf+ function_name
> >  

If you run that in a psql shell when psql has been passed `-E`, you'll see that under the
hood it runs:

SELECT n.nspname as "Schema",
  p.proname as "Name",
  pg_catalog.pg_get_function_result(p.oid) as "Result data type",
  pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",
 CASE p.prokind
  WHEN 'a' THEN 'agg'
  WHEN 'w' THEN 'window'
  WHEN 'p' THEN 'proc'
  ELSE 'func'
 END as "Type",
 CASE
  WHEN p.provolatile = 'i' THEN 'immutable'
  WHEN p.provolatile = 's' THEN 'stable'
  WHEN p.provolatile = 'v' THEN 'volatile'
 END as "Volatility",
 CASE
  WHEN p.proparallel = 'r' THEN 'restricted'
  WHEN p.proparallel = 's' THEN 'safe'
  WHEN p.proparallel = 'u' THEN 'unsafe'
 END as "Parallel",
 pg_catalog.pg_get_userbyid(p.proowner) as "Owner",
 CASE WHEN prosecdef THEN 'definer' ELSE 'invoker' END AS "Security",
 pg_catalog.array_to_string(p.proacl, E'\n') AS "Access privileges",
 l.lanname as "Language",
 p.prosrc as "Source code",
 pg_catalog.obj_description(p.oid, 'pg_proc') as "Description"
FROM pg_catalog.pg_proc p
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
     LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang
WHERE pg_catalog.pg_function_is_visible(p.oid)
      AND n.nspname <> 'pg_catalog'
      AND n.nspname <> 'information_schema'
ORDER BY 1, 2, 4;



Re: How to reveal the codes of functions properly?

From
"David G. Johnston"
Date:
On Tue, Nov 30, 2021 at 1:17 PM Shaozhong SHI <shishaozhong@gmail.com> wrote:
In what environment, that did not work.


In what environment did you wish the answer to be given?

David J.