Begin RI fast-path index scan under the switched user id

ri_FastPathCheck() called index_beginscan() before switching to the
referenced relation's owner for the permission check and probe.  For
btree this has no consequence, but starting the scan before the user id
switch sets a poor example for code dealing with out-of-tree access
methods, whose beginscan could observe the wrong user id.  Move
index_beginscan() after the SetUserIdAndSecContext() call.

Reported-by: Noah Misch <[email protected]>
Reviewed-by: Ayush Tiwari <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f68f47fe7d66a475d934823624013bcb7fae6f01

Modified Files
--------------
src/backend/utils/adt/ri_triggers.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)

Reply via email to