First attempt: support for "\dg" in psql
G'day folks,
Attached is my first attempt at providing "\du"-like functionality for
groups (i.e. a basic "\dg"). It's really just a copy of describeUsers().
It has one major limitation - members are listed by numeric id as I can't
think of a "cheap" way of turning the list into the corresponding list of
usernames.
I thought about having describeGroups() do a lookup on pg_user, but that
could become quite expensive if there is a large number of groups and/or
users (have I missed an obvious facility for caching this information?).
Also, the TODO mentions that the intention is to have \du list groups - I
assume that means output along the lines of the following is wanted?
List of database users
User name | User ID | Attributes | Groups
-----------+---------+----------------------------+---------------
test | 100 | superuser, create database | testg1, testg2
Getting the group names for \du or the usernames for \dg are both
relatively easy with the appropriate JOIN, but the result is always a set
of rows. How to turn that into a single array? What would be handy is a
a library function returning an array, which takes an array, a table and two
two columns from that table:
F(A,T,C1,C2) returning an array of T.C2 values, one for each
value of T.C1 found in A.
With regard to criticism, please be gentle - this is only my second
contribution (the first being a very minor update to to_char). ;-)
Ciao.
--
-------------------------------------------------------+---------------------
Daniel Baldoni BAppSc, PGradDipCompSci | Technical Director
require 'std/disclaimer.pl' | LcdS Pty. Ltd.
-------------------------------------------------------+ 856B Canning Hwy
Phone/FAX: +61-8-9364-8171 | Applecross
Mobile: 041-888-9794 | WA 6153
URL: http://www.lcds.com.au/ | Australia
-------------------------------------------------------+---------------------
"Any time there's something so ridiculous that no rational systems programmer
would even consider trying it, they send for me."; paraphrased from "King Of
The Murgos" by David Eddings. (I'm not good, just crazy)
Attachments:
pg.difftext/plain; charset=us-ascii; name=pg.diffDownload+59-2
This is already in:
The - in front of that item on the todo list[1]http://developer.postgresql.org/todo.php means that it's already
done. This information probably needs to appear more prominently on the
todo page.
[1]: http://developer.postgresql.org/todo.php
Thanks.
--
Markus Bertheau <twanger@bluetwanger.de>
I have moved the mention of the dash higher in the TODO file.
---------------------------------------------------------------------------
Markus Bertheau wrote:
This is already in:
The - in front of that item on the todo list[1] means that it's already
done. This information probably needs to appear more prominently on the
todo page.[1] http://developer.postgresql.org/todo.php
Thanks.
--
Markus Bertheau <twanger@bluetwanger.de>---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)!DSPAM:40e56844212136178011369!
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian said:
I have moved the mention of the dash higher in the TODO file.
Maybe you could put the dash in a different color (red?) so it stands out
more. Or maybe the whole item could go in a different color if done.
cheers
andrew
В Втр, 06.07.2004, в 19:09, Andrew Dunstan пишет:
Bruce Momjian said:
I have moved the mention of the dash higher in the TODO file.
Maybe you could put the dash in a different color (red?) so it stands out
more. Or maybe the whole item could go in a different color if done.
Yes, what about stroke through:
done TODO item
--
Markus Bertheau <twanger@bluetwanger.de>
I have moved the mention of the dash higher in the TODO file.
Maybe you could put the dash in a different color (red?) so it stands out
more. Or maybe the whole item could go in a different color if done./Yes, what about stroke through:
Because neither works in the plain text version.
Chris
Christopher Kings-Lynne wrote:
I have moved the mention of the dash higher in the TODO file.
Maybe you could put the dash in a different color (red?) so it stands out
more. Or maybe the whole item could go in a different color if done./Yes, what about stroke through:
Because neither works in the plain text version.
OK, I updated to the newest version of txt2html and got the line to
appear in bold.
I also removed some blank lines and reordered the descriptions:
http://developer.postgresql.org/todo.php
Any other suggestions on how to improve this?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073