Hi Amit,
On 6/9/23 14:25, Amit Langote wrote:
On Fri, Jun 9, 2023 at 17:28 David Steele <da...@pgmasters.net
<mailto:da...@pgmasters.net>> 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