From 28f604d628bfefa26b3016421756f91c8b6b2817 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 9 Jul 2025 13:45:50 -0500 Subject: [PATCH] Make pg_monitor neon_superuser test more robust (#12532) Make sure to check for NULL just in case. Signed-off-by: Tristan Partin Co-authored-by: Vikas Jain --- .../0004-grant_pg_monitor_to_neon_superuser.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compute_tools/src/migrations/tests/0004-grant_pg_monitor_to_neon_superuser.sql b/compute_tools/src/migrations/tests/0004-grant_pg_monitor_to_neon_superuser.sql index deb7a364af..3464a2b1cf 100644 --- a/compute_tools/src/migrations/tests/0004-grant_pg_monitor_to_neon_superuser.sql +++ b/compute_tools/src/migrations/tests/0004-grant_pg_monitor_to_neon_superuser.sql @@ -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 $$;