Make pg_monitor neon_superuser test more robust (#12532)

Make sure to check for NULL just in case.

Signed-off-by: Tristan Partin <tristan.partin@databricks.com>
Co-authored-by: Vikas Jain <vikas.jain@databricks.com>
This commit is contained in:
Tristan Partin
2025-07-09 13:45:50 -05:00
committed by GitHub
parent fe0ddb7169
commit 28f604d628

View File

@@ -6,14 +6,18 @@ BEGIN
admin_option AS admin
INTO monitor
FROM pg_auth_members
WHERE roleid = 'neon_superuser'::regrole
AND member = 'pg_monitor'::regrole;
WHERE roleid = 'pg_monitor'::regrole
AND member = 'neon_superuser'::regrole;
IF NOT monitor.member THEN
IF monitor IS NULL THEN
RAISE EXCEPTION 'no entry in pg_auth_members for neon_superuser and pg_monitor';
END IF;
IF monitor.admin IS NULL OR NOT monitor.member THEN
RAISE EXCEPTION 'neon_superuser is not a member of pg_monitor';
END IF;
IF NOT monitor.admin THEN
IF monitor.admin IS NULL OR NOT monitor.admin THEN
RAISE EXCEPTION 'neon_superuser cannot grant pg_monitor';
END IF;
END $$;