Search code examples
postgresqloracle-databaseamazon-web-servicesdatabase-migrationamazon-aurora

Oracle READ WRITE mode in postgres


I am migrating Oracle database to Postgres Aurora. There is one Oracle PL/SQL block which checks if the database is in read write open mode. Below is the query like:

Select open_mode into v_open_mode from v$database;
if v_open_mode = 'READ WRITE' then
-- perform some steps.

I want to know if we have any equivalent query in Postgres. Or even if I can know the postgres node is WRITE mode.

I am also open to get anything which is native to Aurora which show if the node is reader or writer.


Solution

  • I am not sure what the Oracle thing does, but I assume the closest thing would be to check if Postgres is in recovery mode using pg_is_in_recovery()

    So something like:

     if not pg_is_in_recovery() then 
        -- do some steps
     end if;
    

    That is from "stock" Postgres, I don't know if Amazon Aurora does anything different or provides other functions.