2012/3/14 David Fetter <da...@fetter.org>

>
> I don't know how frequently people use VALID UNTIL, but I'm guessing
> it's not terribly often because yours is the first comment about how
> it's not exposed, so I'd tend toward putting it in attributes rather
> than a separate column.
>
>
The attached patch put VALID UNTIL into attributes column in verbose mode
like example above.

bdteste=# \du
                             List of roles
 Role name |                   Attributes                   | Member of
-----------+------------------------------------------------+-----------
 bucardo   | Superuser, Create role, Create DB, Replication | {}
 postgres  | Superuser, Create role, Create DB, Replication | {}

bdteste=# \du+
                                                          List of roles
 Role name |                                        Attributes
                            | Member of | Description
-----------+-------------------------------------------------------------------------------------------+-----------+--------------
 bucardo   | Superuser, Create role, Create DB, Valid until 2012-12-31
23:59:59.999999-02, Replication | {}        | bucardo role
 postgres  | Superuser, Create role, Create DB, Replication
                           | {}        |


Regards,

-- 
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
***************
*** 2382,2388 **** describeRoles(const char *pattern, bool verbose)
  						  "  ARRAY(SELECT b.rolname\n"
  						  "        FROM pg_catalog.pg_auth_members m\n"
  				 "        JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
! 						  "        WHERE m.member = r.oid) as memberof");
  
  		if (verbose && pset.sversion >= 80200)
  		{
--- 2382,2389 ----
  						  "  ARRAY(SELECT b.rolname\n"
  						  "        FROM pg_catalog.pg_auth_members m\n"
  				 "        JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
! 						  "        WHERE m.member = r.oid) as memberof,\n"
! 						  "  'Valid until '::text||r.rolvaliduntil::text as rolvaliduntil");
  
  		if (verbose && pset.sversion >= 80200)
  		{
***************
*** 2407,2413 **** describeRoles(const char *pattern, bool verbose)
  						  "  true AS rolinherit, false AS rolcreaterole,\n"
  					 "  u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
  						  "  -1 AS rolconnlimit,\n"
! 						  "  ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
  						  "\nFROM pg_catalog.pg_user u\n");
  
  		processSQLNamePattern(pset.db, &buf, pattern, false, false,
--- 2408,2415 ----
  						  "  true AS rolinherit, false AS rolcreaterole,\n"
  					 "  u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
  						  "  -1 AS rolconnlimit,\n"
! 						  "  ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof,\n"
! 						  "  'Valid until '::text||u.valuntil::text as rolvaliduntil"
  						  "\nFROM pg_catalog.pg_user u\n");
  
  		processSQLNamePattern(pset.db, &buf, pattern, false, false,
***************
*** 2452,2459 **** describeRoles(const char *pattern, bool verbose)
  		if (strcmp(PQgetvalue(res, i, 5), "t") != 0)
  			add_role_attribute(&buf, _("Cannot login"));
  
  		if (pset.sversion >= 90100)
! 			if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0)
  				add_role_attribute(&buf, _("Replication"));
  
  		conns = atoi(PQgetvalue(res, i, 6));
--- 2454,2464 ----
  		if (strcmp(PQgetvalue(res, i, 5), "t") != 0)
  			add_role_attribute(&buf, _("Cannot login"));
  
+ 		if (strcmp(PQgetvalue(res, i, 8), "") != 0 && verbose)
+       add_role_attribute(&buf, PQgetvalue(res, i, 8));
+ 
  		if (pset.sversion >= 90100)
! 			if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
  				add_role_attribute(&buf, _("Replication"));
  
  		conns = atoi(PQgetvalue(res, i, 6));
***************
*** 2478,2485 **** describeRoles(const char *pattern, bool verbose)
  		printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
  
  		if (verbose && pset.sversion >= 80200)
! 			printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
! 	}
  	termPQExpBuffer(&buf);
  
  	printTable(&cont, pset.queryFout, pset.logfile);
--- 2483,2491 ----
  		printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false);
  
  		if (verbose && pset.sversion >= 80200)
! 			printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
! 	
!   }
  	termPQExpBuffer(&buf);
  
  	printTable(&cont, pset.queryFout, pset.logfile);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to