| From: | Amit Langote <amitlan(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Ensure ExecutorCheckPerms_hook is called from RI fast path |
| Date: | 2026-09-24 10:33:00 |
| Message-ID: | E1x9glA-0000000138R-2DfZ@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <noah(at)leadboat(dot)com>
Discussion: https://postgr.es/m/20260705210533.ee.noahmisch%40microsoft.com
Backpatch-through: 19
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2cdd1950f28cf1567ebf1c747422691b09041b30
Modified Files
--------------
src/backend/utils/adt/ri_triggers.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2026-09-24 11:50:12 | pgsql: Fix assertion in pg_get_shmem_pagesize() in single-user mode |
| Previous Message | Amit Langote | 2026-09-24 10:32:46 | pgsql: Ensure ExecutorCheckPerms_hook is called from RI fast path |