Re: [SQL] Recursive SELECT problem

2006-05-17 Thread Dave Page
 

> -Original Message-
> From: Tom Lane [mailto:[EMAIL PROTECTED] 
> Sent: 17 May 2006 15:07
> To: Dave Page
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Recursive SELECT problem 
> 
> "Dave Page"  writes:
> > I'm trying to write a query to determine whether or not the current 
> > login role has CREATEDB (or CREATEROLE) privileges, either 
> directly or 
> > inherited from a parent role.
> 
> Those privileges don't inherit, so I'm not sure why you need 
> a recursive check.

Because I didn't realise they didn't inherit 'cos I missed the note at
the bottom of the CREATE ROLE page :-)

Thanks - that makes life significantly easier!

Regards, Dave.

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [SQL] Recursive SELECT problem

2006-05-17 Thread Tom Lane
"Dave Page"  writes:
> I'm trying to write a query to determine whether or not the current
> login role has CREATEDB (or CREATEROLE) privileges, either directly or
> inherited from a parent role.

Those privileges don't inherit, so I'm not sure why you need a recursive
check.

regards, tom lane

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[SQL] Recursive SELECT problem

2006-05-17 Thread Dave Page
Hi,

I'm trying to write a query to determine whether or not the current
login role has CREATEDB (or CREATEROLE) privileges, either directly or
inherited from a parent role.

The query:

SELECT EXISTS (SELECT 1 FROM pg_authid WHERE rolcreatedb = TRUE AND
pg_has_role(rolname, 'MEMBER')) AS has_createdb

does the job for CREATEDB, except that it doesn't honour rolinherit.
Anyone know how I can do this in pure SQL?

Thanks, Dave.

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq