title: What is the "type" of a role in PostgreSQL, and can it be a parameter to a procedure?
body: <p>I am trying to write a stored procedure to automate the creation and granting of roles, where the name of the role is the variable passed to the procedure:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE OR REPLACE PROCEDURE touch_user (uname text) LANGUAGE plpgsql AS $$
    BEGIN
      CREATE ROLE uname NOLOGIN;
    END
  $$;
  </code></pre>
  <p>To which I see the following:</p>
  <pre class="lang-none prettyprint-override"><code>postgres=# call touch_user('foobar');
  CALL
  postgres=# \du
                                                                List of roles
             Role name            |                         Attributes                         |                 Member of                  
  --------------------------------+------------------------------------------------------------+--------------------------------------------
   authenticator                  | No inheritance                                             | {anonymous,auth0_62ca0f44f2c735713aeef929}
   postgres                       | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
   uname                          | Cannot login                                               | {}
  </code></pre>
  <p>Clearly this just creates a role with the literal name <code>uname</code>, rather than a role dynamically named with the content of the <code>uname</code> parameter.</p>
  <p>I am wondering if there's a way around this - rather than <code>text</code>, should the <code>uname</code> parameter be of a different type? Is there a <code>role</code> data type...? I know the creation of roles is a very privileged action, but just glossing over that detail, I'd like to treat roles <em>as data</em>.</p>