I agree it should work. With permissions GRANT ... ON ALL TABLES
should include views too.
Did you create the view after granting the privileges to testuser
? If so then it doesn’t have the same privileges as the other tables. That’s because GRANT ... ON ALL TABLES
means “on all tables that currently exist”. To include tables/views you create in the future, you can say:
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO testuser;
Or if you want to give more than SELECT
, you can say ALL PRIVILEGES
instead.
I think this behavior of ON ALL TABLES
is one of the most misunderstood bits about Postgres permissions, and it isn’t really called out in the standard documentation, so I tried to emphasize it in my own Postgres permissions overview.