Grant execute on snapshot functions to neon_superuser (#8346)

## Problem
I need `neon_superuser` to be allowed to create snapshots for
replication tests

## Summary of changes
Adds a migration that grants these functions to neon_superuser
This commit is contained in:
Sasha Krassovsky
2024-07-11 13:29:35 -07:00
committed by Alex Chi Z
parent 90f447b79d
commit 119ddf6ccf
3 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
DO $$
BEGIN
IF (SELECT setting::numeric >= 160000 FROM pg_settings WHERE name = 'server_version_num') THEN
EXECUTE 'GRANT EXECUTE ON FUNCTION pg_export_snapshot TO neon_superuser';
EXECUTE 'GRANT EXECUTE ON FUNCTION pg_log_standby_snapshot TO neon_superuser';
END IF;
END $$;

View File

@@ -790,6 +790,9 @@ pub fn handle_migrations(client: &mut Client) -> Result<()> {
"./migrations/0007-grant_all_on_sequences_to_neon_superuser_with_grant_option.sql"
),
include_str!("./migrations/0008-revoke_replication_for_previously_allowed_roles.sql"),
include_str!(
"./migrations/0009-grant_snapshot_synchronization_funcs_to_neon_superuser.sql"
),
];
MigrationRunner::new(client, &migrations).run_migrations()?;

View File

@@ -13,7 +13,7 @@ def test_migrations(neon_simple_env: NeonEnv):
endpoint.wait_for_migrations()
num_migrations = 9
num_migrations = 10
with endpoint.cursor() as cur:
cur.execute("SELECT id FROM neon_migration.migration_id")