Feature proposal: list role members in psql

Lists: pgsql-hackers
From: Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Feature proposal: list role members in psql
Date: 2012-03-28 10:55:06
Message-ID: 4F72EE0A.6080709@thl.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

It seems there is no way to get role members using psql. \du and \dg
give you "this role is a member of" information, but no information
about who have been granted the role.

I would like to write a patch implementing this feature. Some questions:
- Is this wanted?
- Should there be a new flag for this: \du[m+] where m list the role
memebers. Or could this be added to the '+' flag?
- Any pointers for patches implementing a similar addition to psql?
That would help me a lot, as I do not know the code base.
- Should the roles be fetched recursively, or should it be just the
direct role members? My opinion is that direct role members is what is
wanted.

The output would be something like:

Role name | Attributes | Member of | Role members
-----------+--------------+------------------------+---------------
hot2_dba | Cannot login | {hot2_user,common_dba} | {akaariai}

- Anssi Kääriäinen


From: David Fetter <david(at)fetter(dot)org>
To: Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Feature proposal: list role members in psql
Date: 2012-03-28 16:08:57
Message-ID: 20120328160857.GA5886@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 28, 2012 at 01:55:06PM +0300, Anssi Kääriäinen wrote:
> It seems there is no way to get role members using psql. \du and \dg
> give you "this role is a member of" information, but no information
> about who have been granted the role.
>
> I would like to write a patch implementing this feature. Some questions:
> - Is this wanted?

It is by at least by one person :)

> - Should there be a new flag for this: \du[m+] where m list the
> role memebers. Or could this be added to the '+' flag?

See below.

> - Any pointers for patches implementing a similar addition to
> psql? That would help me a lot, as I do not know the code base.

It's a pretty standard catalog lookup. Lemme see about a patch...

> - Should the roles be fetched recursively, or should it be just
> the direct role members? My opinion is that direct role members is
> what is wanted.
>
> The output would be something like:
>
> Role name | Attributes | Member of | Role members
> -----------+--------------+------------------------+---------------
> hot2_dba | Cannot login | {hot2_user,common_dba} | {akaariai}
>
>
> - Anssi Kääriäinen

I'd say add first-level "Role members" to \du, all the way up the DAG (or
tree, if you're structured like that) for \du+

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate