Re: User mapping: view over a foreign table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vladimir Ryabtsev <greatvovan(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: User mapping: view over a foreign table
Date: 2019-07-21 03:27:17
Message-ID: 8095.1563679637@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Vladimir Ryabtsev <greatvovan(at)gmail(dot)com> writes:
> Supposing I have a foreign table F and a view V that selects rows from F.
> The owner of F is USER1.
> The owner of V is USER2.
> The currently logged user is "me".

> When I query the foreign table F, the DBMS engine looks for USER MAPPING
> for "me", regardless of who is the owner of the table.

> When I query the view V, the engine searches the USER MAPPING for USER2 who
> is the owner of the view.

> This looks inconsistent and misleading.

AFAICS, it's exactly parallel to the handling of SQL permissions for
the foreign table. If you query F directly, you must have SELECT
permissions on F (or whatever is appropriate for your query type).
If you query F via V, you must have SELECT on V and the owner of V
must have SELECT on F.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message jay chauhan 2019-07-21 18:53:47 Request for resolution || Support
Previous Message Tom Lane 2019-07-21 03:19:12 Re: REINDEX CONCURRENTLY causes ALTER TABLE to fail