I am getting the following error on postgresql 12:
ERROR: permission denied for schema public
even though I am logged in as postgres (who is superuser), and I have granted all on the schema, and on all the tables:
GRANT all ON SCHEMA public TO postgres;
grant all on all tables in schema "public" to postgres;
And postgres is superuser:
=# \duS+
List of roles
Role name | Attributes | Member of | Description
---------------------------+------------------------------------------------------------+--------------------------------------------------------------+-------------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} |
When checking the grants, it looks like I should have INSERT privileges:
SELECT *
FROM information_schema.role_table_grants
WHERE grantee ='postgres' and table_name='wms_zone';
grantor | grantee | table_catalog | table_schema | table_name | privilege_type | is_grantable | with_hierarchy
----------+----------+---------------+--------------+------------+----------------+--------------+----------------
sapphire | postgres | table1 | public | wms_zone | TRIGGER | YES | NO
sapphire | postgres | table1 | public | wms_zone | REFERENCES | YES | NO
sapphire | postgres | table1 | public | wms_zone | TRUNCATE | YES | NO
sapphire | postgres | table1 | public | wms_zone | DELETE | YES | NO
sapphire | postgres | table1 | public | wms_zone | UPDATE | YES | NO
sapphire | postgres | table1 | public | wms_zone | SELECT | YES | YES
sapphire | postgres | table1 | public | wms_zone | INSERT | YES | NO
Update INSERTing into another table in the same database and schema does work.
postgresrole still has theSuperuserattribute? What's\duS+showing in psql?postgresrole to something else and create a regular role of that name, without thesuperuserattribute. The bootstrap role that does have to have this attribute, doesn't necessarily have to be namedpostgres, leaving the name to be used freely. If yourpostgreswas in fact asuperuser, they shouldn't be checked for privileges of any kind except for login.set role not_postgres;making it so that even though you were connected aspostgres, from that point you were acting asnot_postgresrole.select current_user;should clarify that.postgresis superuser. See updated question.