DROP ROLE IF EXISTS G;
DROP ROLE IF EXISTS R;
DROP ROLE IF EXISTS M;

CREATE ROLE M CREATEROLE;
CREATE ROLE G ADMIN M;
CREATE ROLE R;

GRANT G TO R;

SET ROLE M;
REVOKE G FROM R;
DO $$ -- Fails if REVOKE is no-ops.
BEGIN
	IF pg_has_role('r', 'g', 'USAGE') THEN
		RAISE EXCEPTION 'REVOKE failed';
	END IF;
END $$;
