psql \du and \dg commands.

Lists: pgsql-hackers
From: David BOURIAUD <david(dot)bouriaud(at)ac-rouen(dot)fr>
To: pgsql-hackers(at)postgresql(dot)org
Subject: psql \du and \dg commands.
Date: 2008-04-09 14:35:38
Message-ID: 200804091635.40836.david.bouriaud@ac-rouen.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,
I don't really know since when those commands are provided by psql, but I
found them recently and was quite annoyed by the output given by both of
them.
Though I find that the \du command's output is quite accurate, I wonder why
\dg gives the same informations ?
I would have expected to see the group names in a left column, and the list of
users that belongs to this group.
I know I can get the information by fetching rows of pg_group system table,
but I was just wondering about this issue and see what you here would think
of it.
Thanks for any suggestions about this behavior.


From: Shane Ambler <pgsql(at)Sheeky(dot)Biz>
To: David BOURIAUD <david(dot)bouriaud(at)ac-rouen(dot)fr>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql \du and \dg commands.
Date: 2008-04-09 16:22:03
Message-ID: 47FCED2B.2010502@Sheeky.Biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

David BOURIAUD wrote:
> Hello,
> I don't really know since when those commands are provided by psql, but I
> found them recently and was quite annoyed by the output given by both of
> them.

Not certain since when but I would think from a very early version.

> Though I find that the \du command's output is quite accurate, I wonder why
> \dg gives the same informations ?
> I would have expected to see the group names in a left column, and the list of
> users that belongs to this group.
> I know I can get the information by fetching rows of pg_group system table,
> but I was just wondering about this issue and see what you here would think
> of it.
> Thanks for any suggestions about this behavior.

Historically old versions had a clear definition between groups and
users. 8.1 introduced the role as we use today replacing the users and
groups.

The views in pg_catalog that are used to replace the old users and
groups defines a group as a role that cannot login. This is an
approximation only as any role can have members assigned to them as if
it was a group, inheriting privileges of that role.
And nologin may be assigned to any role for more reasons than to define
it as a group.

The \dg and \du commands in psql need to remain as the new version can
still connect to old servers that don't support the new roles. But with
an 8.1 or newer server it can't reliably distinguish between a user and
a group role so returns the same info.

I guess there is always a chance of someone making a patch that would
hide the two options (maybe replace them with \dr?) when connected to an
8.1 or higher server. But I wouldn't expect it any time soon.

--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz