When encountering the error 2F004: Reading SQL Data Not Permitted from a Postgres database, the immediate action to take is to check the permissions of the user encountering this error. You can do this by connecting to the Postgres database using a command-line client or a database management interface and running specific SQL commands.
your_database
with the name of your database, and your_username
with your username:psql -d your_database -U your_username
SELECT * FROM information_schema.role_table_grants WHERE grantee = CURRENT_USER;
your_table_name
with the name of your table in the query below to verify permissions:SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name = 'your_table_name' AND grantee = CURRENT_USER;
SELECT rolname FROM pg_roles WHERE oid = ANY (current_user::regrole::oid <<| array(select oid from pg_roles));
SELECT policyname, cmd, roles, qual, with_check
FROM pg_policies
WHERE schemaname = 'your_schema_name' AND tablename = 'your_table_name';
your_schema_name
with the schema name of your table, and your_table_name
with the name of your table.By following these steps, you should be able to identify why the error "Reading SQL Data Not Permitted" is occurring. If it's due to missing permissions, you may need to contact whoever has administrative access to grant the necessary permissions. If you have the necessary privileges, you can grant select permission to the user for the table in question using:
GRANT SELECT ON your_table_name TO your_username;
Replace your_table_name
with the name of your table and your_username
with the name of the user needing access.
Let Dr. Droid create custom investigation plans for your infrastructure.
Start Free POC (15-min setup) →