has_table_privilege for a table in unprivileged schema causes an error

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: has_table_privilege for a table in unprivileged schema causes an error
Date: 2018-08-16 22:51:00
Message-ID: 20180817075100.bc99378255943d3c3951ad63@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


I found that has_table_privilege returns an error when a table is specified
by schema-qualified name and the user doen't have privilege for its schema.

postgres=> select has_table_privilege('myschema.tbl','select');
ERROR: permission denied for schema myschema

I think that this function should return false because the user doesn't have
the privilege on this table eventually. It is more useful for users because
it is not needed to parse the schema-qualified table name and check the
privilege on the schema in advance.

Attached is a patch to modify the function like that. This is WIP patch, so
only has_table_previlege is modified and other familiy functions are left as
they are. Also, there is no additional test yet.

One consern on this patch is that modifying the function can break the
back-compatibility, so it might be better to add a new parameter to
control the behavior of the function.

Any comments would be appriciated.

Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

Attachment Content-Type Size
has_table_privilege.patch text/x-diff 4.4 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-08-16 22:56:00 Re: Incorrect error handling for two-phase state files resulting in data loss
Previous Message Jonathan S. Katz 2018-08-16 22:27:56 Re: docs: note ownership requirement for refreshing materialized views