From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vladimir Ryabtsev <greatvovan@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: User mapping: view over a foreign table
Date: Sat, 20 Jul 2019 23:27:17 -0400
Message-ID: <8095.1563679637@sss.pgh.pa.us> (raw)
In-Reply-To: <CAMqTPqnFvqgOnfMwvbOW6LnyobrriUBe5yDS73f71YcSHS81AA@mail.gmail.com>
References: <CAMqTPqnFvqgOnfMwvbOW6LnyobrriUBe5yDS73f71YcSHS81AA@mail.gmail.com>
Vladimir Ryabtsev <greatvovan@gmail.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, greatvovan@gmail.com
Subject: Re: User mapping: view over a foreign table
In-Reply-To: <8095.1563679637@sss.pgh.pa.us>
References: <CAMqTPqnFvqgOnfMwvbOW6LnyobrriUBe5yDS73f71YcSHS81AA@mail.gmail.com> <8095.1563679637@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox