Re: psql missing feature: show permissions for functions

Lists: pgsql-bugs
From: Jorge Godoy <godoy(at)ieee(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: psql missing feature: show permissions for functions
Date: 2004-09-20 17:03:55
Message-ID: m3sm9cc1ok.fsf@g2ctech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Hi,

I was trying to check some permissions on functions and then I noticed
that there's no command in psql to show that information. I've tried
using "\z", "\df" and "\df+" without success on PostgreSQL 7.4.5.

It would be an interesting addition to have that, as we do have the
commands to show permissions on tables.

Thanks for your attention,
--
Godoy. <godoy(at)ieee(dot)org>


From: "John R Pierce" <pierce(at)hogranch(dot)com>
To: <pgsql-bugs(at)postgresql(dot)org>, "Jorge Godoy" <godoy(at)ieee(dot)org>
Subject: Re: psql missing feature: show permissions for functions
Date: 2004-09-20 22:15:25
Message-ID: 132201c49f5f$5444efd0$0200a8c0@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

> I was trying to check some permissions on functions and then I noticed
> that there's no command in psql to show that information. I've tried
> using "\z", "\df" and "\df+" without success on PostgreSQL 7.4.5.
>
> It would be an interesting addition to have that, as we do have the
> commands to show permissions on tables.

ah, I found it. try...

SELECT proacl FROM pg_proc WHERE proname='functioname';


From: Jorge Godoy <godoy(at)ieee(dot)org>
To: "John R Pierce" <pierce(at)hogranch(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: psql missing feature: show permissions for functions
Date: 2004-09-20 22:35:58
Message-ID: m3sm9cefg1.fsf@g2ctech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"John R Pierce" <pierce(at)hogranch(dot)com> writes:

>> I was trying to check some permissions on functions and then I noticed
>> that there's no command in psql to show that information. I've tried
>> using "\z", "\df" and "\df+" without success on PostgreSQL 7.4.5.
>> It would be an interesting addition to have that, as we do have the
>> commands to show permissions on tables.
>
> ah, I found it. try...
>
> SELECT proacl FROM pg_proc WHERE proname='functioname';

Hi John!

It works. How does it deal with overloaded functions? :-) I don't have
any here, yet, but from pg_proc's contents I couldn't find one way to
define exactly what is the function that is authorized for use (we have
to pass the parameters of the function at the command line, otherwise
there's an error:

testbase=# GRANT EXECUTE ON FUNCTION my_function(VARCHAR, VARCHAR) TO dbmanager;
GRANT
testbase=# GRANT EXECUTE ON FUNCTION my_function TO dbmanager;
ERROR: syntax error at or near "to" at character 41
testbase=# GRANT EXECUTE ON FUNCTION my_functon() TO dbmanager;
ERROR: function my_function() does not exist
testbase=#

<some more testing>

I found that I can check 'proargtypes' column and compare it with the
definitions I want, but it would be great if there was some psql builtin
macro to do that :-)

This solves my problem from the SQL point of view, but I still think
that psql should have something like that (with the appropriate
proargtypes replacement from numeric to the type name...).

testbase=# SELECT proacl, proargtypes FROM pg_proc WHERE proname='to_ascii';
proacl | proargtypes
---------------+-------------
{=X/postgres} | 25
{=X/postgres} | 25 19
{=X/postgres} | 25 23
(3 rows)

testbase=#

Where can I find this '25', '19', '23', etc. name? :-)

Thanks.
--
Godoy. <godoy(at)ieee(dot)org>


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Jorge Godoy <godoy(at)ieee(dot)org>
Cc: John R Pierce <pierce(at)hogranch(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql missing feature: show permissions for functions
Date: 2004-09-21 01:11:06
Message-ID: 20040921011106.GA7013@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Sep 20, 2004 at 07:35:58PM -0300, Jorge Godoy wrote:

> testbase=# SELECT proacl, proargtypes FROM pg_proc WHERE proname='to_ascii';
> proacl | proargtypes
> ---------------+-------------
> {=X/postgres} | 25
> {=X/postgres} | 25 19
> {=X/postgres} | 25 23
> (3 rows)
>
> testbase=#
>
> Where can I find this '25', '19', '23', etc. name? :-)

Those are OIDs from the pg_type catalog. The format_type(oid, integer)
function can give you the actual name, as in

alvherre=# SELECT proacl, proargtypes, format_type(proargtypes[0], 0),
format_type(proargtypes[1], 0) FROM pg_proc WHERE proname='to_ascii';
proacl | proargtypes | format_type | format_type
---------------+-------------+-------------+-------------
{=X/alvherre} | 25 | text | -
{=X/alvherre} | 25 19 | text | name
{=X/alvherre} | 25 23 | text | integer
(3 filas)

The second argument is the type's typmod (the 25 in varchar(25), for
instance).

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"The ability to monopolize a planet is insignificant
next to the power of the source"


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Jorge Godoy <godoy(at)ieee(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: psql missing feature: show permissions for functions]
Date: 2004-09-21 06:29:25
Message-ID: 200409210629.i8L6TPN05516@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Jorge Godoy wrote:
>
> Hi,
>
>
> I was trying to check some permissions on functions and then I noticed
> that there's no command in psql to show that information. I've tried
> using "\z", "\df" and "\df+" without success on PostgreSQL 7.4.5.
>
> It would be an interesting addition to have that, as we do have the
> commands to show permissions on tables.

I believe this is fixed in 8.0.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073