Random sequence ID functions do not work when used with dump.sh
Random sequence ID functions do not work when following the "Anonymizing an SQL file" instructions i.e. when using the dump.sh entrypoint of the docker image. Note that reproducing this issue will first require the fix I described in #515 (closed) i.e. the addition of the "CREATE EXTENSION" call to dump.sh. I encountered this issue while using a custom docker image which has the fix.
The first problem is that the "dump_anon" role doesn't have the required permissions to call nextval for the anon.random_id_seq sequence. "pg_dump" returns the following error:
pg_dump: detail: Error message from server: ERROR: permission denied for sequence random_id_seq
This is because the "dump_anon" role is given the pg_read_all_data permissions but this doesn't give UPDATE or USAGE permissions to sequences, only SELECT permissions are given.
We tried to circumvent this by givin the "dump_anon" role the pg_write_all_data permissions in our custom image. But then we ran into another problem with pg_dump:
pg_dump: detail: Error message from server: ERROR: cannot execute nextval() in a read-only transaction
So it seems that usage of the random sequence ID functions is not possible here because pg_dump uses a read-only transaction.
Here are files for reproducing this issue: dump.sql
As a side issue, I noticed that the documentation has a typo in one of the random sequence ID functions. The documentation specifies a function called anon.random_id_small_int() when the function is actually anon.random_id_smallint(). Documentation link: https://postgresql-anonymizer.readthedocs.io/en/stable/masking_functions/#random-sequence-id