Re: CREATE USER system privilege? - Mailing list pgsql-admin

From Tom Lane
Subject Re: CREATE USER system privilege?
Date
Msg-id 18346.1072628571@sss.pgh.pa.us
Whole thread Raw
In response to Re: CREATE USER system privilege?  (Oli Sennhauser <oli.sennhauser@bluewin.ch>)
Responses Re: CREATE USER system privilege?
List pgsql-admin
Oli Sennhauser <oli.sennhauser@bluewin.ch> writes:
>> You need to use EXECUTE to construct this query as a string.

> Facit: pgplsql does not work for my problem, execute does not work problem.

I didn't think I would have to spell it out in gory detail ...

regression=# create or replace function cruser(text) returns void as '
regression'# begin
regression'#   execute ''CREATE USER '' || quote_ident($1);
regression'#   return;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select cruser('foo');
 cruser
--------

(1 row)

regression=# select cruser('bar');
 cruser
--------

(1 row)

regression=# select usename from pg_user;
        usename
-----------------------
 postgres
 pleb
 foo
 bar
(5 rows)

regression=#

            regards, tom lane

pgsql-admin by date:

Previous
From: Oli Sennhauser
Date:
Subject: Re: CREATE USER system privilege?
Next
From: Сизых Павел Леонидович
Date:
Subject: 7.1.3 -> 7.3.2