How to reveal the codes of functions properly?

Started by Shaozhong SHIover 4 years ago6 messagesgeneral
Jump to latest
#1Shaozhong SHI
shishaozhong@gmail.com

Any one can shed the light on this?

Regards,

David

#2Rob Sargent
robjsargent@gmail.com
In reply to: Shaozhong SHI (#1)
Re: How to reveal the codes of functions properly?

On 11/30/21 9:30 AM, Shaozhong SHI wrote:

Any one can shed the light on this?

Regards,

David

\sf+ function_name

#3Shaozhong SHI
shishaozhong@gmail.com
In reply to: Rob Sargent (#2)
Re: How to reveal the codes of functions properly?

In what environment, that did not work.

On Tuesday, 30 November 2021, Rob Sargent <robjsargent@gmail.com> wrote:

Show quoted text

On 11/30/21 9:30 AM, Shaozhong SHI wrote:

Any one can shed the light on this?

Regards,

David

\sf+ function_name

#4Rob Sargent
robjsargent@gmail.com
In reply to: Shaozhong SHI (#3)
Re: How to reveal the codes of functions properly?

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
<mailto: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

#5Wicher
wicher+pglist@gavagai.nl
In reply to: Shaozhong SHI (#3)
Re: How to reveal the codes of functions properly?

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;

#6David G. Johnston
david.g.johnston@gmail.com
In reply to: Shaozhong SHI (#3)
Re: How to reveal the codes of functions properly?

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.