import logging


def is_db_user_superuser(conn):
    """Function to test whether the current DB user is a PostgreSQL superuser."""
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute("""SELECT rolsuper
                         FROM pg_roles
                        WHERE rolname = CURRENT_USER""")
        res = cur.fetchone()
        if res is None:
            logger.warn('Failed to find CURRENT_USER in pg_roles table')
            return False
        return res[0]