SELECT u.usename AS "User name",
       u.usesysid AS "User ID",
       CASE WHEN u.usesuper AND u.usecreatedb THEN CAST(pg_catalog.pg_gettext('superuser, create database') AS pg_catalog.text)
            WHEN u.usesuper THEN CAST(pg_catalog.pg_gettext('superuser') AS pg_catalog.text)
            WHEN u.usecreatedb THEN CAST(pg_catalog.pg_gettext('create database') AS pg_catalog.text)
            ELSE CAST('' AS pg_catalog.text)
       END AS "Attributes"
FROM pg_catalog.pg_user u,
     (SELECT $1 AS cmd) AS cmd,
     pg_catalog.pg_name_pattern($2) AS (schpat text, userpat text)
WHERE u.usename ~ userpat
ORDER BY 1