Re: Views no longer in rangeTabls? - Mailing list pgsql-hackers

From Amit Langote
Subject Re: Views no longer in rangeTabls?
Date
Msg-id CA+HiwqFC0xDCCiXbUjb-xisxo9PPuA8_ykn8Fz+6RbBJBE8mVA@mail.gmail.com
Whole thread Raw
In response to Views no longer in rangeTabls?  (David Steele <david@pgmasters.net>)
Responses Re: Views no longer in rangeTabls?
List pgsql-hackers
Hi David,

On Fri, Jun 9, 2023 at 17:28 David Steele <david@pgmasters.net> wrote:
Hackers,

While updating pgAudit for PG16 I found the following (from our
perspective) regression.

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.

I’m away from a computer atm, so I am not able to easily copy-paste an example of that from the core code, but maybe you can search for code sites that need to filter out relation RTEs from the range table.

Perhaps, we are missing a comment near the hook definition mentioning this detail about views.
--
Thanks, Amit Langote
EDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: Do we want a hashset type?
Next
From: jian he
Date:
Subject: Re: Do we want a hashset type?