title: Create trigger on create role
body: <p>I have a PostgreSQL database. I create new <em>READ-ONLY</em> users as follows:</p>
  
  <pre><code>$ sudo -upostgres psql postgres
  postgres=# CREATE ROLE readonly;
  postgres=# GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
  postgres=# BEGIN;
  postgres=# CREATE ROLE "&lt;PUT_READONLY_USERNAME_HERE&gt;" WITH LOGIN ENCRYPTED PASSWORD '&lt;USE_A_NICE_STRONG_PASSWORD_PLEASE' IN ROLE readonly;
  postgres=# COMMIT;
  </code></pre>
  
  <p>Also I have a table "is_admin" where I manually add new users (it happens really rarely). If it is read-only user <code>users.is_admin = false</code> and if it is user with all priveleges <code>users.is_admin = tru</code>e.</p>
  
  <p><PRE>
     users.oid     users.is_admin (bool)
         1            true
         2            false
         3            false
        ...            ...
  </PRE></p>
  
  <p>Then in code I check if user is admin or not with this query:</p>
  
  <pre><code>SELECT users.is_admin
  FROM users.users
  JOIN pg_authid ON pg_authid.oid = users.oid::oid
  WHERE rolname = "PUT_ROLNAME";
  </code></pre>
  
  <p>So, the main question is how to automatically add new users to "is_admin" table? I read that trigger or smth like that can help me (for example,  trigger ON CREATE ROLE).</p>