Sunday, March 27, 2011

simple function for test if somebody is superuser

I needed a small functions:
CREATE OR REPLACE FUNCTION is_superuser(text)
RETURNS boolean AS $$
  SELECT EXISTS(SELECT 1 FROM pg_roles WHERE rolname = $1 AND rolsuper);
$$ LANGUAGE sql;

postgres=# SELECT is_superuser('tom');
 is_superuser 
--------------
 f
(1 row)

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home