Re: usernames of a group from SQL

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: kijato <kijato(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: usernames of a group from SQL
Date: 2006-05-21 10:34:10
Message-ID: 44704222.5080807@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, Kijato,

kijato schrieb:

> CREATE FUNCTION kodok.group_users(group_name "varchar")
> RETURNS SETOF "varchar" AS
> $BODY$
> SELECT pg_user.usename
> FROM pg_user, pg_group
> WHERE usesysid = any (pg_group.grolist) AND pg_group.groname=$1;
> $BODY$
> LANGUAGE 'sql' VOLATILE;

The pg_user.username column uses the PostgreSQL internal type "name"
which is used for identifiers like table and user names. The PostgreSQL
Documentation contains more about this.

I think you can cast it to varchar, like:

SELECT pg_user.username::varchar

HTH,
Markus

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-05-21 15:31:02 Re: timestamp query doesn't use an index ...
Previous Message kijato 2006-05-21 08:04:30 Re: usernames of a group from SQL