Re: Can I check if somebody is superuser in stored procedure?

From: Jim Nasby <jim(at)nasby(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Can I check if somebody is superuser in stored procedure?
Date: 2011-04-06 14:51:22
Message-ID: 0C066B83-8A3A-4E44-AC08-6DD9E74FE72F@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mar 28, 2011, at 1:29 AM, Pavel Stehule wrote:
>>> Is there some simple possibility to check a rights from stored procedure?
>>
>> Well, there's the catalog lookup method:
>>
>> SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_roles WHERE rolname=$1 AND rolsuper)
>>
>> Is that what you had in mind?
>
> I found this too, but it isn't what I searched - I searched a some
> exported function based on internal cache.
>
> For my purpose is this solution enough.

Note that doesn't work if the user has superuser because it was granted via another role.
--
Jim C. Nasby, Database Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2011-04-06 14:54:59 Re: Triggers on system catalog
Previous Message aaronenabs 2011-04-06 13:48:37 Re: Transaction log