Ensure ExecutorCheckPerms_hook is called from RI fast path The fast path's ri_CheckPermissions() called ExecCheckOneRelPerms() directly, so ExecutorCheckPerms_hook never saw the referenced-table access that the SPI path's query exposed to it via ExecutorStart(). Modules such as sepgsql that rely on this hook therefore lost control over FK checks against referenced tables that go through the fast path.
So, build a one-entry range table and permission-info list and call ExecCheckPermissions(). The hook now sees the same relation and requiredPerms as before, once per check that goes through the fast path. This also drops the shortcut that skipped the column-level check when table-level privileges sufficed, since the hook must run regardless. While at it, drop the explicit frees in the old code, because both callers run ri_CheckPermissions() in a per-tuple context that is reset after each check, so they were redundant. Reported-by: Noah Misch <[email protected]> Discussion: https://postgr.es/m/20260705210533.ee.noahmisch%40microsoft.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5aeb36f3273c768831284082f85b63066e84f16d Modified Files -------------- src/backend/utils/adt/ri_triggers.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
