public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Steele <[email protected]>
To: Amit Langote <[email protected]>
Cc: Pg Hackers <[email protected]>
Subject: Re: Views no longer in rangeTabls?
Date: Fri, 9 Jun 2023 17:46:48 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+HiwqFC0xDCCiXbUjb-xisxo9PPuA8_ykn8Fz+6RbBJBE8mVA@mail.gmail.com>
References: <[email protected]>
<CA+HiwqFC0xDCCiXbUjb-xisxo9PPuA8_ykn8Fz+6RbBJBE8mVA@mail.gmail.com>
Hi Amit,
On 6/9/23 14:25, Amit Langote wrote:
> On Fri, Jun 9, 2023 at 17:28 David Steele <[email protected]
> <mailto:[email protected]>> wrote:
>
> In prior versions of Postgres, views were listed in rangeTabls when
> ExecutorCheckPerms_hook() was called but in PG16 the views are no
> longer
> in this list.
>
> I’m not exactly sure how pgAudit’s code is searching for view relations
> in the range table, but if the code involves filtering on rtekind ==
> RTE_RELATION, then yes, such code won’t find views anymore. That’s
> because the rewriter no longer adds extraneous RTE_RELATION RTEs for
> views into the range table. Views are still there, it’s just that their
> RTEs are of kind RTE_SUBQUERY, but they do contain some RELATION fields
> like relid, rellockmode, etc. So an extension hook’s relation RTE
> filtering code should also consider relid, not just rtekind.
Thank you, this was very helpful. I am able to get the expected result
now with:
/* We only care about tables/views and can ignore subqueries, etc. */
if (!(rte->rtekind == RTE_RELATION ||
(rte->rtekind == RTE_SUBQUERY && OidIsValid(rte->relid))))
continue;
One thing, though, rte->relkind is not set for views, so I still need to
call get_rel_relkind(rte->relid). Not a big deal, but do you think it
would make sense to set rte->relkind for views?
> Perhaps, we are missing a comment near the hook definition mentioning
> this detail about views.
I don't see any meaningful comments near the hook definition. That would
certainly be helpful.
Thanks!
-David
view thread (3+ messages) latest in thread
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Views no longer in rangeTabls?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox