On Wed, 2013-09-18 at 20:13 +0530, Amit Khandekar wrote:
> What's the reason behind calling pg_has_role(proowner, 'USAGE') before
> calling pg_get_function_arg_default() ? :
>
> CASE WHEN pg_has_role(proowner, 'USAGE')
> THEN pg_get_function_arg_default(p_oid, (ss.x).n)
> ELSE NULL END
>
> There is already a pg_has_role() filter added while fetching the
> pg_proc entries : FROM pg_namespace n, pg_proc p
> WHERE n.oid = p.pronamespace AND
> (pg_has_role(p.proowner, 'USAGE') OR
> has_function_privilege(p.oid, 'EXECUTE'))) AS ss
>
> So the proc oid in pg_get_function_arg_default(p_oid, (ss.x).n)
> belongs to a procedure for which the current user has USAGE
> privilege.
No, the pg_proc entry belongs to a function for which the current user
is the owner *or* has EXECUTE privilege. The default, however, is only
shown to the owner. This is per SQL standard.