pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: Joe Conway <mail@joeconway.com>
Cc: Rob Abernethy IV <abernethy@dynedge.com>
Cc: postgresql <pgsql-admin@postgresql.org>
Subject: Re: pg_group view
Date: 31 Dec 2002 01:31:28 +0000
Message-ID: <1041298288.22899.23.camel@linda.lfix.co.uk> (raw)
In-Reply-To: <3E10C5C3.6010906@joeconway.com>
References: <20021230153246.M60737@dynedge.com>
	<3E10C5C3.6010906@joeconway.com>

On Mon, 2002-12-30 at 22:16, Joe Conway wrote:
> Rob Abernethy IV wrote:
> > Does anyone have a good recipe for a view that will display users/gruops in a
> > way that can be used with Tomcat's JDBCRelam configuration? 
...
> CREATE OR REPLACE FUNCTION expand_groups() RETURNS SETOF group_view AS '
> DECLARE
>    rec record;
>    groview record;
>    low int;
>    high int;
> BEGIN
>    FOR rec IN SELECT grosysid FROM pg_group LOOP
>      SELECT INTO low
>        replace(split_part(array_dims(grolist),'':'',1),''['','''')::int
>        FROM pg_group WHERE grosysid = rec.grosysid;
>      SELECT INTO high
>        replace(split_part(array_dims(grolist),'':'',2),'']'','''')::int
>        FROM pg_group WHERE grosysid = rec.grosysid;
> 
>      FOR i IN low..high LOOP
>        SELECT INTO groview g.grosysid, g.groname, s.usesysid, s.usename
>          FROM pg_shadow s join pg_group g on s.usesysid = g.grolist[i];
                                                                       ^^^
           WHERE grosysid = rec.grosysid;

>        RETURN NEXT groview;
>      END LOOP;
>    END LOOP;
>    RETURN;
> END;
> ' LANGUAGE 'plpgsql';

Without the extra WHERE clause, the wrong group is shown where a user is
a member of more than one group.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Ye have heard that it hath been said, Thou shalt love 
      thy neighbour, and hate thine enemy. But I say unto 
      you, Love your enemies, bless them that curse you, do 
      good to them that hate you, and pray for them which 
      despitefully use you, and persecute you;"          
                                     Matthew 5:43,44 




view thread (4+ messages)  latest in thread

Message-ID: <1041298288.22899.23.camel@linda.lfix.co.uk>
Permalink:  ../1041298288.22899.23.camel@linda.lfix.co.uk/
Also on:    postgresql.org/message-id/1041298288.22899.23.camel@linda.lfix.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: olly@lfix.co.uk, mail@joeconway.com, abernethy@dynedge.com
  Subject: Re: pg_group view
  In-Reply-To: <1041298288.22899.23.camel@linda.lfix.co.uk>
  References: <20021230153246.M60737@dynedge.com> <3E10C5C3.6010906@joeconway.com> <1041298288.22899.23.camel@linda.lfix.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox